From 0549672f34e34d65d33e082d878e27f8aad8b844 Mon Sep 17 00:00:00 2001 From: moskrive <42451970+moskrive@users.noreply.github.com> Date: Thu, 6 Jun 2024 15:54:21 -0700 Subject: [PATCH] Add capability to delete configuration using attributes (#236) --- gen/definitions/feature_bfd.yaml | 2 +- gen/definitions/feature_bgp.yaml | 2 +- gen/definitions/feature_dhcp.yaml | 2 +- gen/definitions/feature_evpn.yaml | 2 +- gen/definitions/feature_hmm.yaml | 2 +- gen/definitions/feature_hsrp.yaml | 2 +- gen/definitions/feature_interface_vlan.yaml | 2 +- gen/definitions/feature_isis.yaml | 2 +- gen/definitions/feature_lacp.yaml | 2 +- gen/definitions/feature_lldp.yaml | 2 +- gen/definitions/feature_macsec.yaml | 2 +- gen/definitions/feature_netflow.yaml | 2 +- gen/definitions/feature_nv_overlay.yaml | 2 +- gen/definitions/feature_ospf.yaml | 2 +- gen/definitions/feature_ospfv3.yaml | 2 +- gen/definitions/feature_pim.yaml | 2 +- gen/definitions/feature_ptp.yaml | 2 +- gen/definitions/feature_pvlan.yaml | 2 +- gen/definitions/feature_ssh.yaml | 2 +- gen/definitions/feature_tacacs.yaml | 2 +- gen/definitions/feature_telnet.yaml | 2 +- gen/definitions/feature_udld.yaml | 2 +- gen/definitions/feature_vn_segment.yaml | 2 +- gen/definitions/feature_vpc.yaml | 2 +- gen/definitions/physical_interface.yaml | 21 +++++++++++++++ gen/generator.go | 1 + gen/schema/schema.yaml | 1 + gen/templates/model.go | 20 ++++++++++++++ gen/templates/resource.go | 21 +++++++++++---- internal/provider/model_nxos_bgp.go | 6 +++++ .../provider/model_nxos_bgp_address_family.go | 6 +++++ .../model_nxos_bgp_advertised_prefix.go | 6 +++++ .../model_nxos_bgp_graceful_restart.go | 6 +++++ internal/provider/model_nxos_bgp_instance.go | 6 +++++ internal/provider/model_nxos_bgp_peer.go | 6 +++++ .../model_nxos_bgp_peer_address_family.go | 6 +++++ ...peer_address_family_prefix_list_control.go | 6 +++++ ...s_bgp_peer_address_family_route_control.go | 6 +++++ .../provider/model_nxos_bgp_peer_template.go | 6 +++++ ...l_nxos_bgp_peer_template_address_family.go | 6 +++++ ...model_nxos_bgp_peer_template_max_prefix.go | 6 +++++ .../provider/model_nxos_bgp_route_control.go | 6 +++++ internal/provider/model_nxos_bgp_vrf.go | 6 +++++ internal/provider/model_nxos_bridge_domain.go | 6 +++++ .../model_nxos_default_qos_class_map.go | 6 +++++ .../model_nxos_default_qos_class_map_dscp.go | 6 +++++ ...el_nxos_default_qos_policy_interface_in.go | 6 +++++ ...ault_qos_policy_interface_in_policy_map.go | 6 +++++ .../model_nxos_default_qos_policy_map.go | 6 +++++ ..._default_qos_policy_map_match_class_map.go | 6 +++++ ...t_qos_policy_map_match_class_map_police.go | 6 +++++ ...olicy_map_match_class_map_set_qos_group.go | 6 +++++ .../provider/model_nxos_dhcp_relay_address.go | 6 +++++ .../model_nxos_dhcp_relay_interface.go | 6 +++++ internal/provider/model_nxos_ethernet.go | 6 +++++ internal/provider/model_nxos_evpn.go | 6 +++++ internal/provider/model_nxos_evpn_vni.go | 6 +++++ .../model_nxos_evpn_vni_route_target.go | 6 +++++ ...el_nxos_evpn_vni_route_target_direction.go | 6 +++++ internal/provider/model_nxos_feature_bfd.go | 7 +++++ internal/provider/model_nxos_feature_bgp.go | 7 +++++ internal/provider/model_nxos_feature_dhcp.go | 7 +++++ internal/provider/model_nxos_feature_evpn.go | 7 +++++ internal/provider/model_nxos_feature_hmm.go | 7 +++++ internal/provider/model_nxos_feature_hsrp.go | 7 +++++ .../model_nxos_feature_interface_vlan.go | 7 +++++ internal/provider/model_nxos_feature_isis.go | 7 +++++ internal/provider/model_nxos_feature_lacp.go | 7 +++++ internal/provider/model_nxos_feature_lldp.go | 7 +++++ .../provider/model_nxos_feature_macsec.go | 7 +++++ .../provider/model_nxos_feature_netflow.go | 7 +++++ .../provider/model_nxos_feature_nv_overlay.go | 7 +++++ internal/provider/model_nxos_feature_ospf.go | 7 +++++ .../provider/model_nxos_feature_ospfv3.go | 7 +++++ internal/provider/model_nxos_feature_pim.go | 7 +++++ internal/provider/model_nxos_feature_ptp.go | 7 +++++ internal/provider/model_nxos_feature_pvlan.go | 7 +++++ internal/provider/model_nxos_feature_ssh.go | 7 +++++ .../provider/model_nxos_feature_tacacs.go | 7 +++++ .../provider/model_nxos_feature_telnet.go | 7 +++++ internal/provider/model_nxos_feature_udld.go | 7 +++++ .../provider/model_nxos_feature_vn_segment.go | 7 +++++ internal/provider/model_nxos_feature_vpc.go | 7 +++++ internal/provider/model_nxos_hmm.go | 6 +++++ internal/provider/model_nxos_hmm_instance.go | 6 +++++ internal/provider/model_nxos_hmm_interface.go | 6 +++++ .../provider/model_nxos_ipv4_access_list.go | 6 +++++ .../model_nxos_ipv4_access_list_entry.go | 6 +++++ ...pv4_access_list_policy_egress_interface.go | 6 +++++ ...v4_access_list_policy_ingress_interface.go | 6 +++++ .../provider/model_nxos_ipv4_interface.go | 6 +++++ .../model_nxos_ipv4_interface_address.go | 6 +++++ .../model_nxos_ipv4_prefix_list_rule.go | 6 +++++ .../model_nxos_ipv4_prefix_list_rule_entry.go | 6 +++++ .../provider/model_nxos_ipv4_static_route.go | 6 +++++ internal/provider/model_nxos_ipv4_vrf.go | 6 +++++ internal/provider/model_nxos_isis.go | 6 +++++ internal/provider/model_nxos_isis_instance.go | 6 +++++ .../provider/model_nxos_isis_interface.go | 6 +++++ internal/provider/model_nxos_isis_vrf.go | 6 +++++ .../provider/model_nxos_loopback_interface.go | 6 +++++ .../model_nxos_loopback_interface_vrf.go | 6 +++++ internal/provider/model_nxos_ntp_server.go | 6 +++++ internal/provider/model_nxos_nve_interface.go | 6 +++++ internal/provider/model_nxos_nve_vni.go | 6 +++++ .../provider/model_nxos_nve_vni_container.go | 6 +++++ .../model_nxos_nve_vni_ingress_replication.go | 6 +++++ internal/provider/model_nxos_ospf.go | 6 +++++ internal/provider/model_nxos_ospf_area.go | 6 +++++ .../model_nxos_ospf_authentication.go | 6 +++++ internal/provider/model_nxos_ospf_instance.go | 6 +++++ .../provider/model_nxos_ospf_interface.go | 6 +++++ internal/provider/model_nxos_ospf_vrf.go | 6 +++++ .../provider/model_nxos_physical_interface.go | 27 +++++++++++++++++++ .../model_nxos_physical_interface_vrf.go | 6 +++++ internal/provider/model_nxos_pim.go | 6 +++++ .../provider/model_nxos_pim_anycast_rp.go | 6 +++++ .../model_nxos_pim_anycast_rp_peer.go | 6 +++++ internal/provider/model_nxos_pim_instance.go | 6 +++++ internal/provider/model_nxos_pim_interface.go | 6 +++++ .../provider/model_nxos_pim_ssm_policy.go | 6 +++++ internal/provider/model_nxos_pim_ssm_range.go | 6 +++++ internal/provider/model_nxos_pim_static_rp.go | 6 +++++ .../model_nxos_pim_static_rp_group_list.go | 6 +++++ .../model_nxos_pim_static_rp_policy.go | 6 +++++ internal/provider/model_nxos_pim_vrf.go | 6 +++++ .../model_nxos_port_channel_interface.go | 6 +++++ ...odel_nxos_port_channel_interface_member.go | 6 +++++ .../model_nxos_port_channel_interface_vrf.go | 6 +++++ .../model_nxos_queuing_qos_policy_map.go | 6 +++++ ..._queuing_qos_policy_map_match_class_map.go | 6 +++++ ...qos_policy_map_match_class_map_priority.go | 6 +++++ ...map_match_class_map_remaining_bandwidth.go | 6 +++++ ...odel_nxos_queuing_qos_policy_system_out.go | 6 +++++ ...ueuing_qos_policy_system_out_policy_map.go | 6 +++++ .../provider/model_nxos_route_map_rule.go | 6 +++++ .../model_nxos_route_map_rule_entry.go | 6 +++++ ...l_nxos_route_map_rule_entry_match_route.go | 6 +++++ ..._map_rule_entry_match_route_prefix_list.go | 6 +++++ ...te_map_rule_entry_set_regular_community.go | 6 +++++ ...p_rule_entry_set_regular_community_item.go | 6 +++++ .../model_nxos_spanning_tree_interface.go | 6 +++++ internal/provider/model_nxos_subinterface.go | 6 +++++ .../provider/model_nxos_subinterface_vrf.go | 6 +++++ internal/provider/model_nxos_svi_interface.go | 6 +++++ .../provider/model_nxos_svi_interface_vrf.go | 6 +++++ internal/provider/model_nxos_system.go | 6 +++++ internal/provider/model_nxos_vpc_domain.go | 6 +++++ internal/provider/model_nxos_vpc_instance.go | 6 +++++ internal/provider/model_nxos_vpc_interface.go | 6 +++++ internal/provider/model_nxos_vpc_keepalive.go | 6 +++++ internal/provider/model_nxos_vpc_peerlink.go | 6 +++++ internal/provider/model_nxos_vrf.go | 6 +++++ .../provider/model_nxos_vrf_address_family.go | 6 +++++ .../provider/model_nxos_vrf_route_target.go | 6 +++++ ...el_nxos_vrf_route_target_address_family.go | 6 +++++ .../model_nxos_vrf_route_target_direction.go | 6 +++++ internal/provider/model_nxos_vrf_routing.go | 6 +++++ internal/provider/resource_nxos_bgp.go | 20 ++++++++++---- .../resource_nxos_bgp_address_family.go | 20 ++++++++++---- .../resource_nxos_bgp_advertised_prefix.go | 20 ++++++++++---- .../resource_nxos_bgp_graceful_restart.go | 20 ++++++++++---- .../provider/resource_nxos_bgp_instance.go | 20 ++++++++++---- internal/provider/resource_nxos_bgp_peer.go | 20 ++++++++++---- .../resource_nxos_bgp_peer_address_family.go | 20 ++++++++++---- ...peer_address_family_prefix_list_control.go | 20 ++++++++++---- ...s_bgp_peer_address_family_route_control.go | 20 ++++++++++---- .../resource_nxos_bgp_peer_template.go | 20 ++++++++++---- ...e_nxos_bgp_peer_template_address_family.go | 20 ++++++++++---- ...ource_nxos_bgp_peer_template_max_prefix.go | 20 ++++++++++---- .../resource_nxos_bgp_route_control.go | 20 ++++++++++---- internal/provider/resource_nxos_bgp_vrf.go | 20 ++++++++++---- .../provider/resource_nxos_bridge_domain.go | 20 ++++++++++---- .../resource_nxos_default_qos_class_map.go | 20 ++++++++++---- ...esource_nxos_default_qos_class_map_dscp.go | 20 ++++++++++---- ...ce_nxos_default_qos_policy_interface_in.go | 20 ++++++++++---- ...ault_qos_policy_interface_in_policy_map.go | 20 ++++++++++---- .../resource_nxos_default_qos_policy_map.go | 20 ++++++++++---- ..._default_qos_policy_map_match_class_map.go | 20 ++++++++++---- ...t_qos_policy_map_match_class_map_police.go | 20 ++++++++++---- ...olicy_map_match_class_map_set_qos_group.go | 20 ++++++++++---- .../resource_nxos_dhcp_relay_address.go | 20 ++++++++++---- .../resource_nxos_dhcp_relay_interface.go | 20 ++++++++++---- internal/provider/resource_nxos_ethernet.go | 20 ++++++++++---- internal/provider/resource_nxos_evpn.go | 20 ++++++++++---- internal/provider/resource_nxos_evpn_vni.go | 20 ++++++++++---- .../resource_nxos_evpn_vni_route_target.go | 20 ++++++++++---- ...ce_nxos_evpn_vni_route_target_direction.go | 20 ++++++++++---- .../provider/resource_nxos_feature_bfd.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_bgp.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_dhcp.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_evpn.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_hmm.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_hsrp.go | 20 ++++++++++++++ .../resource_nxos_feature_interface_vlan.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_isis.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_lacp.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_lldp.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_macsec.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_netflow.go | 20 ++++++++++++++ .../resource_nxos_feature_nv_overlay.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_ospf.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_ospfv3.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_pim.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_ptp.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_pvlan.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_ssh.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_tacacs.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_telnet.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_udld.go | 20 ++++++++++++++ .../resource_nxos_feature_vn_segment.go | 20 ++++++++++++++ .../provider/resource_nxos_feature_vpc.go | 20 ++++++++++++++ internal/provider/resource_nxos_hmm.go | 20 ++++++++++---- .../provider/resource_nxos_hmm_instance.go | 20 ++++++++++---- .../provider/resource_nxos_hmm_interface.go | 20 ++++++++++---- .../resource_nxos_ipv4_access_list.go | 20 ++++++++++---- .../resource_nxos_ipv4_access_list_entry.go | 20 ++++++++++---- ...pv4_access_list_policy_egress_interface.go | 20 ++++++++++---- ...v4_access_list_policy_ingress_interface.go | 20 ++++++++++---- .../provider/resource_nxos_ipv4_interface.go | 20 ++++++++++---- .../resource_nxos_ipv4_interface_address.go | 20 ++++++++++---- .../resource_nxos_ipv4_prefix_list_rule.go | 20 ++++++++++---- ...source_nxos_ipv4_prefix_list_rule_entry.go | 20 ++++++++++---- .../resource_nxos_ipv4_static_route.go | 20 ++++++++++---- internal/provider/resource_nxos_ipv4_vrf.go | 20 ++++++++++---- internal/provider/resource_nxos_isis.go | 20 ++++++++++---- .../provider/resource_nxos_isis_instance.go | 20 ++++++++++---- .../provider/resource_nxos_isis_interface.go | 20 ++++++++++---- internal/provider/resource_nxos_isis_vrf.go | 20 ++++++++++---- .../resource_nxos_loopback_interface.go | 20 ++++++++++---- .../resource_nxos_loopback_interface_vrf.go | 20 ++++++++++---- internal/provider/resource_nxos_ntp_server.go | 20 ++++++++++---- .../provider/resource_nxos_nve_interface.go | 20 ++++++++++---- internal/provider/resource_nxos_nve_vni.go | 20 ++++++++++---- .../resource_nxos_nve_vni_container.go | 20 ++++++++++---- ...source_nxos_nve_vni_ingress_replication.go | 20 ++++++++++---- internal/provider/resource_nxos_ospf.go | 20 ++++++++++---- internal/provider/resource_nxos_ospf_area.go | 20 ++++++++++---- .../resource_nxos_ospf_authentication.go | 20 ++++++++++---- .../provider/resource_nxos_ospf_instance.go | 20 ++++++++++---- .../provider/resource_nxos_ospf_interface.go | 20 ++++++++++---- internal/provider/resource_nxos_ospf_vrf.go | 20 ++++++++++---- .../resource_nxos_physical_interface.go | 20 ++++++++++---- .../resource_nxos_physical_interface_vrf.go | 20 ++++++++++---- internal/provider/resource_nxos_pim.go | 20 ++++++++++---- .../provider/resource_nxos_pim_anycast_rp.go | 20 ++++++++++---- .../resource_nxos_pim_anycast_rp_peer.go | 20 ++++++++++---- .../provider/resource_nxos_pim_instance.go | 20 ++++++++++---- .../provider/resource_nxos_pim_interface.go | 20 ++++++++++---- .../provider/resource_nxos_pim_ssm_policy.go | 20 ++++++++++---- .../provider/resource_nxos_pim_ssm_range.go | 20 ++++++++++---- .../provider/resource_nxos_pim_static_rp.go | 20 ++++++++++---- .../resource_nxos_pim_static_rp_group_list.go | 20 ++++++++++---- .../resource_nxos_pim_static_rp_policy.go | 20 ++++++++++---- internal/provider/resource_nxos_pim_vrf.go | 20 ++++++++++---- .../resource_nxos_port_channel_interface.go | 20 ++++++++++---- ...urce_nxos_port_channel_interface_member.go | 20 ++++++++++---- ...esource_nxos_port_channel_interface_vrf.go | 20 ++++++++++---- .../resource_nxos_queuing_qos_policy_map.go | 20 ++++++++++---- ..._queuing_qos_policy_map_match_class_map.go | 20 ++++++++++---- ...qos_policy_map_match_class_map_priority.go | 20 ++++++++++---- ...map_match_class_map_remaining_bandwidth.go | 20 ++++++++++---- ...urce_nxos_queuing_qos_policy_system_out.go | 20 ++++++++++---- ...ueuing_qos_policy_system_out_policy_map.go | 20 ++++++++++---- .../provider/resource_nxos_route_map_rule.go | 20 ++++++++++---- .../resource_nxos_route_map_rule_entry.go | 20 ++++++++++---- ...e_nxos_route_map_rule_entry_match_route.go | 20 ++++++++++---- ..._map_rule_entry_match_route_prefix_list.go | 20 ++++++++++---- ...te_map_rule_entry_set_regular_community.go | 20 ++++++++++---- ...p_rule_entry_set_regular_community_item.go | 20 ++++++++++---- .../resource_nxos_spanning_tree_interface.go | 20 ++++++++++---- .../provider/resource_nxos_subinterface.go | 20 ++++++++++---- .../resource_nxos_subinterface_vrf.go | 20 ++++++++++---- .../provider/resource_nxos_svi_interface.go | 20 ++++++++++---- .../resource_nxos_svi_interface_vrf.go | 20 ++++++++++---- internal/provider/resource_nxos_vpc_domain.go | 20 ++++++++++---- .../provider/resource_nxos_vpc_instance.go | 20 ++++++++++---- .../provider/resource_nxos_vpc_interface.go | 20 ++++++++++---- .../provider/resource_nxos_vpc_keepalive.go | 20 ++++++++++---- .../provider/resource_nxos_vpc_peerlink.go | 20 ++++++++++---- internal/provider/resource_nxos_vrf.go | 20 ++++++++++---- .../resource_nxos_vrf_address_family.go | 20 ++++++++++---- .../resource_nxos_vrf_route_target.go | 20 ++++++++++---- ...ce_nxos_vrf_route_target_address_family.go | 20 ++++++++++---- ...esource_nxos_vrf_route_target_direction.go | 20 ++++++++++---- .../provider/resource_nxos_vrf_routing.go | 20 ++++++++++---- 286 files changed, 2942 insertions(+), 549 deletions(-) diff --git a/gen/definitions/feature_bfd.yaml b/gen/definitions/feature_bfd.yaml index cf1ddef6..d8c5f986 100644 --- a/gen/definitions/feature_bfd.yaml +++ b/gen/definitions/feature_bfd.yaml @@ -2,7 +2,6 @@ name: Feature BFD class_name: fmBfd dn: sys/fm/bfd -no_delete: true ds_description: This data source can read the BFD feature configuration. res_description: This resource can manage the BFD feature configuration. doc_path: Feature%20Management/fm:Bfd/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_bgp.yaml b/gen/definitions/feature_bgp.yaml index 40ef2308..72f774b0 100644 --- a/gen/definitions/feature_bgp.yaml +++ b/gen/definitions/feature_bgp.yaml @@ -2,7 +2,6 @@ name: Feature BGP class_name: fmBgp dn: sys/fm/bgp -no_delete: true ds_description: This data source can read the BGP feature configuration. res_description: This resource can manage the BGP feature configuration. doc_path: Feature%20Management/fm:Bgp/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_dhcp.yaml b/gen/definitions/feature_dhcp.yaml index d96bc693..8b93175e 100644 --- a/gen/definitions/feature_dhcp.yaml +++ b/gen/definitions/feature_dhcp.yaml @@ -2,7 +2,6 @@ name: Feature DHCP class_name: fmDhcp dn: sys/fm/dhcp -no_delete: true ds_description: This data source can read the DHCP feature configuration. res_description: This resource can manage the DHCP feature configuration. doc_path: Feature%20Management/fm:Dhcp/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_evpn.yaml b/gen/definitions/feature_evpn.yaml index fe7a4819..7bfb53d3 100644 --- a/gen/definitions/feature_evpn.yaml +++ b/gen/definitions/feature_evpn.yaml @@ -2,7 +2,6 @@ name: Feature EVPN class_name: fmEvpn dn: sys/fm/evpn -no_delete: true ds_description: This data source can read the EVPN feature (aka `nv overlay evpn`) configuration. res_description: This resource can manage the EVPN feature (aka `nv overlay evpn`) configuration. doc_path: Feature%20Management/fm:Evpn/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_hmm.yaml b/gen/definitions/feature_hmm.yaml index fb928a2e..e3f6101c 100644 --- a/gen/definitions/feature_hmm.yaml +++ b/gen/definitions/feature_hmm.yaml @@ -2,7 +2,6 @@ name: Feature HMM class_name: fmHmm dn: sys/fm/hmm -no_delete: true ds_description: This data source can read the HMM feature (aka `feature fabric forwarding`) configuration. res_description: This resource can manage the HMM feature (aka `feature fabric forwarding`) configuration. doc_path: Feature%20Management/fm:Hmm/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_hsrp.yaml b/gen/definitions/feature_hsrp.yaml index c8dbcabd..29d43653 100644 --- a/gen/definitions/feature_hsrp.yaml +++ b/gen/definitions/feature_hsrp.yaml @@ -2,7 +2,6 @@ name: Feature HSRP class_name: fmHsrp dn: sys/fm/hsrp -no_delete: true ds_description: This data source can read the HSRP feature configuration. res_description: This resource can manage the HSRP feature configuration. doc_path: Feature%20Management/fm:Hsrp/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_interface_vlan.yaml b/gen/definitions/feature_interface_vlan.yaml index bf2fa2be..029e2915 100644 --- a/gen/definitions/feature_interface_vlan.yaml +++ b/gen/definitions/feature_interface_vlan.yaml @@ -2,7 +2,6 @@ name: Feature Interface VLAN class_name: fmInterfaceVlan dn: sys/fm/ifvlan -no_delete: true ds_description: This data source can read the Interface VLAN feature configuration. res_description: This resource can manage the Interface VLAN feature configuration. doc_path: Feature%20Management/fm:InterfaceVlan/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_isis.yaml b/gen/definitions/feature_isis.yaml index cb5ca637..fd9f05a1 100644 --- a/gen/definitions/feature_isis.yaml +++ b/gen/definitions/feature_isis.yaml @@ -2,7 +2,6 @@ name: Feature ISIS class_name: fmIsis dn: sys/fm/isis -no_delete: true ds_description: This data source can read the ISIS feature configuration. res_description: This resource can manage the ISIS feature configuration. doc_path: Feature%20Management/fm:Isis/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_lacp.yaml b/gen/definitions/feature_lacp.yaml index 5174ff0c..a5395a5a 100644 --- a/gen/definitions/feature_lacp.yaml +++ b/gen/definitions/feature_lacp.yaml @@ -2,7 +2,6 @@ name: Feature LACP class_name: fmLacp dn: sys/fm/lacp -no_delete: true ds_description: This data source can read the LACP feature configuration. res_description: This resource can manage the LACP feature configuration. doc_path: Feature%20Management/fm:Lacp/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_lldp.yaml b/gen/definitions/feature_lldp.yaml index e8a5a236..8bad9592 100644 --- a/gen/definitions/feature_lldp.yaml +++ b/gen/definitions/feature_lldp.yaml @@ -2,7 +2,6 @@ name: Feature LLDP class_name: fmLldp dn: sys/fm/lldp -no_delete: true ds_description: This data source can read the LLDP feature configuration. res_description: This resource can manage the LLDP feature configuration. doc_path: Feature%20Management/fm:Lldp/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_macsec.yaml b/gen/definitions/feature_macsec.yaml index 50e13d51..dd81311d 100644 --- a/gen/definitions/feature_macsec.yaml +++ b/gen/definitions/feature_macsec.yaml @@ -2,7 +2,6 @@ name: Feature MACsec class_name: fmMacsec dn: sys/fm/macsec -no_delete: true test_tags: [MACSEC] ds_description: This data source can read the MACsec feature configuration. res_description: This resource can manage the MACsec feature configuration. @@ -18,3 +17,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_netflow.yaml b/gen/definitions/feature_netflow.yaml index e984ecf7..3b62c92c 100644 --- a/gen/definitions/feature_netflow.yaml +++ b/gen/definitions/feature_netflow.yaml @@ -2,7 +2,6 @@ name: Feature Netflow class_name: fmNetflow dn: sys/fm/netflow -no_delete: true test_tags: [NETFLOW] ds_description: This data source can read the Netflow feature configuration. res_description: This resource can manage the Netflow feature configuration. @@ -18,3 +17,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_nv_overlay.yaml b/gen/definitions/feature_nv_overlay.yaml index db3901f0..6ffd7da5 100644 --- a/gen/definitions/feature_nv_overlay.yaml +++ b/gen/definitions/feature_nv_overlay.yaml @@ -2,7 +2,6 @@ name: Feature NV Overlay class_name: fmNvo dn: sys/fm/nvo -no_delete: true ds_description: This data source can read the NV Overlay feature configuration. res_description: This resource can manage the NV Overlay feature configuration. doc_path: Feature%20Management/fm:Nvo/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_ospf.yaml b/gen/definitions/feature_ospf.yaml index 9c38e84b..cf015007 100644 --- a/gen/definitions/feature_ospf.yaml +++ b/gen/definitions/feature_ospf.yaml @@ -2,7 +2,6 @@ name: Feature OSPF class_name: fmOspf dn: sys/fm/ospf -no_delete: true ds_description: This data source can read the OSPF feature configuration. res_description: This resource can manage the OSPF feature configuration. doc_path: Feature%20Management/fm:Ospf/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_ospfv3.yaml b/gen/definitions/feature_ospfv3.yaml index 95d3a0da..fb2ff7c1 100644 --- a/gen/definitions/feature_ospfv3.yaml +++ b/gen/definitions/feature_ospfv3.yaml @@ -2,7 +2,6 @@ name: Feature OSPFv3 class_name: fmOspfv3 dn: sys/fm/ospfv3 -no_delete: true ds_description: This data source can read the OSPFv3 feature configuration. res_description: This resource can manage the OSPFv3 feature configuration. doc_path: Feature%20Management/fm:Ospfv3/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_pim.yaml b/gen/definitions/feature_pim.yaml index 28bcd920..b057c31f 100644 --- a/gen/definitions/feature_pim.yaml +++ b/gen/definitions/feature_pim.yaml @@ -2,7 +2,6 @@ name: Feature PIM class_name: fmPim dn: sys/fm/pim -no_delete: true ds_description: This data source can read the PIM feature configuration. res_description: This resource can manage the PIM feature configuration. doc_path: Feature%20Management/fm:Pim/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_ptp.yaml b/gen/definitions/feature_ptp.yaml index c68410ad..95799c34 100644 --- a/gen/definitions/feature_ptp.yaml +++ b/gen/definitions/feature_ptp.yaml @@ -2,7 +2,6 @@ name: Feature PTP class_name: fmPtp dn: sys/fm/ptp -no_delete: true ds_description: This data source can read the PTP feature configuration. res_description: This resource can manage the PTP feature configuration. doc_path: Feature%20Management/fm:Ptp/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_pvlan.yaml b/gen/definitions/feature_pvlan.yaml index c2e15b8b..3e76ad9e 100644 --- a/gen/definitions/feature_pvlan.yaml +++ b/gen/definitions/feature_pvlan.yaml @@ -2,7 +2,6 @@ name: Feature PVLAN class_name: fmPvlan dn: sys/fm/pvlan -no_delete: true ds_description: This data source can read the PVLAN feature configuration. res_description: This resource can manage the PVLAN feature configuration. doc_path: Feature%20Management/fm:Pvlan/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_ssh.yaml b/gen/definitions/feature_ssh.yaml index 143009ad..0f924405 100644 --- a/gen/definitions/feature_ssh.yaml +++ b/gen/definitions/feature_ssh.yaml @@ -2,7 +2,6 @@ name: Feature SSH class_name: fmSsh dn: sys/fm/ssh -no_delete: true ds_description: This data source can read the SSH feature configuration. res_description: This resource can manage the SSH feature configuration. doc_path: Feature%20Management/fm:Ssh/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: enabled diff --git a/gen/definitions/feature_tacacs.yaml b/gen/definitions/feature_tacacs.yaml index acb61507..be23c3bb 100644 --- a/gen/definitions/feature_tacacs.yaml +++ b/gen/definitions/feature_tacacs.yaml @@ -2,7 +2,6 @@ name: Feature TACACS class_name: fmTacacsplus dn: sys/fm/tacacsplus -no_delete: true ds_description: This data source can read the TACACS+ feature configuration. res_description: This resource can manage the TACACS+ feature configuration. doc_path: Feature%20Management/fm:Tacacsplus/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_telnet.yaml b/gen/definitions/feature_telnet.yaml index f3005eb3..52de226d 100644 --- a/gen/definitions/feature_telnet.yaml +++ b/gen/definitions/feature_telnet.yaml @@ -2,7 +2,6 @@ name: Feature Telnet class_name: fmTelnet dn: sys/fm/telnet -no_delete: true ds_description: This data source can read the Telnet feature configuration. res_description: This resource can manage the Telnet feature configuration. doc_path: Feature%20Management/fm:Telnet/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_udld.yaml b/gen/definitions/feature_udld.yaml index a33a6e85..2fd21b1b 100644 --- a/gen/definitions/feature_udld.yaml +++ b/gen/definitions/feature_udld.yaml @@ -2,7 +2,6 @@ name: Feature UDLD class_name: fmUdld dn: sys/fm/udld -no_delete: true ds_description: This data source can read the UDLD feature configuration. res_description: This resource can manage the UDLD feature configuration. doc_path: Feature%20Management/fm:Udld/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_vn_segment.yaml b/gen/definitions/feature_vn_segment.yaml index 0cb4234a..b3078bf2 100644 --- a/gen/definitions/feature_vn_segment.yaml +++ b/gen/definitions/feature_vn_segment.yaml @@ -2,7 +2,6 @@ name: Feature VN Segment class_name: fmVnSegment dn: sys/fm/vnsegment -no_delete: true ds_description: This data source can read the VN Segment feature configuration. res_description: This resource can manage the VN Segment feature configuration. doc_path: Feature%20Management/fm:VnSegment/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/feature_vpc.yaml b/gen/definitions/feature_vpc.yaml index 40fdd5ed..ce3d4364 100644 --- a/gen/definitions/feature_vpc.yaml +++ b/gen/definitions/feature_vpc.yaml @@ -2,7 +2,6 @@ name: Feature VPC class_name: fmVpc dn: sys/fm/vpc -no_delete: true ds_description: This data source can read the VPC feature configuration. res_description: This resource can manage the VPC feature configuration. doc_path: Feature%20Management/fm:Vpc/ @@ -17,3 +16,4 @@ attributes: - enabled - disabled example: enabled + delete_value: disabled diff --git a/gen/definitions/physical_interface.yaml b/gen/definitions/physical_interface.yaml index 75e28f19..a3542f05 100644 --- a/gen/definitions/physical_interface.yaml +++ b/gen/definitions/physical_interface.yaml @@ -29,12 +29,14 @@ attributes: - kp-fec default_value: auto example: auto + delete_value: auto - nxos_name: accessVlan tf_name: access_vlan type: String description: 'Access VLAN. Possible values are `unknown`, `vlan-XX` or `vxlan-XX`.' default_value: vlan-1 example: unknown + delete_value: vlan-1 - nxos_name: adminSt tf_name: admin_state type: String @@ -44,6 +46,7 @@ attributes: - down default_value: up example: up + delete_value: DME_UNSET_PROPERTY_MARKER - nxos_name: autoNeg tf_name: auto_negotiation type: String @@ -54,6 +57,7 @@ attributes: - 25G default_value: 'on' example: 'on' + delete_value: 'on' - nxos_name: bw tf_name: bandwidth type: Int64 @@ -62,6 +66,7 @@ attributes: max_int: 3200000000 default_value: 0 example: 1000 + delete_value: 0 - nxos_name: delay tf_name: delay type: Int64 @@ -70,11 +75,13 @@ attributes: max_int: 16777215 default_value: 1 example: 10 + delete_value: 1 - nxos_name: descr tf_name: description type: String description: 'Interface description.' example: My Description + delete_value: DME_UNSET_PROPERTY_MARKER - nxos_name: duplex tf_name: duplex type: String @@ -85,6 +92,7 @@ attributes: - half default_value: auto example: auto + delete_value: auto - nxos_name: layer tf_name: layer type: String @@ -94,6 +102,7 @@ attributes: - Layer3 default_value: Layer2 example: Layer3 + delete_value: Layer2 - nxos_name: linkLog tf_name: link_logging type: String @@ -104,6 +113,7 @@ attributes: - disable default_value: default example: enable + delete_value: default - nxos_name: linkDebounce tf_name: link_debounce_down type: Int64 @@ -112,6 +122,7 @@ attributes: max_int: 20000 default_value: 100 example: 200 + delete_value: 100 - nxos_name: linkDebounceLinkUp tf_name: link_debounce_up type: Int64 @@ -120,6 +131,7 @@ attributes: max_int: 20000 default_value: 0 example: 0 + delete_value: 0 - nxos_name: medium tf_name: medium type: String @@ -129,6 +141,7 @@ attributes: - p2p default_value: broadcast example: broadcast + delete_value: broadcast - nxos_name: mode tf_name: mode type: String @@ -145,6 +158,7 @@ attributes: - vntag default_value: access example: access + delete_value: access - nxos_name: mtu tf_name: mtu type: Int64 @@ -153,12 +167,14 @@ attributes: max_int: 9216 default_value: 1500 example: 1500 + delete_value: 1500 - nxos_name: nativeVlan tf_name: native_vlan type: String description: 'Native VLAN. Possible values are `unknown`, `vlan-XX` or `vxlan-XX`.' default_value: vlan-1 example: unknown + delete_value: vlan-1 - nxos_name: speed tf_name: speed type: String @@ -184,6 +200,7 @@ attributes: - auto 100M 1G 2.5G 5G default_value: auto example: auto + delete_value: auto - nxos_name: speedGroup tf_name: speed_group type: String @@ -197,12 +214,14 @@ attributes: - '25000' default_value: auto example: auto + delete_value: auto - nxos_name: trunkVlans tf_name: trunk_vlans type: String description: 'List of trunk VLANs.' default_value: 1-4094 example: 1-4094 + delete_value: 1-4094 - nxos_name: uniDirectionalEthernet tf_name: uni_directional_ethernet type: String @@ -213,8 +232,10 @@ attributes: - receive-only default_value: disable example: disable + delete_value: disable - nxos_name: userCfgdFlags tf_name: user_configured_flags type: String description: 'Port User Config Flags.' example: 'admin_layer,admin_mtu,admin_state' + delete_value: none diff --git a/gen/generator.go b/gen/generator.go index 4a3c269a..c2dfeefc 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -127,6 +127,7 @@ type YamlConfigAttribute struct { MinInt int `yaml:"min_int"` MaxInt int `yaml:"max_int"` DefaultValue string `yaml:"default_value"` + DeleteValue string `yaml:"delete_value"` ExcludeTest bool `yaml:"exclude_test"` RequiresReplace bool `yaml:"requires_replace"` } diff --git a/gen/schema/schema.yaml b/gen/schema/schema.yaml index ac7b9abc..2fd498f8 100644 --- a/gen/schema/schema.yaml +++ b/gen/schema/schema.yaml @@ -31,6 +31,7 @@ attribute: min_int: int(required=False) max_int: int(required=False) default_value: any(str(), int(), bool(), required=False) + delete_value: any(str(), int(), bool(), required=False) exclude_test: bool(required=False) requires_replace: bool(required=False) diff --git a/gen/templates/model.go b/gen/templates/model.go index 48ae1a69..af91c06b 100644 --- a/gen/templates/model.go +++ b/gen/templates/model.go @@ -249,3 +249,23 @@ func (data *{{camelCase .Name}}) fromBody(res gjson.Result, all bool) { {{- end}} {{- end}} } + +func (data {{camelCase .Name}}) toDeleteBody() nxos.Body { + body := "" + {{- range .Attributes}} + {{- if not .ReferenceOnly}} + {{- if .DeleteValue}} + + {{- if eq .Type "Int64"}} + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"{{.NxosName}}", strconv.FormatInt({{ .DeleteValue}}, 10)) + {{- else if eq .Type "Bool"}} + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"{{.NxosName}}", strconv.FormatBool({{ .DeleteValue}})) + {{- else if eq .Type "String"}} + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"{{.NxosName}}", "{{ .DeleteValue}}") + {{- end}} + {{- end}} + {{- end}} + {{- end}} + + return nxos.Body{body} +} \ No newline at end of file diff --git a/gen/templates/resource.go b/gen/templates/resource.go index c94a0241..857174c7 100644 --- a/gen/templates/resource.go +++ b/gen/templates/resource.go @@ -345,14 +345,25 @@ func (r *{{camelCase .Name}}Resource) Delete(ctx context.Context, req resource.D tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) {{ if not .NoDelete}} - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + + body := state.toDeleteBody() + + if (len(body.Str) > 0) { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } {{ end}} tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/model_nxos_bgp.go b/internal/provider/model_nxos_bgp.go index 38d5aea8..ba8e27ae 100644 --- a/internal/provider/model_nxos_bgp.go +++ b/internal/provider/model_nxos_bgp.go @@ -57,3 +57,9 @@ func (data *BGP) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data BGP) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_address_family.go b/internal/provider/model_nxos_bgp_address_family.go index 9989a216..f4562a28 100644 --- a/internal/provider/model_nxos_bgp_address_family.go +++ b/internal/provider/model_nxos_bgp_address_family.go @@ -80,3 +80,9 @@ func (data *BGPAddressFamily) fromBody(res gjson.Result, all bool) { data.NonCriticalNexthopTimeout = types.Int64Null() } } + +func (data BGPAddressFamily) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_advertised_prefix.go b/internal/provider/model_nxos_bgp_advertised_prefix.go index 82eb55f8..d5246761 100644 --- a/internal/provider/model_nxos_bgp_advertised_prefix.go +++ b/internal/provider/model_nxos_bgp_advertised_prefix.go @@ -71,3 +71,9 @@ func (data *BGPAdvertisedPrefix) fromBody(res gjson.Result, all bool) { data.RouteMap = types.StringNull() } } + +func (data BGPAdvertisedPrefix) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_graceful_restart.go b/internal/provider/model_nxos_bgp_graceful_restart.go index 70f60121..f4320d20 100644 --- a/internal/provider/model_nxos_bgp_graceful_restart.go +++ b/internal/provider/model_nxos_bgp_graceful_restart.go @@ -71,3 +71,9 @@ func (data *BGPGracefulRestart) fromBody(res gjson.Result, all bool) { data.StaleInterval = types.Int64Null() } } + +func (data BGPGracefulRestart) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_instance.go b/internal/provider/model_nxos_bgp_instance.go index 945d6822..f5f0f7a6 100644 --- a/internal/provider/model_nxos_bgp_instance.go +++ b/internal/provider/model_nxos_bgp_instance.go @@ -78,3 +78,9 @@ func (data *BGPInstance) fromBody(res gjson.Result, all bool) { data.EnhancedErrorHandling = types.BoolNull() } } + +func (data BGPInstance) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_peer.go b/internal/provider/model_nxos_bgp_peer.go index e194d60d..8257bb7f 100644 --- a/internal/provider/model_nxos_bgp_peer.go +++ b/internal/provider/model_nxos_bgp_peer.go @@ -125,3 +125,9 @@ func (data *BGPPeer) fromBody(res gjson.Result, all bool) { data.Keepalive = types.Int64Null() } } + +func (data BGPPeer) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_peer_address_family.go b/internal/provider/model_nxos_bgp_peer_address_family.go index 8dfadb72..dea0d776 100644 --- a/internal/provider/model_nxos_bgp_peer_address_family.go +++ b/internal/provider/model_nxos_bgp_peer_address_family.go @@ -89,3 +89,9 @@ func (data *BGPPeerAddressFamily) fromBody(res gjson.Result, all bool) { data.SendCommunityStandard = types.StringNull() } } + +func (data BGPPeerAddressFamily) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_peer_address_family_prefix_list_control.go b/internal/provider/model_nxos_bgp_peer_address_family_prefix_list_control.go index c650102f..9870747c 100644 --- a/internal/provider/model_nxos_bgp_peer_address_family_prefix_list_control.go +++ b/internal/provider/model_nxos_bgp_peer_address_family_prefix_list_control.go @@ -72,3 +72,9 @@ func (data *BGPPeerAddressFamilyPrefixListControl) fromBody(res gjson.Result, al data.List = types.StringNull() } } + +func (data BGPPeerAddressFamilyPrefixListControl) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_peer_address_family_route_control.go b/internal/provider/model_nxos_bgp_peer_address_family_route_control.go index 2dc7f6ea..f15adcb7 100644 --- a/internal/provider/model_nxos_bgp_peer_address_family_route_control.go +++ b/internal/provider/model_nxos_bgp_peer_address_family_route_control.go @@ -72,3 +72,9 @@ func (data *BGPPeerAddressFamilyRouteControl) fromBody(res gjson.Result, all boo data.RouteMapName = types.StringNull() } } + +func (data BGPPeerAddressFamilyRouteControl) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_peer_template.go b/internal/provider/model_nxos_bgp_peer_template.go index ccee5f67..0ba33b73 100644 --- a/internal/provider/model_nxos_bgp_peer_template.go +++ b/internal/provider/model_nxos_bgp_peer_template.go @@ -96,3 +96,9 @@ func (data *BGPPeerTemplate) fromBody(res gjson.Result, all bool) { data.SourceInterface = types.StringNull() } } + +func (data BGPPeerTemplate) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_peer_template_address_family.go b/internal/provider/model_nxos_bgp_peer_template_address_family.go index 52a4b8d8..bb195854 100644 --- a/internal/provider/model_nxos_bgp_peer_template_address_family.go +++ b/internal/provider/model_nxos_bgp_peer_template_address_family.go @@ -88,3 +88,9 @@ func (data *BGPPeerTemplateAddressFamily) fromBody(res gjson.Result, all bool) { data.SendCommunityStandard = types.StringNull() } } + +func (data BGPPeerTemplateAddressFamily) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_peer_template_max_prefix.go b/internal/provider/model_nxos_bgp_peer_template_max_prefix.go index 401f8fbe..10a16f42 100644 --- a/internal/provider/model_nxos_bgp_peer_template_max_prefix.go +++ b/internal/provider/model_nxos_bgp_peer_template_max_prefix.go @@ -90,3 +90,9 @@ func (data *BGPPeerTemplateMaxPrefix) fromBody(res gjson.Result, all bool) { data.Threshold = types.Int64Null() } } + +func (data BGPPeerTemplateMaxPrefix) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_route_control.go b/internal/provider/model_nxos_bgp_route_control.go index f0907b77..73485963 100644 --- a/internal/provider/model_nxos_bgp_route_control.go +++ b/internal/provider/model_nxos_bgp_route_control.go @@ -88,3 +88,9 @@ func (data *BGPRouteControl) fromBody(res gjson.Result, all bool) { data.SuppressRoutes = types.StringNull() } } + +func (data BGPRouteControl) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bgp_vrf.go b/internal/provider/model_nxos_bgp_vrf.go index 8f381cf7..a9fb4770 100644 --- a/internal/provider/model_nxos_bgp_vrf.go +++ b/internal/provider/model_nxos_bgp_vrf.go @@ -69,3 +69,9 @@ func (data *BGPVRF) fromBody(res gjson.Result, all bool) { data.RouterId = types.StringNull() } } + +func (data BGPVRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_bridge_domain.go b/internal/provider/model_nxos_bridge_domain.go index 1d26ea36..b9391971 100644 --- a/internal/provider/model_nxos_bridge_domain.go +++ b/internal/provider/model_nxos_bridge_domain.go @@ -77,3 +77,9 @@ func (data *BridgeDomain) fromBody(res gjson.Result, all bool) { data.Name = types.StringNull() } } + +func (data BridgeDomain) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_default_qos_class_map.go b/internal/provider/model_nxos_default_qos_class_map.go index 133daf40..d073fd1f 100644 --- a/internal/provider/model_nxos_default_qos_class_map.go +++ b/internal/provider/model_nxos_default_qos_class_map.go @@ -68,3 +68,9 @@ func (data *DefaultQOSClassMap) fromBody(res gjson.Result, all bool) { data.MatchType = types.StringNull() } } + +func (data DefaultQOSClassMap) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_default_qos_class_map_dscp.go b/internal/provider/model_nxos_default_qos_class_map_dscp.go index c9f8443e..1303311b 100644 --- a/internal/provider/model_nxos_default_qos_class_map_dscp.go +++ b/internal/provider/model_nxos_default_qos_class_map_dscp.go @@ -60,3 +60,9 @@ func (data *DefaultQOSClassMapDSCP) fromBody(res gjson.Result, all bool) { data.Value = types.StringNull() } } + +func (data DefaultQOSClassMapDSCP) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_default_qos_policy_interface_in.go b/internal/provider/model_nxos_default_qos_policy_interface_in.go index 7e5f3960..4048f5de 100644 --- a/internal/provider/model_nxos_default_qos_policy_interface_in.go +++ b/internal/provider/model_nxos_default_qos_policy_interface_in.go @@ -59,3 +59,9 @@ func (data *DefaultQOSPolicyInterfaceIn) fromBody(res gjson.Result, all bool) { data.InterfaceId = types.StringNull() } } + +func (data DefaultQOSPolicyInterfaceIn) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_default_qos_policy_interface_in_policy_map.go b/internal/provider/model_nxos_default_qos_policy_interface_in_policy_map.go index daa6a5c4..5c2468c0 100644 --- a/internal/provider/model_nxos_default_qos_policy_interface_in_policy_map.go +++ b/internal/provider/model_nxos_default_qos_policy_interface_in_policy_map.go @@ -60,3 +60,9 @@ func (data *DefaultQOSPolicyInterfaceInPolicyMap) fromBody(res gjson.Result, all data.PolicyMapName = types.StringNull() } } + +func (data DefaultQOSPolicyInterfaceInPolicyMap) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_default_qos_policy_map.go b/internal/provider/model_nxos_default_qos_policy_map.go index cde775fa..aa0f758c 100644 --- a/internal/provider/model_nxos_default_qos_policy_map.go +++ b/internal/provider/model_nxos_default_qos_policy_map.go @@ -68,3 +68,9 @@ func (data *DefaultQOSPolicyMap) fromBody(res gjson.Result, all bool) { data.MatchType = types.StringNull() } } + +func (data DefaultQOSPolicyMap) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_default_qos_policy_map_match_class_map.go b/internal/provider/model_nxos_default_qos_policy_map_match_class_map.go index f2474585..e9eb90a0 100644 --- a/internal/provider/model_nxos_default_qos_policy_map_match_class_map.go +++ b/internal/provider/model_nxos_default_qos_policy_map_match_class_map.go @@ -60,3 +60,9 @@ func (data *DefaultQOSPolicyMapMatchClassMap) fromBody(res gjson.Result, all boo data.Name = types.StringNull() } } + +func (data DefaultQOSPolicyMapMatchClassMap) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_default_qos_policy_map_match_class_map_police.go b/internal/provider/model_nxos_default_qos_policy_map_match_class_map_police.go index 8113ee1b..b741cc45 100644 --- a/internal/provider/model_nxos_default_qos_policy_map_match_class_map_police.go +++ b/internal/provider/model_nxos_default_qos_policy_map_match_class_map_police.go @@ -260,3 +260,9 @@ func (data *DefaultQOSPolicyMapMatchClassMapPolice) fromBody(res gjson.Result, a data.ViolateSetQosGroup = types.Int64Null() } } + +func (data DefaultQOSPolicyMapMatchClassMapPolice) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_default_qos_policy_map_match_class_map_set_qos_group.go b/internal/provider/model_nxos_default_qos_policy_map_match_class_map_set_qos_group.go index 1985310d..9b4d1e79 100644 --- a/internal/provider/model_nxos_default_qos_policy_map_match_class_map_set_qos_group.go +++ b/internal/provider/model_nxos_default_qos_policy_map_match_class_map_set_qos_group.go @@ -62,3 +62,9 @@ func (data *DefaultQOSPolicyMapMatchClassMapSetQOSGroup) fromBody(res gjson.Resu data.QosGroupId = types.Int64Null() } } + +func (data DefaultQOSPolicyMapMatchClassMapSetQOSGroup) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_dhcp_relay_address.go b/internal/provider/model_nxos_dhcp_relay_address.go index 8a8fc8dd..2b7fd340 100644 --- a/internal/provider/model_nxos_dhcp_relay_address.go +++ b/internal/provider/model_nxos_dhcp_relay_address.go @@ -69,3 +69,9 @@ func (data *DHCPRelayAddress) fromBody(res gjson.Result, all bool) { data.Address = types.StringNull() } } + +func (data DHCPRelayAddress) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_dhcp_relay_interface.go b/internal/provider/model_nxos_dhcp_relay_interface.go index ff8637d7..b0c67e51 100644 --- a/internal/provider/model_nxos_dhcp_relay_interface.go +++ b/internal/provider/model_nxos_dhcp_relay_interface.go @@ -59,3 +59,9 @@ func (data *DHCPRelayInterface) fromBody(res gjson.Result, all bool) { data.InterfaceId = types.StringNull() } } + +func (data DHCPRelayInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ethernet.go b/internal/provider/model_nxos_ethernet.go index b1954a7f..269ba852 100644 --- a/internal/provider/model_nxos_ethernet.go +++ b/internal/provider/model_nxos_ethernet.go @@ -59,3 +59,9 @@ func (data *Ethernet) fromBody(res gjson.Result, all bool) { data.Mtu = types.Int64Null() } } + +func (data Ethernet) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_evpn.go b/internal/provider/model_nxos_evpn.go index 3780f23a..4ca3d435 100644 --- a/internal/provider/model_nxos_evpn.go +++ b/internal/provider/model_nxos_evpn.go @@ -57,3 +57,9 @@ func (data *EVPN) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data EVPN) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_evpn_vni.go b/internal/provider/model_nxos_evpn_vni.go index ac24c556..8470939a 100644 --- a/internal/provider/model_nxos_evpn_vni.go +++ b/internal/provider/model_nxos_evpn_vni.go @@ -68,3 +68,9 @@ func (data *EVPNVNI) fromBody(res gjson.Result, all bool) { data.RouteDistinguisher = types.StringNull() } } + +func (data EVPNVNI) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_evpn_vni_route_target.go b/internal/provider/model_nxos_evpn_vni_route_target.go index c7e091e8..70161325 100644 --- a/internal/provider/model_nxos_evpn_vni_route_target.go +++ b/internal/provider/model_nxos_evpn_vni_route_target.go @@ -61,3 +61,9 @@ func (data *EVPNVNIRouteTarget) fromBody(res gjson.Result, all bool) { data.RouteTarget = types.StringNull() } } + +func (data EVPNVNIRouteTarget) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_evpn_vni_route_target_direction.go b/internal/provider/model_nxos_evpn_vni_route_target_direction.go index fd79d65c..eab58a23 100644 --- a/internal/provider/model_nxos_evpn_vni_route_target_direction.go +++ b/internal/provider/model_nxos_evpn_vni_route_target_direction.go @@ -60,3 +60,9 @@ func (data *EVPNVNIRouteTargetDirection) fromBody(res gjson.Result, all bool) { data.Direction = types.StringNull() } } + +func (data EVPNVNIRouteTargetDirection) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_bfd.go b/internal/provider/model_nxos_feature_bfd.go index d4f78d4a..7fe442a5 100644 --- a/internal/provider/model_nxos_feature_bfd.go +++ b/internal/provider/model_nxos_feature_bfd.go @@ -57,3 +57,10 @@ func (data *FeatureBFD) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureBFD) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_bgp.go b/internal/provider/model_nxos_feature_bgp.go index aa1b7364..6df9fb8c 100644 --- a/internal/provider/model_nxos_feature_bgp.go +++ b/internal/provider/model_nxos_feature_bgp.go @@ -57,3 +57,10 @@ func (data *FeatureBGP) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureBGP) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_dhcp.go b/internal/provider/model_nxos_feature_dhcp.go index e599770c..b734cae3 100644 --- a/internal/provider/model_nxos_feature_dhcp.go +++ b/internal/provider/model_nxos_feature_dhcp.go @@ -57,3 +57,10 @@ func (data *FeatureDHCP) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureDHCP) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_evpn.go b/internal/provider/model_nxos_feature_evpn.go index ef2ee1af..ecd8f5a6 100644 --- a/internal/provider/model_nxos_feature_evpn.go +++ b/internal/provider/model_nxos_feature_evpn.go @@ -57,3 +57,10 @@ func (data *FeatureEVPN) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureEVPN) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_hmm.go b/internal/provider/model_nxos_feature_hmm.go index a093f531..3fe1c7c6 100644 --- a/internal/provider/model_nxos_feature_hmm.go +++ b/internal/provider/model_nxos_feature_hmm.go @@ -57,3 +57,10 @@ func (data *FeatureHMM) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureHMM) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_hsrp.go b/internal/provider/model_nxos_feature_hsrp.go index f0eb8648..c01848b6 100644 --- a/internal/provider/model_nxos_feature_hsrp.go +++ b/internal/provider/model_nxos_feature_hsrp.go @@ -57,3 +57,10 @@ func (data *FeatureHSRP) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureHSRP) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_interface_vlan.go b/internal/provider/model_nxos_feature_interface_vlan.go index 761f58a9..395528c8 100644 --- a/internal/provider/model_nxos_feature_interface_vlan.go +++ b/internal/provider/model_nxos_feature_interface_vlan.go @@ -57,3 +57,10 @@ func (data *FeatureInterfaceVLAN) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureInterfaceVLAN) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_isis.go b/internal/provider/model_nxos_feature_isis.go index 5862f118..2f1c4d58 100644 --- a/internal/provider/model_nxos_feature_isis.go +++ b/internal/provider/model_nxos_feature_isis.go @@ -57,3 +57,10 @@ func (data *FeatureISIS) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureISIS) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_lacp.go b/internal/provider/model_nxos_feature_lacp.go index 18b9869b..b4744edc 100644 --- a/internal/provider/model_nxos_feature_lacp.go +++ b/internal/provider/model_nxos_feature_lacp.go @@ -57,3 +57,10 @@ func (data *FeatureLACP) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureLACP) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_lldp.go b/internal/provider/model_nxos_feature_lldp.go index cea76959..3f2c1aa2 100644 --- a/internal/provider/model_nxos_feature_lldp.go +++ b/internal/provider/model_nxos_feature_lldp.go @@ -57,3 +57,10 @@ func (data *FeatureLLDP) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureLLDP) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_macsec.go b/internal/provider/model_nxos_feature_macsec.go index eaff9f91..41e07823 100644 --- a/internal/provider/model_nxos_feature_macsec.go +++ b/internal/provider/model_nxos_feature_macsec.go @@ -57,3 +57,10 @@ func (data *FeatureMACsec) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureMACsec) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_netflow.go b/internal/provider/model_nxos_feature_netflow.go index b2b51c33..96bd58bd 100644 --- a/internal/provider/model_nxos_feature_netflow.go +++ b/internal/provider/model_nxos_feature_netflow.go @@ -57,3 +57,10 @@ func (data *FeatureNetflow) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureNetflow) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_nv_overlay.go b/internal/provider/model_nxos_feature_nv_overlay.go index 39848fa0..088ecb8a 100644 --- a/internal/provider/model_nxos_feature_nv_overlay.go +++ b/internal/provider/model_nxos_feature_nv_overlay.go @@ -57,3 +57,10 @@ func (data *FeatureNVOverlay) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureNVOverlay) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_ospf.go b/internal/provider/model_nxos_feature_ospf.go index 140a7fc6..ee9ff2da 100644 --- a/internal/provider/model_nxos_feature_ospf.go +++ b/internal/provider/model_nxos_feature_ospf.go @@ -57,3 +57,10 @@ func (data *FeatureOSPF) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureOSPF) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_ospfv3.go b/internal/provider/model_nxos_feature_ospfv3.go index 0a4d547d..b917d552 100644 --- a/internal/provider/model_nxos_feature_ospfv3.go +++ b/internal/provider/model_nxos_feature_ospfv3.go @@ -57,3 +57,10 @@ func (data *FeatureOSPFv3) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureOSPFv3) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_pim.go b/internal/provider/model_nxos_feature_pim.go index c49b061b..6e1a914b 100644 --- a/internal/provider/model_nxos_feature_pim.go +++ b/internal/provider/model_nxos_feature_pim.go @@ -57,3 +57,10 @@ func (data *FeaturePIM) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeaturePIM) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_ptp.go b/internal/provider/model_nxos_feature_ptp.go index 7c0fe6eb..e078dfd5 100644 --- a/internal/provider/model_nxos_feature_ptp.go +++ b/internal/provider/model_nxos_feature_ptp.go @@ -57,3 +57,10 @@ func (data *FeaturePTP) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeaturePTP) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_pvlan.go b/internal/provider/model_nxos_feature_pvlan.go index 9db92290..71d2f259 100644 --- a/internal/provider/model_nxos_feature_pvlan.go +++ b/internal/provider/model_nxos_feature_pvlan.go @@ -57,3 +57,10 @@ func (data *FeaturePVLAN) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeaturePVLAN) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_ssh.go b/internal/provider/model_nxos_feature_ssh.go index 5c95b1c2..be274895 100644 --- a/internal/provider/model_nxos_feature_ssh.go +++ b/internal/provider/model_nxos_feature_ssh.go @@ -57,3 +57,10 @@ func (data *FeatureSSH) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureSSH) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "enabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_tacacs.go b/internal/provider/model_nxos_feature_tacacs.go index 8a8258bd..bfb7229c 100644 --- a/internal/provider/model_nxos_feature_tacacs.go +++ b/internal/provider/model_nxos_feature_tacacs.go @@ -57,3 +57,10 @@ func (data *FeatureTACACS) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureTACACS) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_telnet.go b/internal/provider/model_nxos_feature_telnet.go index 7ff8aa36..a97c72ff 100644 --- a/internal/provider/model_nxos_feature_telnet.go +++ b/internal/provider/model_nxos_feature_telnet.go @@ -57,3 +57,10 @@ func (data *FeatureTelnet) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureTelnet) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_udld.go b/internal/provider/model_nxos_feature_udld.go index 573a40a9..92404005 100644 --- a/internal/provider/model_nxos_feature_udld.go +++ b/internal/provider/model_nxos_feature_udld.go @@ -57,3 +57,10 @@ func (data *FeatureUDLD) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureUDLD) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_vn_segment.go b/internal/provider/model_nxos_feature_vn_segment.go index 821e2dee..eb60019f 100644 --- a/internal/provider/model_nxos_feature_vn_segment.go +++ b/internal/provider/model_nxos_feature_vn_segment.go @@ -57,3 +57,10 @@ func (data *FeatureVNSegment) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureVNSegment) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_feature_vpc.go b/internal/provider/model_nxos_feature_vpc.go index f5439673..f3aa66bf 100644 --- a/internal/provider/model_nxos_feature_vpc.go +++ b/internal/provider/model_nxos_feature_vpc.go @@ -57,3 +57,10 @@ func (data *FeatureVPC) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data FeatureVPC) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "disabled") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_hmm.go b/internal/provider/model_nxos_hmm.go index f9fd3ebd..6042852f 100644 --- a/internal/provider/model_nxos_hmm.go +++ b/internal/provider/model_nxos_hmm.go @@ -57,3 +57,9 @@ func (data *HMM) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data HMM) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_hmm_instance.go b/internal/provider/model_nxos_hmm_instance.go index 72ec50d7..1badf148 100644 --- a/internal/provider/model_nxos_hmm_instance.go +++ b/internal/provider/model_nxos_hmm_instance.go @@ -66,3 +66,9 @@ func (data *HMMInstance) fromBody(res gjson.Result, all bool) { data.AnycastMac = types.StringNull() } } + +func (data HMMInstance) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_hmm_interface.go b/internal/provider/model_nxos_hmm_interface.go index 0cb455ab..8197e801 100644 --- a/internal/provider/model_nxos_hmm_interface.go +++ b/internal/provider/model_nxos_hmm_interface.go @@ -77,3 +77,9 @@ func (data *HMMInterface) fromBody(res gjson.Result, all bool) { data.Mode = types.StringNull() } } + +func (data HMMInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ipv4_access_list.go b/internal/provider/model_nxos_ipv4_access_list.go index 6bd41f43..e701e7e2 100644 --- a/internal/provider/model_nxos_ipv4_access_list.go +++ b/internal/provider/model_nxos_ipv4_access_list.go @@ -59,3 +59,9 @@ func (data *IPv4AccessList) fromBody(res gjson.Result, all bool) { data.Name = types.StringNull() } } + +func (data IPv4AccessList) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ipv4_access_list_entry.go b/internal/provider/model_nxos_ipv4_access_list_entry.go index 6d1861c6..4a506241 100644 --- a/internal/provider/model_nxos_ipv4_access_list_entry.go +++ b/internal/provider/model_nxos_ipv4_access_list_entry.go @@ -467,3 +467,9 @@ func (data *IPv4AccessListEntry) fromBody(res gjson.Result, all bool) { data.Vni = types.StringNull() } } + +func (data IPv4AccessListEntry) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ipv4_access_list_policy_egress_interface.go b/internal/provider/model_nxos_ipv4_access_list_policy_egress_interface.go index f5a12569..c8c88b2e 100644 --- a/internal/provider/model_nxos_ipv4_access_list_policy_egress_interface.go +++ b/internal/provider/model_nxos_ipv4_access_list_policy_egress_interface.go @@ -82,3 +82,9 @@ func (data *IPv4AccessListPolicyEgressInterface) fromBody(res gjson.Result, all data.AccessListName = types.StringNull() } } + +func (data IPv4AccessListPolicyEgressInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ipv4_access_list_policy_ingress_interface.go b/internal/provider/model_nxos_ipv4_access_list_policy_ingress_interface.go index b00ee1a3..db9a9ee3 100644 --- a/internal/provider/model_nxos_ipv4_access_list_policy_ingress_interface.go +++ b/internal/provider/model_nxos_ipv4_access_list_policy_ingress_interface.go @@ -82,3 +82,9 @@ func (data *IPv4AccessListPolicyIngressInterface) fromBody(res gjson.Result, all data.AccessListName = types.StringNull() } } + +func (data IPv4AccessListPolicyIngressInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ipv4_interface.go b/internal/provider/model_nxos_ipv4_interface.go index 3dd326a9..4ae35e00 100644 --- a/internal/provider/model_nxos_ipv4_interface.go +++ b/internal/provider/model_nxos_ipv4_interface.go @@ -96,3 +96,9 @@ func (data *IPv4Interface) fromBody(res gjson.Result, all bool) { data.Urpf = types.StringNull() } } + +func (data IPv4Interface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ipv4_interface_address.go b/internal/provider/model_nxos_ipv4_interface_address.go index d510f8fd..3f2c9c83 100644 --- a/internal/provider/model_nxos_ipv4_interface_address.go +++ b/internal/provider/model_nxos_ipv4_interface_address.go @@ -70,3 +70,9 @@ func (data *IPv4InterfaceAddress) fromBody(res gjson.Result, all bool) { data.Type = types.StringNull() } } + +func (data IPv4InterfaceAddress) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ipv4_prefix_list_rule.go b/internal/provider/model_nxos_ipv4_prefix_list_rule.go index 0bf1ec85..c2091f53 100644 --- a/internal/provider/model_nxos_ipv4_prefix_list_rule.go +++ b/internal/provider/model_nxos_ipv4_prefix_list_rule.go @@ -59,3 +59,9 @@ func (data *IPv4PrefixListRule) fromBody(res gjson.Result, all bool) { data.Name = types.StringNull() } } + +func (data IPv4PrefixListRule) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ipv4_prefix_list_rule_entry.go b/internal/provider/model_nxos_ipv4_prefix_list_rule_entry.go index ed420b05..02081d96 100644 --- a/internal/provider/model_nxos_ipv4_prefix_list_rule_entry.go +++ b/internal/provider/model_nxos_ipv4_prefix_list_rule_entry.go @@ -106,3 +106,9 @@ func (data *IPv4PrefixListRuleEntry) fromBody(res gjson.Result, all bool) { data.ToRange = types.Int64Null() } } + +func (data IPv4PrefixListRuleEntry) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ipv4_static_route.go b/internal/provider/model_nxos_ipv4_static_route.go index fe8c1ba4..25846098 100644 --- a/internal/provider/model_nxos_ipv4_static_route.go +++ b/internal/provider/model_nxos_ipv4_static_route.go @@ -172,3 +172,9 @@ func (data *IPv4StaticRoute) fromBody(res gjson.Result, all bool) { } } } + +func (data IPv4StaticRoute) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ipv4_vrf.go b/internal/provider/model_nxos_ipv4_vrf.go index f10603b5..0f114446 100644 --- a/internal/provider/model_nxos_ipv4_vrf.go +++ b/internal/provider/model_nxos_ipv4_vrf.go @@ -59,3 +59,9 @@ func (data *IPv4VRF) fromBody(res gjson.Result, all bool) { data.Name = types.StringNull() } } + +func (data IPv4VRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_isis.go b/internal/provider/model_nxos_isis.go index 49b1589a..8d5ba75d 100644 --- a/internal/provider/model_nxos_isis.go +++ b/internal/provider/model_nxos_isis.go @@ -57,3 +57,9 @@ func (data *ISIS) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data ISIS) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_isis_instance.go b/internal/provider/model_nxos_isis_instance.go index a53993c0..441f5e67 100644 --- a/internal/provider/model_nxos_isis_instance.go +++ b/internal/provider/model_nxos_isis_instance.go @@ -68,3 +68,9 @@ func (data *ISISInstance) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data ISISInstance) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_isis_interface.go b/internal/provider/model_nxos_isis_interface.go index 85797f70..14b4fb33 100644 --- a/internal/provider/model_nxos_isis_interface.go +++ b/internal/provider/model_nxos_isis_interface.go @@ -307,3 +307,9 @@ func (data *ISISInterface) fromBody(res gjson.Result, all bool) { data.EnableIpv4 = types.BoolNull() } } + +func (data ISISInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_isis_vrf.go b/internal/provider/model_nxos_isis_vrf.go index e6db6e6a..b5fb387b 100644 --- a/internal/provider/model_nxos_isis_vrf.go +++ b/internal/provider/model_nxos_isis_vrf.go @@ -178,3 +178,9 @@ func (data *ISISVRF) fromBody(res gjson.Result, all bool) { data.PassiveDefault = types.StringNull() } } + +func (data ISISVRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_loopback_interface.go b/internal/provider/model_nxos_loopback_interface.go index fa2fcd6d..475a9b04 100644 --- a/internal/provider/model_nxos_loopback_interface.go +++ b/internal/provider/model_nxos_loopback_interface.go @@ -77,3 +77,9 @@ func (data *LoopbackInterface) fromBody(res gjson.Result, all bool) { data.Description = types.StringNull() } } + +func (data LoopbackInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_loopback_interface_vrf.go b/internal/provider/model_nxos_loopback_interface_vrf.go index 892d6a3e..b6514ca4 100644 --- a/internal/provider/model_nxos_loopback_interface_vrf.go +++ b/internal/provider/model_nxos_loopback_interface_vrf.go @@ -60,3 +60,9 @@ func (data *LoopbackInterfaceVRF) fromBody(res gjson.Result, all bool) { data.VrfDn = types.StringNull() } } + +func (data LoopbackInterfaceVRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ntp_server.go b/internal/provider/model_nxos_ntp_server.go index c7f3df93..20c8741d 100644 --- a/internal/provider/model_nxos_ntp_server.go +++ b/internal/provider/model_nxos_ntp_server.go @@ -105,3 +105,9 @@ func (data *NTPServer) fromBody(res gjson.Result, all bool) { data.MaxPoll = types.Int64Null() } } + +func (data NTPServer) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_nve_interface.go b/internal/provider/model_nxos_nve_interface.go index c6123c76..d4492212 100644 --- a/internal/provider/model_nxos_nve_interface.go +++ b/internal/provider/model_nxos_nve_interface.go @@ -150,3 +150,9 @@ func (data *NVEInterface) fromBody(res gjson.Result, all bool) { data.SuppressMacRoute = types.BoolNull() } } + +func (data NVEInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_nve_vni.go b/internal/provider/model_nxos_nve_vni.go index 78281daf..a3230225 100644 --- a/internal/provider/model_nxos_nve_vni.go +++ b/internal/provider/model_nxos_nve_vni.go @@ -97,3 +97,9 @@ func (data *NVEVNI) fromBody(res gjson.Result, all bool) { data.SuppressArp = types.StringNull() } } + +func (data NVEVNI) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_nve_vni_container.go b/internal/provider/model_nxos_nve_vni_container.go index 0f65efd0..8ca43830 100644 --- a/internal/provider/model_nxos_nve_vni_container.go +++ b/internal/provider/model_nxos_nve_vni_container.go @@ -48,3 +48,9 @@ func (data NVEVNIContainer) toBody() nxos.Body { func (data *NVEVNIContainer) fromBody(res gjson.Result, all bool) { } + +func (data NVEVNIContainer) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_nve_vni_ingress_replication.go b/internal/provider/model_nxos_nve_vni_ingress_replication.go index 5ef317f7..ae37bbe5 100644 --- a/internal/provider/model_nxos_nve_vni_ingress_replication.go +++ b/internal/provider/model_nxos_nve_vni_ingress_replication.go @@ -60,3 +60,9 @@ func (data *NVEVNIIngressReplication) fromBody(res gjson.Result, all bool) { data.Protocol = types.StringNull() } } + +func (data NVEVNIIngressReplication) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ospf.go b/internal/provider/model_nxos_ospf.go index 163570bd..749f1f6a 100644 --- a/internal/provider/model_nxos_ospf.go +++ b/internal/provider/model_nxos_ospf.go @@ -57,3 +57,9 @@ func (data *OSPF) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data OSPF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ospf_area.go b/internal/provider/model_nxos_ospf_area.go index be157a10..6e6072f8 100644 --- a/internal/provider/model_nxos_ospf_area.go +++ b/internal/provider/model_nxos_ospf_area.go @@ -89,3 +89,9 @@ func (data *OSPFArea) fromBody(res gjson.Result, all bool) { data.Type = types.StringNull() } } + +func (data OSPFArea) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ospf_authentication.go b/internal/provider/model_nxos_ospf_authentication.go index bf7fb0ac..858cec9c 100644 --- a/internal/provider/model_nxos_ospf_authentication.go +++ b/internal/provider/model_nxos_ospf_authentication.go @@ -108,3 +108,9 @@ func (data *OSPFAuthentication) fromBody(res gjson.Result, all bool) { data.Type = types.StringNull() } } + +func (data OSPFAuthentication) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ospf_instance.go b/internal/provider/model_nxos_ospf_instance.go index 2db6d4cc..831bc28e 100644 --- a/internal/provider/model_nxos_ospf_instance.go +++ b/internal/provider/model_nxos_ospf_instance.go @@ -68,3 +68,9 @@ func (data *OSPFInstance) fromBody(res gjson.Result, all bool) { data.Name = types.StringNull() } } + +func (data OSPFInstance) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ospf_interface.go b/internal/provider/model_nxos_ospf_interface.go index 34ef18da..239a5941 100644 --- a/internal/provider/model_nxos_ospf_interface.go +++ b/internal/provider/model_nxos_ospf_interface.go @@ -144,3 +144,9 @@ func (data *OSPFInterface) fromBody(res gjson.Result, all bool) { data.Priority = types.Int64Null() } } + +func (data OSPFInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_ospf_vrf.go b/internal/provider/model_nxos_ospf_vrf.go index 52deac33..fccf6459 100644 --- a/internal/provider/model_nxos_ospf_vrf.go +++ b/internal/provider/model_nxos_ospf_vrf.go @@ -106,3 +106,9 @@ func (data *OSPFVRF) fromBody(res gjson.Result, all bool) { data.RouterId = types.StringNull() } } + +func (data OSPFVRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_physical_interface.go b/internal/provider/model_nxos_physical_interface.go index 69a1eabe..c44997a4 100644 --- a/internal/provider/model_nxos_physical_interface.go +++ b/internal/provider/model_nxos_physical_interface.go @@ -249,3 +249,30 @@ func (data *PhysicalInterface) fromBody(res gjson.Result, all bool) { data.UserConfiguredFlags = types.StringNull() } } + +func (data PhysicalInterface) toDeleteBody() nxos.Body { + body := "" + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"FECMode", "auto") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"accessVlan", "vlan-1") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"adminSt", "DME_UNSET_PROPERTY_MARKER") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"autoNeg", "on") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"bw", strconv.FormatInt(0, 10)) + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"delay", strconv.FormatInt(1, 10)) + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"descr", "DME_UNSET_PROPERTY_MARKER") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"duplex", "auto") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"layer", "Layer2") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"linkLog", "default") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"linkDebounce", strconv.FormatInt(100, 10)) + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"linkDebounceLinkUp", strconv.FormatInt(0, 10)) + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"medium", "broadcast") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"mode", "access") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"mtu", strconv.FormatInt(1500, 10)) + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"nativeVlan", "vlan-1") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"speed", "auto") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"speedGroup", "auto") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"trunkVlans", "1-4094") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"uniDirectionalEthernet", "disable") + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"userCfgdFlags", "none") + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_physical_interface_vrf.go b/internal/provider/model_nxos_physical_interface_vrf.go index 03131200..39f425ff 100644 --- a/internal/provider/model_nxos_physical_interface_vrf.go +++ b/internal/provider/model_nxos_physical_interface_vrf.go @@ -60,3 +60,9 @@ func (data *PhysicalInterfaceVRF) fromBody(res gjson.Result, all bool) { data.VrfDn = types.StringNull() } } + +func (data PhysicalInterfaceVRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim.go b/internal/provider/model_nxos_pim.go index cbc6d187..66902b30 100644 --- a/internal/provider/model_nxos_pim.go +++ b/internal/provider/model_nxos_pim.go @@ -57,3 +57,9 @@ func (data *PIM) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data PIM) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim_anycast_rp.go b/internal/provider/model_nxos_pim_anycast_rp.go index c816d63b..ac9ef5ef 100644 --- a/internal/provider/model_nxos_pim_anycast_rp.go +++ b/internal/provider/model_nxos_pim_anycast_rp.go @@ -69,3 +69,9 @@ func (data *PIMAnycastRP) fromBody(res gjson.Result, all bool) { data.SourceInterface = types.StringNull() } } + +func (data PIMAnycastRP) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim_anycast_rp_peer.go b/internal/provider/model_nxos_pim_anycast_rp_peer.go index 055328c4..d9a00e47 100644 --- a/internal/provider/model_nxos_pim_anycast_rp_peer.go +++ b/internal/provider/model_nxos_pim_anycast_rp_peer.go @@ -69,3 +69,9 @@ func (data *PIMAnycastRPPeer) fromBody(res gjson.Result, all bool) { data.RpSetAddress = types.StringNull() } } + +func (data PIMAnycastRPPeer) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim_instance.go b/internal/provider/model_nxos_pim_instance.go index cb40a9aa..d9ff6bc1 100644 --- a/internal/provider/model_nxos_pim_instance.go +++ b/internal/provider/model_nxos_pim_instance.go @@ -57,3 +57,9 @@ func (data *PIMInstance) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data PIMInstance) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim_interface.go b/internal/provider/model_nxos_pim_interface.go index ceb64139..9cb77c21 100644 --- a/internal/provider/model_nxos_pim_interface.go +++ b/internal/provider/model_nxos_pim_interface.go @@ -107,3 +107,9 @@ func (data *PIMInterface) fromBody(res gjson.Result, all bool) { data.SparseMode = types.BoolNull() } } + +func (data PIMInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim_ssm_policy.go b/internal/provider/model_nxos_pim_ssm_policy.go index 213f26f3..987f3599 100644 --- a/internal/provider/model_nxos_pim_ssm_policy.go +++ b/internal/provider/model_nxos_pim_ssm_policy.go @@ -60,3 +60,9 @@ func (data *PIMSSMPolicy) fromBody(res gjson.Result, all bool) { data.Name = types.StringNull() } } + +func (data PIMSSMPolicy) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim_ssm_range.go b/internal/provider/model_nxos_pim_ssm_range.go index a18513ba..d4310273 100644 --- a/internal/provider/model_nxos_pim_ssm_range.go +++ b/internal/provider/model_nxos_pim_ssm_range.go @@ -116,3 +116,9 @@ func (data *PIMSSMRange) fromBody(res gjson.Result, all bool) { data.SsmNone = types.BoolNull() } } + +func (data PIMSSMRange) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim_static_rp.go b/internal/provider/model_nxos_pim_static_rp.go index db878a41..f1910fb0 100644 --- a/internal/provider/model_nxos_pim_static_rp.go +++ b/internal/provider/model_nxos_pim_static_rp.go @@ -60,3 +60,9 @@ func (data *PIMStaticRP) fromBody(res gjson.Result, all bool) { data.Address = types.StringNull() } } + +func (data PIMStaticRP) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim_static_rp_group_list.go b/internal/provider/model_nxos_pim_static_rp_group_list.go index eb3f98a3..63a3f94c 100644 --- a/internal/provider/model_nxos_pim_static_rp_group_list.go +++ b/internal/provider/model_nxos_pim_static_rp_group_list.go @@ -81,3 +81,9 @@ func (data *PIMStaticRPGroupList) fromBody(res gjson.Result, all bool) { data.Override = types.BoolNull() } } + +func (data PIMStaticRPGroupList) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim_static_rp_policy.go b/internal/provider/model_nxos_pim_static_rp_policy.go index 4c85fa9c..2098b6fd 100644 --- a/internal/provider/model_nxos_pim_static_rp_policy.go +++ b/internal/provider/model_nxos_pim_static_rp_policy.go @@ -60,3 +60,9 @@ func (data *PIMStaticRPPolicy) fromBody(res gjson.Result, all bool) { data.Name = types.StringNull() } } + +func (data PIMStaticRPPolicy) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_pim_vrf.go b/internal/provider/model_nxos_pim_vrf.go index 6d06b1d2..bf644ec7 100644 --- a/internal/provider/model_nxos_pim_vrf.go +++ b/internal/provider/model_nxos_pim_vrf.go @@ -79,3 +79,9 @@ func (data *PIMVRF) fromBody(res gjson.Result, all bool) { data.Bfd = types.BoolNull() } } + +func (data PIMVRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_port_channel_interface.go b/internal/provider/model_nxos_port_channel_interface.go index 91019b0a..aa813fb2 100644 --- a/internal/provider/model_nxos_port_channel_interface.go +++ b/internal/provider/model_nxos_port_channel_interface.go @@ -240,3 +240,9 @@ func (data *PortChannelInterface) fromBody(res gjson.Result, all bool) { data.UserConfiguredFlags = types.StringNull() } } + +func (data PortChannelInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_port_channel_interface_member.go b/internal/provider/model_nxos_port_channel_interface_member.go index d14382d2..7a628a2e 100644 --- a/internal/provider/model_nxos_port_channel_interface_member.go +++ b/internal/provider/model_nxos_port_channel_interface_member.go @@ -71,3 +71,9 @@ func (data *PortChannelInterfaceMember) fromBody(res gjson.Result, all bool) { data.Force = types.BoolNull() } } + +func (data PortChannelInterfaceMember) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_port_channel_interface_vrf.go b/internal/provider/model_nxos_port_channel_interface_vrf.go index 023edae4..a12b76ff 100644 --- a/internal/provider/model_nxos_port_channel_interface_vrf.go +++ b/internal/provider/model_nxos_port_channel_interface_vrf.go @@ -60,3 +60,9 @@ func (data *PortChannelInterfaceVRF) fromBody(res gjson.Result, all bool) { data.VrfDn = types.StringNull() } } + +func (data PortChannelInterfaceVRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_queuing_qos_policy_map.go b/internal/provider/model_nxos_queuing_qos_policy_map.go index a72712bd..628705fb 100644 --- a/internal/provider/model_nxos_queuing_qos_policy_map.go +++ b/internal/provider/model_nxos_queuing_qos_policy_map.go @@ -68,3 +68,9 @@ func (data *QueuingQOSPolicyMap) fromBody(res gjson.Result, all bool) { data.MatchType = types.StringNull() } } + +func (data QueuingQOSPolicyMap) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map.go b/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map.go index 71abdab6..16404b3e 100644 --- a/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map.go +++ b/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map.go @@ -60,3 +60,9 @@ func (data *QueuingQOSPolicyMapMatchClassMap) fromBody(res gjson.Result, all boo data.Name = types.StringNull() } } + +func (data QueuingQOSPolicyMapMatchClassMap) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map_priority.go b/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map_priority.go index a69cc728..a30779b8 100644 --- a/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map_priority.go +++ b/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map_priority.go @@ -62,3 +62,9 @@ func (data *QueuingQOSPolicyMapMatchClassMapPriority) fromBody(res gjson.Result, data.Level = types.Int64Null() } } + +func (data QueuingQOSPolicyMapMatchClassMapPriority) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map_remaining_bandwidth.go b/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map_remaining_bandwidth.go index d7d89707..e2b0876c 100644 --- a/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map_remaining_bandwidth.go +++ b/internal/provider/model_nxos_queuing_qos_policy_map_match_class_map_remaining_bandwidth.go @@ -62,3 +62,9 @@ func (data *QueuingQOSPolicyMapMatchClassMapRemainingBandwidth) fromBody(res gjs data.Value = types.Int64Null() } } + +func (data QueuingQOSPolicyMapMatchClassMapRemainingBandwidth) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_queuing_qos_policy_system_out.go b/internal/provider/model_nxos_queuing_qos_policy_system_out.go index 1a899984..f965399f 100644 --- a/internal/provider/model_nxos_queuing_qos_policy_system_out.go +++ b/internal/provider/model_nxos_queuing_qos_policy_system_out.go @@ -48,3 +48,9 @@ func (data QueuingQOSPolicySystemOut) toBody() nxos.Body { func (data *QueuingQOSPolicySystemOut) fromBody(res gjson.Result, all bool) { } + +func (data QueuingQOSPolicySystemOut) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_queuing_qos_policy_system_out_policy_map.go b/internal/provider/model_nxos_queuing_qos_policy_system_out_policy_map.go index 981880c7..f1ffcca1 100644 --- a/internal/provider/model_nxos_queuing_qos_policy_system_out_policy_map.go +++ b/internal/provider/model_nxos_queuing_qos_policy_system_out_policy_map.go @@ -57,3 +57,9 @@ func (data *QueuingQOSPolicySystemOutPolicyMap) fromBody(res gjson.Result, all b data.PolicyMapName = types.StringNull() } } + +func (data QueuingQOSPolicySystemOutPolicyMap) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_route_map_rule.go b/internal/provider/model_nxos_route_map_rule.go index ddf02498..470ea5f3 100644 --- a/internal/provider/model_nxos_route_map_rule.go +++ b/internal/provider/model_nxos_route_map_rule.go @@ -59,3 +59,9 @@ func (data *RouteMapRule) fromBody(res gjson.Result, all bool) { data.Name = types.StringNull() } } + +func (data RouteMapRule) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_route_map_rule_entry.go b/internal/provider/model_nxos_route_map_rule_entry.go index d5a017b2..d300bf43 100644 --- a/internal/provider/model_nxos_route_map_rule_entry.go +++ b/internal/provider/model_nxos_route_map_rule_entry.go @@ -70,3 +70,9 @@ func (data *RouteMapRuleEntry) fromBody(res gjson.Result, all bool) { data.Action = types.StringNull() } } + +func (data RouteMapRuleEntry) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_route_map_rule_entry_match_route.go b/internal/provider/model_nxos_route_map_rule_entry_match_route.go index daa4b993..b9855d02 100644 --- a/internal/provider/model_nxos_route_map_rule_entry_match_route.go +++ b/internal/provider/model_nxos_route_map_rule_entry_match_route.go @@ -52,3 +52,9 @@ func (data RouteMapRuleEntryMatchRoute) toBody() nxos.Body { func (data *RouteMapRuleEntryMatchRoute) fromBody(res gjson.Result, all bool) { } + +func (data RouteMapRuleEntryMatchRoute) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_route_map_rule_entry_match_route_prefix_list.go b/internal/provider/model_nxos_route_map_rule_entry_match_route_prefix_list.go index be1649e5..10e2408c 100644 --- a/internal/provider/model_nxos_route_map_rule_entry_match_route_prefix_list.go +++ b/internal/provider/model_nxos_route_map_rule_entry_match_route_prefix_list.go @@ -61,3 +61,9 @@ func (data *RouteMapRuleEntryMatchRoutePrefixList) fromBody(res gjson.Result, al data.PrefixListDn = types.StringNull() } } + +func (data RouteMapRuleEntryMatchRoutePrefixList) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_route_map_rule_entry_set_regular_community.go b/internal/provider/model_nxos_route_map_rule_entry_set_regular_community.go index b7d9f1ff..81e8ad91 100644 --- a/internal/provider/model_nxos_route_map_rule_entry_set_regular_community.go +++ b/internal/provider/model_nxos_route_map_rule_entry_set_regular_community.go @@ -79,3 +79,9 @@ func (data *RouteMapRuleEntrySetRegularCommunity) fromBody(res gjson.Result, all data.SetCriteria = types.StringNull() } } + +func (data RouteMapRuleEntrySetRegularCommunity) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_route_map_rule_entry_set_regular_community_item.go b/internal/provider/model_nxos_route_map_rule_entry_set_regular_community_item.go index 4262325d..1f7a88ff 100644 --- a/internal/provider/model_nxos_route_map_rule_entry_set_regular_community_item.go +++ b/internal/provider/model_nxos_route_map_rule_entry_set_regular_community_item.go @@ -61,3 +61,9 @@ func (data *RouteMapRuleEntrySetRegularCommunityItem) fromBody(res gjson.Result, data.Community = types.StringNull() } } + +func (data RouteMapRuleEntrySetRegularCommunityItem) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_spanning_tree_interface.go b/internal/provider/model_nxos_spanning_tree_interface.go index 01aa6c52..278a1326 100644 --- a/internal/provider/model_nxos_spanning_tree_interface.go +++ b/internal/provider/model_nxos_spanning_tree_interface.go @@ -132,3 +132,9 @@ func (data *SpanningTreeInterface) fromBody(res gjson.Result, all bool) { data.Priority = types.Int64Null() } } + +func (data SpanningTreeInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_subinterface.go b/internal/provider/model_nxos_subinterface.go index 866743a6..53079824 100644 --- a/internal/provider/model_nxos_subinterface.go +++ b/internal/provider/model_nxos_subinterface.go @@ -132,3 +132,9 @@ func (data *Subinterface) fromBody(res gjson.Result, all bool) { data.Mtu = types.Int64Null() } } + +func (data Subinterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_subinterface_vrf.go b/internal/provider/model_nxos_subinterface_vrf.go index 3bd150fc..a9d0957f 100644 --- a/internal/provider/model_nxos_subinterface_vrf.go +++ b/internal/provider/model_nxos_subinterface_vrf.go @@ -60,3 +60,9 @@ func (data *SubinterfaceVRF) fromBody(res gjson.Result, all bool) { data.VrfDn = types.StringNull() } } + +func (data SubinterfaceVRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_svi_interface.go b/internal/provider/model_nxos_svi_interface.go index e6d36240..922de2c1 100644 --- a/internal/provider/model_nxos_svi_interface.go +++ b/internal/provider/model_nxos_svi_interface.go @@ -114,3 +114,9 @@ func (data *SVIInterface) fromBody(res gjson.Result, all bool) { data.Mtu = types.Int64Null() } } + +func (data SVIInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_svi_interface_vrf.go b/internal/provider/model_nxos_svi_interface_vrf.go index ee73bd98..9b7f6594 100644 --- a/internal/provider/model_nxos_svi_interface_vrf.go +++ b/internal/provider/model_nxos_svi_interface_vrf.go @@ -60,3 +60,9 @@ func (data *SVIInterfaceVRF) fromBody(res gjson.Result, all bool) { data.VrfDn = types.StringNull() } } + +func (data SVIInterfaceVRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_system.go b/internal/provider/model_nxos_system.go index f285e141..0189e811 100644 --- a/internal/provider/model_nxos_system.go +++ b/internal/provider/model_nxos_system.go @@ -57,3 +57,9 @@ func (data *System) fromBody(res gjson.Result, all bool) { data.Name = types.StringNull() } } + +func (data System) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vpc_domain.go b/internal/provider/model_nxos_vpc_domain.go index ec59abc3..b7020f21 100644 --- a/internal/provider/model_nxos_vpc_domain.go +++ b/internal/provider/model_nxos_vpc_domain.go @@ -239,3 +239,9 @@ func (data *VPCDomain) fromBody(res gjson.Result, all bool) { data.VirtualIp = types.StringNull() } } + +func (data VPCDomain) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vpc_instance.go b/internal/provider/model_nxos_vpc_instance.go index 8f1fac72..ea13402b 100644 --- a/internal/provider/model_nxos_vpc_instance.go +++ b/internal/provider/model_nxos_vpc_instance.go @@ -57,3 +57,9 @@ func (data *VPCInstance) fromBody(res gjson.Result, all bool) { data.AdminState = types.StringNull() } } + +func (data VPCInstance) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vpc_interface.go b/internal/provider/model_nxos_vpc_interface.go index 98022e1b..b4e10ea2 100644 --- a/internal/provider/model_nxos_vpc_interface.go +++ b/internal/provider/model_nxos_vpc_interface.go @@ -83,3 +83,9 @@ func (data *VPCInterface) fromBody(res gjson.Result, all bool) { data.PortChannelInterfaceDn = types.StringNull() } } + +func (data VPCInterface) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vpc_keepalive.go b/internal/provider/model_nxos_vpc_keepalive.go index fc2504a6..e3522972 100644 --- a/internal/provider/model_nxos_vpc_keepalive.go +++ b/internal/provider/model_nxos_vpc_keepalive.go @@ -167,3 +167,9 @@ func (data *VPCKeepalive) fromBody(res gjson.Result, all bool) { data.Vrf = types.StringNull() } } + +func (data VPCKeepalive) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vpc_peerlink.go b/internal/provider/model_nxos_vpc_peerlink.go index ffe941a4..a19962e3 100644 --- a/internal/provider/model_nxos_vpc_peerlink.go +++ b/internal/provider/model_nxos_vpc_peerlink.go @@ -57,3 +57,9 @@ func (data *VPCPeerlink) fromBody(res gjson.Result, all bool) { data.PortChannelId = types.StringNull() } } + +func (data VPCPeerlink) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vrf.go b/internal/provider/model_nxos_vrf.go index 65fcf867..3d4ca1ca 100644 --- a/internal/provider/model_nxos_vrf.go +++ b/internal/provider/model_nxos_vrf.go @@ -77,3 +77,9 @@ func (data *VRF) fromBody(res gjson.Result, all bool) { data.Encap = types.StringNull() } } + +func (data VRF) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vrf_address_family.go b/internal/provider/model_nxos_vrf_address_family.go index ade80d0e..4ba06dd0 100644 --- a/internal/provider/model_nxos_vrf_address_family.go +++ b/internal/provider/model_nxos_vrf_address_family.go @@ -60,3 +60,9 @@ func (data *VRFAddressFamily) fromBody(res gjson.Result, all bool) { data.AddressFamily = types.StringNull() } } + +func (data VRFAddressFamily) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vrf_route_target.go b/internal/provider/model_nxos_vrf_route_target.go index 56bd3e12..6c05ec8d 100644 --- a/internal/provider/model_nxos_vrf_route_target.go +++ b/internal/provider/model_nxos_vrf_route_target.go @@ -63,3 +63,9 @@ func (data *VRFRouteTarget) fromBody(res gjson.Result, all bool) { data.RouteTarget = types.StringNull() } } + +func (data VRFRouteTarget) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vrf_route_target_address_family.go b/internal/provider/model_nxos_vrf_route_target_address_family.go index 8082fc4b..509e3780 100644 --- a/internal/provider/model_nxos_vrf_route_target_address_family.go +++ b/internal/provider/model_nxos_vrf_route_target_address_family.go @@ -61,3 +61,9 @@ func (data *VRFRouteTargetAddressFamily) fromBody(res gjson.Result, all bool) { data.RouteTargetAddressFamily = types.StringNull() } } + +func (data VRFRouteTargetAddressFamily) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vrf_route_target_direction.go b/internal/provider/model_nxos_vrf_route_target_direction.go index 49cb894e..c9df957f 100644 --- a/internal/provider/model_nxos_vrf_route_target_direction.go +++ b/internal/provider/model_nxos_vrf_route_target_direction.go @@ -62,3 +62,9 @@ func (data *VRFRouteTargetDirection) fromBody(res gjson.Result, all bool) { data.Direction = types.StringNull() } } + +func (data VRFRouteTargetDirection) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/model_nxos_vrf_routing.go b/internal/provider/model_nxos_vrf_routing.go index 8390eb09..2d3a373c 100644 --- a/internal/provider/model_nxos_vrf_routing.go +++ b/internal/provider/model_nxos_vrf_routing.go @@ -60,3 +60,9 @@ func (data *VRFRouting) fromBody(res gjson.Result, all bool) { data.RouteDistinguisher = types.StringNull() } } + +func (data VRFRouting) toDeleteBody() nxos.Body { + body := "" + + return nxos.Body{body} +} diff --git a/internal/provider/resource_nxos_bgp.go b/internal/provider/resource_nxos_bgp.go index e248b357..9fc19c00 100644 --- a/internal/provider/resource_nxos_bgp.go +++ b/internal/provider/resource_nxos_bgp.go @@ -184,14 +184,24 @@ func (r *BGPResource) Delete(ctx context.Context, req resource.DeleteRequest, re tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_address_family.go b/internal/provider/resource_nxos_bgp_address_family.go index f3a8e162..c00b4b87 100644 --- a/internal/provider/resource_nxos_bgp_address_family.go +++ b/internal/provider/resource_nxos_bgp_address_family.go @@ -218,14 +218,24 @@ func (r *BGPAddressFamilyResource) Delete(ctx context.Context, req resource.Dele tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_advertised_prefix.go b/internal/provider/resource_nxos_bgp_advertised_prefix.go index 5543c442..f14777c1 100644 --- a/internal/provider/resource_nxos_bgp_advertised_prefix.go +++ b/internal/provider/resource_nxos_bgp_advertised_prefix.go @@ -209,14 +209,24 @@ func (r *BGPAdvertisedPrefixResource) Delete(ctx context.Context, req resource.D tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_graceful_restart.go b/internal/provider/resource_nxos_bgp_graceful_restart.go index 5ade8093..897f70a0 100644 --- a/internal/provider/resource_nxos_bgp_graceful_restart.go +++ b/internal/provider/resource_nxos_bgp_graceful_restart.go @@ -207,14 +207,24 @@ func (r *BGPGracefulRestartResource) Delete(ctx context.Context, req resource.De tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_instance.go b/internal/provider/resource_nxos_bgp_instance.go index 277df304..e992235b 100644 --- a/internal/provider/resource_nxos_bgp_instance.go +++ b/internal/provider/resource_nxos_bgp_instance.go @@ -198,14 +198,24 @@ func (r *BGPInstanceResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_peer.go b/internal/provider/resource_nxos_bgp_peer.go index 50766638..858acf3d 100644 --- a/internal/provider/resource_nxos_bgp_peer.go +++ b/internal/provider/resource_nxos_bgp_peer.go @@ -243,14 +243,24 @@ func (r *BGPPeerResource) Delete(ctx context.Context, req resource.DeleteRequest tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_peer_address_family.go b/internal/provider/resource_nxos_bgp_peer_address_family.go index be6ff5ad..aa17f812 100644 --- a/internal/provider/resource_nxos_bgp_peer_address_family.go +++ b/internal/provider/resource_nxos_bgp_peer_address_family.go @@ -228,14 +228,24 @@ func (r *BGPPeerAddressFamilyResource) Delete(ctx context.Context, req resource. tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_peer_address_family_prefix_list_control.go b/internal/provider/resource_nxos_bgp_peer_address_family_prefix_list_control.go index 0258f4a9..43879dfc 100644 --- a/internal/provider/resource_nxos_bgp_peer_address_family_prefix_list_control.go +++ b/internal/provider/resource_nxos_bgp_peer_address_family_prefix_list_control.go @@ -219,14 +219,24 @@ func (r *BGPPeerAddressFamilyPrefixListControlResource) Delete(ctx context.Conte tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_peer_address_family_route_control.go b/internal/provider/resource_nxos_bgp_peer_address_family_route_control.go index 9500a367..b59dfd5d 100644 --- a/internal/provider/resource_nxos_bgp_peer_address_family_route_control.go +++ b/internal/provider/resource_nxos_bgp_peer_address_family_route_control.go @@ -219,14 +219,24 @@ func (r *BGPPeerAddressFamilyRouteControlResource) Delete(ctx context.Context, r tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_peer_template.go b/internal/provider/resource_nxos_bgp_peer_template.go index 8566d25e..0cf226cf 100644 --- a/internal/provider/resource_nxos_bgp_peer_template.go +++ b/internal/provider/resource_nxos_bgp_peer_template.go @@ -212,14 +212,24 @@ func (r *BGPPeerTemplateResource) Delete(ctx context.Context, req resource.Delet tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_peer_template_address_family.go b/internal/provider/resource_nxos_bgp_peer_template_address_family.go index 1c844662..fee412a3 100644 --- a/internal/provider/resource_nxos_bgp_peer_template_address_family.go +++ b/internal/provider/resource_nxos_bgp_peer_template_address_family.go @@ -221,14 +221,24 @@ func (r *BGPPeerTemplateAddressFamilyResource) Delete(ctx context.Context, req r tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_peer_template_max_prefix.go b/internal/provider/resource_nxos_bgp_peer_template_max_prefix.go index 2b971a4f..e8c0a370 100644 --- a/internal/provider/resource_nxos_bgp_peer_template_max_prefix.go +++ b/internal/provider/resource_nxos_bgp_peer_template_max_prefix.go @@ -232,14 +232,24 @@ func (r *BGPPeerTemplateMaxPrefixResource) Delete(ctx context.Context, req resou tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_route_control.go b/internal/provider/resource_nxos_bgp_route_control.go index 56685e87..026ed8e5 100644 --- a/internal/provider/resource_nxos_bgp_route_control.go +++ b/internal/provider/resource_nxos_bgp_route_control.go @@ -225,14 +225,24 @@ func (r *BGPRouteControlResource) Delete(ctx context.Context, req resource.Delet tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bgp_vrf.go b/internal/provider/resource_nxos_bgp_vrf.go index fb36d30a..914f37a8 100644 --- a/internal/provider/resource_nxos_bgp_vrf.go +++ b/internal/provider/resource_nxos_bgp_vrf.go @@ -190,14 +190,24 @@ func (r *BGPVRFResource) Delete(ctx context.Context, req resource.DeleteRequest, tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_bridge_domain.go b/internal/provider/resource_nxos_bridge_domain.go index c09eb519..0d49f772 100644 --- a/internal/provider/resource_nxos_bridge_domain.go +++ b/internal/provider/resource_nxos_bridge_domain.go @@ -190,14 +190,24 @@ func (r *BridgeDomainResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_default_qos_class_map.go b/internal/provider/resource_nxos_default_qos_class_map.go index f8a3a4e4..3c8ced68 100644 --- a/internal/provider/resource_nxos_default_qos_class_map.go +++ b/internal/provider/resource_nxos_default_qos_class_map.go @@ -191,14 +191,24 @@ func (r *DefaultQOSClassMapResource) Delete(ctx context.Context, req resource.De tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_default_qos_class_map_dscp.go b/internal/provider/resource_nxos_default_qos_class_map_dscp.go index 6cd29cb3..1a14ab42 100644 --- a/internal/provider/resource_nxos_default_qos_class_map_dscp.go +++ b/internal/provider/resource_nxos_default_qos_class_map_dscp.go @@ -186,14 +186,24 @@ func (r *DefaultQOSClassMapDSCPResource) Delete(ctx context.Context, req resourc tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_default_qos_policy_interface_in.go b/internal/provider/resource_nxos_default_qos_policy_interface_in.go index d5dd1866..04fb8558 100644 --- a/internal/provider/resource_nxos_default_qos_policy_interface_in.go +++ b/internal/provider/resource_nxos_default_qos_policy_interface_in.go @@ -179,14 +179,24 @@ func (r *DefaultQOSPolicyInterfaceInResource) Delete(ctx context.Context, req re tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_default_qos_policy_interface_in_policy_map.go b/internal/provider/resource_nxos_default_qos_policy_interface_in_policy_map.go index 84379c10..0a1e7cf9 100644 --- a/internal/provider/resource_nxos_default_qos_policy_interface_in_policy_map.go +++ b/internal/provider/resource_nxos_default_qos_policy_interface_in_policy_map.go @@ -183,14 +183,24 @@ func (r *DefaultQOSPolicyInterfaceInPolicyMapResource) Delete(ctx context.Contex tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_default_qos_policy_map.go b/internal/provider/resource_nxos_default_qos_policy_map.go index 4a2d613f..9b1954f5 100644 --- a/internal/provider/resource_nxos_default_qos_policy_map.go +++ b/internal/provider/resource_nxos_default_qos_policy_map.go @@ -191,14 +191,24 @@ func (r *DefaultQOSPolicyMapResource) Delete(ctx context.Context, req resource.D tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_default_qos_policy_map_match_class_map.go b/internal/provider/resource_nxos_default_qos_policy_map_match_class_map.go index 075c84cb..2d1a5e83 100644 --- a/internal/provider/resource_nxos_default_qos_policy_map_match_class_map.go +++ b/internal/provider/resource_nxos_default_qos_policy_map_match_class_map.go @@ -186,14 +186,24 @@ func (r *DefaultQOSPolicyMapMatchClassMapResource) Delete(ctx context.Context, r tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_default_qos_policy_map_match_class_map_police.go b/internal/provider/resource_nxos_default_qos_policy_map_match_class_map_police.go index f06aa4e5..57403296 100644 --- a/internal/provider/resource_nxos_default_qos_policy_map_match_class_map_police.go +++ b/internal/provider/resource_nxos_default_qos_policy_map_match_class_map_police.go @@ -396,14 +396,24 @@ func (r *DefaultQOSPolicyMapMatchClassMapPoliceResource) Delete(ctx context.Cont tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_default_qos_policy_map_match_class_map_set_qos_group.go b/internal/provider/resource_nxos_default_qos_policy_map_match_class_map_set_qos_group.go index bbfe9d18..89c8d297 100644 --- a/internal/provider/resource_nxos_default_qos_policy_map_match_class_map_set_qos_group.go +++ b/internal/provider/resource_nxos_default_qos_policy_map_match_class_map_set_qos_group.go @@ -198,14 +198,24 @@ func (r *DefaultQOSPolicyMapMatchClassMapSetQOSGroupResource) Delete(ctx context tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_dhcp_relay_address.go b/internal/provider/resource_nxos_dhcp_relay_address.go index e367b85d..8a04a67e 100644 --- a/internal/provider/resource_nxos_dhcp_relay_address.go +++ b/internal/provider/resource_nxos_dhcp_relay_address.go @@ -193,14 +193,24 @@ func (r *DHCPRelayAddressResource) Delete(ctx context.Context, req resource.Dele tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_dhcp_relay_interface.go b/internal/provider/resource_nxos_dhcp_relay_interface.go index 2178955a..2f6cbcff 100644 --- a/internal/provider/resource_nxos_dhcp_relay_interface.go +++ b/internal/provider/resource_nxos_dhcp_relay_interface.go @@ -179,14 +179,24 @@ func (r *DHCPRelayInterfaceResource) Delete(ctx context.Context, req resource.De tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ethernet.go b/internal/provider/resource_nxos_ethernet.go index 15143294..8db9faf9 100644 --- a/internal/provider/resource_nxos_ethernet.go +++ b/internal/provider/resource_nxos_ethernet.go @@ -184,14 +184,24 @@ func (r *EthernetResource) Delete(ctx context.Context, req resource.DeleteReques tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_evpn.go b/internal/provider/resource_nxos_evpn.go index 95b29bbc..87495fc8 100644 --- a/internal/provider/resource_nxos_evpn.go +++ b/internal/provider/resource_nxos_evpn.go @@ -184,14 +184,24 @@ func (r *EVPNResource) Delete(ctx context.Context, req resource.DeleteRequest, r tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_evpn_vni.go b/internal/provider/resource_nxos_evpn_vni.go index 3241bb5e..a2437ae9 100644 --- a/internal/provider/resource_nxos_evpn_vni.go +++ b/internal/provider/resource_nxos_evpn_vni.go @@ -186,14 +186,24 @@ func (r *EVPNVNIResource) Delete(ctx context.Context, req resource.DeleteRequest tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_evpn_vni_route_target.go b/internal/provider/resource_nxos_evpn_vni_route_target.go index 8a7ac911..5bf4e990 100644 --- a/internal/provider/resource_nxos_evpn_vni_route_target.go +++ b/internal/provider/resource_nxos_evpn_vni_route_target.go @@ -198,14 +198,24 @@ func (r *EVPNVNIRouteTargetResource) Delete(ctx context.Context, req resource.De tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_evpn_vni_route_target_direction.go b/internal/provider/resource_nxos_evpn_vni_route_target_direction.go index 456f49de..372a77d1 100644 --- a/internal/provider/resource_nxos_evpn_vni_route_target_direction.go +++ b/internal/provider/resource_nxos_evpn_vni_route_target_direction.go @@ -191,14 +191,24 @@ func (r *EVPNVNIRouteTargetDirectionResource) Delete(ctx context.Context, req re tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_feature_bfd.go b/internal/provider/resource_nxos_feature_bfd.go index 95b3a1ec..b8780c57 100644 --- a/internal/provider/resource_nxos_feature_bfd.go +++ b/internal/provider/resource_nxos_feature_bfd.go @@ -181,6 +181,26 @@ func (r *FeatureBFDResource) Delete(ctx context.Context, req resource.DeleteRequ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_bgp.go b/internal/provider/resource_nxos_feature_bgp.go index a63bd34d..6251b76b 100644 --- a/internal/provider/resource_nxos_feature_bgp.go +++ b/internal/provider/resource_nxos_feature_bgp.go @@ -181,6 +181,26 @@ func (r *FeatureBGPResource) Delete(ctx context.Context, req resource.DeleteRequ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_dhcp.go b/internal/provider/resource_nxos_feature_dhcp.go index 49b13ef4..8c3b8b7d 100644 --- a/internal/provider/resource_nxos_feature_dhcp.go +++ b/internal/provider/resource_nxos_feature_dhcp.go @@ -181,6 +181,26 @@ func (r *FeatureDHCPResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_evpn.go b/internal/provider/resource_nxos_feature_evpn.go index ec21a198..92419516 100644 --- a/internal/provider/resource_nxos_feature_evpn.go +++ b/internal/provider/resource_nxos_feature_evpn.go @@ -181,6 +181,26 @@ func (r *FeatureEVPNResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_hmm.go b/internal/provider/resource_nxos_feature_hmm.go index 3d5b6649..92ddde47 100644 --- a/internal/provider/resource_nxos_feature_hmm.go +++ b/internal/provider/resource_nxos_feature_hmm.go @@ -181,6 +181,26 @@ func (r *FeatureHMMResource) Delete(ctx context.Context, req resource.DeleteRequ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_hsrp.go b/internal/provider/resource_nxos_feature_hsrp.go index 079c1c54..0dfd5546 100644 --- a/internal/provider/resource_nxos_feature_hsrp.go +++ b/internal/provider/resource_nxos_feature_hsrp.go @@ -181,6 +181,26 @@ func (r *FeatureHSRPResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_interface_vlan.go b/internal/provider/resource_nxos_feature_interface_vlan.go index dbd02dce..b0fb3d9d 100644 --- a/internal/provider/resource_nxos_feature_interface_vlan.go +++ b/internal/provider/resource_nxos_feature_interface_vlan.go @@ -181,6 +181,26 @@ func (r *FeatureInterfaceVLANResource) Delete(ctx context.Context, req resource. tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_isis.go b/internal/provider/resource_nxos_feature_isis.go index 45769d30..97169781 100644 --- a/internal/provider/resource_nxos_feature_isis.go +++ b/internal/provider/resource_nxos_feature_isis.go @@ -181,6 +181,26 @@ func (r *FeatureISISResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_lacp.go b/internal/provider/resource_nxos_feature_lacp.go index 8697785e..2e74c721 100644 --- a/internal/provider/resource_nxos_feature_lacp.go +++ b/internal/provider/resource_nxos_feature_lacp.go @@ -181,6 +181,26 @@ func (r *FeatureLACPResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_lldp.go b/internal/provider/resource_nxos_feature_lldp.go index d2b44f6e..57937e9c 100644 --- a/internal/provider/resource_nxos_feature_lldp.go +++ b/internal/provider/resource_nxos_feature_lldp.go @@ -181,6 +181,26 @@ func (r *FeatureLLDPResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_macsec.go b/internal/provider/resource_nxos_feature_macsec.go index 3bdb6c9d..54b58ced 100644 --- a/internal/provider/resource_nxos_feature_macsec.go +++ b/internal/provider/resource_nxos_feature_macsec.go @@ -181,6 +181,26 @@ func (r *FeatureMACsecResource) Delete(ctx context.Context, req resource.DeleteR tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_netflow.go b/internal/provider/resource_nxos_feature_netflow.go index 1c8c4772..e2cd4dbf 100644 --- a/internal/provider/resource_nxos_feature_netflow.go +++ b/internal/provider/resource_nxos_feature_netflow.go @@ -181,6 +181,26 @@ func (r *FeatureNetflowResource) Delete(ctx context.Context, req resource.Delete tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_nv_overlay.go b/internal/provider/resource_nxos_feature_nv_overlay.go index 4ec1fc92..37f04026 100644 --- a/internal/provider/resource_nxos_feature_nv_overlay.go +++ b/internal/provider/resource_nxos_feature_nv_overlay.go @@ -181,6 +181,26 @@ func (r *FeatureNVOverlayResource) Delete(ctx context.Context, req resource.Dele tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_ospf.go b/internal/provider/resource_nxos_feature_ospf.go index 5a53a9d3..bbb0e4b3 100644 --- a/internal/provider/resource_nxos_feature_ospf.go +++ b/internal/provider/resource_nxos_feature_ospf.go @@ -181,6 +181,26 @@ func (r *FeatureOSPFResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_ospfv3.go b/internal/provider/resource_nxos_feature_ospfv3.go index db95cb4f..af349f8e 100644 --- a/internal/provider/resource_nxos_feature_ospfv3.go +++ b/internal/provider/resource_nxos_feature_ospfv3.go @@ -181,6 +181,26 @@ func (r *FeatureOSPFv3Resource) Delete(ctx context.Context, req resource.DeleteR tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_pim.go b/internal/provider/resource_nxos_feature_pim.go index 09253d90..3455d37e 100644 --- a/internal/provider/resource_nxos_feature_pim.go +++ b/internal/provider/resource_nxos_feature_pim.go @@ -181,6 +181,26 @@ func (r *FeaturePIMResource) Delete(ctx context.Context, req resource.DeleteRequ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_ptp.go b/internal/provider/resource_nxos_feature_ptp.go index 84ea3372..ea58e0de 100644 --- a/internal/provider/resource_nxos_feature_ptp.go +++ b/internal/provider/resource_nxos_feature_ptp.go @@ -181,6 +181,26 @@ func (r *FeaturePTPResource) Delete(ctx context.Context, req resource.DeleteRequ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_pvlan.go b/internal/provider/resource_nxos_feature_pvlan.go index 207c5b65..2922711d 100644 --- a/internal/provider/resource_nxos_feature_pvlan.go +++ b/internal/provider/resource_nxos_feature_pvlan.go @@ -181,6 +181,26 @@ func (r *FeaturePVLANResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_ssh.go b/internal/provider/resource_nxos_feature_ssh.go index 8afee069..cfea685f 100644 --- a/internal/provider/resource_nxos_feature_ssh.go +++ b/internal/provider/resource_nxos_feature_ssh.go @@ -181,6 +181,26 @@ func (r *FeatureSSHResource) Delete(ctx context.Context, req resource.DeleteRequ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_tacacs.go b/internal/provider/resource_nxos_feature_tacacs.go index 577910fb..1fe3f7e2 100644 --- a/internal/provider/resource_nxos_feature_tacacs.go +++ b/internal/provider/resource_nxos_feature_tacacs.go @@ -181,6 +181,26 @@ func (r *FeatureTACACSResource) Delete(ctx context.Context, req resource.DeleteR tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_telnet.go b/internal/provider/resource_nxos_feature_telnet.go index 6b7a9682..22795fc6 100644 --- a/internal/provider/resource_nxos_feature_telnet.go +++ b/internal/provider/resource_nxos_feature_telnet.go @@ -181,6 +181,26 @@ func (r *FeatureTelnetResource) Delete(ctx context.Context, req resource.DeleteR tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_udld.go b/internal/provider/resource_nxos_feature_udld.go index d81670a4..baef43d0 100644 --- a/internal/provider/resource_nxos_feature_udld.go +++ b/internal/provider/resource_nxos_feature_udld.go @@ -181,6 +181,26 @@ func (r *FeatureUDLDResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_vn_segment.go b/internal/provider/resource_nxos_feature_vn_segment.go index 1ce2cc60..c48bc6a4 100644 --- a/internal/provider/resource_nxos_feature_vn_segment.go +++ b/internal/provider/resource_nxos_feature_vn_segment.go @@ -181,6 +181,26 @@ func (r *FeatureVNSegmentResource) Delete(ctx context.Context, req resource.Dele tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_feature_vpc.go b/internal/provider/resource_nxos_feature_vpc.go index 8497faf4..c89a3fa2 100644 --- a/internal/provider/resource_nxos_feature_vpc.go +++ b/internal/provider/resource_nxos_feature_vpc.go @@ -181,6 +181,26 @@ func (r *FeatureVPCResource) Delete(ctx context.Context, req resource.DeleteRequ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } + } + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) resp.State.RemoveResource(ctx) diff --git a/internal/provider/resource_nxos_hmm.go b/internal/provider/resource_nxos_hmm.go index 73c1c59c..983caaf6 100644 --- a/internal/provider/resource_nxos_hmm.go +++ b/internal/provider/resource_nxos_hmm.go @@ -184,14 +184,24 @@ func (r *HMMResource) Delete(ctx context.Context, req resource.DeleteRequest, re tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_hmm_instance.go b/internal/provider/resource_nxos_hmm_instance.go index 9e2f1a5b..800f8dd1 100644 --- a/internal/provider/resource_nxos_hmm_instance.go +++ b/internal/provider/resource_nxos_hmm_instance.go @@ -190,14 +190,24 @@ func (r *HMMInstanceResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_hmm_interface.go b/internal/provider/resource_nxos_hmm_interface.go index 650ad45c..0827bb5e 100644 --- a/internal/provider/resource_nxos_hmm_interface.go +++ b/internal/provider/resource_nxos_hmm_interface.go @@ -200,14 +200,24 @@ func (r *HMMInterfaceResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ipv4_access_list.go b/internal/provider/resource_nxos_ipv4_access_list.go index 1f745616..26292edc 100644 --- a/internal/provider/resource_nxos_ipv4_access_list.go +++ b/internal/provider/resource_nxos_ipv4_access_list.go @@ -179,14 +179,24 @@ func (r *IPv4AccessListResource) Delete(ctx context.Context, req resource.Delete tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ipv4_access_list_entry.go b/internal/provider/resource_nxos_ipv4_access_list_entry.go index 0f98d5ab..e9e381ac 100644 --- a/internal/provider/resource_nxos_ipv4_access_list_entry.go +++ b/internal/provider/resource_nxos_ipv4_access_list_entry.go @@ -431,14 +431,24 @@ func (r *IPv4AccessListEntryResource) Delete(ctx context.Context, req resource.D tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ipv4_access_list_policy_egress_interface.go b/internal/provider/resource_nxos_ipv4_access_list_policy_egress_interface.go index fc300568..c1de8569 100644 --- a/internal/provider/resource_nxos_ipv4_access_list_policy_egress_interface.go +++ b/internal/provider/resource_nxos_ipv4_access_list_policy_egress_interface.go @@ -184,14 +184,24 @@ func (r *IPv4AccessListPolicyEgressInterfaceResource) Delete(ctx context.Context tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ipv4_access_list_policy_ingress_interface.go b/internal/provider/resource_nxos_ipv4_access_list_policy_ingress_interface.go index 8b2c2269..1ab0c855 100644 --- a/internal/provider/resource_nxos_ipv4_access_list_policy_ingress_interface.go +++ b/internal/provider/resource_nxos_ipv4_access_list_policy_ingress_interface.go @@ -184,14 +184,24 @@ func (r *IPv4AccessListPolicyIngressInterfaceResource) Delete(ctx context.Contex tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ipv4_interface.go b/internal/provider/resource_nxos_ipv4_interface.go index 08af8e7b..d3a388e6 100644 --- a/internal/provider/resource_nxos_ipv4_interface.go +++ b/internal/provider/resource_nxos_ipv4_interface.go @@ -222,14 +222,24 @@ func (r *IPv4InterfaceResource) Delete(ctx context.Context, req resource.DeleteR tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ipv4_interface_address.go b/internal/provider/resource_nxos_ipv4_interface_address.go index d8d5f0a2..91f951e2 100644 --- a/internal/provider/resource_nxos_ipv4_interface_address.go +++ b/internal/provider/resource_nxos_ipv4_interface_address.go @@ -205,14 +205,24 @@ func (r *IPv4InterfaceAddressResource) Delete(ctx context.Context, req resource. tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ipv4_prefix_list_rule.go b/internal/provider/resource_nxos_ipv4_prefix_list_rule.go index 7e7f2f9b..ca8b3398 100644 --- a/internal/provider/resource_nxos_ipv4_prefix_list_rule.go +++ b/internal/provider/resource_nxos_ipv4_prefix_list_rule.go @@ -179,14 +179,24 @@ func (r *IPv4PrefixListRuleResource) Delete(ctx context.Context, req resource.De tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ipv4_prefix_list_rule_entry.go b/internal/provider/resource_nxos_ipv4_prefix_list_rule_entry.go index f7dc875a..2c2fcd09 100644 --- a/internal/provider/resource_nxos_ipv4_prefix_list_rule_entry.go +++ b/internal/provider/resource_nxos_ipv4_prefix_list_rule_entry.go @@ -235,14 +235,24 @@ func (r *IPv4PrefixListRuleEntryResource) Delete(ctx context.Context, req resour tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ipv4_static_route.go b/internal/provider/resource_nxos_ipv4_static_route.go index 74a4d9a3..114b7fa2 100644 --- a/internal/provider/resource_nxos_ipv4_static_route.go +++ b/internal/provider/resource_nxos_ipv4_static_route.go @@ -243,14 +243,24 @@ func (r *IPv4StaticRouteResource) Delete(ctx context.Context, req resource.Delet tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ipv4_vrf.go b/internal/provider/resource_nxos_ipv4_vrf.go index 50362b47..f0c3a45c 100644 --- a/internal/provider/resource_nxos_ipv4_vrf.go +++ b/internal/provider/resource_nxos_ipv4_vrf.go @@ -179,14 +179,24 @@ func (r *IPv4VRFResource) Delete(ctx context.Context, req resource.DeleteRequest tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_isis.go b/internal/provider/resource_nxos_isis.go index 522f4b04..07eb4751 100644 --- a/internal/provider/resource_nxos_isis.go +++ b/internal/provider/resource_nxos_isis.go @@ -184,14 +184,24 @@ func (r *ISISResource) Delete(ctx context.Context, req resource.DeleteRequest, r tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_isis_instance.go b/internal/provider/resource_nxos_isis_instance.go index ca2293a2..3cb65d25 100644 --- a/internal/provider/resource_nxos_isis_instance.go +++ b/internal/provider/resource_nxos_isis_instance.go @@ -191,14 +191,24 @@ func (r *ISISInstanceResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_isis_interface.go b/internal/provider/resource_nxos_isis_interface.go index decef227..4d552be1 100644 --- a/internal/provider/resource_nxos_isis_interface.go +++ b/internal/provider/resource_nxos_isis_interface.go @@ -400,14 +400,24 @@ func (r *ISISInterfaceResource) Delete(ctx context.Context, req resource.DeleteR tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_isis_vrf.go b/internal/provider/resource_nxos_isis_vrf.go index 9cc7b3cb..3b8b132e 100644 --- a/internal/provider/resource_nxos_isis_vrf.go +++ b/internal/provider/resource_nxos_isis_vrf.go @@ -297,14 +297,24 @@ func (r *ISISVRFResource) Delete(ctx context.Context, req resource.DeleteRequest tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_loopback_interface.go b/internal/provider/resource_nxos_loopback_interface.go index b08c8872..13a70696 100644 --- a/internal/provider/resource_nxos_loopback_interface.go +++ b/internal/provider/resource_nxos_loopback_interface.go @@ -195,14 +195,24 @@ func (r *LoopbackInterfaceResource) Delete(ctx context.Context, req resource.Del tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_loopback_interface_vrf.go b/internal/provider/resource_nxos_loopback_interface_vrf.go index c9931420..111512ca 100644 --- a/internal/provider/resource_nxos_loopback_interface_vrf.go +++ b/internal/provider/resource_nxos_loopback_interface_vrf.go @@ -183,14 +183,24 @@ func (r *LoopbackInterfaceVRFResource) Delete(ctx context.Context, req resource. tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ntp_server.go b/internal/provider/resource_nxos_ntp_server.go index 1ec96c84..affda296 100644 --- a/internal/provider/resource_nxos_ntp_server.go +++ b/internal/provider/resource_nxos_ntp_server.go @@ -222,14 +222,24 @@ func (r *NTPServerResource) Delete(ctx context.Context, req resource.DeleteReque tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_nve_interface.go b/internal/provider/resource_nxos_nve_interface.go index 96e22f91..b68571d3 100644 --- a/internal/provider/resource_nxos_nve_interface.go +++ b/internal/provider/resource_nxos_nve_interface.go @@ -253,14 +253,24 @@ func (r *NVEInterfaceResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_nve_vni.go b/internal/provider/resource_nxos_nve_vni.go index 92550717..e3655fbf 100644 --- a/internal/provider/resource_nxos_nve_vni.go +++ b/internal/provider/resource_nxos_nve_vni.go @@ -222,14 +222,24 @@ func (r *NVEVNIResource) Delete(ctx context.Context, req resource.DeleteRequest, tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_nve_vni_container.go b/internal/provider/resource_nxos_nve_vni_container.go index 6e2d83bc..2b02b9d5 100644 --- a/internal/provider/resource_nxos_nve_vni_container.go +++ b/internal/provider/resource_nxos_nve_vni_container.go @@ -172,14 +172,24 @@ func (r *NVEVNIContainerResource) Delete(ctx context.Context, req resource.Delet tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_nve_vni_ingress_replication.go b/internal/provider/resource_nxos_nve_vni_ingress_replication.go index 0cba254a..4856c672 100644 --- a/internal/provider/resource_nxos_nve_vni_ingress_replication.go +++ b/internal/provider/resource_nxos_nve_vni_ingress_replication.go @@ -196,14 +196,24 @@ func (r *NVEVNIIngressReplicationResource) Delete(ctx context.Context, req resou tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ospf.go b/internal/provider/resource_nxos_ospf.go index d2eb45f4..bf5b8126 100644 --- a/internal/provider/resource_nxos_ospf.go +++ b/internal/provider/resource_nxos_ospf.go @@ -184,14 +184,24 @@ func (r *OSPFResource) Delete(ctx context.Context, req resource.DeleteRequest, r tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ospf_area.go b/internal/provider/resource_nxos_ospf_area.go index c3023d7e..5133de48 100644 --- a/internal/provider/resource_nxos_ospf_area.go +++ b/internal/provider/resource_nxos_ospf_area.go @@ -225,14 +225,24 @@ func (r *OSPFAreaResource) Delete(ctx context.Context, req resource.DeleteReques tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ospf_authentication.go b/internal/provider/resource_nxos_ospf_authentication.go index 2eaff6f5..70ffc9ca 100644 --- a/internal/provider/resource_nxos_ospf_authentication.go +++ b/internal/provider/resource_nxos_ospf_authentication.go @@ -241,14 +241,24 @@ func (r *OSPFAuthenticationResource) Delete(ctx context.Context, req resource.De tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ospf_instance.go b/internal/provider/resource_nxos_ospf_instance.go index 18174a26..47b7c435 100644 --- a/internal/provider/resource_nxos_ospf_instance.go +++ b/internal/provider/resource_nxos_ospf_instance.go @@ -191,14 +191,24 @@ func (r *OSPFInstanceResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ospf_interface.go b/internal/provider/resource_nxos_ospf_interface.go index 7d7a9af7..45b31742 100644 --- a/internal/provider/resource_nxos_ospf_interface.go +++ b/internal/provider/resource_nxos_ospf_interface.go @@ -274,14 +274,24 @@ func (r *OSPFInterfaceResource) Delete(ctx context.Context, req resource.DeleteR tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_ospf_vrf.go b/internal/provider/resource_nxos_ospf_vrf.go index aa62c3fb..e0d231e8 100644 --- a/internal/provider/resource_nxos_ospf_vrf.go +++ b/internal/provider/resource_nxos_ospf_vrf.go @@ -233,14 +233,24 @@ func (r *OSPFVRFResource) Delete(ctx context.Context, req resource.DeleteRequest tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_physical_interface.go b/internal/provider/resource_nxos_physical_interface.go index b6a65767..ebf25e7c 100644 --- a/internal/provider/resource_nxos_physical_interface.go +++ b/internal/provider/resource_nxos_physical_interface.go @@ -354,14 +354,24 @@ func (r *PhysicalInterfaceResource) Delete(ctx context.Context, req resource.Del tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_physical_interface_vrf.go b/internal/provider/resource_nxos_physical_interface_vrf.go index 4af6f44e..1572254b 100644 --- a/internal/provider/resource_nxos_physical_interface_vrf.go +++ b/internal/provider/resource_nxos_physical_interface_vrf.go @@ -183,14 +183,24 @@ func (r *PhysicalInterfaceVRFResource) Delete(ctx context.Context, req resource. tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim.go b/internal/provider/resource_nxos_pim.go index c70a4cf7..fc966b75 100644 --- a/internal/provider/resource_nxos_pim.go +++ b/internal/provider/resource_nxos_pim.go @@ -184,14 +184,24 @@ func (r *PIMResource) Delete(ctx context.Context, req resource.DeleteRequest, re tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim_anycast_rp.go b/internal/provider/resource_nxos_pim_anycast_rp.go index 943a041e..c825a4a3 100644 --- a/internal/provider/resource_nxos_pim_anycast_rp.go +++ b/internal/provider/resource_nxos_pim_anycast_rp.go @@ -187,14 +187,24 @@ func (r *PIMAnycastRPResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim_anycast_rp_peer.go b/internal/provider/resource_nxos_pim_anycast_rp_peer.go index a4dea267..6775ddad 100644 --- a/internal/provider/resource_nxos_pim_anycast_rp_peer.go +++ b/internal/provider/resource_nxos_pim_anycast_rp_peer.go @@ -193,14 +193,24 @@ func (r *PIMAnycastRPPeerResource) Delete(ctx context.Context, req resource.Dele tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim_instance.go b/internal/provider/resource_nxos_pim_instance.go index befa73ed..8f26ac1c 100644 --- a/internal/provider/resource_nxos_pim_instance.go +++ b/internal/provider/resource_nxos_pim_instance.go @@ -184,14 +184,24 @@ func (r *PIMInstanceResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim_interface.go b/internal/provider/resource_nxos_pim_interface.go index e097ec09..9f6922f7 100644 --- a/internal/provider/resource_nxos_pim_interface.go +++ b/internal/provider/resource_nxos_pim_interface.go @@ -231,14 +231,24 @@ func (r *PIMInterfaceResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim_ssm_policy.go b/internal/provider/resource_nxos_pim_ssm_policy.go index 0553ff09..8ed25287 100644 --- a/internal/provider/resource_nxos_pim_ssm_policy.go +++ b/internal/provider/resource_nxos_pim_ssm_policy.go @@ -183,14 +183,24 @@ func (r *PIMSSMPolicyResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim_ssm_range.go b/internal/provider/resource_nxos_pim_ssm_range.go index fd307a36..862f32ef 100644 --- a/internal/provider/resource_nxos_pim_ssm_range.go +++ b/internal/provider/resource_nxos_pim_ssm_range.go @@ -219,14 +219,24 @@ func (r *PIMSSMRangeResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim_static_rp.go b/internal/provider/resource_nxos_pim_static_rp.go index 72cbebd6..e492dbae 100644 --- a/internal/provider/resource_nxos_pim_static_rp.go +++ b/internal/provider/resource_nxos_pim_static_rp.go @@ -186,14 +186,24 @@ func (r *PIMStaticRPResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim_static_rp_group_list.go b/internal/provider/resource_nxos_pim_static_rp_group_list.go index 0da1f154..9a9f19d7 100644 --- a/internal/provider/resource_nxos_pim_static_rp_group_list.go +++ b/internal/provider/resource_nxos_pim_static_rp_group_list.go @@ -206,14 +206,24 @@ func (r *PIMStaticRPGroupListResource) Delete(ctx context.Context, req resource. tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim_static_rp_policy.go b/internal/provider/resource_nxos_pim_static_rp_policy.go index ec0d1942..7c218d63 100644 --- a/internal/provider/resource_nxos_pim_static_rp_policy.go +++ b/internal/provider/resource_nxos_pim_static_rp_policy.go @@ -183,14 +183,24 @@ func (r *PIMStaticRPPolicyResource) Delete(ctx context.Context, req resource.Del tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_pim_vrf.go b/internal/provider/resource_nxos_pim_vrf.go index 3affac9c..00409145 100644 --- a/internal/provider/resource_nxos_pim_vrf.go +++ b/internal/provider/resource_nxos_pim_vrf.go @@ -198,14 +198,24 @@ func (r *PIMVRFResource) Delete(ctx context.Context, req resource.DeleteRequest, tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_port_channel_interface.go b/internal/provider/resource_nxos_port_channel_interface.go index 5eb6332f..c1b192e7 100644 --- a/internal/provider/resource_nxos_port_channel_interface.go +++ b/internal/provider/resource_nxos_port_channel_interface.go @@ -345,14 +345,24 @@ func (r *PortChannelInterfaceResource) Delete(ctx context.Context, req resource. tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_port_channel_interface_member.go b/internal/provider/resource_nxos_port_channel_interface_member.go index 4891dad0..98517294 100644 --- a/internal/provider/resource_nxos_port_channel_interface_member.go +++ b/internal/provider/resource_nxos_port_channel_interface_member.go @@ -190,14 +190,24 @@ func (r *PortChannelInterfaceMemberResource) Delete(ctx context.Context, req res tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_port_channel_interface_vrf.go b/internal/provider/resource_nxos_port_channel_interface_vrf.go index 51052b5c..db5996f7 100644 --- a/internal/provider/resource_nxos_port_channel_interface_vrf.go +++ b/internal/provider/resource_nxos_port_channel_interface_vrf.go @@ -183,14 +183,24 @@ func (r *PortChannelInterfaceVRFResource) Delete(ctx context.Context, req resour tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_queuing_qos_policy_map.go b/internal/provider/resource_nxos_queuing_qos_policy_map.go index a9d15a57..cf496cdc 100644 --- a/internal/provider/resource_nxos_queuing_qos_policy_map.go +++ b/internal/provider/resource_nxos_queuing_qos_policy_map.go @@ -191,14 +191,24 @@ func (r *QueuingQOSPolicyMapResource) Delete(ctx context.Context, req resource.D tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map.go b/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map.go index bfc7bd21..c6db6ed4 100644 --- a/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map.go +++ b/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map.go @@ -186,14 +186,24 @@ func (r *QueuingQOSPolicyMapMatchClassMapResource) Delete(ctx context.Context, r tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map_priority.go b/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map_priority.go index 30bf1ae6..7f31a757 100644 --- a/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map_priority.go +++ b/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map_priority.go @@ -195,14 +195,24 @@ func (r *QueuingQOSPolicyMapMatchClassMapPriorityResource) Delete(ctx context.Co tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map_remaining_bandwidth.go b/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map_remaining_bandwidth.go index 5910c723..2832422d 100644 --- a/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map_remaining_bandwidth.go +++ b/internal/provider/resource_nxos_queuing_qos_policy_map_match_class_map_remaining_bandwidth.go @@ -195,14 +195,24 @@ func (r *QueuingQOSPolicyMapMatchClassMapRemainingBandwidthResource) Delete(ctx tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_queuing_qos_policy_system_out.go b/internal/provider/resource_nxos_queuing_qos_policy_system_out.go index cd018355..9c554d32 100644 --- a/internal/provider/resource_nxos_queuing_qos_policy_system_out.go +++ b/internal/provider/resource_nxos_queuing_qos_policy_system_out.go @@ -172,14 +172,24 @@ func (r *QueuingQOSPolicySystemOutResource) Delete(ctx context.Context, req reso tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_queuing_qos_policy_system_out_policy_map.go b/internal/provider/resource_nxos_queuing_qos_policy_system_out_policy_map.go index c0360f02..6de8ded5 100644 --- a/internal/provider/resource_nxos_queuing_qos_policy_system_out_policy_map.go +++ b/internal/provider/resource_nxos_queuing_qos_policy_system_out_policy_map.go @@ -176,14 +176,24 @@ func (r *QueuingQOSPolicySystemOutPolicyMapResource) Delete(ctx context.Context, tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_route_map_rule.go b/internal/provider/resource_nxos_route_map_rule.go index 1ceb22a2..ec1877ec 100644 --- a/internal/provider/resource_nxos_route_map_rule.go +++ b/internal/provider/resource_nxos_route_map_rule.go @@ -179,14 +179,24 @@ func (r *RouteMapRuleResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_route_map_rule_entry.go b/internal/provider/resource_nxos_route_map_rule_entry.go index fffafc27..c1037928 100644 --- a/internal/provider/resource_nxos_route_map_rule_entry.go +++ b/internal/provider/resource_nxos_route_map_rule_entry.go @@ -203,14 +203,24 @@ func (r *RouteMapRuleEntryResource) Delete(ctx context.Context, req resource.Del tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_route_map_rule_entry_match_route.go b/internal/provider/resource_nxos_route_map_rule_entry_match_route.go index 8957d816..2cca2fc1 100644 --- a/internal/provider/resource_nxos_route_map_rule_entry_match_route.go +++ b/internal/provider/resource_nxos_route_map_rule_entry_match_route.go @@ -192,14 +192,24 @@ func (r *RouteMapRuleEntryMatchRouteResource) Delete(ctx context.Context, req re tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_route_map_rule_entry_match_route_prefix_list.go b/internal/provider/resource_nxos_route_map_rule_entry_match_route_prefix_list.go index 4b845b23..61568be5 100644 --- a/internal/provider/resource_nxos_route_map_rule_entry_match_route_prefix_list.go +++ b/internal/provider/resource_nxos_route_map_rule_entry_match_route_prefix_list.go @@ -199,14 +199,24 @@ func (r *RouteMapRuleEntryMatchRoutePrefixListResource) Delete(ctx context.Conte tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_route_map_rule_entry_set_regular_community.go b/internal/provider/resource_nxos_route_map_rule_entry_set_regular_community.go index 9a6892e7..4128c24e 100644 --- a/internal/provider/resource_nxos_route_map_rule_entry_set_regular_community.go +++ b/internal/provider/resource_nxos_route_map_rule_entry_set_regular_community.go @@ -221,14 +221,24 @@ func (r *RouteMapRuleEntrySetRegularCommunityResource) Delete(ctx context.Contex tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_route_map_rule_entry_set_regular_community_item.go b/internal/provider/resource_nxos_route_map_rule_entry_set_regular_community_item.go index 33b9b626..054a1439 100644 --- a/internal/provider/resource_nxos_route_map_rule_entry_set_regular_community_item.go +++ b/internal/provider/resource_nxos_route_map_rule_entry_set_regular_community_item.go @@ -199,14 +199,24 @@ func (r *RouteMapRuleEntrySetRegularCommunityItemResource) Delete(ctx context.Co tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_spanning_tree_interface.go b/internal/provider/resource_nxos_spanning_tree_interface.go index 51a586b5..4d1447f4 100644 --- a/internal/provider/resource_nxos_spanning_tree_interface.go +++ b/internal/provider/resource_nxos_spanning_tree_interface.go @@ -256,14 +256,24 @@ func (r *SpanningTreeInterfaceResource) Delete(ctx context.Context, req resource tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_subinterface.go b/internal/provider/resource_nxos_subinterface.go index ea096117..05ba1ab5 100644 --- a/internal/provider/resource_nxos_subinterface.go +++ b/internal/provider/resource_nxos_subinterface.go @@ -248,14 +248,24 @@ func (r *SubinterfaceResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_subinterface_vrf.go b/internal/provider/resource_nxos_subinterface_vrf.go index d7c4e242..9cc96209 100644 --- a/internal/provider/resource_nxos_subinterface_vrf.go +++ b/internal/provider/resource_nxos_subinterface_vrf.go @@ -183,14 +183,24 @@ func (r *SubinterfaceVRFResource) Delete(ctx context.Context, req resource.Delet tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_svi_interface.go b/internal/provider/resource_nxos_svi_interface.go index 1388fc4f..072b840e 100644 --- a/internal/provider/resource_nxos_svi_interface.go +++ b/internal/provider/resource_nxos_svi_interface.go @@ -233,14 +233,24 @@ func (r *SVIInterfaceResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_svi_interface_vrf.go b/internal/provider/resource_nxos_svi_interface_vrf.go index 0c4abf2b..0e94e0e6 100644 --- a/internal/provider/resource_nxos_svi_interface_vrf.go +++ b/internal/provider/resource_nxos_svi_interface_vrf.go @@ -183,14 +183,24 @@ func (r *SVIInterfaceVRFResource) Delete(ctx context.Context, req resource.Delet tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vpc_domain.go b/internal/provider/resource_nxos_vpc_domain.go index bc35552a..01f635b5 100644 --- a/internal/provider/resource_nxos_vpc_domain.go +++ b/internal/provider/resource_nxos_vpc_domain.go @@ -349,14 +349,24 @@ func (r *VPCDomainResource) Delete(ctx context.Context, req resource.DeleteReque tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vpc_instance.go b/internal/provider/resource_nxos_vpc_instance.go index 49d3536b..33200f2b 100644 --- a/internal/provider/resource_nxos_vpc_instance.go +++ b/internal/provider/resource_nxos_vpc_instance.go @@ -184,14 +184,24 @@ func (r *VPCInstanceResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vpc_interface.go b/internal/provider/resource_nxos_vpc_interface.go index 01d57c2d..8aeac415 100644 --- a/internal/provider/resource_nxos_vpc_interface.go +++ b/internal/provider/resource_nxos_vpc_interface.go @@ -190,14 +190,24 @@ func (r *VPCInterfaceResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vpc_keepalive.go b/internal/provider/resource_nxos_vpc_keepalive.go index 94d5420c..0f70deb2 100644 --- a/internal/provider/resource_nxos_vpc_keepalive.go +++ b/internal/provider/resource_nxos_vpc_keepalive.go @@ -275,14 +275,24 @@ func (r *VPCKeepaliveResource) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vpc_peerlink.go b/internal/provider/resource_nxos_vpc_peerlink.go index 64998bb1..50e3ee7b 100644 --- a/internal/provider/resource_nxos_vpc_peerlink.go +++ b/internal/provider/resource_nxos_vpc_peerlink.go @@ -176,14 +176,24 @@ func (r *VPCPeerlinkResource) Delete(ctx context.Context, req resource.DeleteReq tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vrf.go b/internal/provider/resource_nxos_vrf.go index 57df299e..07ed1141 100644 --- a/internal/provider/resource_nxos_vrf.go +++ b/internal/provider/resource_nxos_vrf.go @@ -190,14 +190,24 @@ func (r *VRFResource) Delete(ctx context.Context, req resource.DeleteRequest, re tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vrf_address_family.go b/internal/provider/resource_nxos_vrf_address_family.go index d18b9d39..4d8204bb 100644 --- a/internal/provider/resource_nxos_vrf_address_family.go +++ b/internal/provider/resource_nxos_vrf_address_family.go @@ -191,14 +191,24 @@ func (r *VRFAddressFamilyResource) Delete(ctx context.Context, req resource.Dele tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vrf_route_target.go b/internal/provider/resource_nxos_vrf_route_target.go index 417e622a..16a039e1 100644 --- a/internal/provider/resource_nxos_vrf_route_target.go +++ b/internal/provider/resource_nxos_vrf_route_target.go @@ -218,14 +218,24 @@ func (r *VRFRouteTargetResource) Delete(ctx context.Context, req resource.Delete tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vrf_route_target_address_family.go b/internal/provider/resource_nxos_vrf_route_target_address_family.go index 21dbfc14..f7a176ef 100644 --- a/internal/provider/resource_nxos_vrf_route_target_address_family.go +++ b/internal/provider/resource_nxos_vrf_route_target_address_family.go @@ -201,14 +201,24 @@ func (r *VRFRouteTargetAddressFamilyResource) Delete(ctx context.Context, req re tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vrf_route_target_direction.go b/internal/provider/resource_nxos_vrf_route_target_direction.go index 19d09031..d1c2d840 100644 --- a/internal/provider/resource_nxos_vrf_route_target_direction.go +++ b/internal/provider/resource_nxos_vrf_route_target_direction.go @@ -211,14 +211,24 @@ func (r *VRFRouteTargetDirectionResource) Delete(ctx context.Context, req resour tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString())) diff --git a/internal/provider/resource_nxos_vrf_routing.go b/internal/provider/resource_nxos_vrf_routing.go index db436f04..927d1415 100644 --- a/internal/provider/resource_nxos_vrf_routing.go +++ b/internal/provider/resource_nxos_vrf_routing.go @@ -186,14 +186,24 @@ func (r *VRFRoutingResource) Delete(ctx context.Context, req resource.DeleteRequ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Dn.ValueString())) - res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) - if err != nil { - errCode := res.Get("imdata.0.error.attributes.code").Str - // Ignore errors of type "Cannot delete object" - if errCode != "1" && errCode != "107" { + body := state.toDeleteBody() + + if len(body.Str) > 0 { + _, err := r.clients[state.Device.ValueString()].Post(state.getDn(), body.Str) + if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) return } + } else { + res, err := r.clients[state.Device.ValueString()].DeleteDn(state.Dn.ValueString()) + if err != nil { + errCode := res.Get("imdata.0.error.attributes.code").Str + // Ignore errors of type "Cannot delete object" + if errCode != "1" && errCode != "107" { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err)) + return + } + } } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Dn.ValueString()))