diff --git a/gen/definitions/appliance_cellular_firewall_rules.yaml b/gen/definitions/appliance_cellular_firewall_rules.yaml index 4ce7f813..333dca56 100644 --- a/gen/definitions/appliance_cellular_firewall_rules.yaml +++ b/gen/definitions/appliance_cellular_firewall_rules.yaml @@ -18,7 +18,6 @@ attributes: mandatory: true description: An ordered array of the firewall rules (not including the default rule) ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: comment type: String diff --git a/gen/definitions/appliance_connectivity_monitoring_destinations.yaml b/gen/definitions/appliance_connectivity_monitoring_destinations.yaml index 86f5b63e..652aebb8 100644 --- a/gen/definitions/appliance_connectivity_monitoring_destinations.yaml +++ b/gen/definitions/appliance_connectivity_monitoring_destinations.yaml @@ -17,14 +17,6 @@ attributes: type: List mandatory: true description: The list of connectivity monitoring destinations. Is set to Google DNS (8.8.8.8) when the resource is not created and gets reset to it on resource deletion - destroy_value: |- - []interface{}{ - map[string]interface{}{ - "ip": "8.8.8.8", - "default": true, - "description": "Google", - }, - } attributes: - model_name: default type: Bool diff --git a/gen/definitions/appliance_firewall_multicast_forwarding.yaml b/gen/definitions/appliance_firewall_multicast_forwarding.yaml index 9d3ce558..87dbe35c 100644 --- a/gen/definitions/appliance_firewall_multicast_forwarding.yaml +++ b/gen/definitions/appliance_firewall_multicast_forwarding.yaml @@ -1,4 +1,4 @@ -# Customize Read() function to handle org level GET request +# Customize Create(), Read() function to handle org level GET request name: Appliance Firewall Multicast Forwarding spec_endpoint: /networks/{networkId}/appliance/firewall/multicastForwarding rest_endpoint: /networks/%v/appliance/firewall/multicastForwarding @@ -21,7 +21,6 @@ attributes: type: List mandatory: true description: Static multicast forwarding rules. Pass an empty array to clear all rules. - destroy_value: '[]interface{}{}' attributes: - model_name: address type: String diff --git a/gen/definitions/appliance_inbound_cellular_firewall_rules.yaml b/gen/definitions/appliance_inbound_cellular_firewall_rules.yaml index 47d9ff34..cbba4da0 100644 --- a/gen/definitions/appliance_inbound_cellular_firewall_rules.yaml +++ b/gen/definitions/appliance_inbound_cellular_firewall_rules.yaml @@ -18,7 +18,6 @@ attributes: mandatory: true description: An ordered array of the firewall rules (not including the default rule) ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: comment type: String diff --git a/gen/definitions/appliance_inbound_firewall_rules.yaml b/gen/definitions/appliance_inbound_firewall_rules.yaml index ba86a5b9..e035b4ca 100644 --- a/gen/definitions/appliance_inbound_firewall_rules.yaml +++ b/gen/definitions/appliance_inbound_firewall_rules.yaml @@ -24,7 +24,6 @@ attributes: mandatory: true description: An ordered array of the firewall rules (not including the default rule) ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: comment type: String diff --git a/gen/definitions/appliance_l3_firewall_rules.yaml b/gen/definitions/appliance_l3_firewall_rules.yaml index 0b240a21..6f27bf2c 100644 --- a/gen/definitions/appliance_l3_firewall_rules.yaml +++ b/gen/definitions/appliance_l3_firewall_rules.yaml @@ -23,7 +23,6 @@ attributes: mandatory: true description: An ordered array of the firewall rules (not including the default rule) ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: comment type: String diff --git a/gen/definitions/appliance_l7_firewall_rules.yaml b/gen/definitions/appliance_l7_firewall_rules.yaml index a6ae608a..151a2ed4 100644 --- a/gen/definitions/appliance_l7_firewall_rules.yaml +++ b/gen/definitions/appliance_l7_firewall_rules.yaml @@ -18,7 +18,6 @@ attributes: mandatory: true description: An ordered array of the MX L7 firewall rules ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: policy type: String diff --git a/gen/definitions/appliance_one_to_many_nat_rules.yaml b/gen/definitions/appliance_one_to_many_nat_rules.yaml index 75f5ab57..ba9e7dbe 100644 --- a/gen/definitions/appliance_one_to_many_nat_rules.yaml +++ b/gen/definitions/appliance_one_to_many_nat_rules.yaml @@ -17,7 +17,6 @@ attributes: type: List mandatory: true description: An array of 1:Many nat rules - destroy_value: '[]interface{}{}' attributes: - model_name: publicIp type: String diff --git a/gen/definitions/appliance_one_to_one_nat_rules.yaml b/gen/definitions/appliance_one_to_one_nat_rules.yaml index 78be902b..882e7517 100644 --- a/gen/definitions/appliance_one_to_one_nat_rules.yaml +++ b/gen/definitions/appliance_one_to_one_nat_rules.yaml @@ -17,7 +17,6 @@ attributes: type: List mandatory: true description: An array of 1:1 nat rules - destroy_value: '[]interface{}{}' attributes: - model_name: lanIp type: String diff --git a/gen/definitions/appliance_organization_security_intrusion.yaml b/gen/definitions/appliance_organization_security_intrusion.yaml index 5b50ff26..9dcfa5f4 100644 --- a/gen/definitions/appliance_organization_security_intrusion.yaml +++ b/gen/definitions/appliance_organization_security_intrusion.yaml @@ -18,7 +18,6 @@ attributes: type: List mandatory: true description: Sets a list of specific SNORT signatures to allow - destroy_value: '[]interface{}{}' attributes: - model_name: message type: String diff --git a/gen/definitions/appliance_port_forwarding_rules.yaml b/gen/definitions/appliance_port_forwarding_rules.yaml index ba9f34f8..2dc39ae1 100644 --- a/gen/definitions/appliance_port_forwarding_rules.yaml +++ b/gen/definitions/appliance_port_forwarding_rules.yaml @@ -17,7 +17,6 @@ attributes: type: List mandatory: true description: An array of port forwarding params - destroy_value: '[]interface{}{}' attributes: - model_name: lanIp type: String diff --git a/gen/definitions/appliance_third_party_vpn_peers.yaml b/gen/definitions/appliance_third_party_vpn_peers.yaml index b459d3b3..2fdd2bb3 100644 --- a/gen/definitions/appliance_third_party_vpn_peers.yaml +++ b/gen/definitions/appliance_third_party_vpn_peers.yaml @@ -17,7 +17,6 @@ attributes: type: List mandatory: true description: The list of VPN peers - destroy_value: '[]interface{}{}' attributes: - model_name: ikeVersion type: String diff --git a/gen/definitions/appliance_traffic_shaping_rules.yaml b/gen/definitions/appliance_traffic_shaping_rules.yaml index 597cfee0..e18f76bc 100644 --- a/gen/definitions/appliance_traffic_shaping_rules.yaml +++ b/gen/definitions/appliance_traffic_shaping_rules.yaml @@ -20,9 +20,9 @@ attributes: example: "true" - model_name: rules type: List + write_empty_list: true description: An array of traffic shaping rules. Rules are applied in the order that they are specified in. An empty list (or null) means no rules. Note that you are allowed a maximum of 8 rules. ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: dscpTagValue type: Int64 diff --git a/gen/definitions/appliance_traffic_shaping_uplink_selection.yaml b/gen/definitions/appliance_traffic_shaping_uplink_selection.yaml index a8e4439c..81e23c4f 100644 --- a/gen/definitions/appliance_traffic_shaping_uplink_selection.yaml +++ b/gen/definitions/appliance_traffic_shaping_uplink_selection.yaml @@ -35,10 +35,10 @@ attributes: example: "true" - model_name: vpnTrafficUplinkPreferences type: List + write_empty_list: true exclude_test: true description: Array of uplink preference rules for VPN traffic ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: failOverCriterion type: String diff --git a/gen/definitions/appliance_traffic_shaping_vpn_exclusions.yaml b/gen/definitions/appliance_traffic_shaping_vpn_exclusions.yaml index cabbeda7..773b4663 100644 --- a/gen/definitions/appliance_traffic_shaping_vpn_exclusions.yaml +++ b/gen/definitions/appliance_traffic_shaping_vpn_exclusions.yaml @@ -21,9 +21,9 @@ attributes: test_value: meraki_network.test.id - model_name: custom type: List + write_empty_list: true description: Custom VPN exclusion rules. Pass an empty array to clear existing rules. ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: destination type: String @@ -41,8 +41,8 @@ attributes: enum_values: [any, dns, icmp, tcp, udp] - model_name: majorApplications type: List + write_empty_list: true description: Major Application based VPN exclusion rules. Pass an empty array to clear existing rules. - destroy_value: '[]interface{}{}' attributes: - model_name: id type: String diff --git a/gen/definitions/appliance_vpn_firewall_rules.yaml b/gen/definitions/appliance_vpn_firewall_rules.yaml index b68eae9b..a23e44e3 100644 --- a/gen/definitions/appliance_vpn_firewall_rules.yaml +++ b/gen/definitions/appliance_vpn_firewall_rules.yaml @@ -23,7 +23,6 @@ attributes: mandatory: true description: An ordered array of the firewall rules (not including the default rule) ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: comment type: String diff --git a/gen/definitions/appliance_vpn_site_to_site_ipsec_peers_slas.yaml b/gen/definitions/appliance_vpn_site_to_site_ipsec_peers_slas.yaml index 9b343907..f5fb0f19 100644 --- a/gen/definitions/appliance_vpn_site_to_site_ipsec_peers_slas.yaml +++ b/gen/definitions/appliance_vpn_site_to_site_ipsec_peers_slas.yaml @@ -17,7 +17,6 @@ attributes: type: List mandatory: true description: List of IPsec SLA policies - destroy_value: '[]interface{}{}' attributes: - model_name: name type: String diff --git a/gen/definitions/camera_device_wireless_profiles.yaml b/gen/definitions/camera_device_wireless_profiles.yaml index 6845fa0d..ffbba273 100644 --- a/gen/definitions/camera_device_wireless_profiles.yaml +++ b/gen/definitions/camera_device_wireless_profiles.yaml @@ -1,3 +1,4 @@ +# Customize Delete() function as resetting profiles to empty string is not supported name: Camera Device Wireless Profiles spec_endpoint: /devices/{serial}/camera/wirelessProfiles rest_endpoint: /devices/%v/camera/wirelessProfiles diff --git a/gen/definitions/cellular_gateway_connectivity_monitoring_destinations.yaml b/gen/definitions/cellular_gateway_connectivity_monitoring_destinations.yaml index 019fb2f8..97c393fd 100644 --- a/gen/definitions/cellular_gateway_connectivity_monitoring_destinations.yaml +++ b/gen/definitions/cellular_gateway_connectivity_monitoring_destinations.yaml @@ -17,14 +17,6 @@ attributes: type: List mandatory: true description: The list of connectivity monitoring destinations. Is set to Google DNS (8.8.8.8) when the resource is not created and gets reset to it on resource deletion - destroy_value: |- - []interface{}{ - map[string]interface{}{ - "ip": "8.8.8.8", - "default": true, - "description": "Google", - }, - } attributes: - model_name: default type: Bool diff --git a/gen/definitions/cellular_gateway_lan.yaml b/gen/definitions/cellular_gateway_lan.yaml index 1698f3aa..19434fae 100644 --- a/gen/definitions/cellular_gateway_lan.yaml +++ b/gen/definitions/cellular_gateway_lan.yaml @@ -17,7 +17,6 @@ attributes: type: List mandatory: true description: list of all fixed IP assignments for a single MG - destroy_value: '[]interface{}{}' attributes: - model_name: ip type: String @@ -37,7 +36,6 @@ attributes: type: List mandatory: true description: list of all reserved IP ranges for a single MG - destroy_value: '[]interface{}{}' attributes: - model_name: comment type: String diff --git a/gen/definitions/cellular_gateway_port_forwarding_rules.yaml b/gen/definitions/cellular_gateway_port_forwarding_rules.yaml index 234a870f..d2d4a456 100644 --- a/gen/definitions/cellular_gateway_port_forwarding_rules.yaml +++ b/gen/definitions/cellular_gateway_port_forwarding_rules.yaml @@ -18,7 +18,6 @@ attributes: mandatory: true description: An array of port forwarding params ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: access type: String diff --git a/gen/definitions/cellular_gateway_uplink.yaml b/gen/definitions/cellular_gateway_uplink.yaml index 4435c244..29f58351 100644 --- a/gen/definitions/cellular_gateway_uplink.yaml +++ b/gen/definitions/cellular_gateway_uplink.yaml @@ -19,11 +19,13 @@ attributes: description: The maximum download limit (integer, in Kbps). null indicates no limit example: "1000000" minimum_test_value: "10000" + destroy_value: nil - model_name: limitUp type: Int64 data_path: [bandwidthLimits] description: The maximum upload limit (integer, in Kbps). null indicates no limit example: "1000000" + destroy_value: nil test_prerequisites: | data "meraki_organization" "test" { name = var.test_org diff --git a/gen/definitions/network_syslog_servers.yaml b/gen/definitions/network_syslog_servers.yaml index f316050b..f17ec3ea 100644 --- a/gen/definitions/network_syslog_servers.yaml +++ b/gen/definitions/network_syslog_servers.yaml @@ -17,7 +17,6 @@ attributes: type: List mandatory: true description: A list of the syslog servers for this network - destroy_value: '[]interface{}{}' attributes: - model_name: host type: String diff --git a/gen/definitions/switch_access_control_lists.yaml b/gen/definitions/switch_access_control_lists.yaml index 05bd38ed..f70cc36e 100644 --- a/gen/definitions/switch_access_control_lists.yaml +++ b/gen/definitions/switch_access_control_lists.yaml @@ -18,7 +18,6 @@ attributes: mandatory: true description: An ordered array of the access control list rules (not including the default rule). An empty array will clear the rules. ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: comment type: String diff --git a/gen/definitions/switch_dscp_to_cos_mappings.yaml b/gen/definitions/switch_dscp_to_cos_mappings.yaml index 1433f6ab..51c08483 100644 --- a/gen/definitions/switch_dscp_to_cos_mappings.yaml +++ b/gen/definitions/switch_dscp_to_cos_mappings.yaml @@ -17,7 +17,6 @@ attributes: type: List mandatory: true description: An array of DSCP to CoS mappings. An empty array will reset the mappings to default. - destroy_value: '[]interface{}{}' attributes: - model_name: cos type: Int64 diff --git a/gen/definitions/switch_port.yaml b/gen/definitions/switch_port.yaml index 90a7697d..17e23e13 100644 --- a/gen/definitions/switch_port.yaml +++ b/gen/definitions/switch_port.yaml @@ -1,4 +1,4 @@ -# Customize toDestroyBody(), Update() and Delete() for bulk resource to conditionally remove adaptive policy (if present) during deleting +# Customize addDeleteValues(), Update() and Delete() for bulk resource to conditionally remove adaptive policy (if present) during deleting name: Switch Port spec_endpoint: /devices/{serial}/switch/ports/{portId} rest_endpoint: /devices/%v/switch/ports/%v @@ -33,7 +33,6 @@ attributes: description: The type of the access policy of the switch port. Only applicable to access ports. Can be one of `Open`, `Custom access policy`, `MAC allow list` or `Sticky MAC allow list`. example: Sticky MAC allow list enum_values: [Custom access policy, MAC allow list, Open, Sticky MAC allow list] - destroy_value: '"Open"' - model_name: adaptivePolicyGroupId type: String exclude_test: true @@ -141,7 +140,6 @@ attributes: data_path: [profile] description: When enabled, override this port`s configuration with a port profile. example: "false" - destroy_value: "false" - model_name: id type: String data_path: [profile] diff --git a/gen/definitions/wireless_air_marshal_settings.yaml b/gen/definitions/wireless_air_marshal_settings.yaml index e5dee055..9a381d82 100644 --- a/gen/definitions/wireless_air_marshal_settings.yaml +++ b/gen/definitions/wireless_air_marshal_settings.yaml @@ -1,4 +1,4 @@ -# Customize Read() to support org level endpoint +# Customize Create(), Read() to support org level endpoint name: Wireless Air Marshal Settings spec_endpoint: /networks/{networkId}/wireless/airMarshal/settings rest_endpoint: /networks/%v/wireless/airMarshal/settings diff --git a/gen/definitions/wireless_location_scanning.yaml b/gen/definitions/wireless_location_scanning.yaml index ae3b93b7..fa165738 100644 --- a/gen/definitions/wireless_location_scanning.yaml +++ b/gen/definitions/wireless_location_scanning.yaml @@ -1,4 +1,4 @@ -# Customize Read() function to handle org level GET request +# Customize Create(), Read() function to handle org level GET request name: Wireless Location Scanning spec_endpoint: /networks/{networkId}/wireless/location/scanning rest_endpoint: /networks/%v/wireless/location/scanning diff --git a/gen/definitions/wireless_ssid.yaml b/gen/definitions/wireless_ssid.yaml index 6d1f7a87..c2a06141 100644 --- a/gen/definitions/wireless_ssid.yaml +++ b/gen/definitions/wireless_ssid.yaml @@ -32,18 +32,15 @@ attributes: exclude_test: true description: Boolean indicating whether or not adult content will be blocked example: "false" - destroy_value: "false" - model_name: authMode type: String description: The association control method for the SSID (`open`, `open-enhanced`, `psk`, `open-with-radius`, `open-with-nac`, `8021x-meraki`, `8021x-nac`, `8021x-radius`, `8021x-google`, `8021x-entra`, `8021x-localradius`, `ipsk-with-radius`, `ipsk-without-radius` or `ipsk-with-nac`) example: psk enum_values: [8021x-entra, 8021x-google, 8021x-localradius, 8021x-meraki, 8021x-nac, 8021x-radius, ipsk-with-nac, ipsk-with-radius, ipsk-without-radius, open, open-enhanced, open-with-nac, open-with-radius, psk] - destroy_value: '"open"' - model_name: availableOnAllAps type: Bool description: Boolean indicating whether all APs should broadcast the SSID or if it should be restricted to APs matching any availability tags. Can only be false if the SSID has availability tags. example: "false" - destroy_value: "true" - model_name: bandSelection type: String description: The client-serving radio frequencies of this SSID in the default indoor RF profile. (`Dual band operation`, `5 GHz band only` or `Dual band operation with Band Steering`) @@ -67,7 +64,6 @@ attributes: type: Bool description: Whether or not the SSID is enabled example: "false" - destroy_value: "false" - model_name: encryptionMode type: String description: The psk encryption mode for the SSID (`wep` or `wpa`). This param is only valid if the authMode is `psk` @@ -84,7 +80,6 @@ attributes: description: The client IP assignment mode (`NAT mode`, `Bridge mode`, `Layer 3 roaming`, `Ethernet over GRE`, `Layer 3 roaming with a concentrator` or `VPN`) example: Bridge mode enum_values: [Bridge mode, Ethernet over GRE, Layer 3 roaming, Layer 3 roaming with a concentrator, NAT mode, VPN] - destroy_value: '"NAT mode"' - model_name: lanIsolationEnabled type: Bool description: Boolean indicating whether Layer 2 LAN isolation should be enabled or disabled. Only configurable when ipAssignmentMode is `Bridge mode`. @@ -93,7 +88,6 @@ attributes: type: Bool description: If true, Mandatory DHCP will enforce that clients connecting to this SSID must use the IP address assigned by the DHCP server. Clients who use a static IP address won`t be able to associate. example: "false" - destroy_value: "false" - model_name: minBitrate type: Float64 description: The minimum bitrate in Mbps of this SSID in the default indoor RF profile. (`1`, `2`, `5.5`, `6`, `9`, `11`, `12`, `18`, `24`, `36`, `48` or `54`) @@ -103,27 +97,22 @@ attributes: mandatory: true description: The name of the SSID example: My SSID - destroy_value: '"Unconfigured SSID"' - model_name: perClientBandwidthLimitDown type: Int64 description: The download bandwidth limit in Kbps. (0 represents no limit.) example: "0" - destroy_value: "0" - model_name: perClientBandwidthLimitUp type: Int64 description: The upload bandwidth limit in Kbps. (0 represents no limit.) example: "0" - destroy_value: "0" - model_name: perSsidBandwidthLimitDown type: Int64 description: The total download bandwidth limit in Kbps. (0 represents no limit.) example: "0" - destroy_value: "0" - model_name: perSsidBandwidthLimitUp type: Int64 description: The total upload bandwidth limit in Kbps. (0 represents no limit.) example: "0" - destroy_value: "0" - model_name: psk type: String description: The passkey for the SSID. This param is only valid if the authMode is `psk` @@ -221,7 +210,6 @@ attributes: description: The type of splash page for the SSID (`None`, `Click-through splash page`, `Billing`, `Password-protected with Meraki RADIUS`, `Password-protected with custom RADIUS`, `Password-protected with Active Directory`, `Password-protected with LDAP`, `SMS authentication`, `Systems Manager Sentry`, `Facebook Wi-Fi`, `Google OAuth`, `Microsoft Entra ID`, `Sponsored guest`, `Cisco ISE` or `Google Apps domain`). This attribute is not supported for template children. example: Click-through splash page enum_values: [Billing, Cisco ISE, Click-through splash page, Facebook Wi-Fi, Google Apps domain, Google OAuth, Microsoft Entra ID, None, Password-protected with Active Directory, Password-protected with LDAP, Password-protected with Meraki RADIUS, Password-protected with custom RADIUS, SMS authentication, Sponsored guest, Systems Manager Sentry] - destroy_value: '"None"' - model_name: useVlanTagging type: Bool description: Whether or not traffic should be directed to use specific VLANs. This param is only valid if the ipAssignmentMode is `Bridge mode` or `Layer 3 roaming` @@ -230,7 +218,6 @@ attributes: type: Bool description: Boolean indicating whether APs should advertise or hide this SSID. APs will only broadcast this SSID if set to true example: "false" - destroy_value: "true" - model_name: vlanId type: Int64 exclude_test: true @@ -279,7 +266,6 @@ attributes: exclude_test: true description: Boolean indicating whether or not DNS server rewrite is enabled. If disabled, upstream DNS will be used example: "false" - destroy_value: "false" - model_name: dnsCustomNameservers type: List element_type: String @@ -287,7 +273,6 @@ attributes: exclude_test: true description: User specified DNS servers (up to two servers) example: 8.8.8.8 - destroy_value: '[]interface{}{}' - model_name: adaptive type: Bool data_path: [dot11r] @@ -504,7 +489,6 @@ attributes: data_path: [speedBurst] description: Boolean indicating whether or not to allow users to temporarily exceed the bandwidth limit for short periods while still keeping them under the bandwidth limit over time. example: "false" - destroy_value: "false" - model_name: apTagsAndVlanIds type: List exclude_test: true @@ -524,7 +508,6 @@ attributes: element_type: String description: Accepts a list of tags for this SSID. If availableOnAllAps is false, then the SSID will only be broadcast by APs with tags matching any of the tags in this list. example: tag1 - destroy_value: '[]interface{}{}' - model_name: radiusAccountingServers type: List exclude_test: true diff --git a/gen/definitions/wireless_ssid_eap_override.yaml b/gen/definitions/wireless_ssid_eap_override.yaml index 6213a53e..a3031954 100644 --- a/gen/definitions/wireless_ssid_eap_override.yaml +++ b/gen/definitions/wireless_ssid_eap_override.yaml @@ -24,6 +24,7 @@ attributes: description: Maximum number of general EAP retries. example: "5" minimum_test_value: "5" + destroy_value: "5" - model_name: timeout type: Int64 description: General EAP timeout in seconds. @@ -62,4 +63,9 @@ test_prerequisites: |- name = "My SSID" network_id = meraki_network.test.id ip_assignment_mode = "Bridge mode" + auth_mode = "8021x-radius" + radius_servers = [{ + host = "1.2.3.4" + secret = "secret123" + }] } diff --git a/gen/definitions/wireless_ssid_l3_firewall_rules.yaml b/gen/definitions/wireless_ssid_l3_firewall_rules.yaml index 1fc5b74d..1ca7257c 100644 --- a/gen/definitions/wireless_ssid_l3_firewall_rules.yaml +++ b/gen/definitions/wireless_ssid_l3_firewall_rules.yaml @@ -27,9 +27,9 @@ attributes: minimum_test_value: "false" - model_name: rules type: List + write_empty_list: true description: An ordered array of the firewall rules for this SSID (not including the local LAN access rule or the default rule). ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: comment type: String diff --git a/gen/definitions/wireless_ssid_l7_firewall_rules.yaml b/gen/definitions/wireless_ssid_l7_firewall_rules.yaml index 271ebe9a..65d9c8ff 100644 --- a/gen/definitions/wireless_ssid_l7_firewall_rules.yaml +++ b/gen/definitions/wireless_ssid_l7_firewall_rules.yaml @@ -23,9 +23,9 @@ attributes: test_value: meraki_wireless_ssid.test.id - model_name: rules type: List + write_empty_list: true description: An array of L7 firewall rules for this SSID. Rules will get applied in the same order user has specified in request. Empty array will clear the L7 firewall rule configuration. ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: policy type: String diff --git a/gen/definitions/wireless_ssid_traffic_shaping_rules.yaml b/gen/definitions/wireless_ssid_traffic_shaping_rules.yaml index 5c5c207c..2afee82f 100644 --- a/gen/definitions/wireless_ssid_traffic_shaping_rules.yaml +++ b/gen/definitions/wireless_ssid_traffic_shaping_rules.yaml @@ -30,9 +30,9 @@ attributes: example: "true" - model_name: rules type: List + write_empty_list: true description: An array of traffic shaping rules. Rules are applied in the order that they are specified in. An empty list (or null) means no rules. Note that you are allowed a maximum of 8 rules. ordered_list: true - destroy_value: '[]interface{}{}' attributes: - model_name: dscpTagValue type: Int64 diff --git a/gen/definitions/wireless_zigbee.yaml b/gen/definitions/wireless_zigbee.yaml index d0bdf641..ea7623ae 100644 --- a/gen/definitions/wireless_zigbee.yaml +++ b/gen/definitions/wireless_zigbee.yaml @@ -1,4 +1,4 @@ -# Customize Read() to support org level endpoint +# Customize Create(), Read() to support org level endpoint # Test currently fails with "500 Internal Error", might require specific AP name: Wireless Zigbee spec_endpoint: /networks/{networkId}/wireless/zigbee diff --git a/gen/schema/schema.yaml b/gen/schema/schema.yaml index 732d443a..ad5d9279 100644 --- a/gen/schema/schema.yaml +++ b/gen/schema/schema.yaml @@ -43,6 +43,7 @@ attribute: mandatory: bool(required=False) # Set to true if the attribute is mandatory write_only: bool(required=False) # Set to true if the attribute is write-only, meaning we cannot read the value write_changes_only: bool(required=False) # Set to true if the attribute should only be written (included in PUT payload) if it has changed + write_empty_list: bool(required=False) # Set to true if the attribute should be written as an empty list if it is not set, only relevant if type is "List" or "Set" exclude_test: bool(required=False) # Exclude attribute from example (documentation) and acceptance test exclude_example: bool(required=False) # Exclude attribute from acceptance test only (example/documentation is still generated) allow_import_changes: bool(required=False) # Allow changes to the attribute during import diff --git a/gen/templates/bulk/model_resource.go b/gen/templates/bulk/model_resource.go index 6cb3d150..c7e000d2 100644 --- a/gen/templates/bulk/model_resource.go +++ b/gen/templates/bulk/model_resource.go @@ -688,9 +688,9 @@ func (data *Resource{{camelCase .BulkName}}) fromBodyImport(ctx context.Context, // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data Resource{{camelCase .BulkName}}) toDestroyBody(ctx context.Context) string { +func (data Resource{{camelCase .BulkName}}) addDeleteValues(ctx context.Context) string { body := "" {{- range getBulkItemAttributes .}} {{- if .DestroyValue}} @@ -700,7 +700,7 @@ func (data Resource{{camelCase .BulkName}}) toDestroyBody(ctx context.Context) s return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/gen/templates/bulk/resource.go b/gen/templates/bulk/resource.go index 0373aeb5..72cc33e2 100644 --- a/gen/templates/bulk/resource.go +++ b/gen/templates/bulk/resource.go @@ -644,7 +644,7 @@ func (r *{{camelCase .BulkName}}Resource) Update(ctx context.Context, req resour actions = append(actions, meraki.ActionModel{ Operation: "update", Resource: plan.getItemPath(itemState.{{toGoName ((getId .Attributes).TfName)}}.ValueString()), - Body: plan.toDestroyBody(ctx), + Body: plan.addDeleteValues(ctx), }) {{- else if not .NoDelete}} actions = append(actions, meraki.ActionModel{ @@ -755,7 +755,7 @@ func (r *{{camelCase .BulkName}}Resource) Delete(ctx context.Context, req resour actions[i] = meraki.ActionModel{ Operation: "update", Resource: state.getItemPath(item.{{toGoName ((getId .Attributes).TfName)}}.ValueString()), - Body: state.toDestroyBody(ctx), + Body: state.addDeleteValues(ctx), } } if len(actions) > 0 { diff --git a/gen/templates/model.go b/gen/templates/model.go index 94053426..553eb8bf 100644 --- a/gen/templates/model.go +++ b/gen/templates/model.go @@ -157,7 +157,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context, state {{camelCase .N body, _ = sjson.Set(body, "{{getFullModelName . true}}", values) } {{- else if isNestedListSetMap .}} - {{if not .Mandatory}}if len(data.{{toGoName .TfName}}) > 0 {{end}}{ + {{if and (not .Mandatory) (not .WriteEmptyList)}}if len(data.{{toGoName .TfName}}) > 0 {{end}}{ {{- if isNestedMap .}} body, _ = sjson.Set(body, "{{getFullModelName . true}}", map[string]interface{}{}) for key, item := range data.{{toGoName .TfName}} { @@ -182,7 +182,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context, state {{camelCase .N itemBody, _ = sjson.Set(itemBody, "{{getFullModelName . true}}", values) } {{- else if isNestedListSetMap .}} - {{if not .Mandatory}}if len(item.{{toGoName .TfName}}) > 0 {{end}}{ + {{if and (not .Mandatory) (not .WriteEmptyList)}}if len(item.{{toGoName .TfName}}) > 0 {{end}}{ {{- if isNestedMap .}} itemBody, _ = sjson.Set(itemBody, "{{getFullModelName . true}}", map[string]interface{}{}) for key, childItem := range item.{{toGoName .TfName}} { @@ -207,7 +207,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context, state {{camelCase .N itemChildBody, _ = sjson.Set(itemChildBody, "{{getFullModelName . true}}", values) } {{- else if isNestedListSetMap .}} - {{if not .Mandatory}}if len(childItem.{{toGoName .TfName}}) > 0 {{end}}{ + {{if and (not .Mandatory) (not .WriteEmptyList)}}if len(childItem.{{toGoName .TfName}}) > 0 {{end}}{ {{- if isNestedMap .}} itemChildBody, _ = sjson.Set(itemChildBody, "{{getFullModelName . true}}", map[string]interface{}{}) for key, childChildItem := range childItem.{{toGoName .TfName}} { @@ -515,10 +515,9 @@ func (data *{{camelCase .Name}}) fromBodyUnknowns(ctx context.Context, res merak // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data {{camelCase .Name}}) toDestroyBody(ctx context.Context) string { - body := "" +func (data {{camelCase .Name}}) addDeleteValues(ctx context.Context, body string) string { {{- range .Attributes}} {{- if .DestroyValue}} body, _ = sjson.Set(body, "{{getFullModelName . true}}", {{.DestroyValue}}) @@ -527,7 +526,7 @@ func (data {{camelCase .Name}}) toDestroyBody(ctx context.Context) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues {{- range .Attributes}} {{- range .Attributes}} diff --git a/gen/templates/resource.go b/gen/templates/resource.go index ed5e89c9..219e621d 100644 --- a/gen/templates/resource.go +++ b/gen/templates/resource.go @@ -410,7 +410,7 @@ func (r *{{camelCase .Name}}Resource) Configure(_ context.Context, req resource. // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *{{camelCase .Name}}Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan {{camelCase .Name}} + var plan{{if isSingleton .}}, initialState{{end}} {{camelCase .Name}} // Read plan diags := req.Plan.Get(ctx, &plan) @@ -420,6 +420,17 @@ func (r *{{camelCase .Name}}Resource) Create(ctx context.Context, req resource.C tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + {{- if isSingleton .}} + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, {{camelCase .Name}}{}), resp.Private, &resp.Diagnostics) + {{- end}} + // Create object body := plan.toBody(ctx, {{camelCase .Name}}{}) @@ -568,8 +579,21 @@ func (r *{{camelCase .Name}}Resource) Delete(ctx context.Context, req resource.D tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - {{- if hasDestroyValues .Attributes}} - body := state.toDestroyBody(ctx) + {{- if isSingleton .}} + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } + {{- else if hasDestroyValues .Attributes}} + body := state.addDeleteValues(ctx, "") res, err := r.client.Put(state.getPath(), body) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) diff --git a/gen/yamlconfig/main.go b/gen/yamlconfig/main.go index eb0da3c8..4cc62a4a 100644 --- a/gen/yamlconfig/main.go +++ b/gen/yamlconfig/main.go @@ -96,6 +96,7 @@ type YamlConfigAttribute struct { Mandatory bool `yaml:"mandatory,omitempty"` WriteOnly bool `yaml:"write_only,omitempty"` WriteChangesOnly bool `yaml:"write_changes_only,omitempty"` + WriteEmptyList bool `yaml:"write_empty_list,omitempty"` ExcludeTest bool `yaml:"exclude_test,omitempty"` ExcludeExample bool `yaml:"exclude_example,omitempty"` AllowImportChanges bool `yaml:"allow_import_changes,omitempty"` @@ -139,6 +140,7 @@ type YamlConfigAttributeP struct { Mandatory *bool `yaml:"mandatory,omitempty"` WriteOnly *bool `yaml:"write_only,omitempty"` WriteChangesOnly *bool `yaml:"write_changes_only,omitempty"` + WriteEmptyList *bool `yaml:"write_empty_list,omitempty"` ExcludeTest *bool `yaml:"exclude_test,omitempty"` ExcludeExample *bool `yaml:"exclude_example,omitempty"` AllowImportChanges *bool `yaml:"allow_import_changes,omitempty"` @@ -534,6 +536,11 @@ func GetBulkItemIdTfName(config YamlConfig) string { return "id" } +// IsSingleton returns true if the resource is a singleton +func IsSingleton(config YamlConfig) bool { + return config.PutCreate && config.NoDelete && !config.NoRead +} + // Map of templating functions var Functions = template.FuncMap{ "toGoName": ToGoName, @@ -571,6 +578,7 @@ var Functions = template.FuncMap{ "hasOrganizationId": HasOrganizationId, "getBulkItemId": GetBulkItemId, "getBulkItemIdTfName": GetBulkItemIdTfName, + "isSingleton": IsSingleton, } var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)") @@ -883,6 +891,9 @@ func MergeYamlConfigAttribute(existing *YamlConfigAttributeP, new *YamlConfigAtt if existing.WriteChangesOnly != nil { new.WriteChangesOnly = existing.WriteChangesOnly } + if existing.WriteEmptyList != nil { + new.WriteEmptyList = existing.WriteEmptyList + } if existing.ExcludeTest != nil { new.ExcludeTest = existing.ExcludeTest } diff --git a/internal/provider/data_source_meraki_appliance_firewall_multicast_forwarding.go b/internal/provider/data_source_meraki_appliance_firewall_multicast_forwarding.go index 2a3a363f..785146ed 100644 --- a/internal/provider/data_source_meraki_appliance_firewall_multicast_forwarding.go +++ b/internal/provider/data_source_meraki_appliance_firewall_multicast_forwarding.go @@ -28,7 +28,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/netascode/go-meraki" - "github.com/tidwall/gjson" ) // End of section. //template:end imports @@ -122,22 +121,14 @@ func (d *ApplianceFirewallMulticastForwardingDataSource) Read(ctx context.Contex } orgId := res.Get("organizationId").String() - rulesPath := fmt.Sprintf("/organizations/%v/appliance/firewall/multicastForwarding/byNetwork", orgId) + rulesPath := fmt.Sprintf("/organizations/%v/appliance/firewall/multicastForwarding/byNetwork?networkIds[]=%v", orgId, config.NetworkId.ValueString()) res, err = d.client.Get(rulesPath) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve multicast forwarding (GET), got error: %s, %s", err, res.String())) return } - if len(res.Get("items").Array()) > 0 { - res.Get("items").ForEach(func(k, v gjson.Result) bool { - if config.NetworkId.ValueString() == v.Get("network.id").String() { - res = meraki.Res{Result: v} - return false - } - return true - }) - } + res = meraki.Res{Result: res.Get("items.0")} config.fromBody(ctx, res) config.Id = config.NetworkId diff --git a/internal/provider/data_source_meraki_appliance_traffic_shaping_vpn_exclusions.go b/internal/provider/data_source_meraki_appliance_traffic_shaping_vpn_exclusions.go index b358bdc8..53184fc2 100644 --- a/internal/provider/data_source_meraki_appliance_traffic_shaping_vpn_exclusions.go +++ b/internal/provider/data_source_meraki_appliance_traffic_shaping_vpn_exclusions.go @@ -27,7 +27,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/netascode/go-meraki" - "github.com/tidwall/gjson" ) // End of section. //template:end imports @@ -136,22 +135,14 @@ func (d *ApplianceTrafficShapingVPNExclusionsDataSource) Read(ctx context.Contex } orgId := res.Get("organizationId").String() - rulesPath := fmt.Sprintf("/organizations/%v/appliance/trafficShaping/vpnExclusions/byNetwork", orgId) + rulesPath := fmt.Sprintf("/organizations/%v/appliance/trafficShaping/vpnExclusions/byNetwork?networkIds[]=%v", orgId, config.NetworkId.ValueString()) res, err = d.client.Get(rulesPath) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve vpn exceptions (GET), got error: %s, %s", err, res.String())) return } - if len(res.Get("items").Array()) > 0 { - res.Get("items").ForEach(func(k, v gjson.Result) bool { - if config.NetworkId.ValueString() == v.Get("networkId").String() { - res = meraki.Res{Result: v} - return false - } - return true - }) - } + res = meraki.Res{Result: res.Get("items.0")} config.Id = config.NetworkId diff --git a/internal/provider/data_source_meraki_wireless_ssid_eap_override_test.go b/internal/provider/data_source_meraki_wireless_ssid_eap_override_test.go index 3b8f475d..c205417c 100644 --- a/internal/provider/data_source_meraki_wireless_ssid_eap_override_test.go +++ b/internal/provider/data_source_meraki_wireless_ssid_eap_override_test.go @@ -72,6 +72,11 @@ resource "meraki_wireless_ssid" "test" { name = "My SSID" network_id = meraki_network.test.id ip_assignment_mode = "Bridge mode" + auth_mode = "8021x-radius" + radius_servers = [{ + host = "1.2.3.4" + secret = "secret123" + }] } ` diff --git a/internal/provider/helpers/flag.go b/internal/provider/helpers/private_state.go similarity index 57% rename from internal/provider/helpers/flag.go rename to internal/provider/helpers/private_state.go index a57631c3..9e4ab58b 100644 --- a/internal/provider/helpers/flag.go +++ b/internal/provider/helpers/private_state.go @@ -33,6 +33,29 @@ func SetFlagImporting(ctx context.Context, importing bool, sk SetKeyer, respDiag respDiags.Append(diags...) } +func GetJsonInitialState(ctx context.Context, req resource.DeleteRequest) (string, diag.Diagnostics) { + v, diags := req.Private.GetKey(ctx, "initial_state") + if diags.HasError() { + return "", diags + } + + return string(v), diags +} + +// SetJsonInitialState checks the respDiags and if they are error-free it sets the `initial_state` as a private JSON value inside +// SetKeyer. It appends its own results to respDiags. +// +// The caller must include in respDiags the result of state modification in the first place, to ensure consistency. +// The SetKeyer is something like resp.Private. +func SetJsonInitialState(ctx context.Context, jsonValue string, sk SetKeyer, respDiags *diag.Diagnostics) { + if respDiags.HasError() { + return + } + + diags := sk.SetKey(ctx, "initial_state", []byte(jsonValue)) + respDiags.Append(diags...) +} + func IsFlag(ctx context.Context, req resource.ReadRequest, flagName string) (bool, diag.Diagnostics) { v, diags := req.Private.GetKey(ctx, flagName) @@ -53,6 +76,24 @@ func SetFlag(ctx context.Context, flagName string, value bool, sk SetKeyer, resp respDiags.Append(diags...) } +func GetJson(ctx context.Context, req resource.DeleteRequest, keyName string) (string, diag.Diagnostics) { + v, diags := req.Private.GetKey(ctx, keyName) + if diags.HasError() { + return "", diags + } + + return string(v), diags +} + +func SetJson(ctx context.Context, keyName string, jsonValue string, sk SetKeyer, respDiags *diag.Diagnostics) { + if respDiags.HasError() { + return + } + + diags := sk.SetKey(ctx, keyName, []byte(jsonValue)) + respDiags.Append(diags...) +} + // SetKeyer is something like ReadResponse.Private or ImportStateResponse.Private. type SetKeyer interface { SetKey(ctx context.Context, key string, value []byte) diag.Diagnostics diff --git a/internal/provider/model_meraki_appliance_cellular_firewall_rules.go b/internal/provider/model_meraki_appliance_cellular_firewall_rules.go index dbcf7ee4..17d552b0 100644 --- a/internal/provider/model_meraki_appliance_cellular_firewall_rules.go +++ b/internal/provider/model_meraki_appliance_cellular_firewall_rules.go @@ -234,12 +234,10 @@ func (data *ApplianceCellularFirewallRules) fromBodyUnknowns(ctx context.Context // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceCellularFirewallRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data ApplianceCellularFirewallRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_connectivity_monitoring_destinations.go b/internal/provider/model_meraki_appliance_connectivity_monitoring_destinations.go index 19576355..c9329f16 100644 --- a/internal/provider/model_meraki_appliance_connectivity_monitoring_destinations.go +++ b/internal/provider/model_meraki_appliance_connectivity_monitoring_destinations.go @@ -186,18 +186,10 @@ func (data *ApplianceConnectivityMonitoringDestinations) fromBodyUnknowns(ctx co // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceConnectivityMonitoringDestinations) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "destinations", []interface{}{ - map[string]interface{}{ - "ip": "8.8.8.8", - "default": true, - "description": "Google", - }, - }) +func (data ApplianceConnectivityMonitoringDestinations) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_content_filtering.go b/internal/provider/model_meraki_appliance_content_filtering.go index 2763e170..c44e2dea 100644 --- a/internal/provider/model_meraki_appliance_content_filtering.go +++ b/internal/provider/model_meraki_appliance_content_filtering.go @@ -126,11 +126,10 @@ func (data *ApplianceContentFiltering) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceContentFiltering) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceContentFiltering) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_dns_local_profile.go b/internal/provider/model_meraki_appliance_dns_local_profile.go index b45b5953..f1c18283 100644 --- a/internal/provider/model_meraki_appliance_dns_local_profile.go +++ b/internal/provider/model_meraki_appliance_dns_local_profile.go @@ -97,11 +97,10 @@ func (data *ApplianceDNSLocalProfile) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceDNSLocalProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceDNSLocalProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_dns_local_profile_assignments.go b/internal/provider/model_meraki_appliance_dns_local_profile_assignments.go index 119738b7..d574c6b1 100644 --- a/internal/provider/model_meraki_appliance_dns_local_profile_assignments.go +++ b/internal/provider/model_meraki_appliance_dns_local_profile_assignments.go @@ -251,11 +251,10 @@ func (data *ApplianceDNSLocalProfileAssignments) fromBodyUnknowns(ctx context.Co // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceDNSLocalProfileAssignments) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceDNSLocalProfileAssignments) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_dns_local_record.go b/internal/provider/model_meraki_appliance_dns_local_record.go index d7403eea..65150c4b 100644 --- a/internal/provider/model_meraki_appliance_dns_local_record.go +++ b/internal/provider/model_meraki_appliance_dns_local_record.go @@ -125,11 +125,10 @@ func (data *ApplianceDNSLocalRecord) fromBodyUnknowns(ctx context.Context, res m // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceDNSLocalRecord) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceDNSLocalRecord) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_dns_split_profile.go b/internal/provider/model_meraki_appliance_dns_split_profile.go index b1003047..17d7c740 100644 --- a/internal/provider/model_meraki_appliance_dns_split_profile.go +++ b/internal/provider/model_meraki_appliance_dns_split_profile.go @@ -130,11 +130,10 @@ func (data *ApplianceDNSSplitProfile) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceDNSSplitProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceDNSSplitProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_dns_split_profile_assignments.go b/internal/provider/model_meraki_appliance_dns_split_profile_assignments.go index f676fad9..51f5e67f 100644 --- a/internal/provider/model_meraki_appliance_dns_split_profile_assignments.go +++ b/internal/provider/model_meraki_appliance_dns_split_profile_assignments.go @@ -251,11 +251,10 @@ func (data *ApplianceDNSSplitProfileAssignments) fromBodyUnknowns(ctx context.Co // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceDNSSplitProfileAssignments) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceDNSSplitProfileAssignments) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_firewall_multicast_forwarding.go b/internal/provider/model_meraki_appliance_firewall_multicast_forwarding.go index 70ddb1a5..c5dc0ffc 100644 --- a/internal/provider/model_meraki_appliance_firewall_multicast_forwarding.go +++ b/internal/provider/model_meraki_appliance_firewall_multicast_forwarding.go @@ -189,12 +189,10 @@ func (data *ApplianceFirewallMulticastForwarding) fromBodyUnknowns(ctx context.C // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceFirewallMulticastForwarding) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data ApplianceFirewallMulticastForwarding) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_firewall_settings.go b/internal/provider/model_meraki_appliance_firewall_settings.go index 31f62aa4..9f81492d 100644 --- a/internal/provider/model_meraki_appliance_firewall_settings.go +++ b/internal/provider/model_meraki_appliance_firewall_settings.go @@ -97,11 +97,10 @@ func (data *ApplianceFirewallSettings) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceFirewallSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceFirewallSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_firewalled_service.go b/internal/provider/model_meraki_appliance_firewalled_service.go index 76920f9a..04767005 100644 --- a/internal/provider/model_meraki_appliance_firewalled_service.go +++ b/internal/provider/model_meraki_appliance_firewalled_service.go @@ -115,11 +115,10 @@ func (data *ApplianceFirewalledService) fromBodyUnknowns(ctx context.Context, re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceFirewalledService) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceFirewalledService) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_inbound_cellular_firewall_rules.go b/internal/provider/model_meraki_appliance_inbound_cellular_firewall_rules.go index d7c21097..5f199595 100644 --- a/internal/provider/model_meraki_appliance_inbound_cellular_firewall_rules.go +++ b/internal/provider/model_meraki_appliance_inbound_cellular_firewall_rules.go @@ -234,12 +234,10 @@ func (data *ApplianceInboundCellularFirewallRules) fromBodyUnknowns(ctx context. // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceInboundCellularFirewallRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data ApplianceInboundCellularFirewallRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_inbound_firewall_rules.go b/internal/provider/model_meraki_appliance_inbound_firewall_rules.go index bac236cf..0d132093 100644 --- a/internal/provider/model_meraki_appliance_inbound_firewall_rules.go +++ b/internal/provider/model_meraki_appliance_inbound_firewall_rules.go @@ -238,12 +238,10 @@ func (data *ApplianceInboundFirewallRules) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceInboundFirewallRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data ApplianceInboundFirewallRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_l3_firewall_rules.go b/internal/provider/model_meraki_appliance_l3_firewall_rules.go index 0d6c4eba..93849fc2 100644 --- a/internal/provider/model_meraki_appliance_l3_firewall_rules.go +++ b/internal/provider/model_meraki_appliance_l3_firewall_rules.go @@ -238,12 +238,10 @@ func (data *ApplianceL3FirewallRules) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceL3FirewallRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data ApplianceL3FirewallRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_l7_firewall_rules.go b/internal/provider/model_meraki_appliance_l7_firewall_rules.go index 51e7bcf4..2d646b2f 100644 --- a/internal/provider/model_meraki_appliance_l7_firewall_rules.go +++ b/internal/provider/model_meraki_appliance_l7_firewall_rules.go @@ -198,12 +198,10 @@ func (data *ApplianceL7FirewallRules) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceL7FirewallRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data ApplianceL7FirewallRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_network_security_intrusion.go b/internal/provider/model_meraki_appliance_network_security_intrusion.go index 377daadc..b0c0d0f5 100644 --- a/internal/provider/model_meraki_appliance_network_security_intrusion.go +++ b/internal/provider/model_meraki_appliance_network_security_intrusion.go @@ -158,11 +158,10 @@ func (data *ApplianceNetworkSecurityIntrusion) fromBodyUnknowns(ctx context.Cont // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceNetworkSecurityIntrusion) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceNetworkSecurityIntrusion) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_one_to_many_nat_rules.go b/internal/provider/model_meraki_appliance_one_to_many_nat_rules.go index 7fbdecfd..fb40f4d6 100644 --- a/internal/provider/model_meraki_appliance_one_to_many_nat_rules.go +++ b/internal/provider/model_meraki_appliance_one_to_many_nat_rules.go @@ -317,12 +317,10 @@ func (data *ApplianceOneToManyNATRules) fromBodyUnknowns(ctx context.Context, re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceOneToManyNATRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data ApplianceOneToManyNATRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_one_to_one_nat_rules.go b/internal/provider/model_meraki_appliance_one_to_one_nat_rules.go index 21e6696b..467b7875 100644 --- a/internal/provider/model_meraki_appliance_one_to_one_nat_rules.go +++ b/internal/provider/model_meraki_appliance_one_to_one_nat_rules.go @@ -305,12 +305,10 @@ func (data *ApplianceOneToOneNATRules) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceOneToOneNATRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data ApplianceOneToOneNATRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_organization_security_intrusion.go b/internal/provider/model_meraki_appliance_organization_security_intrusion.go index 0e7a97c6..a23a9a44 100644 --- a/internal/provider/model_meraki_appliance_organization_security_intrusion.go +++ b/internal/provider/model_meraki_appliance_organization_security_intrusion.go @@ -172,12 +172,10 @@ func (data *ApplianceOrganizationSecurityIntrusion) fromBodyUnknowns(ctx context // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceOrganizationSecurityIntrusion) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "allowedRules", []interface{}{}) +func (data ApplianceOrganizationSecurityIntrusion) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_port.go b/internal/provider/model_meraki_appliance_port.go index 2ca460d8..2440c9f7 100644 --- a/internal/provider/model_meraki_appliance_port.go +++ b/internal/provider/model_meraki_appliance_port.go @@ -168,11 +168,10 @@ func (data *AppliancePort) fromBodyUnknowns(ctx context.Context, res meraki.Res) // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data AppliancePort) toDestroyBody(ctx context.Context) string { - body := "" +func (data AppliancePort) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_port_forwarding_rules.go b/internal/provider/model_meraki_appliance_port_forwarding_rules.go index c075dcd9..959cade2 100644 --- a/internal/provider/model_meraki_appliance_port_forwarding_rules.go +++ b/internal/provider/model_meraki_appliance_port_forwarding_rules.go @@ -245,12 +245,10 @@ func (data *AppliancePortForwardingRules) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data AppliancePortForwardingRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data AppliancePortForwardingRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_prefix_delegated_static.go b/internal/provider/model_meraki_appliance_prefix_delegated_static.go index 805a2158..1eee61ba 100644 --- a/internal/provider/model_meraki_appliance_prefix_delegated_static.go +++ b/internal/provider/model_meraki_appliance_prefix_delegated_static.go @@ -142,11 +142,10 @@ func (data *AppliancePrefixDelegatedStatic) fromBodyUnknowns(ctx context.Context // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data AppliancePrefixDelegatedStatic) toDestroyBody(ctx context.Context) string { - body := "" +func (data AppliancePrefixDelegatedStatic) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_radio_settings.go b/internal/provider/model_meraki_appliance_radio_settings.go index 9610016a..d85c7953 100644 --- a/internal/provider/model_meraki_appliance_radio_settings.go +++ b/internal/provider/model_meraki_appliance_radio_settings.go @@ -167,11 +167,10 @@ func (data *ApplianceRadioSettings) fromBodyUnknowns(ctx context.Context, res me // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceRadioSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceRadioSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_rf_profile.go b/internal/provider/model_meraki_appliance_rf_profile.go index f53f7c18..0c7994da 100644 --- a/internal/provider/model_meraki_appliance_rf_profile.go +++ b/internal/provider/model_meraki_appliance_rf_profile.go @@ -265,11 +265,10 @@ func (data *ApplianceRFProfile) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceRFProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceRFProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_sdwan_internet_policies.go b/internal/provider/model_meraki_appliance_sdwan_internet_policies.go index ddc6db63..54346dc5 100644 --- a/internal/provider/model_meraki_appliance_sdwan_internet_policies.go +++ b/internal/provider/model_meraki_appliance_sdwan_internet_policies.go @@ -460,12 +460,11 @@ func (data *ApplianceSDWANInternetPolicies) fromBodyUnknowns(ctx context.Context // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceSDWANInternetPolicies) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceSDWANInternetPolicies) addDeleteValues(ctx context.Context, body string) string { body, _ = sjson.Set(body, "wanTrafficUplinkPreferences", []interface{}{}) return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_security_malware.go b/internal/provider/model_meraki_appliance_security_malware.go index cbb42f8c..f97e7c8a 100644 --- a/internal/provider/model_meraki_appliance_security_malware.go +++ b/internal/provider/model_meraki_appliance_security_malware.go @@ -272,11 +272,10 @@ func (data *ApplianceSecurityMalware) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceSecurityMalware) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceSecurityMalware) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_settings.go b/internal/provider/model_meraki_appliance_settings.go index e4a5baec..2e08f612 100644 --- a/internal/provider/model_meraki_appliance_settings.go +++ b/internal/provider/model_meraki_appliance_settings.go @@ -139,11 +139,10 @@ func (data *ApplianceSettings) fromBodyUnknowns(ctx context.Context, res meraki. // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_single_lan.go b/internal/provider/model_meraki_appliance_single_lan.go index 1adc92db..8ef1f5e2 100644 --- a/internal/provider/model_meraki_appliance_single_lan.go +++ b/internal/provider/model_meraki_appliance_single_lan.go @@ -248,11 +248,10 @@ func (data *ApplianceSingleLAN) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceSingleLAN) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceSingleLAN) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_site_to_site_vpn.go b/internal/provider/model_meraki_appliance_site_to_site_vpn.go index 22b6ff05..2cacd6ab 100644 --- a/internal/provider/model_meraki_appliance_site_to_site_vpn.go +++ b/internal/provider/model_meraki_appliance_site_to_site_vpn.go @@ -314,11 +314,10 @@ func (data *ApplianceSiteToSiteVPN) fromBodyUnknowns(ctx context.Context, res me // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceSiteToSiteVPN) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceSiteToSiteVPN) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_ssid.go b/internal/provider/model_meraki_appliance_ssid.go index 9acac370..74e19b38 100644 --- a/internal/provider/model_meraki_appliance_ssid.go +++ b/internal/provider/model_meraki_appliance_ssid.go @@ -306,11 +306,10 @@ func (data *ApplianceSSID) fromBodyUnknowns(ctx context.Context, res meraki.Res) // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceSSID) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceSSID) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_static_route.go b/internal/provider/model_meraki_appliance_static_route.go index b1431ff2..af71a925 100644 --- a/internal/provider/model_meraki_appliance_static_route.go +++ b/internal/provider/model_meraki_appliance_static_route.go @@ -139,11 +139,10 @@ func (data *ApplianceStaticRoute) fromBodyUnknowns(ctx context.Context, res mera // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceStaticRoute) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceStaticRoute) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_third_party_vpn_peers.go b/internal/provider/model_meraki_appliance_third_party_vpn_peers.go index c4093bc7..76a8c7fb 100644 --- a/internal/provider/model_meraki_appliance_third_party_vpn_peers.go +++ b/internal/provider/model_meraki_appliance_third_party_vpn_peers.go @@ -671,12 +671,10 @@ func (data *ApplianceThirdPartyVPNPeers) fromBodyUnknowns(ctx context.Context, r // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceThirdPartyVPNPeers) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "peers", []interface{}{}) +func (data ApplianceThirdPartyVPNPeers) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_traffic_shaping.go b/internal/provider/model_meraki_appliance_traffic_shaping.go index 89a94f4b..0e25aaee 100644 --- a/internal/provider/model_meraki_appliance_traffic_shaping.go +++ b/internal/provider/model_meraki_appliance_traffic_shaping.go @@ -111,11 +111,10 @@ func (data *ApplianceTrafficShaping) fromBodyUnknowns(ctx context.Context, res m // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceTrafficShaping) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceTrafficShaping) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_traffic_shaping_custom_performance_class.go b/internal/provider/model_meraki_appliance_traffic_shaping_custom_performance_class.go index 08a30507..94ddd5f6 100644 --- a/internal/provider/model_meraki_appliance_traffic_shaping_custom_performance_class.go +++ b/internal/provider/model_meraki_appliance_traffic_shaping_custom_performance_class.go @@ -139,11 +139,10 @@ func (data *ApplianceTrafficShapingCustomPerformanceClass) fromBodyUnknowns(ctx // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceTrafficShapingCustomPerformanceClass) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceTrafficShapingCustomPerformanceClass) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_traffic_shaping_rules.go b/internal/provider/model_meraki_appliance_traffic_shaping_rules.go index 1db512db..72b17806 100644 --- a/internal/provider/model_meraki_appliance_traffic_shaping_rules.go +++ b/internal/provider/model_meraki_appliance_traffic_shaping_rules.go @@ -65,12 +65,13 @@ func (data ApplianceTrafficShapingRules) getPath() string { } // End of section. //template:end getPath + func (data ApplianceTrafficShapingRules) toBody(ctx context.Context, state ApplianceTrafficShapingRules) string { body := "" if !data.DefaultRulesEnabled.IsNull() { body, _ = sjson.Set(body, "defaultRulesEnabled", data.DefaultRulesEnabled.ValueBool()) } - if len(data.Rules) > 0 { + { body, _ = sjson.Set(body, "rules", []interface{}{}) for _, item := range data.Rules { itemBody := "" @@ -300,12 +301,10 @@ func (data *ApplianceTrafficShapingRules) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceTrafficShapingRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data ApplianceTrafficShapingRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_traffic_shaping_uplink_bandwidth.go b/internal/provider/model_meraki_appliance_traffic_shaping_uplink_bandwidth.go index 455b8126..9b44015e 100644 --- a/internal/provider/model_meraki_appliance_traffic_shaping_uplink_bandwidth.go +++ b/internal/provider/model_meraki_appliance_traffic_shaping_uplink_bandwidth.go @@ -167,11 +167,10 @@ func (data *ApplianceTrafficShapingUplinkBandwidth) fromBodyUnknowns(ctx context // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceTrafficShapingUplinkBandwidth) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceTrafficShapingUplinkBandwidth) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_traffic_shaping_uplink_selection.go b/internal/provider/model_meraki_appliance_traffic_shaping_uplink_selection.go index ac8c7ffc..32ae1d4a 100644 --- a/internal/provider/model_meraki_appliance_traffic_shaping_uplink_selection.go +++ b/internal/provider/model_meraki_appliance_traffic_shaping_uplink_selection.go @@ -114,7 +114,7 @@ func (data ApplianceTrafficShapingUplinkSelection) toBody(ctx context.Context, s if !data.FailoverAndFailbackImmediateEnabled.IsNull() { body, _ = sjson.Set(body, "failoverAndFailback.immediate.enabled", data.FailoverAndFailbackImmediateEnabled.ValueBool()) } - if len(data.VpnTrafficUplinkPreferences) > 0 { + { body, _ = sjson.Set(body, "vpnTrafficUplinkPreferences", []interface{}{}) for _, item := range data.VpnTrafficUplinkPreferences { itemBody := "" @@ -718,12 +718,10 @@ func (data *ApplianceTrafficShapingUplinkSelection) fromBodyUnknowns(ctx context // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceTrafficShapingUplinkSelection) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "vpnTrafficUplinkPreferences", []interface{}{}) +func (data ApplianceTrafficShapingUplinkSelection) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_traffic_shaping_vpn_exclusions.go b/internal/provider/model_meraki_appliance_traffic_shaping_vpn_exclusions.go index a96c92b6..d9e12755 100644 --- a/internal/provider/model_meraki_appliance_traffic_shaping_vpn_exclusions.go +++ b/internal/provider/model_meraki_appliance_traffic_shaping_vpn_exclusions.go @@ -67,7 +67,7 @@ func (data ApplianceTrafficShapingVPNExclusions) getPath() string { func (data ApplianceTrafficShapingVPNExclusions) toBody(ctx context.Context, state ApplianceTrafficShapingVPNExclusions) string { body := "" - if len(data.Custom) > 0 { + { body, _ = sjson.Set(body, "custom", []interface{}{}) for _, item := range data.Custom { itemBody := "" @@ -83,7 +83,7 @@ func (data ApplianceTrafficShapingVPNExclusions) toBody(ctx context.Context, sta body, _ = sjson.SetRaw(body, "custom.-1", itemBody) } } - if len(data.MajorApplications) > 0 { + { body, _ = sjson.Set(body, "majorApplications", []interface{}{}) for _, item := range data.MajorApplications { itemBody := "" @@ -248,13 +248,10 @@ func (data *ApplianceTrafficShapingVPNExclusions) fromBodyUnknowns(ctx context.C // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceTrafficShapingVPNExclusions) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "custom", []interface{}{}) - body, _ = sjson.Set(body, "majorApplications", []interface{}{}) +func (data ApplianceTrafficShapingVPNExclusions) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_uplinks_settings.go b/internal/provider/model_meraki_appliance_uplinks_settings.go index 12d52791..1632d8b0 100644 --- a/internal/provider/model_meraki_appliance_uplinks_settings.go +++ b/internal/provider/model_meraki_appliance_uplinks_settings.go @@ -492,11 +492,10 @@ func (data *ApplianceUplinksSettings) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceUplinksSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceUplinksSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_vlan.go b/internal/provider/model_meraki_appliance_vlan.go index c42fa3f0..5a4a833e 100644 --- a/internal/provider/model_meraki_appliance_vlan.go +++ b/internal/provider/model_meraki_appliance_vlan.go @@ -702,11 +702,10 @@ func (data *ApplianceVLAN) fromBodyUnknowns(ctx context.Context, res meraki.Res) // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceVLAN) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceVLAN) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_vlan_dhcp.go b/internal/provider/model_meraki_appliance_vlan_dhcp.go index 0c21add6..8f7e6e46 100644 --- a/internal/provider/model_meraki_appliance_vlan_dhcp.go +++ b/internal/provider/model_meraki_appliance_vlan_dhcp.go @@ -411,11 +411,10 @@ func (data *ApplianceVLANDHCP) fromBodyUnknowns(ctx context.Context, res meraki. // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceVLANDHCP) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceVLANDHCP) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_vlans_settings.go b/internal/provider/model_meraki_appliance_vlans_settings.go index 936f7f49..baa73a57 100644 --- a/internal/provider/model_meraki_appliance_vlans_settings.go +++ b/internal/provider/model_meraki_appliance_vlans_settings.go @@ -97,11 +97,10 @@ func (data *ApplianceVLANsSettings) fromBodyUnknowns(ctx context.Context, res me // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceVLANsSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceVLANsSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_vmx_authentication_token.go b/internal/provider/model_meraki_appliance_vmx_authentication_token.go index cdafb807..62b62806 100644 --- a/internal/provider/model_meraki_appliance_vmx_authentication_token.go +++ b/internal/provider/model_meraki_appliance_vmx_authentication_token.go @@ -118,11 +118,10 @@ func (data *ApplianceVMXAuthenticationToken) fromBodyUnknowns(ctx context.Contex // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceVMXAuthenticationToken) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceVMXAuthenticationToken) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_vpn_bgp.go b/internal/provider/model_meraki_appliance_vpn_bgp.go index 7341da4b..144ce2cf 100644 --- a/internal/provider/model_meraki_appliance_vpn_bgp.go +++ b/internal/provider/model_meraki_appliance_vpn_bgp.go @@ -385,11 +385,10 @@ func (data *ApplianceVPNBGP) fromBodyUnknowns(ctx context.Context, res meraki.Re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceVPNBGP) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceVPNBGP) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_vpn_firewall_rules.go b/internal/provider/model_meraki_appliance_vpn_firewall_rules.go index 66727aca..4dd179c7 100644 --- a/internal/provider/model_meraki_appliance_vpn_firewall_rules.go +++ b/internal/provider/model_meraki_appliance_vpn_firewall_rules.go @@ -238,12 +238,10 @@ func (data *ApplianceVPNFirewallRules) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceVPNFirewallRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data ApplianceVPNFirewallRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_vpn_site_to_site_ipsec_peers_slas.go b/internal/provider/model_meraki_appliance_vpn_site_to_site_ipsec_peers_slas.go index 25abc311..fe0046c0 100644 --- a/internal/provider/model_meraki_appliance_vpn_site_to_site_ipsec_peers_slas.go +++ b/internal/provider/model_meraki_appliance_vpn_site_to_site_ipsec_peers_slas.go @@ -172,12 +172,10 @@ func (data *ApplianceVPNSiteToSiteIPsecPeersSLAs) fromBodyUnknowns(ctx context.C // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceVPNSiteToSiteIPsecPeersSLAs) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "items", []interface{}{}) +func (data ApplianceVPNSiteToSiteIPsecPeersSLAs) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_appliance_warm_spare.go b/internal/provider/model_meraki_appliance_warm_spare.go index 7c3d0446..86133d84 100644 --- a/internal/provider/model_meraki_appliance_warm_spare.go +++ b/internal/provider/model_meraki_appliance_warm_spare.go @@ -145,11 +145,10 @@ func (data *ApplianceWarmSpare) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ApplianceWarmSpare) toDestroyBody(ctx context.Context) string { - body := "" +func (data ApplianceWarmSpare) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_camera_custom_analytics.go b/internal/provider/model_meraki_camera_custom_analytics.go index e0082f7d..ae6fc0f0 100644 --- a/internal/provider/model_meraki_camera_custom_analytics.go +++ b/internal/provider/model_meraki_camera_custom_analytics.go @@ -200,11 +200,10 @@ func (data *CameraCustomAnalytics) fromBodyUnknowns(ctx context.Context, res mer // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CameraCustomAnalytics) toDestroyBody(ctx context.Context) string { - body := "" +func (data CameraCustomAnalytics) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_camera_device_wireless_profiles.go b/internal/provider/model_meraki_camera_device_wireless_profiles.go index 7b3a8008..a06ce157 100644 --- a/internal/provider/model_meraki_camera_device_wireless_profiles.go +++ b/internal/provider/model_meraki_camera_device_wireless_profiles.go @@ -125,11 +125,10 @@ func (data *CameraDeviceWirelessProfiles) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CameraDeviceWirelessProfiles) toDestroyBody(ctx context.Context) string { - body := "" +func (data CameraDeviceWirelessProfiles) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_camera_quality_retention.go b/internal/provider/model_meraki_camera_quality_retention.go index cb8dd3fe..cbd7a3b2 100644 --- a/internal/provider/model_meraki_camera_quality_retention.go +++ b/internal/provider/model_meraki_camera_quality_retention.go @@ -181,11 +181,10 @@ func (data *CameraQualityRetention) fromBodyUnknowns(ctx context.Context, res me // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CameraQualityRetention) toDestroyBody(ctx context.Context) string { - body := "" +func (data CameraQualityRetention) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_camera_quality_retention_profile.go b/internal/provider/model_meraki_camera_quality_retention_profile.go index 43ed5e1b..bc908c90 100644 --- a/internal/provider/model_meraki_camera_quality_retention_profile.go +++ b/internal/provider/model_meraki_camera_quality_retention_profile.go @@ -881,11 +881,10 @@ func (data *CameraQualityRetentionProfile) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CameraQualityRetentionProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data CameraQualityRetentionProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_camera_role.go b/internal/provider/model_meraki_camera_role.go index 30e28969..45193dcd 100644 --- a/internal/provider/model_meraki_camera_role.go +++ b/internal/provider/model_meraki_camera_role.go @@ -400,11 +400,10 @@ func (data *CameraRole) fromBodyUnknowns(ctx context.Context, res meraki.Res) { // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CameraRole) toDestroyBody(ctx context.Context) string { - body := "" +func (data CameraRole) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_camera_sense.go b/internal/provider/model_meraki_camera_sense.go index 2f933816..c36154b4 100644 --- a/internal/provider/model_meraki_camera_sense.go +++ b/internal/provider/model_meraki_camera_sense.go @@ -139,11 +139,10 @@ func (data *CameraSense) fromBodyUnknowns(ctx context.Context, res meraki.Res) { // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CameraSense) toDestroyBody(ctx context.Context) string { - body := "" +func (data CameraSense) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_camera_video_settings.go b/internal/provider/model_meraki_camera_video_settings.go index 55ec60a8..931d3746 100644 --- a/internal/provider/model_meraki_camera_video_settings.go +++ b/internal/provider/model_meraki_camera_video_settings.go @@ -97,11 +97,10 @@ func (data *CameraVideoSettings) fromBodyUnknowns(ctx context.Context, res merak // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CameraVideoSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data CameraVideoSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_camera_wireless_profile.go b/internal/provider/model_meraki_camera_wireless_profile.go index 11900790..89c957ab 100644 --- a/internal/provider/model_meraki_camera_wireless_profile.go +++ b/internal/provider/model_meraki_camera_wireless_profile.go @@ -181,11 +181,10 @@ func (data *CameraWirelessProfile) fromBodyUnknowns(ctx context.Context, res mer // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CameraWirelessProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data CameraWirelessProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_cellular_gateway_connectivity_monitoring_destinations.go b/internal/provider/model_meraki_cellular_gateway_connectivity_monitoring_destinations.go index ccf93467..975d2e8b 100644 --- a/internal/provider/model_meraki_cellular_gateway_connectivity_monitoring_destinations.go +++ b/internal/provider/model_meraki_cellular_gateway_connectivity_monitoring_destinations.go @@ -187,18 +187,10 @@ func (data *CellularGatewayConnectivityMonitoringDestinations) fromBodyUnknowns( // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CellularGatewayConnectivityMonitoringDestinations) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "destinations", []interface{}{ - map[string]interface{}{ - "ip": "8.8.8.8", - "default": true, - "description": "Google", - }, - }) +func (data CellularGatewayConnectivityMonitoringDestinations) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_cellular_gateway_dhcp.go b/internal/provider/model_meraki_cellular_gateway_dhcp.go index a4291f7f..799dd656 100644 --- a/internal/provider/model_meraki_cellular_gateway_dhcp.go +++ b/internal/provider/model_meraki_cellular_gateway_dhcp.go @@ -128,11 +128,10 @@ func (data *CellularGatewayDHCP) fromBodyUnknowns(ctx context.Context, res merak // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CellularGatewayDHCP) toDestroyBody(ctx context.Context) string { - body := "" +func (data CellularGatewayDHCP) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_cellular_gateway_lan.go b/internal/provider/model_meraki_cellular_gateway_lan.go index b49ed455..2acda529 100644 --- a/internal/provider/model_meraki_cellular_gateway_lan.go +++ b/internal/provider/model_meraki_cellular_gateway_lan.go @@ -286,13 +286,10 @@ func (data *CellularGatewayLAN) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CellularGatewayLAN) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "fixedIpAssignments", []interface{}{}) - body, _ = sjson.Set(body, "reservedIpRanges", []interface{}{}) +func (data CellularGatewayLAN) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_cellular_gateway_port_forwarding_rules.go b/internal/provider/model_meraki_cellular_gateway_port_forwarding_rules.go index 92016864..7b776d07 100644 --- a/internal/provider/model_meraki_cellular_gateway_port_forwarding_rules.go +++ b/internal/provider/model_meraki_cellular_gateway_port_forwarding_rules.go @@ -220,12 +220,10 @@ func (data *CellularGatewayPortForwardingRules) fromBodyUnknowns(ctx context.Con // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CellularGatewayPortForwardingRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data CellularGatewayPortForwardingRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_cellular_gateway_subnet_pool.go b/internal/provider/model_meraki_cellular_gateway_subnet_pool.go index c0cc79e3..ed9ebc97 100644 --- a/internal/provider/model_meraki_cellular_gateway_subnet_pool.go +++ b/internal/provider/model_meraki_cellular_gateway_subnet_pool.go @@ -111,11 +111,10 @@ func (data *CellularGatewaySubnetPool) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CellularGatewaySubnetPool) toDestroyBody(ctx context.Context) string { - body := "" +func (data CellularGatewaySubnetPool) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_cellular_gateway_uplink.go b/internal/provider/model_meraki_cellular_gateway_uplink.go index c677e477..e10de33d 100644 --- a/internal/provider/model_meraki_cellular_gateway_uplink.go +++ b/internal/provider/model_meraki_cellular_gateway_uplink.go @@ -111,11 +111,12 @@ func (data *CellularGatewayUplink) fromBodyUnknowns(ctx context.Context, res mer // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data CellularGatewayUplink) toDestroyBody(ctx context.Context) string { - body := "" +func (data CellularGatewayUplink) addDeleteValues(ctx context.Context, body string) string { + body, _ = sjson.Set(body, "bandwidthLimits.limitDown", nil) + body, _ = sjson.Set(body, "bandwidthLimits.limitUp", nil) return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_device.go b/internal/provider/model_meraki_device.go index 5db69cf8..df122e93 100644 --- a/internal/provider/model_meraki_device.go +++ b/internal/provider/model_meraki_device.go @@ -182,11 +182,10 @@ func (data *Device) fromBodyUnknowns(ctx context.Context, res meraki.Res) { // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data Device) toDestroyBody(ctx context.Context) string { - body := "" +func (data Device) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_device_cellular_sims.go b/internal/provider/model_meraki_device_cellular_sims.go index 50543647..43391544 100644 --- a/internal/provider/model_meraki_device_cellular_sims.go +++ b/internal/provider/model_meraki_device_cellular_sims.go @@ -361,11 +361,10 @@ func (data *DeviceCellularSIMs) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data DeviceCellularSIMs) toDestroyBody(ctx context.Context) string { - body := "" +func (data DeviceCellularSIMs) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_device_management_interface.go b/internal/provider/model_meraki_device_management_interface.go index 1ef9eef3..62fb65bb 100644 --- a/internal/provider/model_meraki_device_management_interface.go +++ b/internal/provider/model_meraki_device_management_interface.go @@ -284,11 +284,10 @@ func (data *DeviceManagementInterface) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data DeviceManagementInterface) toDestroyBody(ctx context.Context) string { - body := "" +func (data DeviceManagementInterface) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_insight_monitored_media_server.go b/internal/provider/model_meraki_insight_monitored_media_server.go index f4b5b5f3..2dd431bf 100644 --- a/internal/provider/model_meraki_insight_monitored_media_server.go +++ b/internal/provider/model_meraki_insight_monitored_media_server.go @@ -125,11 +125,10 @@ func (data *InsightMonitoredMediaServer) fromBodyUnknowns(ctx context.Context, r // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data InsightMonitoredMediaServer) toDestroyBody(ctx context.Context) string { - body := "" +func (data InsightMonitoredMediaServer) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network.go b/internal/provider/model_meraki_network.go index 711f766f..26072b92 100644 --- a/internal/provider/model_meraki_network.go +++ b/internal/provider/model_meraki_network.go @@ -158,11 +158,10 @@ func (data *Network) fromBodyUnknowns(ctx context.Context, res meraki.Res) { // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data Network) toDestroyBody(ctx context.Context) string { - body := "" +func (data Network) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_alerts_settings.go b/internal/provider/model_meraki_network_alerts_settings.go index 9f897c68..a3791dcf 100644 --- a/internal/provider/model_meraki_network_alerts_settings.go +++ b/internal/provider/model_meraki_network_alerts_settings.go @@ -635,11 +635,10 @@ func (data *NetworkAlertsSettings) fromBodyUnknowns(ctx context.Context, res mer // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkAlertsSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkAlertsSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_client_policy.go b/internal/provider/model_meraki_network_client_policy.go index 03cd01d3..277ab5b3 100644 --- a/internal/provider/model_meraki_network_client_policy.go +++ b/internal/provider/model_meraki_network_client_policy.go @@ -112,11 +112,10 @@ func (data *NetworkClientPolicy) fromBodyUnknowns(ctx context.Context, res merak // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkClientPolicy) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkClientPolicy) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_client_splash_authorization_status.go b/internal/provider/model_meraki_network_client_splash_authorization_status.go index 58b11466..9f7b3bec 100644 --- a/internal/provider/model_meraki_network_client_splash_authorization_status.go +++ b/internal/provider/model_meraki_network_client_splash_authorization_status.go @@ -294,11 +294,10 @@ func (data *NetworkClientSplashAuthorizationStatus) fromBodyUnknowns(ctx context // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkClientSplashAuthorizationStatus) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkClientSplashAuthorizationStatus) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_device_claim.go b/internal/provider/model_meraki_network_device_claim.go index 6b2af465..b4ec0c85 100644 --- a/internal/provider/model_meraki_network_device_claim.go +++ b/internal/provider/model_meraki_network_device_claim.go @@ -269,11 +269,10 @@ func (data *NetworkDeviceClaim) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkDeviceClaim) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkDeviceClaim) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_device_claim_vmx.go b/internal/provider/model_meraki_network_device_claim_vmx.go index c0e85439..ad55f323 100644 --- a/internal/provider/model_meraki_network_device_claim_vmx.go +++ b/internal/provider/model_meraki_network_device_claim_vmx.go @@ -115,11 +115,10 @@ func (data *NetworkDeviceClaimVMX) fromBodyUnknowns(ctx context.Context, res mer // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkDeviceClaimVMX) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkDeviceClaimVMX) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_firmware_upgrades.go b/internal/provider/model_meraki_network_firmware_upgrades.go index cc410583..cb04f112 100644 --- a/internal/provider/model_meraki_network_firmware_upgrades.go +++ b/internal/provider/model_meraki_network_firmware_upgrades.go @@ -503,11 +503,10 @@ func (data *NetworkFirmwareUpgrades) fromBodyUnknowns(ctx context.Context, res m // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkFirmwareUpgrades) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkFirmwareUpgrades) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_floor_plan.go b/internal/provider/model_meraki_network_floor_plan.go index ee60cd5d..0ba4a55e 100644 --- a/internal/provider/model_meraki_network_floor_plan.go +++ b/internal/provider/model_meraki_network_floor_plan.go @@ -155,11 +155,10 @@ func (data *NetworkFloorPlan) fromBodyUnknowns(ctx context.Context, res meraki.R // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkFloorPlan) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkFloorPlan) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_group_policy.go b/internal/provider/model_meraki_network_group_policy.go index f96b9d70..2daa0692 100644 --- a/internal/provider/model_meraki_network_group_policy.go +++ b/internal/provider/model_meraki_network_group_policy.go @@ -1116,11 +1116,10 @@ func (data *NetworkGroupPolicy) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkGroupPolicy) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkGroupPolicy) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_meraki_auth_user.go b/internal/provider/model_meraki_network_meraki_auth_user.go index 92e25f50..29f88d01 100644 --- a/internal/provider/model_meraki_network_meraki_auth_user.go +++ b/internal/provider/model_meraki_network_meraki_auth_user.go @@ -237,11 +237,10 @@ func (data *NetworkMerakiAuthUser) fromBodyUnknowns(ctx context.Context, res mer // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkMerakiAuthUser) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkMerakiAuthUser) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_mqtt_broker.go b/internal/provider/model_meraki_network_mqtt_broker.go index 34546d72..7af609b2 100644 --- a/internal/provider/model_meraki_network_mqtt_broker.go +++ b/internal/provider/model_meraki_network_mqtt_broker.go @@ -175,11 +175,10 @@ func (data *NetworkMQTTBroker) fromBodyUnknowns(ctx context.Context, res meraki. // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkMQTTBroker) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkMQTTBroker) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_netflow.go b/internal/provider/model_meraki_network_netflow.go index 6adb34f8..c8a27858 100644 --- a/internal/provider/model_meraki_network_netflow.go +++ b/internal/provider/model_meraki_network_netflow.go @@ -153,11 +153,10 @@ func (data *NetworkNetflow) fromBodyUnknowns(ctx context.Context, res meraki.Res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkNetflow) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkNetflow) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_settings.go b/internal/provider/model_meraki_network_settings.go index 3b915129..e71eb823 100644 --- a/internal/provider/model_meraki_network_settings.go +++ b/internal/provider/model_meraki_network_settings.go @@ -171,11 +171,10 @@ func (data *NetworkSettings) fromBodyUnknowns(ctx context.Context, res meraki.Re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_snmp.go b/internal/provider/model_meraki_network_snmp.go index 17d11b0a..fe1a2780 100644 --- a/internal/provider/model_meraki_network_snmp.go +++ b/internal/provider/model_meraki_network_snmp.go @@ -200,11 +200,10 @@ func (data *NetworkSNMP) fromBodyUnknowns(ctx context.Context, res meraki.Res) { // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkSNMP) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkSNMP) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_syslog_servers.go b/internal/provider/model_meraki_network_syslog_servers.go index 02f374f4..e00758cb 100644 --- a/internal/provider/model_meraki_network_syslog_servers.go +++ b/internal/provider/model_meraki_network_syslog_servers.go @@ -190,12 +190,10 @@ func (data *NetworkSyslogServers) fromBodyUnknowns(ctx context.Context, res mera // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkSyslogServers) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "servers", []interface{}{}) +func (data NetworkSyslogServers) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_traffic_analysis.go b/internal/provider/model_meraki_network_traffic_analysis.go index 0ff0a10e..734fceaf 100644 --- a/internal/provider/model_meraki_network_traffic_analysis.go +++ b/internal/provider/model_meraki_network_traffic_analysis.go @@ -200,11 +200,10 @@ func (data *NetworkTrafficAnalysis) fromBodyUnknowns(ctx context.Context, res me // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkTrafficAnalysis) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkTrafficAnalysis) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_vlan_profile.go b/internal/provider/model_meraki_network_vlan_profile.go index 97ad4fa3..313450bd 100644 --- a/internal/provider/model_meraki_network_vlan_profile.go +++ b/internal/provider/model_meraki_network_vlan_profile.go @@ -303,11 +303,10 @@ func (data *NetworkVLANProfile) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkVLANProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkVLANProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_webhook_http_server.go b/internal/provider/model_meraki_network_webhook_http_server.go index 6af5d592..65300e39 100644 --- a/internal/provider/model_meraki_network_webhook_http_server.go +++ b/internal/provider/model_meraki_network_webhook_http_server.go @@ -143,11 +143,10 @@ func (data *NetworkWebhookHTTPServer) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkWebhookHTTPServer) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkWebhookHTTPServer) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_network_webhook_payload_template.go b/internal/provider/model_meraki_network_webhook_payload_template.go index 13c6041e..49c783be 100644 --- a/internal/provider/model_meraki_network_webhook_payload_template.go +++ b/internal/provider/model_meraki_network_webhook_payload_template.go @@ -228,11 +228,10 @@ func (data *NetworkWebhookPayloadTemplate) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data NetworkWebhookPayloadTemplate) toDestroyBody(ctx context.Context) string { - body := "" +func (data NetworkWebhookPayloadTemplate) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization.go b/internal/provider/model_meraki_organization.go index c07cf393..331e8aa6 100644 --- a/internal/provider/model_meraki_organization.go +++ b/internal/provider/model_meraki_organization.go @@ -184,11 +184,10 @@ func (data *Organization) fromBodyUnknowns(ctx context.Context, res meraki.Res) // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data Organization) toDestroyBody(ctx context.Context) string { - body := "" +func (data Organization) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_adaptive_policy.go b/internal/provider/model_meraki_organization_adaptive_policy.go index 2b7679ad..55668060 100644 --- a/internal/provider/model_meraki_organization_adaptive_policy.go +++ b/internal/provider/model_meraki_organization_adaptive_policy.go @@ -245,11 +245,10 @@ func (data *OrganizationAdaptivePolicy) fromBodyUnknowns(ctx context.Context, re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationAdaptivePolicy) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationAdaptivePolicy) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_adaptive_policy_acl.go b/internal/provider/model_meraki_organization_adaptive_policy_acl.go index 408951c8..18cf5ec0 100644 --- a/internal/provider/model_meraki_organization_adaptive_policy_acl.go +++ b/internal/provider/model_meraki_organization_adaptive_policy_acl.go @@ -245,11 +245,10 @@ func (data *OrganizationAdaptivePolicyACL) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationAdaptivePolicyACL) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationAdaptivePolicyACL) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_adaptive_policy_group.go b/internal/provider/model_meraki_organization_adaptive_policy_group.go index f6761dac..89952768 100644 --- a/internal/provider/model_meraki_organization_adaptive_policy_group.go +++ b/internal/provider/model_meraki_organization_adaptive_policy_group.go @@ -214,11 +214,10 @@ func (data *OrganizationAdaptivePolicyGroup) fromBodyUnknowns(ctx context.Contex // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationAdaptivePolicyGroup) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationAdaptivePolicyGroup) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_adaptive_policy_settings.go b/internal/provider/model_meraki_organization_adaptive_policy_settings.go index 270f83e1..592e2596 100644 --- a/internal/provider/model_meraki_organization_adaptive_policy_settings.go +++ b/internal/provider/model_meraki_organization_adaptive_policy_settings.go @@ -100,11 +100,10 @@ func (data *OrganizationAdaptivePolicySettings) fromBodyUnknowns(ctx context.Con // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationAdaptivePolicySettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationAdaptivePolicySettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_admin.go b/internal/provider/model_meraki_organization_admin.go index ae711855..97c8bb66 100644 --- a/internal/provider/model_meraki_organization_admin.go +++ b/internal/provider/model_meraki_organization_admin.go @@ -314,11 +314,10 @@ func (data *OrganizationAdmin) fromBodyUnknowns(ctx context.Context, res meraki. // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationAdmin) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationAdmin) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_alerts_profile.go b/internal/provider/model_meraki_organization_alerts_profile.go index c29bdcba..0f410d09 100644 --- a/internal/provider/model_meraki_organization_alerts_profile.go +++ b/internal/provider/model_meraki_organization_alerts_profile.go @@ -272,11 +272,10 @@ func (data *OrganizationAlertsProfile) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationAlertsProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationAlertsProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_auth_radius_server.go b/internal/provider/model_meraki_organization_auth_radius_server.go index 04765537..644fb77f 100644 --- a/internal/provider/model_meraki_organization_auth_radius_server.go +++ b/internal/provider/model_meraki_organization_auth_radius_server.go @@ -205,11 +205,10 @@ func (data *OrganizationAuthRADIUSServer) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationAuthRADIUSServer) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationAuthRADIUSServer) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_branding_policies_priorities.go b/internal/provider/model_meraki_organization_branding_policies_priorities.go index 016415ba..87751063 100644 --- a/internal/provider/model_meraki_organization_branding_policies_priorities.go +++ b/internal/provider/model_meraki_organization_branding_policies_priorities.go @@ -100,11 +100,10 @@ func (data *OrganizationBrandingPoliciesPriorities) fromBodyUnknowns(ctx context // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationBrandingPoliciesPriorities) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationBrandingPoliciesPriorities) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_branding_policy.go b/internal/provider/model_meraki_organization_branding_policy.go index 88c571bd..c5a61444 100644 --- a/internal/provider/model_meraki_organization_branding_policy.go +++ b/internal/provider/model_meraki_organization_branding_policy.go @@ -394,11 +394,10 @@ func (data *OrganizationBrandingPolicy) fromBodyUnknowns(ctx context.Context, re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationBrandingPolicy) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationBrandingPolicy) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_config_template.go b/internal/provider/model_meraki_organization_config_template.go index 0f242665..3995d296 100644 --- a/internal/provider/model_meraki_organization_config_template.go +++ b/internal/provider/model_meraki_organization_config_template.go @@ -115,11 +115,10 @@ func (data *OrganizationConfigTemplate) fromBodyUnknowns(ctx context.Context, re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationConfigTemplate) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationConfigTemplate) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_early_access_features_opt_in.go b/internal/provider/model_meraki_organization_early_access_features_opt_in.go index 331192f9..1d13301b 100644 --- a/internal/provider/model_meraki_organization_early_access_features_opt_in.go +++ b/internal/provider/model_meraki_organization_early_access_features_opt_in.go @@ -106,11 +106,10 @@ func (data *OrganizationEarlyAccessFeaturesOptIn) fromBodyUnknowns(ctx context.C // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationEarlyAccessFeaturesOptIn) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationEarlyAccessFeaturesOptIn) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_extensions_thousand_eyes_network.go b/internal/provider/model_meraki_organization_extensions_thousand_eyes_network.go index f348fc59..e873eb75 100644 --- a/internal/provider/model_meraki_organization_extensions_thousand_eyes_network.go +++ b/internal/provider/model_meraki_organization_extensions_thousand_eyes_network.go @@ -130,11 +130,10 @@ func (data *OrganizationExtensionsThousandEyesNetwork) fromBodyUnknowns(ctx cont // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationExtensionsThousandEyesNetwork) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationExtensionsThousandEyesNetwork) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_inventory_claim.go b/internal/provider/model_meraki_organization_inventory_claim.go index aa4f5db3..53176630 100644 --- a/internal/provider/model_meraki_organization_inventory_claim.go +++ b/internal/provider/model_meraki_organization_inventory_claim.go @@ -213,11 +213,10 @@ func (data *OrganizationInventoryClaim) fromBodyUnknowns(ctx context.Context, re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationInventoryClaim) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationInventoryClaim) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_license.go b/internal/provider/model_meraki_organization_license.go index 97dfd29b..2f9b0a0d 100644 --- a/internal/provider/model_meraki_organization_license.go +++ b/internal/provider/model_meraki_organization_license.go @@ -98,11 +98,10 @@ func (data *OrganizationLicense) fromBodyUnknowns(ctx context.Context, res merak // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationLicense) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationLicense) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_login_security.go b/internal/provider/model_meraki_organization_login_security.go index 62350ef1..1ce807f9 100644 --- a/internal/provider/model_meraki_organization_login_security.go +++ b/internal/provider/model_meraki_organization_login_security.go @@ -298,11 +298,10 @@ func (data *OrganizationLoginSecurity) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationLoginSecurity) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationLoginSecurity) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_policy_object.go b/internal/provider/model_meraki_organization_policy_object.go index 795ec62c..19864873 100644 --- a/internal/provider/model_meraki_organization_policy_object.go +++ b/internal/provider/model_meraki_organization_policy_object.go @@ -198,11 +198,10 @@ func (data *OrganizationPolicyObject) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationPolicyObject) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationPolicyObject) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_policy_object_group.go b/internal/provider/model_meraki_organization_policy_object_group.go index 5c39051d..3fc0958d 100644 --- a/internal/provider/model_meraki_organization_policy_object_group.go +++ b/internal/provider/model_meraki_organization_policy_object_group.go @@ -128,11 +128,10 @@ func (data *OrganizationPolicyObjectGroup) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationPolicyObjectGroup) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationPolicyObjectGroup) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_saml.go b/internal/provider/model_meraki_organization_saml.go index 3da53eb6..e83b7da1 100644 --- a/internal/provider/model_meraki_organization_saml.go +++ b/internal/provider/model_meraki_organization_saml.go @@ -97,11 +97,10 @@ func (data *OrganizationSAML) fromBodyUnknowns(ctx context.Context, res meraki.R // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationSAML) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationSAML) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_saml_idp.go b/internal/provider/model_meraki_organization_saml_idp.go index bf5dcfd3..12c71341 100644 --- a/internal/provider/model_meraki_organization_saml_idp.go +++ b/internal/provider/model_meraki_organization_saml_idp.go @@ -111,11 +111,10 @@ func (data *OrganizationSAMLIdP) fromBodyUnknowns(ctx context.Context, res merak // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationSAMLIdP) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationSAMLIdP) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_saml_role.go b/internal/provider/model_meraki_organization_saml_role.go index 8b69dc80..1eca8df3 100644 --- a/internal/provider/model_meraki_organization_saml_role.go +++ b/internal/provider/model_meraki_organization_saml_role.go @@ -286,11 +286,10 @@ func (data *OrganizationSAMLRole) fromBodyUnknowns(ctx context.Context, res mera // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationSAMLRole) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationSAMLRole) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_organization_snmp.go b/internal/provider/model_meraki_organization_snmp.go index 875d3f78..030d8855 100644 --- a/internal/provider/model_meraki_organization_snmp.go +++ b/internal/provider/model_meraki_organization_snmp.go @@ -164,11 +164,10 @@ func (data *OrganizationSNMP) fromBodyUnknowns(ctx context.Context, res meraki.R // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data OrganizationSNMP) toDestroyBody(ctx context.Context) string { - body := "" +func (data OrganizationSNMP) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_sensor_alerts_profile.go b/internal/provider/model_meraki_sensor_alerts_profile.go index 83fd67e7..1176e344 100644 --- a/internal/provider/model_meraki_sensor_alerts_profile.go +++ b/internal/provider/model_meraki_sensor_alerts_profile.go @@ -643,11 +643,10 @@ func (data *SensorAlertsProfile) fromBodyUnknowns(ctx context.Context, res merak // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SensorAlertsProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data SensorAlertsProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_sensor_mqtt_broker.go b/internal/provider/model_meraki_sensor_mqtt_broker.go index cb5e7d35..7532738d 100644 --- a/internal/provider/model_meraki_sensor_mqtt_broker.go +++ b/internal/provider/model_meraki_sensor_mqtt_broker.go @@ -98,12 +98,11 @@ func (data *SensorMQTTBroker) fromBodyUnknowns(ctx context.Context, res meraki.R // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SensorMQTTBroker) toDestroyBody(ctx context.Context) string { - body := "" +func (data SensorMQTTBroker) addDeleteValues(ctx context.Context, body string) string { body, _ = sjson.Set(body, "enabled", false) return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_sensor_relationships.go b/internal/provider/model_meraki_sensor_relationships.go index 9fa1917a..195ba477 100644 --- a/internal/provider/model_meraki_sensor_relationships.go +++ b/internal/provider/model_meraki_sensor_relationships.go @@ -158,11 +158,10 @@ func (data *SensorRelationships) fromBodyUnknowns(ctx context.Context, res merak // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SensorRelationships) toDestroyBody(ctx context.Context) string { - body := "" +func (data SensorRelationships) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_sm_admin_role.go b/internal/provider/model_meraki_sm_admin_role.go index 810f9ddf..ddbb33ff 100644 --- a/internal/provider/model_meraki_sm_admin_role.go +++ b/internal/provider/model_meraki_sm_admin_role.go @@ -128,11 +128,10 @@ func (data *SMAdminRole) fromBodyUnknowns(ctx context.Context, res meraki.Res) { // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SMAdminRole) toDestroyBody(ctx context.Context) string { - body := "" +func (data SMAdminRole) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_sm_target_group.go b/internal/provider/model_meraki_sm_target_group.go index 654185ba..80d1eec5 100644 --- a/internal/provider/model_meraki_sm_target_group.go +++ b/internal/provider/model_meraki_sm_target_group.go @@ -101,11 +101,10 @@ func (data *SMTargetGroup) fromBodyUnknowns(ctx context.Context, res meraki.Res) // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SMTargetGroup) toDestroyBody(ctx context.Context) string { - body := "" +func (data SMTargetGroup) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_access_control_lists.go b/internal/provider/model_meraki_switch_access_control_lists.go index 4e62bf2d..f509cc51 100644 --- a/internal/provider/model_meraki_switch_access_control_lists.go +++ b/internal/provider/model_meraki_switch_access_control_lists.go @@ -248,12 +248,10 @@ func (data *SwitchAccessControlLists) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchAccessControlLists) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data SwitchAccessControlLists) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_access_policy.go b/internal/provider/model_meraki_switch_access_policy.go index ca402bcc..22e7e702 100644 --- a/internal/provider/model_meraki_switch_access_policy.go +++ b/internal/provider/model_meraki_switch_access_policy.go @@ -662,11 +662,10 @@ func (data *SwitchAccessPolicy) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchAccessPolicy) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchAccessPolicy) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_alternate_management_interface.go b/internal/provider/model_meraki_switch_alternate_management_interface.go index edb5ae41..de7b2329 100644 --- a/internal/provider/model_meraki_switch_alternate_management_interface.go +++ b/internal/provider/model_meraki_switch_alternate_management_interface.go @@ -224,11 +224,10 @@ func (data *SwitchAlternateManagementInterface) fromBodyUnknowns(ctx context.Con // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchAlternateManagementInterface) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchAlternateManagementInterface) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_dhcp_server_policy.go b/internal/provider/model_meraki_switch_dhcp_server_policy.go index cb07de1a..e80879d3 100644 --- a/internal/provider/model_meraki_switch_dhcp_server_policy.go +++ b/internal/provider/model_meraki_switch_dhcp_server_policy.go @@ -158,11 +158,10 @@ func (data *SwitchDHCPServerPolicy) fromBodyUnknowns(ctx context.Context, res me // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchDHCPServerPolicy) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchDHCPServerPolicy) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_dhcp_server_policy_arp_inspection_trusted_server.go b/internal/provider/model_meraki_switch_dhcp_server_policy_arp_inspection_trusted_server.go index 992510b0..854c16a9 100644 --- a/internal/provider/model_meraki_switch_dhcp_server_policy_arp_inspection_trusted_server.go +++ b/internal/provider/model_meraki_switch_dhcp_server_policy_arp_inspection_trusted_server.go @@ -125,11 +125,10 @@ func (data *SwitchDHCPServerPolicyARPInspectionTrustedServer) fromBodyUnknowns(c // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchDHCPServerPolicyARPInspectionTrustedServer) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchDHCPServerPolicyARPInspectionTrustedServer) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_dscp_to_cos_mappings.go b/internal/provider/model_meraki_switch_dscp_to_cos_mappings.go index 0e7119f9..ba56a48f 100644 --- a/internal/provider/model_meraki_switch_dscp_to_cos_mappings.go +++ b/internal/provider/model_meraki_switch_dscp_to_cos_mappings.go @@ -187,12 +187,10 @@ func (data *SwitchDSCPToCoSMappings) fromBodyUnknowns(ctx context.Context, res m // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchDSCPToCoSMappings) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "mappings", []interface{}{}) +func (data SwitchDSCPToCoSMappings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_link_aggregation.go b/internal/provider/model_meraki_switch_link_aggregation.go index 1c15fc52..83568f05 100644 --- a/internal/provider/model_meraki_switch_link_aggregation.go +++ b/internal/provider/model_meraki_switch_link_aggregation.go @@ -258,11 +258,10 @@ func (data *SwitchLinkAggregation) fromBodyUnknowns(ctx context.Context, res mer // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchLinkAggregation) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchLinkAggregation) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_mtu.go b/internal/provider/model_meraki_switch_mtu.go index a5d22c83..054ae905 100644 --- a/internal/provider/model_meraki_switch_mtu.go +++ b/internal/provider/model_meraki_switch_mtu.go @@ -180,11 +180,10 @@ func (data *SwitchMTU) fromBodyUnknowns(ctx context.Context, res meraki.Res) { // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchMTU) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchMTU) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_organization_ports_profile.go b/internal/provider/model_meraki_switch_organization_ports_profile.go index 1b1449a6..37ebe3c2 100644 --- a/internal/provider/model_meraki_switch_organization_ports_profile.go +++ b/internal/provider/model_meraki_switch_organization_ports_profile.go @@ -515,11 +515,10 @@ func (data *SwitchOrganizationPortsProfile) fromBodyUnknowns(ctx context.Context // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchOrganizationPortsProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchOrganizationPortsProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_organization_ports_profiles_automation.go b/internal/provider/model_meraki_switch_organization_ports_profiles_automation.go index 9db97666..ff62cfa2 100644 --- a/internal/provider/model_meraki_switch_organization_ports_profiles_automation.go +++ b/internal/provider/model_meraki_switch_organization_ports_profiles_automation.go @@ -420,11 +420,10 @@ func (data *SwitchOrganizationPortsProfilesAutomation) fromBodyUnknowns(ctx cont // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchOrganizationPortsProfilesAutomation) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchOrganizationPortsProfilesAutomation) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_port.go b/internal/provider/model_meraki_switch_port.go index de14c93f..9b11b172 100644 --- a/internal/provider/model_meraki_switch_port.go +++ b/internal/provider/model_meraki_switch_port.go @@ -511,8 +511,7 @@ func (data *SwitchPort) fromBodyUnknowns(ctx context.Context, res meraki.Res) { // End of section. //template:end fromBodyUnknowns -func (data SwitchPort) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchPort) addDeleteValues(ctx context.Context, body string) string { body, _ = sjson.Set(body, "accessPolicyType", "Open") if !data.AdaptivePolicyGroupId.IsNull() { // This can fail with "Adaptive Policy is not enabled in this network" diff --git a/internal/provider/model_meraki_switch_port_schedule.go b/internal/provider/model_meraki_switch_port_schedule.go index dbf2d156..366bae56 100644 --- a/internal/provider/model_meraki_switch_port_schedule.go +++ b/internal/provider/model_meraki_switch_port_schedule.go @@ -391,11 +391,10 @@ func (data *SwitchPortSchedule) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchPortSchedule) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchPortSchedule) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_qos_rule.go b/internal/provider/model_meraki_switch_qos_rule.go index 784aed89..77549820 100644 --- a/internal/provider/model_meraki_switch_qos_rule.go +++ b/internal/provider/model_meraki_switch_qos_rule.go @@ -181,11 +181,10 @@ func (data *SwitchQoSRule) fromBodyUnknowns(ctx context.Context, res meraki.Res) // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchQoSRule) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchQoSRule) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_qos_rule_order.go b/internal/provider/model_meraki_switch_qos_rule_order.go index e32465d3..94d7db6b 100644 --- a/internal/provider/model_meraki_switch_qos_rule_order.go +++ b/internal/provider/model_meraki_switch_qos_rule_order.go @@ -100,11 +100,10 @@ func (data *SwitchQoSRuleOrder) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchQoSRuleOrder) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchQoSRuleOrder) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_routing_interface.go b/internal/provider/model_meraki_switch_routing_interface.go index 121ce558..36b04e83 100644 --- a/internal/provider/model_meraki_switch_routing_interface.go +++ b/internal/provider/model_meraki_switch_routing_interface.go @@ -321,11 +321,10 @@ func (data *SwitchRoutingInterface) fromBodyUnknowns(ctx context.Context, res me // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchRoutingInterface) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchRoutingInterface) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_routing_interface_dhcp.go b/internal/provider/model_meraki_switch_routing_interface_dhcp.go index 9bd1a787..5bd74c63 100644 --- a/internal/provider/model_meraki_switch_routing_interface_dhcp.go +++ b/internal/provider/model_meraki_switch_routing_interface_dhcp.go @@ -504,11 +504,10 @@ func (data *SwitchRoutingInterfaceDHCP) fromBodyUnknowns(ctx context.Context, re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchRoutingInterfaceDHCP) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchRoutingInterfaceDHCP) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_routing_multicast.go b/internal/provider/model_meraki_switch_routing_multicast.go index f5d42ed7..aec51cf9 100644 --- a/internal/provider/model_meraki_switch_routing_multicast.go +++ b/internal/provider/model_meraki_switch_routing_multicast.go @@ -250,11 +250,10 @@ func (data *SwitchRoutingMulticast) fromBodyUnknowns(ctx context.Context, res me // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchRoutingMulticast) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchRoutingMulticast) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_routing_multicast_rendezvous_point.go b/internal/provider/model_meraki_switch_routing_multicast_rendezvous_point.go index e2042517..1a9db05a 100644 --- a/internal/provider/model_meraki_switch_routing_multicast_rendezvous_point.go +++ b/internal/provider/model_meraki_switch_routing_multicast_rendezvous_point.go @@ -125,11 +125,10 @@ func (data *SwitchRoutingMulticastRendezvousPoint) fromBodyUnknowns(ctx context. // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchRoutingMulticastRendezvousPoint) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchRoutingMulticastRendezvousPoint) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_routing_ospf.go b/internal/provider/model_meraki_switch_routing_ospf.go index 0942362e..dd52257f 100644 --- a/internal/provider/model_meraki_switch_routing_ospf.go +++ b/internal/provider/model_meraki_switch_routing_ospf.go @@ -412,11 +412,10 @@ func (data *SwitchRoutingOSPF) fromBodyUnknowns(ctx context.Context, res meraki. // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchRoutingOSPF) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchRoutingOSPF) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_routing_static_route.go b/internal/provider/model_meraki_switch_routing_static_route.go index 27723673..e9560e8b 100644 --- a/internal/provider/model_meraki_switch_routing_static_route.go +++ b/internal/provider/model_meraki_switch_routing_static_route.go @@ -181,11 +181,10 @@ func (data *SwitchRoutingStaticRoute) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchRoutingStaticRoute) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchRoutingStaticRoute) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_settings.go b/internal/provider/model_meraki_switch_settings.go index d3b620cf..5f05bb94 100644 --- a/internal/provider/model_meraki_switch_settings.go +++ b/internal/provider/model_meraki_switch_settings.go @@ -228,11 +228,10 @@ func (data *SwitchSettings) fromBodyUnknowns(ctx context.Context, res meraki.Res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_stack.go b/internal/provider/model_meraki_switch_stack.go index aa291df3..b4f35ead 100644 --- a/internal/provider/model_meraki_switch_stack.go +++ b/internal/provider/model_meraki_switch_stack.go @@ -122,11 +122,10 @@ func (data *SwitchStack) fromBodyUnknowns(ctx context.Context, res meraki.Res) { // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchStack) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchStack) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_stack_routing_interface.go b/internal/provider/model_meraki_switch_stack_routing_interface.go index 9a53c86c..8691c8b1 100644 --- a/internal/provider/model_meraki_switch_stack_routing_interface.go +++ b/internal/provider/model_meraki_switch_stack_routing_interface.go @@ -322,11 +322,10 @@ func (data *SwitchStackRoutingInterface) fromBodyUnknowns(ctx context.Context, r // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchStackRoutingInterface) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchStackRoutingInterface) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_stack_routing_interface_dhcp.go b/internal/provider/model_meraki_switch_stack_routing_interface_dhcp.go index d5c686ee..727d03cc 100644 --- a/internal/provider/model_meraki_switch_stack_routing_interface_dhcp.go +++ b/internal/provider/model_meraki_switch_stack_routing_interface_dhcp.go @@ -505,11 +505,10 @@ func (data *SwitchStackRoutingInterfaceDHCP) fromBodyUnknowns(ctx context.Contex // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchStackRoutingInterfaceDHCP) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchStackRoutingInterfaceDHCP) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_stack_routing_static_route.go b/internal/provider/model_meraki_switch_stack_routing_static_route.go index cabb3135..8a2e42fc 100644 --- a/internal/provider/model_meraki_switch_stack_routing_static_route.go +++ b/internal/provider/model_meraki_switch_stack_routing_static_route.go @@ -182,11 +182,10 @@ func (data *SwitchStackRoutingStaticRoute) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchStackRoutingStaticRoute) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchStackRoutingStaticRoute) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_storm_control.go b/internal/provider/model_meraki_switch_storm_control.go index 2607ae33..790e3ca3 100644 --- a/internal/provider/model_meraki_switch_storm_control.go +++ b/internal/provider/model_meraki_switch_storm_control.go @@ -142,11 +142,10 @@ func (data *SwitchStormControl) fromBodyUnknowns(ctx context.Context, res meraki // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchStormControl) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchStormControl) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_switch_stp.go b/internal/provider/model_meraki_switch_stp.go index befb5be0..a8923cfc 100644 --- a/internal/provider/model_meraki_switch_stp.go +++ b/internal/provider/model_meraki_switch_stp.go @@ -237,14 +237,13 @@ func (data *SwitchSTP) fromBodyUnknowns(ctx context.Context, res meraki.Res) { // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchSTP) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchSTP) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues func setOrNull(s types.Set) types.Set { if len(s.Elements()) == 0 { diff --git a/internal/provider/model_meraki_switch_warm_spare.go b/internal/provider/model_meraki_switch_warm_spare.go index 3bb3ca41..2d1f85b3 100644 --- a/internal/provider/model_meraki_switch_warm_spare.go +++ b/internal/provider/model_meraki_switch_warm_spare.go @@ -111,11 +111,10 @@ func (data *SwitchWarmSpare) fromBodyUnknowns(ctx context.Context, res meraki.Re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data SwitchWarmSpare) toDestroyBody(ctx context.Context) string { - body := "" +func (data SwitchWarmSpare) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_air_marshal_rule.go b/internal/provider/model_meraki_wireless_air_marshal_rule.go index de64a1e7..e455f21e 100644 --- a/internal/provider/model_meraki_wireless_air_marshal_rule.go +++ b/internal/provider/model_meraki_wireless_air_marshal_rule.go @@ -125,11 +125,10 @@ func (data *WirelessAirMarshalRule) fromBodyUnknowns(ctx context.Context, res me // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessAirMarshalRule) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessAirMarshalRule) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_air_marshal_settings.go b/internal/provider/model_meraki_wireless_air_marshal_settings.go index 27c612ca..8db82b2b 100644 --- a/internal/provider/model_meraki_wireless_air_marshal_settings.go +++ b/internal/provider/model_meraki_wireless_air_marshal_settings.go @@ -97,11 +97,10 @@ func (data *WirelessAirMarshalSettings) fromBodyUnknowns(ctx context.Context, re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessAirMarshalSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessAirMarshalSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_alternate_management_interface.go b/internal/provider/model_meraki_wireless_alternate_management_interface.go index 680e547c..831c0f39 100644 --- a/internal/provider/model_meraki_wireless_alternate_management_interface.go +++ b/internal/provider/model_meraki_wireless_alternate_management_interface.go @@ -273,11 +273,10 @@ func (data *WirelessAlternateManagementInterface) fromBodyUnknowns(ctx context.C // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessAlternateManagementInterface) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessAlternateManagementInterface) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_billing.go b/internal/provider/model_meraki_wireless_billing.go index 26afe684..32333db3 100644 --- a/internal/provider/model_meraki_wireless_billing.go +++ b/internal/provider/model_meraki_wireless_billing.go @@ -189,11 +189,10 @@ func (data *WirelessBilling) fromBodyUnknowns(ctx context.Context, res meraki.Re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessBilling) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessBilling) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_device_bluetooth_settings.go b/internal/provider/model_meraki_wireless_device_bluetooth_settings.go index 51ac7261..93a393fd 100644 --- a/internal/provider/model_meraki_wireless_device_bluetooth_settings.go +++ b/internal/provider/model_meraki_wireless_device_bluetooth_settings.go @@ -125,11 +125,10 @@ func (data *WirelessDeviceBluetoothSettings) fromBodyUnknowns(ctx context.Contex // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessDeviceBluetoothSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessDeviceBluetoothSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_device_electronic_shelf_label.go b/internal/provider/model_meraki_wireless_device_electronic_shelf_label.go index ebbd00db..e3dcbed9 100644 --- a/internal/provider/model_meraki_wireless_device_electronic_shelf_label.go +++ b/internal/provider/model_meraki_wireless_device_electronic_shelf_label.go @@ -111,11 +111,10 @@ func (data *WirelessDeviceElectronicShelfLabel) fromBodyUnknowns(ctx context.Con // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessDeviceElectronicShelfLabel) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessDeviceElectronicShelfLabel) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ethernet_port_profile.go b/internal/provider/model_meraki_wireless_ethernet_port_profile.go index c5553784..9881fe9e 100644 --- a/internal/provider/model_meraki_wireless_ethernet_port_profile.go +++ b/internal/provider/model_meraki_wireless_ethernet_port_profile.go @@ -314,11 +314,10 @@ func (data *WirelessEthernetPortProfile) fromBodyUnknowns(ctx context.Context, r // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessEthernetPortProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessEthernetPortProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ethernet_port_profile_assign.go b/internal/provider/model_meraki_wireless_ethernet_port_profile_assign.go index 36c85035..b19ecf95 100644 --- a/internal/provider/model_meraki_wireless_ethernet_port_profile_assign.go +++ b/internal/provider/model_meraki_wireless_ethernet_port_profile_assign.go @@ -114,11 +114,10 @@ func (data *WirelessEthernetPortProfileAssign) fromBodyUnknowns(ctx context.Cont // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessEthernetPortProfileAssign) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessEthernetPortProfileAssign) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ethernet_port_profile_default.go b/internal/provider/model_meraki_wireless_ethernet_port_profile_default.go index ac2bc929..b9a3face 100644 --- a/internal/provider/model_meraki_wireless_ethernet_port_profile_default.go +++ b/internal/provider/model_meraki_wireless_ethernet_port_profile_default.go @@ -101,11 +101,10 @@ func (data *WirelessEthernetPortProfileDefault) fromBodyUnknowns(ctx context.Con // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessEthernetPortProfileDefault) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessEthernetPortProfileDefault) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_location_scanning.go b/internal/provider/model_meraki_wireless_location_scanning.go index a2bac2c1..c11bec69 100644 --- a/internal/provider/model_meraki_wireless_location_scanning.go +++ b/internal/provider/model_meraki_wireless_location_scanning.go @@ -111,11 +111,10 @@ func (data *WirelessLocationScanning) fromBodyUnknowns(ctx context.Context, res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessLocationScanning) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessLocationScanning) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_location_scanning_receiver.go b/internal/provider/model_meraki_wireless_location_scanning_receiver.go index b716fd29..2d37b992 100644 --- a/internal/provider/model_meraki_wireless_location_scanning_receiver.go +++ b/internal/provider/model_meraki_wireless_location_scanning_receiver.go @@ -143,11 +143,10 @@ func (data *WirelessLocationScanningReceiver) fromBodyUnknowns(ctx context.Conte // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessLocationScanningReceiver) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessLocationScanningReceiver) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_network_bluetooth_settings.go b/internal/provider/model_meraki_wireless_network_bluetooth_settings.go index ebc09555..decede94 100644 --- a/internal/provider/model_meraki_wireless_network_bluetooth_settings.go +++ b/internal/provider/model_meraki_wireless_network_bluetooth_settings.go @@ -167,11 +167,10 @@ func (data *WirelessNetworkBluetoothSettings) fromBodyUnknowns(ctx context.Conte // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessNetworkBluetoothSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessNetworkBluetoothSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_network_electronic_shelf_label.go b/internal/provider/model_meraki_wireless_network_electronic_shelf_label.go index a8b160bb..db553d3b 100644 --- a/internal/provider/model_meraki_wireless_network_electronic_shelf_label.go +++ b/internal/provider/model_meraki_wireless_network_electronic_shelf_label.go @@ -125,11 +125,10 @@ func (data *WirelessNetworkElectronicShelfLabel) fromBodyUnknowns(ctx context.Co // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessNetworkElectronicShelfLabel) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessNetworkElectronicShelfLabel) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_radio_settings.go b/internal/provider/model_meraki_wireless_radio_settings.go index df1d58a8..56bf55f2 100644 --- a/internal/provider/model_meraki_wireless_radio_settings.go +++ b/internal/provider/model_meraki_wireless_radio_settings.go @@ -167,11 +167,10 @@ func (data *WirelessRadioSettings) fromBodyUnknowns(ctx context.Context, res mer // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessRadioSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessRadioSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_rf_profile.go b/internal/provider/model_meraki_wireless_rf_profile.go index b0927536..499bbb31 100644 --- a/internal/provider/model_meraki_wireless_rf_profile.go +++ b/internal/provider/model_meraki_wireless_rf_profile.go @@ -1442,11 +1442,10 @@ func (data *WirelessRFProfile) fromBodyUnknowns(ctx context.Context, res meraki. // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessRFProfile) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessRFProfile) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_settings.go b/internal/provider/model_meraki_wireless_settings.go index dfd79771..d5935d9d 100644 --- a/internal/provider/model_meraki_wireless_settings.go +++ b/internal/provider/model_meraki_wireless_settings.go @@ -181,11 +181,10 @@ func (data *WirelessSettings) fromBodyUnknowns(ctx context.Context, res meraki.R // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid.go b/internal/provider/model_meraki_wireless_ssid.go index 81695f15..9906dab4 100644 --- a/internal/provider/model_meraki_wireless_ssid.go +++ b/internal/provider/model_meraki_wireless_ssid.go @@ -1737,28 +1737,10 @@ func (data *WirelessSSID) fromBodyUnknowns(ctx context.Context, res meraki.Res) // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSID) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "adultContentFilteringEnabled", false) - body, _ = sjson.Set(body, "authMode", "open") - body, _ = sjson.Set(body, "availableOnAllAps", true) - body, _ = sjson.Set(body, "enabled", false) - body, _ = sjson.Set(body, "ipAssignmentMode", "NAT mode") - body, _ = sjson.Set(body, "mandatoryDhcpEnabled", false) - body, _ = sjson.Set(body, "name", "Unconfigured SSID") - body, _ = sjson.Set(body, "perClientBandwidthLimitDown", 0) - body, _ = sjson.Set(body, "perClientBandwidthLimitUp", 0) - body, _ = sjson.Set(body, "perSsidBandwidthLimitDown", 0) - body, _ = sjson.Set(body, "perSsidBandwidthLimitUp", 0) - body, _ = sjson.Set(body, "splashPage", "None") - body, _ = sjson.Set(body, "visible", true) - body, _ = sjson.Set(body, "dnsRewrite.enabled", false) - body, _ = sjson.Set(body, "dnsRewrite.dnsCustomNameservers", []interface{}{}) - body, _ = sjson.Set(body, "speedBurst.enabled", false) - body, _ = sjson.Set(body, "availabilityTags", []interface{}{}) +func (data WirelessSSID) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_bonjour_forwarding.go b/internal/provider/model_meraki_wireless_ssid_bonjour_forwarding.go index 0533ad0d..a6ec0aa1 100644 --- a/internal/provider/model_meraki_wireless_ssid_bonjour_forwarding.go +++ b/internal/provider/model_meraki_wireless_ssid_bonjour_forwarding.go @@ -218,11 +218,10 @@ func (data *WirelessSSIDBonjourForwarding) fromBodyUnknowns(ctx context.Context, // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDBonjourForwarding) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessSSIDBonjourForwarding) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_device_type_group_policies.go b/internal/provider/model_meraki_wireless_ssid_device_type_group_policies.go index 8cd55384..fbb0c997 100644 --- a/internal/provider/model_meraki_wireless_ssid_device_type_group_policies.go +++ b/internal/provider/model_meraki_wireless_ssid_device_type_group_policies.go @@ -201,11 +201,10 @@ func (data *WirelessSSIDDeviceTypeGroupPolicies) fromBodyUnknowns(ctx context.Co // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDDeviceTypeGroupPolicies) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessSSIDDeviceTypeGroupPolicies) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_eap_override.go b/internal/provider/model_meraki_wireless_ssid_eap_override.go index 75116b8b..e7e6e06e 100644 --- a/internal/provider/model_meraki_wireless_ssid_eap_override.go +++ b/internal/provider/model_meraki_wireless_ssid_eap_override.go @@ -168,11 +168,11 @@ func (data *WirelessSSIDEAPOverride) fromBodyUnknowns(ctx context.Context, res m // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDEAPOverride) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessSSIDEAPOverride) addDeleteValues(ctx context.Context, body string) string { + body, _ = sjson.Set(body, "maxRetries", 5) return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_firewall_isolation_allowlist_entry.go b/internal/provider/model_meraki_wireless_ssid_firewall_isolation_allowlist_entry.go index b9c7ca79..ff779595 100644 --- a/internal/provider/model_meraki_wireless_ssid_firewall_isolation_allowlist_entry.go +++ b/internal/provider/model_meraki_wireless_ssid_firewall_isolation_allowlist_entry.go @@ -139,11 +139,10 @@ func (data *WirelessSSIDFirewallIsolationAllowlistEntry) fromBodyUnknowns(ctx co // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDFirewallIsolationAllowlistEntry) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessSSIDFirewallIsolationAllowlistEntry) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_hotspot_20.go b/internal/provider/model_meraki_wireless_ssid_hotspot_20.go index 32c218f5..4429f582 100644 --- a/internal/provider/model_meraki_wireless_ssid_hotspot_20.go +++ b/internal/provider/model_meraki_wireless_ssid_hotspot_20.go @@ -498,11 +498,10 @@ func (data *WirelessSSIDHotspot20) fromBodyUnknowns(ctx context.Context, res mer // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDHotspot20) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessSSIDHotspot20) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_identity_psk.go b/internal/provider/model_meraki_wireless_ssid_identity_psk.go index 77f7b5d7..96910b31 100644 --- a/internal/provider/model_meraki_wireless_ssid_identity_psk.go +++ b/internal/provider/model_meraki_wireless_ssid_identity_psk.go @@ -140,11 +140,10 @@ func (data *WirelessSSIDIdentityPSK) fromBodyUnknowns(ctx context.Context, res m // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDIdentityPSK) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessSSIDIdentityPSK) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_l3_firewall_rules.go b/internal/provider/model_meraki_wireless_ssid_l3_firewall_rules.go index c42433f7..c7fedcef 100644 --- a/internal/provider/model_meraki_wireless_ssid_l3_firewall_rules.go +++ b/internal/provider/model_meraki_wireless_ssid_l3_firewall_rules.go @@ -68,7 +68,7 @@ func (data WirelessSSIDL3FirewallRules) toBody(ctx context.Context, state Wirele if !data.AllowLanAccess.IsNull() { body, _ = sjson.Set(body, "allowLanAccess", data.AllowLanAccess.ValueBool()) } - if len(data.Rules) > 0 { + { body, _ = sjson.Set(body, "rules", []interface{}{}) for _, item := range data.Rules { itemBody := "" @@ -214,12 +214,10 @@ func (data *WirelessSSIDL3FirewallRules) fromBodyUnknowns(ctx context.Context, r // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDL3FirewallRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data WirelessSSIDL3FirewallRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_l7_firewall_rules.go b/internal/provider/model_meraki_wireless_ssid_l7_firewall_rules.go index 6156b87f..0d482df0 100644 --- a/internal/provider/model_meraki_wireless_ssid_l7_firewall_rules.go +++ b/internal/provider/model_meraki_wireless_ssid_l7_firewall_rules.go @@ -56,9 +56,10 @@ func (data WirelessSSIDL7FirewallRules) getPath() string { } // End of section. //template:end getPath + func (data WirelessSSIDL7FirewallRules) toBody(ctx context.Context, state WirelessSSIDL7FirewallRules) string { body := "" - if len(data.Rules) > 0 { + { body, _ = sjson.Set(body, "rules", []interface{}{}) for _, item := range data.Rules { itemBody := "" @@ -167,12 +168,10 @@ func (data *WirelessSSIDL7FirewallRules) fromBodyUnknowns(ctx context.Context, r // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDL7FirewallRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data WirelessSSIDL7FirewallRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_schedules.go b/internal/provider/model_meraki_wireless_ssid_schedules.go index 2299329e..c750495a 100644 --- a/internal/provider/model_meraki_wireless_ssid_schedules.go +++ b/internal/provider/model_meraki_wireless_ssid_schedules.go @@ -302,11 +302,10 @@ func (data *WirelessSSIDSchedules) fromBodyUnknowns(ctx context.Context, res mer // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDSchedules) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessSSIDSchedules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_splash_settings.go b/internal/provider/model_meraki_wireless_ssid_splash_settings.go index 0f2d7054..a28656da 100644 --- a/internal/provider/model_meraki_wireless_ssid_splash_settings.go +++ b/internal/provider/model_meraki_wireless_ssid_splash_settings.go @@ -549,11 +549,10 @@ func (data *WirelessSSIDSplashSettings) fromBodyUnknowns(ctx context.Context, re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDSplashSettings) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessSSIDSplashSettings) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_traffic_shaping_rules.go b/internal/provider/model_meraki_wireless_ssid_traffic_shaping_rules.go index c279627e..12da72f3 100644 --- a/internal/provider/model_meraki_wireless_ssid_traffic_shaping_rules.go +++ b/internal/provider/model_meraki_wireless_ssid_traffic_shaping_rules.go @@ -67,6 +67,7 @@ func (data WirelessSSIDTrafficShapingRules) getPath() string { } // End of section. //template:end getPath + func (data WirelessSSIDTrafficShapingRules) toBody(ctx context.Context, state WirelessSSIDTrafficShapingRules) string { body := "" if !data.DefaultRulesEnabled.IsNull() { @@ -75,7 +76,7 @@ func (data WirelessSSIDTrafficShapingRules) toBody(ctx context.Context, state Wi if !data.TrafficShapingEnabled.IsNull() { body, _ = sjson.Set(body, "trafficShapingEnabled", data.TrafficShapingEnabled.ValueBool()) } - if len(data.Rules) > 0 { + { body, _ = sjson.Set(body, "rules", []interface{}{}) for _, item := range data.Rules { itemBody := "" @@ -315,12 +316,10 @@ func (data *WirelessSSIDTrafficShapingRules) fromBodyUnknowns(ctx context.Contex // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDTrafficShapingRules) toDestroyBody(ctx context.Context) string { - body := "" - body, _ = sjson.Set(body, "rules", []interface{}{}) +func (data WirelessSSIDTrafficShapingRules) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_ssid_vpn.go b/internal/provider/model_meraki_wireless_ssid_vpn.go index 8c031018..14071188 100644 --- a/internal/provider/model_meraki_wireless_ssid_vpn.go +++ b/internal/provider/model_meraki_wireless_ssid_vpn.go @@ -274,11 +274,10 @@ func (data *WirelessSSIDVPN) fromBodyUnknowns(ctx context.Context, res meraki.Re // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessSSIDVPN) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessSSIDVPN) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_zigbee.go b/internal/provider/model_meraki_wireless_zigbee.go index 688986e6..affac0b4 100644 --- a/internal/provider/model_meraki_wireless_zigbee.go +++ b/internal/provider/model_meraki_wireless_zigbee.go @@ -181,11 +181,10 @@ func (data *WirelessZigbee) fromBodyUnknowns(ctx context.Context, res meraki.Res // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessZigbee) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessZigbee) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_zigbee_device.go b/internal/provider/model_meraki_wireless_zigbee_device.go index 8c96dd31..d13a4936 100644 --- a/internal/provider/model_meraki_wireless_zigbee_device.go +++ b/internal/provider/model_meraki_wireless_zigbee_device.go @@ -112,11 +112,10 @@ func (data *WirelessZigbeeDevice) fromBodyUnknowns(ctx context.Context, res mera // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessZigbeeDevice) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessZigbeeDevice) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_meraki_wireless_zigbee_door_lock.go b/internal/provider/model_meraki_wireless_zigbee_door_lock.go index 2aafaaaa..cf132d79 100644 --- a/internal/provider/model_meraki_wireless_zigbee_door_lock.go +++ b/internal/provider/model_meraki_wireless_zigbee_door_lock.go @@ -98,11 +98,10 @@ func (data *WirelessZigbeeDoorLock) fromBodyUnknowns(ctx context.Context, res me // End of section. //template:end fromBodyUnknowns -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data WirelessZigbeeDoorLock) toDestroyBody(ctx context.Context) string { - body := "" +func (data WirelessZigbeeDoorLock) addDeleteValues(ctx context.Context, body string) string { return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues diff --git a/internal/provider/model_resource_meraki_appliance_ports.go b/internal/provider/model_resource_meraki_appliance_ports.go index 83d387cc..d8c120c6 100644 --- a/internal/provider/model_resource_meraki_appliance_ports.go +++ b/internal/provider/model_resource_meraki_appliance_ports.go @@ -300,14 +300,14 @@ func (data *ResourceAppliancePorts) fromBodyImport(ctx context.Context, res mera // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceAppliancePorts) toDestroyBody(ctx context.Context) string { +func (data ResourceAppliancePorts) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_appliance_prefix_delegated_statics.go b/internal/provider/model_resource_meraki_appliance_prefix_delegated_statics.go index 52a76d5f..51a2d35e 100644 --- a/internal/provider/model_resource_meraki_appliance_prefix_delegated_statics.go +++ b/internal/provider/model_resource_meraki_appliance_prefix_delegated_statics.go @@ -257,14 +257,14 @@ func (data *ResourceAppliancePrefixDelegatedStatics) fromBodyImport(ctx context. // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceAppliancePrefixDelegatedStatics) toDestroyBody(ctx context.Context) string { +func (data ResourceAppliancePrefixDelegatedStatics) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_appliance_rf_profiles.go b/internal/provider/model_resource_meraki_appliance_rf_profiles.go index 93a209d3..11911b5c 100644 --- a/internal/provider/model_resource_meraki_appliance_rf_profiles.go +++ b/internal/provider/model_resource_meraki_appliance_rf_profiles.go @@ -425,14 +425,14 @@ func (data *ResourceApplianceRFProfiles) fromBodyImport(ctx context.Context, res // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceApplianceRFProfiles) toDestroyBody(ctx context.Context) string { +func (data ResourceApplianceRFProfiles) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_appliance_ssids.go b/internal/provider/model_resource_meraki_appliance_ssids.go index 977e755e..1d70ef80 100644 --- a/internal/provider/model_resource_meraki_appliance_ssids.go +++ b/internal/provider/model_resource_meraki_appliance_ssids.go @@ -480,14 +480,14 @@ func (data *ResourceApplianceSSIDs) fromBodyImport(ctx context.Context, res mera // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceApplianceSSIDs) toDestroyBody(ctx context.Context) string { +func (data ResourceApplianceSSIDs) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_appliance_traffic_shaping_custom_performance_classes.go b/internal/provider/model_resource_meraki_appliance_traffic_shaping_custom_performance_classes.go index caabbd07..38abc820 100644 --- a/internal/provider/model_resource_meraki_appliance_traffic_shaping_custom_performance_classes.go +++ b/internal/provider/model_resource_meraki_appliance_traffic_shaping_custom_performance_classes.go @@ -254,14 +254,14 @@ func (data *ResourceApplianceTrafficShapingCustomPerformanceClasses) fromBodyImp // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceApplianceTrafficShapingCustomPerformanceClasses) toDestroyBody(ctx context.Context) string { +func (data ResourceApplianceTrafficShapingCustomPerformanceClasses) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_appliance_vlans.go b/internal/provider/model_resource_meraki_appliance_vlans.go index 48d7ad13..b9938b9c 100644 --- a/internal/provider/model_resource_meraki_appliance_vlans.go +++ b/internal/provider/model_resource_meraki_appliance_vlans.go @@ -986,14 +986,14 @@ func (data *ResourceApplianceVLANs) fromBodyImport(ctx context.Context, res mera // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceApplianceVLANs) toDestroyBody(ctx context.Context) string { +func (data ResourceApplianceVLANs) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_devices.go b/internal/provider/model_resource_meraki_devices.go index bedc24c0..9a965610 100644 --- a/internal/provider/model_resource_meraki_devices.go +++ b/internal/provider/model_resource_meraki_devices.go @@ -299,14 +299,14 @@ func (data *ResourceDevices) fromBodyImport(ctx context.Context, res meraki.Res) // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceDevices) toDestroyBody(ctx context.Context) string { +func (data ResourceDevices) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_network_group_policies.go b/internal/provider/model_resource_meraki_network_group_policies.go index b3a7f766..16141a1a 100644 --- a/internal/provider/model_resource_meraki_network_group_policies.go +++ b/internal/provider/model_resource_meraki_network_group_policies.go @@ -1500,14 +1500,14 @@ func (data *ResourceNetworkGroupPolicies) fromBodyImport(ctx context.Context, re // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceNetworkGroupPolicies) toDestroyBody(ctx context.Context) string { +func (data ResourceNetworkGroupPolicies) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_network_meraki_auth_users.go b/internal/provider/model_resource_meraki_network_meraki_auth_users.go index 447b9834..6474b2a4 100644 --- a/internal/provider/model_resource_meraki_network_meraki_auth_users.go +++ b/internal/provider/model_resource_meraki_network_meraki_auth_users.go @@ -368,14 +368,14 @@ func (data *ResourceNetworkMerakiAuthUsers) fromBodyImport(ctx context.Context, // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceNetworkMerakiAuthUsers) toDestroyBody(ctx context.Context) string { +func (data ResourceNetworkMerakiAuthUsers) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_network_webhook_payload_templates.go b/internal/provider/model_resource_meraki_network_webhook_payload_templates.go index 475dc137..c69c4d12 100644 --- a/internal/provider/model_resource_meraki_network_webhook_payload_templates.go +++ b/internal/provider/model_resource_meraki_network_webhook_payload_templates.go @@ -359,14 +359,14 @@ func (data *ResourceNetworkWebhookPayloadTemplates) fromBodyImport(ctx context.C // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceNetworkWebhookPayloadTemplates) toDestroyBody(ctx context.Context) string { +func (data ResourceNetworkWebhookPayloadTemplates) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_organization_adaptive_policies.go b/internal/provider/model_resource_meraki_organization_adaptive_policies.go index 5bf08f54..5cc189e7 100644 --- a/internal/provider/model_resource_meraki_organization_adaptive_policies.go +++ b/internal/provider/model_resource_meraki_organization_adaptive_policies.go @@ -391,14 +391,14 @@ func (data *ResourceOrganizationAdaptivePolicies) fromBodyImport(ctx context.Con // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceOrganizationAdaptivePolicies) toDestroyBody(ctx context.Context) string { +func (data ResourceOrganizationAdaptivePolicies) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_organization_adaptive_policy_groups.go b/internal/provider/model_resource_meraki_organization_adaptive_policy_groups.go index 80b587e3..e93db45e 100644 --- a/internal/provider/model_resource_meraki_organization_adaptive_policy_groups.go +++ b/internal/provider/model_resource_meraki_organization_adaptive_policy_groups.go @@ -339,14 +339,14 @@ func (data *ResourceOrganizationAdaptivePolicyGroups) fromBodyImport(ctx context // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceOrganizationAdaptivePolicyGroups) toDestroyBody(ctx context.Context) string { +func (data ResourceOrganizationAdaptivePolicyGroups) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_organization_licenses.go b/internal/provider/model_resource_meraki_organization_licenses.go index ca477f00..1e5287eb 100644 --- a/internal/provider/model_resource_meraki_organization_licenses.go +++ b/internal/provider/model_resource_meraki_organization_licenses.go @@ -204,14 +204,14 @@ func (data *ResourceOrganizationLicenses) fromBodyImport(ctx context.Context, re // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceOrganizationLicenses) toDestroyBody(ctx context.Context) string { +func (data ResourceOrganizationLicenses) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_organization_policy_object_groups.go b/internal/provider/model_resource_meraki_organization_policy_object_groups.go index a9fa3c1e..593e1f5f 100644 --- a/internal/provider/model_resource_meraki_organization_policy_object_groups.go +++ b/internal/provider/model_resource_meraki_organization_policy_object_groups.go @@ -237,14 +237,14 @@ func (data *ResourceOrganizationPolicyObjectGroups) fromBodyImport(ctx context.C // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceOrganizationPolicyObjectGroups) toDestroyBody(ctx context.Context) string { +func (data ResourceOrganizationPolicyObjectGroups) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_organization_policy_objects.go b/internal/provider/model_resource_meraki_organization_policy_objects.go index 8ea5a584..19270d5d 100644 --- a/internal/provider/model_resource_meraki_organization_policy_objects.go +++ b/internal/provider/model_resource_meraki_organization_policy_objects.go @@ -332,14 +332,14 @@ func (data *ResourceOrganizationPolicyObjects) fromBodyImport(ctx context.Contex // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceOrganizationPolicyObjects) toDestroyBody(ctx context.Context) string { +func (data ResourceOrganizationPolicyObjects) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_organization_saml_idps.go b/internal/provider/model_resource_meraki_organization_saml_idps.go index f3351a44..f0215394 100644 --- a/internal/provider/model_resource_meraki_organization_saml_idps.go +++ b/internal/provider/model_resource_meraki_organization_saml_idps.go @@ -215,14 +215,14 @@ func (data *ResourceOrganizationSAMLIdPs) fromBodyImport(ctx context.Context, re // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceOrganizationSAMLIdPs) toDestroyBody(ctx context.Context) string { +func (data ResourceOrganizationSAMLIdPs) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_sensor_alerts_profiles.go b/internal/provider/model_resource_meraki_sensor_alerts_profiles.go index 4b004f35..b69176d1 100644 --- a/internal/provider/model_resource_meraki_sensor_alerts_profiles.go +++ b/internal/provider/model_resource_meraki_sensor_alerts_profiles.go @@ -919,14 +919,14 @@ func (data *ResourceSensorAlertsProfiles) fromBodyImport(ctx context.Context, re // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceSensorAlertsProfiles) toDestroyBody(ctx context.Context) string { +func (data ResourceSensorAlertsProfiles) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_sensor_mqtt_brokers.go b/internal/provider/model_resource_meraki_sensor_mqtt_brokers.go index 2de99b6a..fb29bffd 100644 --- a/internal/provider/model_resource_meraki_sensor_mqtt_brokers.go +++ b/internal/provider/model_resource_meraki_sensor_mqtt_brokers.go @@ -205,15 +205,15 @@ func (data *ResourceSensorMQTTBrokers) fromBodyImport(ctx context.Context, res m // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceSensorMQTTBrokers) toDestroyBody(ctx context.Context) string { +func (data ResourceSensorMQTTBrokers) addDeleteValues(ctx context.Context) string { body := "" body, _ = sjson.Set(body, "enabled", false) return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_sm_admin_roles.go b/internal/provider/model_resource_meraki_sm_admin_roles.go index e32d9394..8d608de8 100644 --- a/internal/provider/model_resource_meraki_sm_admin_roles.go +++ b/internal/provider/model_resource_meraki_sm_admin_roles.go @@ -237,14 +237,14 @@ func (data *ResourceSMAdminRoles) fromBodyImport(ctx context.Context, res meraki // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceSMAdminRoles) toDestroyBody(ctx context.Context) string { +func (data ResourceSMAdminRoles) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_switch_access_policies.go b/internal/provider/model_resource_meraki_switch_access_policies.go index 0eaa7f73..ff28258e 100644 --- a/internal/provider/model_resource_meraki_switch_access_policies.go +++ b/internal/provider/model_resource_meraki_switch_access_policies.go @@ -948,14 +948,14 @@ func (data *ResourceSwitchAccessPolicies) fromBodyImport(ctx context.Context, re // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceSwitchAccessPolicies) toDestroyBody(ctx context.Context) string { +func (data ResourceSwitchAccessPolicies) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_switch_link_aggregations.go b/internal/provider/model_resource_meraki_switch_link_aggregations.go index 82cb22ae..fa8c61a4 100644 --- a/internal/provider/model_resource_meraki_switch_link_aggregations.go +++ b/internal/provider/model_resource_meraki_switch_link_aggregations.go @@ -388,14 +388,14 @@ func (data *ResourceSwitchLinkAggregations) fromBodyImport(ctx context.Context, // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceSwitchLinkAggregations) toDestroyBody(ctx context.Context) string { +func (data ResourceSwitchLinkAggregations) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_switch_ports.go b/internal/provider/model_resource_meraki_switch_ports.go index 5183265b..370d92ea 100644 --- a/internal/provider/model_resource_meraki_switch_ports.go +++ b/internal/provider/model_resource_meraki_switch_ports.go @@ -763,7 +763,7 @@ func (data *ResourceSwitchPorts) fromBodyImport(ctx context.Context, res meraki. // End of section. //template:end fromBodyImport -func (data ResourceSwitchPortsItems) toDestroyBody(ctx context.Context) string { +func (data ResourceSwitchPortsItems) addDeleteValues(ctx context.Context) string { body := "" body, _ = sjson.Set(body, "accessPolicyType", "Open") if !data.AdaptivePolicyGroupId.IsNull() { diff --git a/internal/provider/model_resource_meraki_switch_routing_interfaces.go b/internal/provider/model_resource_meraki_switch_routing_interfaces.go index 110f3325..703b17eb 100644 --- a/internal/provider/model_resource_meraki_switch_routing_interfaces.go +++ b/internal/provider/model_resource_meraki_switch_routing_interfaces.go @@ -501,14 +501,14 @@ func (data *ResourceSwitchRoutingInterfaces) fromBodyImport(ctx context.Context, // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceSwitchRoutingInterfaces) toDestroyBody(ctx context.Context) string { +func (data ResourceSwitchRoutingInterfaces) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_switch_routing_multicast_rendezvous_points.go b/internal/provider/model_resource_meraki_switch_routing_multicast_rendezvous_points.go index 4d620db8..6ad61f19 100644 --- a/internal/provider/model_resource_meraki_switch_routing_multicast_rendezvous_points.go +++ b/internal/provider/model_resource_meraki_switch_routing_multicast_rendezvous_points.go @@ -235,14 +235,14 @@ func (data *ResourceSwitchRoutingMulticastRendezvousPoints) fromBodyImport(ctx c // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceSwitchRoutingMulticastRendezvousPoints) toDestroyBody(ctx context.Context) string { +func (data ResourceSwitchRoutingMulticastRendezvousPoints) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_switch_routing_static_routes.go b/internal/provider/model_resource_meraki_switch_routing_static_routes.go index 76a8f1e9..37a87958 100644 --- a/internal/provider/model_resource_meraki_switch_routing_static_routes.go +++ b/internal/provider/model_resource_meraki_switch_routing_static_routes.go @@ -311,14 +311,14 @@ func (data *ResourceSwitchRoutingStaticRoutes) fromBodyImport(ctx context.Contex // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceSwitchRoutingStaticRoutes) toDestroyBody(ctx context.Context) string { +func (data ResourceSwitchRoutingStaticRoutes) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_switch_stack_routing_interfaces.go b/internal/provider/model_resource_meraki_switch_stack_routing_interfaces.go index 582173c9..0d992cbd 100644 --- a/internal/provider/model_resource_meraki_switch_stack_routing_interfaces.go +++ b/internal/provider/model_resource_meraki_switch_stack_routing_interfaces.go @@ -502,14 +502,14 @@ func (data *ResourceSwitchStackRoutingInterfaces) fromBodyImport(ctx context.Con // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceSwitchStackRoutingInterfaces) toDestroyBody(ctx context.Context) string { +func (data ResourceSwitchStackRoutingInterfaces) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_switch_stack_routing_static_routes.go b/internal/provider/model_resource_meraki_switch_stack_routing_static_routes.go index 209f4f74..7f7a823b 100644 --- a/internal/provider/model_resource_meraki_switch_stack_routing_static_routes.go +++ b/internal/provider/model_resource_meraki_switch_stack_routing_static_routes.go @@ -312,14 +312,14 @@ func (data *ResourceSwitchStackRoutingStaticRoutes) fromBodyImport(ctx context.C // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceSwitchStackRoutingStaticRoutes) toDestroyBody(ctx context.Context) string { +func (data ResourceSwitchStackRoutingStaticRoutes) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_wireless_rf_profiles.go b/internal/provider/model_resource_meraki_wireless_rf_profiles.go index aa16b182..ec21477d 100644 --- a/internal/provider/model_resource_meraki_wireless_rf_profiles.go +++ b/internal/provider/model_resource_meraki_wireless_rf_profiles.go @@ -1996,14 +1996,14 @@ func (data *ResourceWirelessRFProfiles) fromBodyImport(ctx context.Context, res // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceWirelessRFProfiles) toDestroyBody(ctx context.Context) string { +func (data ResourceWirelessRFProfiles) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_wireless_ssid_identity_psks.go b/internal/provider/model_resource_meraki_wireless_ssid_identity_psks.go index 5044c01f..b932690b 100644 --- a/internal/provider/model_resource_meraki_wireless_ssid_identity_psks.go +++ b/internal/provider/model_resource_meraki_wireless_ssid_identity_psks.go @@ -255,14 +255,14 @@ func (data *ResourceWirelessSSIDIdentityPSKs) fromBodyImport(ctx context.Context // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceWirelessSSIDIdentityPSKs) toDestroyBody(ctx context.Context) string { +func (data ResourceWirelessSSIDIdentityPSKs) addDeleteValues(ctx context.Context) string { body := "" return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/model_resource_meraki_wireless_ssids.go b/internal/provider/model_resource_meraki_wireless_ssids.go index 7da5118b..b7279380 100644 --- a/internal/provider/model_resource_meraki_wireless_ssids.go +++ b/internal/provider/model_resource_meraki_wireless_ssids.go @@ -2370,31 +2370,14 @@ func (data *ResourceWirelessSSIDs) fromBodyImport(ctx context.Context, res merak // End of section. //template:end fromBodyImport -// Section below is generated&owned by "gen/generator.go". //template:begin toDestroyBody +// Section below is generated&owned by "gen/generator.go". //template:begin addDeleteValues -func (data ResourceWirelessSSIDs) toDestroyBody(ctx context.Context) string { +func (data ResourceWirelessSSIDs) addDeleteValues(ctx context.Context) string { body := "" - body, _ = sjson.Set(body, "adultContentFilteringEnabled", false) - body, _ = sjson.Set(body, "authMode", "open") - body, _ = sjson.Set(body, "availableOnAllAps", true) - body, _ = sjson.Set(body, "enabled", false) - body, _ = sjson.Set(body, "ipAssignmentMode", "NAT mode") - body, _ = sjson.Set(body, "mandatoryDhcpEnabled", false) - body, _ = sjson.Set(body, "name", "Unconfigured SSID") - body, _ = sjson.Set(body, "perClientBandwidthLimitDown", 0) - body, _ = sjson.Set(body, "perClientBandwidthLimitUp", 0) - body, _ = sjson.Set(body, "perSsidBandwidthLimitDown", 0) - body, _ = sjson.Set(body, "perSsidBandwidthLimitUp", 0) - body, _ = sjson.Set(body, "splashPage", "None") - body, _ = sjson.Set(body, "visible", true) - body, _ = sjson.Set(body, "dnsRewrite.enabled", false) - body, _ = sjson.Set(body, "dnsRewrite.dnsCustomNameservers", []interface{}{}) - body, _ = sjson.Set(body, "speedBurst.enabled", false) - body, _ = sjson.Set(body, "availabilityTags", []interface{}{}) return body } -// End of section. //template:end toDestroyBody +// End of section. //template:end addDeleteValues // Section below is generated&owned by "gen/generator.go". //template:begin hasChanges diff --git a/internal/provider/resource_meraki_appliance_cellular_firewall_rules.go b/internal/provider/resource_meraki_appliance_cellular_firewall_rules.go index 34d7b0e7..7d68a81a 100644 --- a/internal/provider/resource_meraki_appliance_cellular_firewall_rules.go +++ b/internal/provider/resource_meraki_appliance_cellular_firewall_rules.go @@ -140,7 +140,7 @@ func (r *ApplianceCellularFirewallRulesResource) Configure(_ context.Context, re // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceCellularFirewallRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceCellularFirewallRules + var plan, initialState ApplianceCellularFirewallRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -149,6 +149,14 @@ func (r *ApplianceCellularFirewallRulesResource) Create(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceCellularFirewallRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceCellularFirewallRules{}) @@ -259,10 +267,16 @@ func (r *ApplianceCellularFirewallRulesResource) Delete(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_connectivity_monitoring_destinations.go b/internal/provider/resource_meraki_appliance_connectivity_monitoring_destinations.go index 2ec3386f..6c5bf7c1 100644 --- a/internal/provider/resource_meraki_appliance_connectivity_monitoring_destinations.go +++ b/internal/provider/resource_meraki_appliance_connectivity_monitoring_destinations.go @@ -112,7 +112,7 @@ func (r *ApplianceConnectivityMonitoringDestinationsResource) Configure(_ contex // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceConnectivityMonitoringDestinationsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceConnectivityMonitoringDestinations + var plan, initialState ApplianceConnectivityMonitoringDestinations // Read plan diags := req.Plan.Get(ctx, &plan) @@ -121,6 +121,14 @@ func (r *ApplianceConnectivityMonitoringDestinationsResource) Create(ctx context } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceConnectivityMonitoringDestinations{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceConnectivityMonitoringDestinations{}) @@ -231,10 +239,16 @@ func (r *ApplianceConnectivityMonitoringDestinationsResource) Delete(ctx context } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_content_filtering.go b/internal/provider/resource_meraki_appliance_content_filtering.go index b5323f8d..3e20993b 100644 --- a/internal/provider/resource_meraki_appliance_content_filtering.go +++ b/internal/provider/resource_meraki_appliance_content_filtering.go @@ -117,7 +117,7 @@ func (r *ApplianceContentFilteringResource) Configure(_ context.Context, req res // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceContentFilteringResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceContentFiltering + var plan, initialState ApplianceContentFiltering // Read plan diags := req.Plan.Get(ctx, &plan) @@ -126,6 +126,14 @@ func (r *ApplianceContentFilteringResource) Create(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceContentFiltering{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceContentFiltering{}) @@ -236,6 +244,18 @@ func (r *ApplianceContentFilteringResource) Delete(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_firewall_multicast_forwarding.go b/internal/provider/resource_meraki_appliance_firewall_multicast_forwarding.go index d7c93bea..ed525108 100644 --- a/internal/provider/resource_meraki_appliance_firewall_multicast_forwarding.go +++ b/internal/provider/resource_meraki_appliance_firewall_multicast_forwarding.go @@ -32,7 +32,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/netascode/go-meraki" - "github.com/tidwall/gjson" ) // End of section. //template:end imports @@ -112,10 +111,8 @@ func (r *ApplianceFirewallMulticastForwardingResource) Configure(_ context.Conte // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin create - func (r *ApplianceFirewallMulticastForwardingResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceFirewallMulticastForwarding + var plan, initialState ApplianceFirewallMulticastForwarding // Read plan diags := req.Plan.Get(ctx, &plan) @@ -124,6 +121,22 @@ func (r *ApplianceFirewallMulticastForwardingResource) Create(ctx context.Contex } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + networkPath := fmt.Sprintf("/networks/%v", plan.NetworkId.ValueString()) + nres, err := r.client.Get(networkPath) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve network (GET), got error: %s, %s", err, nres.String())) + return + } + orgId := nres.Get("organizationId").String() + getPath := fmt.Sprintf("/organizations/%v/appliance/firewall/multicastForwarding/byNetwork?networkIds[]=%v", orgId, plan.NetworkId.ValueString()) + gres, err := r.client.Get(getPath) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve multicast forwarding (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, meraki.Res{Result: gres.Get("items.0")}) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceFirewallMulticastForwarding{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceFirewallMulticastForwarding{}) @@ -143,8 +156,6 @@ func (r *ApplianceFirewallMulticastForwardingResource) Create(ctx context.Contex helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end create - func (r *ApplianceFirewallMulticastForwardingResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state ApplianceFirewallMulticastForwarding @@ -167,7 +178,7 @@ func (r *ApplianceFirewallMulticastForwardingResource) Read(ctx context.Context, } orgId := res.Get("organizationId").String() - getPath := fmt.Sprintf("/organizations/%v/appliance/firewall/multicastForwarding/byNetwork", orgId) + getPath := fmt.Sprintf("/organizations/%v/appliance/firewall/multicastForwarding/byNetwork?networkIds[]=%v", orgId, state.NetworkId.ValueString()) res, err = r.client.Get(getPath) if err != nil && (strings.Contains(err.Error(), "StatusCode 404") || strings.Contains(err.Error(), "StatusCode 400")) { resp.State.RemoveResource(ctx) @@ -177,15 +188,7 @@ func (r *ApplianceFirewallMulticastForwardingResource) Read(ctx context.Context, return } - if len(res.Get("items").Array()) > 0 { - res.Get("items").ForEach(func(k, v gjson.Result) bool { - if state.Id.ValueString() == v.Get("network.id").String() { - res = meraki.Res{Result: v} - return false - } - return true - }) - } + res = meraki.Res{Result: res.Get("items.0")} imp, diags := helpers.IsFlagImporting(ctx, req) if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { @@ -253,10 +256,16 @@ func (r *ApplianceFirewallMulticastForwardingResource) Delete(ctx context.Contex } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_firewall_settings.go b/internal/provider/resource_meraki_appliance_firewall_settings.go index 593ca54c..92f04740 100644 --- a/internal/provider/resource_meraki_appliance_firewall_settings.go +++ b/internal/provider/resource_meraki_appliance_firewall_settings.go @@ -101,7 +101,7 @@ func (r *ApplianceFirewallSettingsResource) Configure(_ context.Context, req res // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceFirewallSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceFirewallSettings + var plan, initialState ApplianceFirewallSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -110,6 +110,14 @@ func (r *ApplianceFirewallSettingsResource) Create(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceFirewallSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceFirewallSettings{}) @@ -220,6 +228,18 @@ func (r *ApplianceFirewallSettingsResource) Delete(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_firewalled_service.go b/internal/provider/resource_meraki_appliance_firewalled_service.go index 84185e43..dd756fda 100644 --- a/internal/provider/resource_meraki_appliance_firewalled_service.go +++ b/internal/provider/resource_meraki_appliance_firewalled_service.go @@ -117,7 +117,7 @@ func (r *ApplianceFirewalledServiceResource) Configure(_ context.Context, req re // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceFirewalledServiceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceFirewalledService + var plan, initialState ApplianceFirewalledService // Read plan diags := req.Plan.Get(ctx, &plan) @@ -126,6 +126,14 @@ func (r *ApplianceFirewalledServiceResource) Create(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceFirewalledService{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceFirewalledService{}) @@ -236,6 +244,18 @@ func (r *ApplianceFirewalledServiceResource) Delete(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_inbound_cellular_firewall_rules.go b/internal/provider/resource_meraki_appliance_inbound_cellular_firewall_rules.go index cba4b5ec..b6e8248b 100644 --- a/internal/provider/resource_meraki_appliance_inbound_cellular_firewall_rules.go +++ b/internal/provider/resource_meraki_appliance_inbound_cellular_firewall_rules.go @@ -140,7 +140,7 @@ func (r *ApplianceInboundCellularFirewallRulesResource) Configure(_ context.Cont // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceInboundCellularFirewallRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceInboundCellularFirewallRules + var plan, initialState ApplianceInboundCellularFirewallRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -149,6 +149,14 @@ func (r *ApplianceInboundCellularFirewallRulesResource) Create(ctx context.Conte } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceInboundCellularFirewallRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceInboundCellularFirewallRules{}) @@ -259,10 +267,16 @@ func (r *ApplianceInboundCellularFirewallRulesResource) Delete(ctx context.Conte } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_inbound_firewall_rules.go b/internal/provider/resource_meraki_appliance_inbound_firewall_rules.go index 303b403b..9e871811 100644 --- a/internal/provider/resource_meraki_appliance_inbound_firewall_rules.go +++ b/internal/provider/resource_meraki_appliance_inbound_firewall_rules.go @@ -144,7 +144,7 @@ func (r *ApplianceInboundFirewallRulesResource) Configure(_ context.Context, req // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceInboundFirewallRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceInboundFirewallRules + var plan, initialState ApplianceInboundFirewallRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -153,6 +153,14 @@ func (r *ApplianceInboundFirewallRulesResource) Create(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceInboundFirewallRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceInboundFirewallRules{}) @@ -263,10 +271,16 @@ func (r *ApplianceInboundFirewallRulesResource) Delete(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_l3_firewall_rules.go b/internal/provider/resource_meraki_appliance_l3_firewall_rules.go index 7c43e0b2..525eca18 100644 --- a/internal/provider/resource_meraki_appliance_l3_firewall_rules.go +++ b/internal/provider/resource_meraki_appliance_l3_firewall_rules.go @@ -144,7 +144,7 @@ func (r *ApplianceL3FirewallRulesResource) Configure(_ context.Context, req reso // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceL3FirewallRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceL3FirewallRules + var plan, initialState ApplianceL3FirewallRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -153,6 +153,14 @@ func (r *ApplianceL3FirewallRulesResource) Create(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceL3FirewallRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceL3FirewallRules{}) @@ -263,10 +271,16 @@ func (r *ApplianceL3FirewallRulesResource) Delete(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_l7_firewall_rules.go b/internal/provider/resource_meraki_appliance_l7_firewall_rules.go index 7f9f1df3..689a26fa 100644 --- a/internal/provider/resource_meraki_appliance_l7_firewall_rules.go +++ b/internal/provider/resource_meraki_appliance_l7_firewall_rules.go @@ -126,7 +126,7 @@ func (r *ApplianceL7FirewallRulesResource) Configure(_ context.Context, req reso // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceL7FirewallRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceL7FirewallRules + var plan, initialState ApplianceL7FirewallRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -135,6 +135,14 @@ func (r *ApplianceL7FirewallRulesResource) Create(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceL7FirewallRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceL7FirewallRules{}) @@ -245,10 +253,16 @@ func (r *ApplianceL7FirewallRulesResource) Delete(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_network_security_intrusion.go b/internal/provider/resource_meraki_appliance_network_security_intrusion.go index 5134faae..fbffbd53 100644 --- a/internal/provider/resource_meraki_appliance_network_security_intrusion.go +++ b/internal/provider/resource_meraki_appliance_network_security_intrusion.go @@ -123,7 +123,7 @@ func (r *ApplianceNetworkSecurityIntrusionResource) Configure(_ context.Context, // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceNetworkSecurityIntrusionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceNetworkSecurityIntrusion + var plan, initialState ApplianceNetworkSecurityIntrusion // Read plan diags := req.Plan.Get(ctx, &plan) @@ -132,6 +132,14 @@ func (r *ApplianceNetworkSecurityIntrusionResource) Create(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceNetworkSecurityIntrusion{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceNetworkSecurityIntrusion{}) @@ -242,6 +250,18 @@ func (r *ApplianceNetworkSecurityIntrusionResource) Delete(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_one_to_many_nat_rules.go b/internal/provider/resource_meraki_appliance_one_to_many_nat_rules.go index 1e0c1bc8..e144a31e 100644 --- a/internal/provider/resource_meraki_appliance_one_to_many_nat_rules.go +++ b/internal/provider/resource_meraki_appliance_one_to_many_nat_rules.go @@ -150,7 +150,7 @@ func (r *ApplianceOneToManyNATRulesResource) Configure(_ context.Context, req re // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceOneToManyNATRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceOneToManyNATRules + var plan, initialState ApplianceOneToManyNATRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -159,6 +159,14 @@ func (r *ApplianceOneToManyNATRulesResource) Create(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceOneToManyNATRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceOneToManyNATRules{}) @@ -269,10 +277,16 @@ func (r *ApplianceOneToManyNATRulesResource) Delete(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_one_to_one_nat_rules.go b/internal/provider/resource_meraki_appliance_one_to_one_nat_rules.go index 3b35ab0e..0a11a5e2 100644 --- a/internal/provider/resource_meraki_appliance_one_to_one_nat_rules.go +++ b/internal/provider/resource_meraki_appliance_one_to_one_nat_rules.go @@ -147,7 +147,7 @@ func (r *ApplianceOneToOneNATRulesResource) Configure(_ context.Context, req res // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceOneToOneNATRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceOneToOneNATRules + var plan, initialState ApplianceOneToOneNATRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -156,6 +156,14 @@ func (r *ApplianceOneToOneNATRulesResource) Create(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceOneToOneNATRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceOneToOneNATRules{}) @@ -266,10 +274,16 @@ func (r *ApplianceOneToOneNATRulesResource) Delete(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_organization_security_intrusion.go b/internal/provider/resource_meraki_appliance_organization_security_intrusion.go index 43d6c5ab..f2422519 100644 --- a/internal/provider/resource_meraki_appliance_organization_security_intrusion.go +++ b/internal/provider/resource_meraki_appliance_organization_security_intrusion.go @@ -108,7 +108,7 @@ func (r *ApplianceOrganizationSecurityIntrusionResource) Configure(_ context.Con // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceOrganizationSecurityIntrusionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceOrganizationSecurityIntrusion + var plan, initialState ApplianceOrganizationSecurityIntrusion // Read plan diags := req.Plan.Get(ctx, &plan) @@ -117,6 +117,14 @@ func (r *ApplianceOrganizationSecurityIntrusionResource) Create(ctx context.Cont } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceOrganizationSecurityIntrusion{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceOrganizationSecurityIntrusion{}) @@ -227,10 +235,16 @@ func (r *ApplianceOrganizationSecurityIntrusionResource) Delete(ctx context.Cont } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_port.go b/internal/provider/resource_meraki_appliance_port.go index 7c4d447e..f39cd271 100644 --- a/internal/provider/resource_meraki_appliance_port.go +++ b/internal/provider/resource_meraki_appliance_port.go @@ -123,7 +123,7 @@ func (r *AppliancePortResource) Configure(_ context.Context, req resource.Config // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *AppliancePortResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan AppliancePort + var plan, initialState AppliancePort // Read plan diags := req.Plan.Get(ctx, &plan) @@ -132,6 +132,14 @@ func (r *AppliancePortResource) Create(ctx context.Context, req resource.CreateR } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, AppliancePort{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, AppliancePort{}) @@ -242,6 +250,18 @@ func (r *AppliancePortResource) Delete(ctx context.Context, req resource.DeleteR } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_port_forwarding_rules.go b/internal/provider/resource_meraki_appliance_port_forwarding_rules.go index 1515f1ad..270d0b3b 100644 --- a/internal/provider/resource_meraki_appliance_port_forwarding_rules.go +++ b/internal/provider/resource_meraki_appliance_port_forwarding_rules.go @@ -138,7 +138,7 @@ func (r *AppliancePortForwardingRulesResource) Configure(_ context.Context, req // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *AppliancePortForwardingRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan AppliancePortForwardingRules + var plan, initialState AppliancePortForwardingRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -147,6 +147,14 @@ func (r *AppliancePortForwardingRulesResource) Create(ctx context.Context, req r } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, AppliancePortForwardingRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, AppliancePortForwardingRules{}) @@ -257,10 +265,16 @@ func (r *AppliancePortForwardingRulesResource) Delete(ctx context.Context, req r } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_radio_settings.go b/internal/provider/resource_meraki_appliance_radio_settings.go index d14596f2..65347ea5 100644 --- a/internal/provider/resource_meraki_appliance_radio_settings.go +++ b/internal/provider/resource_meraki_appliance_radio_settings.go @@ -116,7 +116,7 @@ func (r *ApplianceRadioSettingsResource) Configure(_ context.Context, req resour // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceRadioSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceRadioSettings + var plan, initialState ApplianceRadioSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -125,6 +125,14 @@ func (r *ApplianceRadioSettingsResource) Create(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceRadioSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceRadioSettings{}) @@ -235,6 +243,18 @@ func (r *ApplianceRadioSettingsResource) Delete(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_sdwan_internet_policies.go b/internal/provider/resource_meraki_appliance_sdwan_internet_policies.go index 37e5e45b..803c3262 100644 --- a/internal/provider/resource_meraki_appliance_sdwan_internet_policies.go +++ b/internal/provider/resource_meraki_appliance_sdwan_internet_policies.go @@ -296,7 +296,7 @@ func (r *ApplianceSDWANInternetPoliciesResource) Delete(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) + body := state.addDeleteValues(ctx, "") res, err := r.client.Put(state.getPath(), body) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) diff --git a/internal/provider/resource_meraki_appliance_security_malware.go b/internal/provider/resource_meraki_appliance_security_malware.go index 7d97a789..2cc7d1a5 100644 --- a/internal/provider/resource_meraki_appliance_security_malware.go +++ b/internal/provider/resource_meraki_appliance_security_malware.go @@ -133,7 +133,7 @@ func (r *ApplianceSecurityMalwareResource) Configure(_ context.Context, req reso // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceSecurityMalwareResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceSecurityMalware + var plan, initialState ApplianceSecurityMalware // Read plan diags := req.Plan.Get(ctx, &plan) @@ -142,6 +142,14 @@ func (r *ApplianceSecurityMalwareResource) Create(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceSecurityMalware{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceSecurityMalware{}) @@ -252,6 +260,18 @@ func (r *ApplianceSecurityMalwareResource) Delete(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_settings.go b/internal/provider/resource_meraki_appliance_settings.go index 7de89858..c21019e9 100644 --- a/internal/provider/resource_meraki_appliance_settings.go +++ b/internal/provider/resource_meraki_appliance_settings.go @@ -116,7 +116,7 @@ func (r *ApplianceSettingsResource) Configure(_ context.Context, req resource.Co // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceSettings + var plan, initialState ApplianceSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -125,6 +125,14 @@ func (r *ApplianceSettingsResource) Create(ctx context.Context, req resource.Cre } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceSettings{}) @@ -235,6 +243,18 @@ func (r *ApplianceSettingsResource) Delete(ctx context.Context, req resource.Del } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_single_lan.go b/internal/provider/resource_meraki_appliance_single_lan.go index 17d80ef5..d1922033 100644 --- a/internal/provider/resource_meraki_appliance_single_lan.go +++ b/internal/provider/resource_meraki_appliance_single_lan.go @@ -143,7 +143,7 @@ func (r *ApplianceSingleLANResource) Configure(_ context.Context, req resource.C // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceSingleLANResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceSingleLAN + var plan, initialState ApplianceSingleLAN // Read plan diags := req.Plan.Get(ctx, &plan) @@ -152,6 +152,14 @@ func (r *ApplianceSingleLANResource) Create(ctx context.Context, req resource.Cr } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceSingleLAN{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceSingleLAN{}) @@ -262,6 +270,18 @@ func (r *ApplianceSingleLANResource) Delete(ctx context.Context, req resource.De } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_site_to_site_vpn.go b/internal/provider/resource_meraki_appliance_site_to_site_vpn.go index 3dfbbf8b..b3e98d55 100644 --- a/internal/provider/resource_meraki_appliance_site_to_site_vpn.go +++ b/internal/provider/resource_meraki_appliance_site_to_site_vpn.go @@ -145,7 +145,7 @@ func (r *ApplianceSiteToSiteVPNResource) Configure(_ context.Context, req resour // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceSiteToSiteVPNResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceSiteToSiteVPN + var plan, initialState ApplianceSiteToSiteVPN // Read plan diags := req.Plan.Get(ctx, &plan) @@ -154,6 +154,14 @@ func (r *ApplianceSiteToSiteVPNResource) Create(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceSiteToSiteVPN{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceSiteToSiteVPN{}) @@ -264,6 +272,18 @@ func (r *ApplianceSiteToSiteVPNResource) Delete(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_ssid.go b/internal/provider/resource_meraki_appliance_ssid.go index bc824331..aeb553d0 100644 --- a/internal/provider/resource_meraki_appliance_ssid.go +++ b/internal/provider/resource_meraki_appliance_ssid.go @@ -174,7 +174,7 @@ func (r *ApplianceSSIDResource) Configure(_ context.Context, req resource.Config // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceSSIDResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceSSID + var plan, initialState ApplianceSSID // Read plan diags := req.Plan.Get(ctx, &plan) @@ -183,6 +183,14 @@ func (r *ApplianceSSIDResource) Create(ctx context.Context, req resource.CreateR } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceSSID{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceSSID{}) @@ -293,6 +301,18 @@ func (r *ApplianceSSIDResource) Delete(ctx context.Context, req resource.DeleteR } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_third_party_vpn_peers.go b/internal/provider/resource_meraki_appliance_third_party_vpn_peers.go index fb001b69..51ec7d75 100644 --- a/internal/provider/resource_meraki_appliance_third_party_vpn_peers.go +++ b/internal/provider/resource_meraki_appliance_third_party_vpn_peers.go @@ -261,7 +261,7 @@ func (r *ApplianceThirdPartyVPNPeersResource) Configure(_ context.Context, req r // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceThirdPartyVPNPeersResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceThirdPartyVPNPeers + var plan, initialState ApplianceThirdPartyVPNPeers // Read plan diags := req.Plan.Get(ctx, &plan) @@ -270,6 +270,14 @@ func (r *ApplianceThirdPartyVPNPeersResource) Create(ctx context.Context, req re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceThirdPartyVPNPeers{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceThirdPartyVPNPeers{}) @@ -380,10 +388,16 @@ func (r *ApplianceThirdPartyVPNPeersResource) Delete(ctx context.Context, req re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_traffic_shaping.go b/internal/provider/resource_meraki_appliance_traffic_shaping.go index 362d5472..71df38fe 100644 --- a/internal/provider/resource_meraki_appliance_traffic_shaping.go +++ b/internal/provider/resource_meraki_appliance_traffic_shaping.go @@ -100,7 +100,7 @@ func (r *ApplianceTrafficShapingResource) Configure(_ context.Context, req resou // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceTrafficShapingResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceTrafficShaping + var plan, initialState ApplianceTrafficShaping // Read plan diags := req.Plan.Get(ctx, &plan) @@ -109,6 +109,14 @@ func (r *ApplianceTrafficShapingResource) Create(ctx context.Context, req resour } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceTrafficShaping{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceTrafficShaping{}) @@ -219,6 +227,18 @@ func (r *ApplianceTrafficShapingResource) Delete(ctx context.Context, req resour } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_traffic_shaping_rules.go b/internal/provider/resource_meraki_appliance_traffic_shaping_rules.go index 84fafee6..b7e0c520 100644 --- a/internal/provider/resource_meraki_appliance_traffic_shaping_rules.go +++ b/internal/provider/resource_meraki_appliance_traffic_shaping_rules.go @@ -145,7 +145,7 @@ func (r *ApplianceTrafficShapingRulesResource) Configure(_ context.Context, req // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceTrafficShapingRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceTrafficShapingRules + var plan, initialState ApplianceTrafficShapingRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -154,6 +154,14 @@ func (r *ApplianceTrafficShapingRulesResource) Create(ctx context.Context, req r } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceTrafficShapingRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceTrafficShapingRules{}) @@ -264,10 +272,16 @@ func (r *ApplianceTrafficShapingRulesResource) Delete(ctx context.Context, req r } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_traffic_shaping_uplink_bandwidth.go b/internal/provider/resource_meraki_appliance_traffic_shaping_uplink_bandwidth.go index 7433fc14..2dde83bb 100644 --- a/internal/provider/resource_meraki_appliance_traffic_shaping_uplink_bandwidth.go +++ b/internal/provider/resource_meraki_appliance_traffic_shaping_uplink_bandwidth.go @@ -116,7 +116,7 @@ func (r *ApplianceTrafficShapingUplinkBandwidthResource) Configure(_ context.Con // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceTrafficShapingUplinkBandwidthResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceTrafficShapingUplinkBandwidth + var plan, initialState ApplianceTrafficShapingUplinkBandwidth // Read plan diags := req.Plan.Get(ctx, &plan) @@ -125,6 +125,14 @@ func (r *ApplianceTrafficShapingUplinkBandwidthResource) Create(ctx context.Cont } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceTrafficShapingUplinkBandwidth{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceTrafficShapingUplinkBandwidth{}) @@ -235,6 +243,18 @@ func (r *ApplianceTrafficShapingUplinkBandwidthResource) Delete(ctx context.Cont } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_traffic_shaping_uplink_selection.go b/internal/provider/resource_meraki_appliance_traffic_shaping_uplink_selection.go index 8c1013a5..becb267f 100644 --- a/internal/provider/resource_meraki_appliance_traffic_shaping_uplink_selection.go +++ b/internal/provider/resource_meraki_appliance_traffic_shaping_uplink_selection.go @@ -33,6 +33,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/netascode/go-meraki" + "github.com/tidwall/sjson" ) // End of section. //template:end imports @@ -275,7 +276,7 @@ func (r *ApplianceTrafficShapingUplinkSelectionResource) Configure(_ context.Con // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceTrafficShapingUplinkSelectionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceTrafficShapingUplinkSelection + var plan, initialState ApplianceTrafficShapingUplinkSelection // Read plan diags := req.Plan.Get(ctx, &plan) @@ -284,6 +285,14 @@ func (r *ApplianceTrafficShapingUplinkSelectionResource) Create(ctx context.Cont } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceTrafficShapingUplinkSelection{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceTrafficShapingUplinkSelection{}) @@ -392,9 +401,14 @@ func (r *ApplianceTrafficShapingUplinkSelectionResource) Delete(ctx context.Cont } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return @@ -408,7 +422,7 @@ func (r *ApplianceTrafficShapingUplinkSelectionResource) Delete(ctx context.Cont sdwanInternetPolicies := ApplianceSDWANInternetPolicies{ NetworkId: state.NetworkId, } - body = sdwanInternetPolicies.toDestroyBody(ctx) + body, _ := sjson.Set("", "wanTrafficUplinkPreferences", []interface{}{}) res, err = r.client.Put(sdwanInternetPolicies.getPath(), body) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to clear Appliance Traffic Shaping Uplink Preferences wan_traffic_uplink_preferences via Appliance SDWAN Internet Policies endpoint (PUT), got error: %s, %s", err, res.String())) diff --git a/internal/provider/resource_meraki_appliance_traffic_shaping_vpn_exclusions.go b/internal/provider/resource_meraki_appliance_traffic_shaping_vpn_exclusions.go index bfee2440..e8039927 100644 --- a/internal/provider/resource_meraki_appliance_traffic_shaping_vpn_exclusions.go +++ b/internal/provider/resource_meraki_appliance_traffic_shaping_vpn_exclusions.go @@ -33,7 +33,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/netascode/go-meraki" - "github.com/tidwall/gjson" ) // End of section. //template:end imports @@ -134,10 +133,8 @@ func (r *ApplianceTrafficShapingVPNExclusionsResource) Configure(_ context.Conte // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin create - func (r *ApplianceTrafficShapingVPNExclusionsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceTrafficShapingVPNExclusions + var plan, initialState ApplianceTrafficShapingVPNExclusions // Read plan diags := req.Plan.Get(ctx, &plan) @@ -146,6 +143,22 @@ func (r *ApplianceTrafficShapingVPNExclusionsResource) Create(ctx context.Contex } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + networkPath := fmt.Sprintf("/networks/%v", plan.NetworkId.ValueString()) + nres, err := r.client.Get(networkPath) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve network (GET), got error: %s, %s", err, nres.String())) + return + } + orgId := nres.Get("organizationId").String() + getPath := fmt.Sprintf("/organizations/%v/appliance/trafficShaping/vpnExclusions/byNetwork?networkIds[]=%v", orgId, plan.NetworkId.ValueString()) + gres, err := r.client.Get(getPath) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve vpn exceptions (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, meraki.Res{Result: gres.Get("items.0")}) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceTrafficShapingVPNExclusions{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceTrafficShapingVPNExclusions{}) @@ -165,8 +178,6 @@ func (r *ApplianceTrafficShapingVPNExclusionsResource) Create(ctx context.Contex helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end create - func (r *ApplianceTrafficShapingVPNExclusionsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state ApplianceTrafficShapingVPNExclusions @@ -189,7 +200,7 @@ func (r *ApplianceTrafficShapingVPNExclusionsResource) Read(ctx context.Context, } orgId := res.Get("organizationId").String() - getPath := fmt.Sprintf("/organizations/%v/appliance/trafficShaping/vpnExclusions/byNetwork", orgId) + getPath := fmt.Sprintf("/organizations/%v/appliance/trafficShaping/vpnExclusions/byNetwork?networkIds[]=%v", orgId, state.NetworkId.ValueString()) res, err = r.client.Get(getPath) if err != nil && (strings.Contains(err.Error(), "StatusCode 404") || strings.Contains(err.Error(), "StatusCode 400")) { resp.State.RemoveResource(ctx) @@ -199,15 +210,7 @@ func (r *ApplianceTrafficShapingVPNExclusionsResource) Read(ctx context.Context, return } - if len(res.Get("items").Array()) > 0 { - res.Get("items").ForEach(func(k, v gjson.Result) bool { - if state.Id.ValueString() == v.Get("networkId").String() { - res = meraki.Res{Result: v} - return false - } - return true - }) - } + res = meraki.Res{Result: res.Get("items.0")} imp, diags := helpers.IsFlagImporting(ctx, req) if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { @@ -275,10 +278,16 @@ func (r *ApplianceTrafficShapingVPNExclusionsResource) Delete(ctx context.Contex } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_uplinks_settings.go b/internal/provider/resource_meraki_appliance_uplinks_settings.go index 8ad4a735..a918d911 100644 --- a/internal/provider/resource_meraki_appliance_uplinks_settings.go +++ b/internal/provider/resource_meraki_appliance_uplinks_settings.go @@ -231,7 +231,7 @@ func (r *ApplianceUplinksSettingsResource) Configure(_ context.Context, req reso // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceUplinksSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceUplinksSettings + var plan, initialState ApplianceUplinksSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -240,6 +240,14 @@ func (r *ApplianceUplinksSettingsResource) Create(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceUplinksSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceUplinksSettings{}) @@ -350,6 +358,18 @@ func (r *ApplianceUplinksSettingsResource) Delete(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_vlan_dhcp.go b/internal/provider/resource_meraki_appliance_vlan_dhcp.go index 2c05bf94..e2c5cfcd 100644 --- a/internal/provider/resource_meraki_appliance_vlan_dhcp.go +++ b/internal/provider/resource_meraki_appliance_vlan_dhcp.go @@ -278,8 +278,6 @@ func (r *ApplianceVLANDHCPResource) Update(ctx context.Context, req resource.Upd resp.Diagnostics.Append(diags...) } -// Section below is generated&owned by "gen/generator.go". //template:begin delete - func (r *ApplianceVLANDHCPResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var state ApplianceVLANDHCP @@ -296,7 +294,5 @@ func (r *ApplianceVLANDHCPResource) Delete(ctx context.Context, req resource.Del resp.State.RemoveResource(ctx) } -// End of section. //template:end delete - // Section below is generated&owned by "gen/generator.go". //template:begin import // End of section. //template:end import diff --git a/internal/provider/resource_meraki_appliance_vlans_settings.go b/internal/provider/resource_meraki_appliance_vlans_settings.go index a32dae67..40e252b2 100644 --- a/internal/provider/resource_meraki_appliance_vlans_settings.go +++ b/internal/provider/resource_meraki_appliance_vlans_settings.go @@ -96,7 +96,7 @@ func (r *ApplianceVLANsSettingsResource) Configure(_ context.Context, req resour // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceVLANsSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceVLANsSettings + var plan, initialState ApplianceVLANsSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -105,6 +105,14 @@ func (r *ApplianceVLANsSettingsResource) Create(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceVLANsSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceVLANsSettings{}) @@ -215,6 +223,18 @@ func (r *ApplianceVLANsSettingsResource) Delete(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_vpn_bgp.go b/internal/provider/resource_meraki_appliance_vpn_bgp.go index ac6f8f28..7f3e5960 100644 --- a/internal/provider/resource_meraki_appliance_vpn_bgp.go +++ b/internal/provider/resource_meraki_appliance_vpn_bgp.go @@ -170,7 +170,7 @@ func (r *ApplianceVPNBGPResource) Configure(_ context.Context, req resource.Conf // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceVPNBGPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceVPNBGP + var plan, initialState ApplianceVPNBGP // Read plan diags := req.Plan.Get(ctx, &plan) @@ -179,6 +179,14 @@ func (r *ApplianceVPNBGPResource) Create(ctx context.Context, req resource.Creat } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceVPNBGP{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceVPNBGP{}) @@ -289,6 +297,18 @@ func (r *ApplianceVPNBGPResource) Delete(ctx context.Context, req resource.Delet } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_appliance_vpn_firewall_rules.go b/internal/provider/resource_meraki_appliance_vpn_firewall_rules.go index a45cbd7e..b3a46f47 100644 --- a/internal/provider/resource_meraki_appliance_vpn_firewall_rules.go +++ b/internal/provider/resource_meraki_appliance_vpn_firewall_rules.go @@ -144,7 +144,7 @@ func (r *ApplianceVPNFirewallRulesResource) Configure(_ context.Context, req res // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceVPNFirewallRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceVPNFirewallRules + var plan, initialState ApplianceVPNFirewallRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -153,6 +153,14 @@ func (r *ApplianceVPNFirewallRulesResource) Create(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceVPNFirewallRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceVPNFirewallRules{}) @@ -263,10 +271,16 @@ func (r *ApplianceVPNFirewallRulesResource) Delete(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_vpn_site_to_site_ipsec_peers_slas.go b/internal/provider/resource_meraki_appliance_vpn_site_to_site_ipsec_peers_slas.go index 7d49bc2f..007cd086 100644 --- a/internal/provider/resource_meraki_appliance_vpn_site_to_site_ipsec_peers_slas.go +++ b/internal/provider/resource_meraki_appliance_vpn_site_to_site_ipsec_peers_slas.go @@ -108,7 +108,7 @@ func (r *ApplianceVPNSiteToSiteIPsecPeersSLAsResource) Configure(_ context.Conte // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceVPNSiteToSiteIPsecPeersSLAsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceVPNSiteToSiteIPsecPeersSLAs + var plan, initialState ApplianceVPNSiteToSiteIPsecPeersSLAs // Read plan diags := req.Plan.Get(ctx, &plan) @@ -117,6 +117,14 @@ func (r *ApplianceVPNSiteToSiteIPsecPeersSLAsResource) Create(ctx context.Contex } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceVPNSiteToSiteIPsecPeersSLAs{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceVPNSiteToSiteIPsecPeersSLAs{}) @@ -227,10 +235,16 @@ func (r *ApplianceVPNSiteToSiteIPsecPeersSLAsResource) Delete(ctx context.Contex } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_appliance_warm_spare.go b/internal/provider/resource_meraki_appliance_warm_spare.go index 4ac94760..4f954f86 100644 --- a/internal/provider/resource_meraki_appliance_warm_spare.go +++ b/internal/provider/resource_meraki_appliance_warm_spare.go @@ -112,7 +112,7 @@ func (r *ApplianceWarmSpareResource) Configure(_ context.Context, req resource.C // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *ApplianceWarmSpareResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan ApplianceWarmSpare + var plan, initialState ApplianceWarmSpare // Read plan diags := req.Plan.Get(ctx, &plan) @@ -121,6 +121,14 @@ func (r *ApplianceWarmSpareResource) Create(ctx context.Context, req resource.Cr } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, ApplianceWarmSpare{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, ApplianceWarmSpare{}) @@ -231,6 +239,18 @@ func (r *ApplianceWarmSpareResource) Delete(ctx context.Context, req resource.De } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_camera_custom_analytics.go b/internal/provider/resource_meraki_camera_custom_analytics.go index fa8b219d..ae5867aa 100644 --- a/internal/provider/resource_meraki_camera_custom_analytics.go +++ b/internal/provider/resource_meraki_camera_custom_analytics.go @@ -116,7 +116,7 @@ func (r *CameraCustomAnalyticsResource) Configure(_ context.Context, req resourc // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CameraCustomAnalyticsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CameraCustomAnalytics + var plan, initialState CameraCustomAnalytics // Read plan diags := req.Plan.Get(ctx, &plan) @@ -125,6 +125,14 @@ func (r *CameraCustomAnalyticsResource) Create(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CameraCustomAnalytics{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CameraCustomAnalytics{}) @@ -235,6 +243,18 @@ func (r *CameraCustomAnalyticsResource) Delete(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_camera_device_wireless_profiles.go b/internal/provider/resource_meraki_camera_device_wireless_profiles.go index d041fb58..ecb376fa 100644 --- a/internal/provider/resource_meraki_camera_device_wireless_profiles.go +++ b/internal/provider/resource_meraki_camera_device_wireless_profiles.go @@ -104,7 +104,7 @@ func (r *CameraDeviceWirelessProfilesResource) Configure(_ context.Context, req // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CameraDeviceWirelessProfilesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CameraDeviceWirelessProfiles + var plan, initialState CameraDeviceWirelessProfiles // Read plan diags := req.Plan.Get(ctx, &plan) @@ -113,6 +113,14 @@ func (r *CameraDeviceWirelessProfilesResource) Create(ctx context.Context, req r } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CameraDeviceWirelessProfiles{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CameraDeviceWirelessProfiles{}) @@ -211,8 +219,6 @@ func (r *CameraDeviceWirelessProfilesResource) Update(ctx context.Context, req r // End of section. //template:end update -// Section below is generated&owned by "gen/generator.go". //template:begin delete - func (r *CameraDeviceWirelessProfilesResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var state CameraDeviceWirelessProfiles @@ -229,8 +235,6 @@ func (r *CameraDeviceWirelessProfilesResource) Delete(ctx context.Context, req r resp.State.RemoveResource(ctx) } -// End of section. //template:end delete - // Section below is generated&owned by "gen/generator.go". //template:begin import func (r *CameraDeviceWirelessProfilesResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { idParts := strings.Split(req.ID, ",") diff --git a/internal/provider/resource_meraki_camera_quality_retention.go b/internal/provider/resource_meraki_camera_quality_retention.go index d89469f1..054215aa 100644 --- a/internal/provider/resource_meraki_camera_quality_retention.go +++ b/internal/provider/resource_meraki_camera_quality_retention.go @@ -128,7 +128,7 @@ func (r *CameraQualityRetentionResource) Configure(_ context.Context, req resour // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CameraQualityRetentionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CameraQualityRetention + var plan, initialState CameraQualityRetention // Read plan diags := req.Plan.Get(ctx, &plan) @@ -137,6 +137,14 @@ func (r *CameraQualityRetentionResource) Create(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CameraQualityRetention{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CameraQualityRetention{}) @@ -247,6 +255,18 @@ func (r *CameraQualityRetentionResource) Delete(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_camera_sense.go b/internal/provider/resource_meraki_camera_sense.go index 3aa8286f..7a6a525b 100644 --- a/internal/provider/resource_meraki_camera_sense.go +++ b/internal/provider/resource_meraki_camera_sense.go @@ -108,7 +108,7 @@ func (r *CameraSenseResource) Configure(_ context.Context, req resource.Configur // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CameraSenseResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CameraSense + var plan, initialState CameraSense // Read plan diags := req.Plan.Get(ctx, &plan) @@ -117,6 +117,14 @@ func (r *CameraSenseResource) Create(ctx context.Context, req resource.CreateReq } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CameraSense{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CameraSense{}) @@ -227,6 +235,18 @@ func (r *CameraSenseResource) Delete(ctx context.Context, req resource.DeleteReq } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_camera_video_settings.go b/internal/provider/resource_meraki_camera_video_settings.go index d542ef97..c2d13e9d 100644 --- a/internal/provider/resource_meraki_camera_video_settings.go +++ b/internal/provider/resource_meraki_camera_video_settings.go @@ -96,7 +96,7 @@ func (r *CameraVideoSettingsResource) Configure(_ context.Context, req resource. // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CameraVideoSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CameraVideoSettings + var plan, initialState CameraVideoSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -105,6 +105,14 @@ func (r *CameraVideoSettingsResource) Create(ctx context.Context, req resource.C } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CameraVideoSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CameraVideoSettings{}) @@ -215,6 +223,18 @@ func (r *CameraVideoSettingsResource) Delete(ctx context.Context, req resource.D } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_cellular_gateway_connectivity_monitoring_destinations.go b/internal/provider/resource_meraki_cellular_gateway_connectivity_monitoring_destinations.go index cd9edaae..afa6f0f8 100644 --- a/internal/provider/resource_meraki_cellular_gateway_connectivity_monitoring_destinations.go +++ b/internal/provider/resource_meraki_cellular_gateway_connectivity_monitoring_destinations.go @@ -112,7 +112,7 @@ func (r *CellularGatewayConnectivityMonitoringDestinationsResource) Configure(_ // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CellularGatewayConnectivityMonitoringDestinationsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CellularGatewayConnectivityMonitoringDestinations + var plan, initialState CellularGatewayConnectivityMonitoringDestinations // Read plan diags := req.Plan.Get(ctx, &plan) @@ -121,6 +121,14 @@ func (r *CellularGatewayConnectivityMonitoringDestinationsResource) Create(ctx c } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CellularGatewayConnectivityMonitoringDestinations{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CellularGatewayConnectivityMonitoringDestinations{}) @@ -231,10 +239,16 @@ func (r *CellularGatewayConnectivityMonitoringDestinationsResource) Delete(ctx c } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_cellular_gateway_dhcp.go b/internal/provider/resource_meraki_cellular_gateway_dhcp.go index b890f387..d0ed5d23 100644 --- a/internal/provider/resource_meraki_cellular_gateway_dhcp.go +++ b/internal/provider/resource_meraki_cellular_gateway_dhcp.go @@ -106,7 +106,7 @@ func (r *CellularGatewayDHCPResource) Configure(_ context.Context, req resource. // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CellularGatewayDHCPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CellularGatewayDHCP + var plan, initialState CellularGatewayDHCP // Read plan diags := req.Plan.Get(ctx, &plan) @@ -115,6 +115,14 @@ func (r *CellularGatewayDHCPResource) Create(ctx context.Context, req resource.C } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CellularGatewayDHCP{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CellularGatewayDHCP{}) @@ -225,6 +233,18 @@ func (r *CellularGatewayDHCPResource) Delete(ctx context.Context, req resource.D } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_cellular_gateway_lan.go b/internal/provider/resource_meraki_cellular_gateway_lan.go index d1fab8b0..d58afab2 100644 --- a/internal/provider/resource_meraki_cellular_gateway_lan.go +++ b/internal/provider/resource_meraki_cellular_gateway_lan.go @@ -132,7 +132,7 @@ func (r *CellularGatewayLANResource) Configure(_ context.Context, req resource.C // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CellularGatewayLANResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CellularGatewayLAN + var plan, initialState CellularGatewayLAN // Read plan diags := req.Plan.Get(ctx, &plan) @@ -141,6 +141,14 @@ func (r *CellularGatewayLANResource) Create(ctx context.Context, req resource.Cr } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CellularGatewayLAN{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CellularGatewayLAN{}) @@ -251,10 +259,16 @@ func (r *CellularGatewayLANResource) Delete(ctx context.Context, req resource.De } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_cellular_gateway_port_forwarding_rules.go b/internal/provider/resource_meraki_cellular_gateway_port_forwarding_rules.go index 5cca7284..6bc49a3d 100644 --- a/internal/provider/resource_meraki_cellular_gateway_port_forwarding_rules.go +++ b/internal/provider/resource_meraki_cellular_gateway_port_forwarding_rules.go @@ -130,7 +130,7 @@ func (r *CellularGatewayPortForwardingRulesResource) Configure(_ context.Context // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CellularGatewayPortForwardingRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CellularGatewayPortForwardingRules + var plan, initialState CellularGatewayPortForwardingRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -139,6 +139,14 @@ func (r *CellularGatewayPortForwardingRulesResource) Create(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CellularGatewayPortForwardingRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CellularGatewayPortForwardingRules{}) @@ -249,10 +257,16 @@ func (r *CellularGatewayPortForwardingRulesResource) Delete(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_cellular_gateway_subnet_pool.go b/internal/provider/resource_meraki_cellular_gateway_subnet_pool.go index 83af1f9d..078d3862 100644 --- a/internal/provider/resource_meraki_cellular_gateway_subnet_pool.go +++ b/internal/provider/resource_meraki_cellular_gateway_subnet_pool.go @@ -100,7 +100,7 @@ func (r *CellularGatewaySubnetPoolResource) Configure(_ context.Context, req res // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CellularGatewaySubnetPoolResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CellularGatewaySubnetPool + var plan, initialState CellularGatewaySubnetPool // Read plan diags := req.Plan.Get(ctx, &plan) @@ -109,6 +109,14 @@ func (r *CellularGatewaySubnetPoolResource) Create(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CellularGatewaySubnetPool{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CellularGatewaySubnetPool{}) @@ -219,6 +227,18 @@ func (r *CellularGatewaySubnetPoolResource) Delete(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_cellular_gateway_uplink.go b/internal/provider/resource_meraki_cellular_gateway_uplink.go index ad6c6cc8..b76c4d38 100644 --- a/internal/provider/resource_meraki_cellular_gateway_uplink.go +++ b/internal/provider/resource_meraki_cellular_gateway_uplink.go @@ -100,7 +100,7 @@ func (r *CellularGatewayUplinkResource) Configure(_ context.Context, req resourc // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CellularGatewayUplinkResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan CellularGatewayUplink + var plan, initialState CellularGatewayUplink // Read plan diags := req.Plan.Get(ctx, &plan) @@ -109,6 +109,14 @@ func (r *CellularGatewayUplinkResource) Create(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, CellularGatewayUplink{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, CellularGatewayUplink{}) @@ -219,6 +227,18 @@ func (r *CellularGatewayUplinkResource) Delete(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_device.go b/internal/provider/resource_meraki_device.go index 38413e08..8a398438 100644 --- a/internal/provider/resource_meraki_device.go +++ b/internal/provider/resource_meraki_device.go @@ -130,7 +130,7 @@ func (r *DeviceResource) Configure(_ context.Context, req resource.ConfigureRequ // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *DeviceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan Device + var plan, initialState Device // Read plan diags := req.Plan.Get(ctx, &plan) @@ -139,6 +139,14 @@ func (r *DeviceResource) Create(ctx context.Context, req resource.CreateRequest, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, Device{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, Device{}) @@ -249,6 +257,18 @@ func (r *DeviceResource) Delete(ctx context.Context, req resource.DeleteRequest, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_device_cellular_sims.go b/internal/provider/resource_meraki_device_cellular_sims.go index d6236611..48d9fdec 100644 --- a/internal/provider/resource_meraki_device_cellular_sims.go +++ b/internal/provider/resource_meraki_device_cellular_sims.go @@ -160,7 +160,7 @@ func (r *DeviceCellularSIMsResource) Configure(_ context.Context, req resource.C // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *DeviceCellularSIMsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan DeviceCellularSIMs + var plan, initialState DeviceCellularSIMs // Read plan diags := req.Plan.Get(ctx, &plan) @@ -169,6 +169,14 @@ func (r *DeviceCellularSIMsResource) Create(ctx context.Context, req resource.Cr } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, DeviceCellularSIMs{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, DeviceCellularSIMs{}) @@ -279,6 +287,18 @@ func (r *DeviceCellularSIMsResource) Delete(ctx context.Context, req resource.De } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_device_management_interface.go b/internal/provider/resource_meraki_device_management_interface.go index 621f446c..8846736f 100644 --- a/internal/provider/resource_meraki_device_management_interface.go +++ b/internal/provider/resource_meraki_device_management_interface.go @@ -159,7 +159,7 @@ func (r *DeviceManagementInterfaceResource) Configure(_ context.Context, req res // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *DeviceManagementInterfaceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan DeviceManagementInterface + var plan, initialState DeviceManagementInterface // Read plan diags := req.Plan.Get(ctx, &plan) @@ -168,6 +168,14 @@ func (r *DeviceManagementInterfaceResource) Create(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, DeviceManagementInterface{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, DeviceManagementInterface{}) @@ -278,6 +286,18 @@ func (r *DeviceManagementInterfaceResource) Delete(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_network_alerts_settings.go b/internal/provider/resource_meraki_network_alerts_settings.go index c4e4306b..d86f261c 100644 --- a/internal/provider/resource_meraki_network_alerts_settings.go +++ b/internal/provider/resource_meraki_network_alerts_settings.go @@ -240,7 +240,7 @@ func (r *NetworkAlertsSettingsResource) Configure(_ context.Context, req resourc // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *NetworkAlertsSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan NetworkAlertsSettings + var plan, initialState NetworkAlertsSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -249,6 +249,14 @@ func (r *NetworkAlertsSettingsResource) Create(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, NetworkAlertsSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, NetworkAlertsSettings{}) @@ -359,6 +367,18 @@ func (r *NetworkAlertsSettingsResource) Delete(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_network_client_policy.go b/internal/provider/resource_meraki_network_client_policy.go index 82643138..4eb882ca 100644 --- a/internal/provider/resource_meraki_network_client_policy.go +++ b/internal/provider/resource_meraki_network_client_policy.go @@ -107,7 +107,7 @@ func (r *NetworkClientPolicyResource) Configure(_ context.Context, req resource. // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *NetworkClientPolicyResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan NetworkClientPolicy + var plan, initialState NetworkClientPolicy // Read plan diags := req.Plan.Get(ctx, &plan) @@ -116,6 +116,14 @@ func (r *NetworkClientPolicyResource) Create(ctx context.Context, req resource.C } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, NetworkClientPolicy{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, NetworkClientPolicy{}) @@ -226,6 +234,18 @@ func (r *NetworkClientPolicyResource) Delete(ctx context.Context, req resource.D } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_network_client_splash_authorization_status.go b/internal/provider/resource_meraki_network_client_splash_authorization_status.go index c874786a..fddaf36e 100644 --- a/internal/provider/resource_meraki_network_client_splash_authorization_status.go +++ b/internal/provider/resource_meraki_network_client_splash_authorization_status.go @@ -159,7 +159,7 @@ func (r *NetworkClientSplashAuthorizationStatusResource) Configure(_ context.Con // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *NetworkClientSplashAuthorizationStatusResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan NetworkClientSplashAuthorizationStatus + var plan, initialState NetworkClientSplashAuthorizationStatus // Read plan diags := req.Plan.Get(ctx, &plan) @@ -168,6 +168,14 @@ func (r *NetworkClientSplashAuthorizationStatusResource) Create(ctx context.Cont } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, NetworkClientSplashAuthorizationStatus{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, NetworkClientSplashAuthorizationStatus{}) @@ -278,6 +286,18 @@ func (r *NetworkClientSplashAuthorizationStatusResource) Delete(ctx context.Cont } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_network_firmware_upgrades.go b/internal/provider/resource_meraki_network_firmware_upgrades.go index 3745d838..02b8ec0a 100644 --- a/internal/provider/resource_meraki_network_firmware_upgrades.go +++ b/internal/provider/resource_meraki_network_firmware_upgrades.go @@ -220,7 +220,7 @@ func (r *NetworkFirmwareUpgradesResource) Configure(_ context.Context, req resou // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *NetworkFirmwareUpgradesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan NetworkFirmwareUpgrades + var plan, initialState NetworkFirmwareUpgrades // Read plan diags := req.Plan.Get(ctx, &plan) @@ -229,6 +229,14 @@ func (r *NetworkFirmwareUpgradesResource) Create(ctx context.Context, req resour } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, NetworkFirmwareUpgrades{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, NetworkFirmwareUpgrades{}) @@ -339,6 +347,18 @@ func (r *NetworkFirmwareUpgradesResource) Delete(ctx context.Context, req resour } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_network_netflow.go b/internal/provider/resource_meraki_network_netflow.go index 4875b1cb..203ab2a9 100644 --- a/internal/provider/resource_meraki_network_netflow.go +++ b/internal/provider/resource_meraki_network_netflow.go @@ -112,7 +112,7 @@ func (r *NetworkNetflowResource) Configure(_ context.Context, req resource.Confi // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *NetworkNetflowResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan NetworkNetflow + var plan, initialState NetworkNetflow // Read plan diags := req.Plan.Get(ctx, &plan) @@ -121,6 +121,14 @@ func (r *NetworkNetflowResource) Create(ctx context.Context, req resource.Create } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, NetworkNetflow{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, NetworkNetflow{}) @@ -231,6 +239,18 @@ func (r *NetworkNetflowResource) Delete(ctx context.Context, req resource.Delete } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_network_settings.go b/internal/provider/resource_meraki_network_settings.go index 7a39af2b..0eeaad4a 100644 --- a/internal/provider/resource_meraki_network_settings.go +++ b/internal/provider/resource_meraki_network_settings.go @@ -120,7 +120,7 @@ func (r *NetworkSettingsResource) Configure(_ context.Context, req resource.Conf // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *NetworkSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan NetworkSettings + var plan, initialState NetworkSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -129,6 +129,14 @@ func (r *NetworkSettingsResource) Create(ctx context.Context, req resource.Creat } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, NetworkSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, NetworkSettings{}) @@ -239,6 +247,18 @@ func (r *NetworkSettingsResource) Delete(ctx context.Context, req resource.Delet } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_network_snmp.go b/internal/provider/resource_meraki_network_snmp.go index 80030877..0736966a 100644 --- a/internal/provider/resource_meraki_network_snmp.go +++ b/internal/provider/resource_meraki_network_snmp.go @@ -121,7 +121,7 @@ func (r *NetworkSNMPResource) Configure(_ context.Context, req resource.Configur // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *NetworkSNMPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan NetworkSNMP + var plan, initialState NetworkSNMP // Read plan diags := req.Plan.Get(ctx, &plan) @@ -130,6 +130,14 @@ func (r *NetworkSNMPResource) Create(ctx context.Context, req resource.CreateReq } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, NetworkSNMP{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, NetworkSNMP{}) @@ -240,6 +248,18 @@ func (r *NetworkSNMPResource) Delete(ctx context.Context, req resource.DeleteReq } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_network_syslog_servers.go b/internal/provider/resource_meraki_network_syslog_servers.go index 7dab6467..f0feb98b 100644 --- a/internal/provider/resource_meraki_network_syslog_servers.go +++ b/internal/provider/resource_meraki_network_syslog_servers.go @@ -114,7 +114,7 @@ func (r *NetworkSyslogServersResource) Configure(_ context.Context, req resource // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *NetworkSyslogServersResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan NetworkSyslogServers + var plan, initialState NetworkSyslogServers // Read plan diags := req.Plan.Get(ctx, &plan) @@ -123,6 +123,14 @@ func (r *NetworkSyslogServersResource) Create(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, NetworkSyslogServers{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, NetworkSyslogServers{}) @@ -233,10 +241,16 @@ func (r *NetworkSyslogServersResource) Delete(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_network_traffic_analysis.go b/internal/provider/resource_meraki_network_traffic_analysis.go index 65740033..41ae744a 100644 --- a/internal/provider/resource_meraki_network_traffic_analysis.go +++ b/internal/provider/resource_meraki_network_traffic_analysis.go @@ -124,7 +124,7 @@ func (r *NetworkTrafficAnalysisResource) Configure(_ context.Context, req resour // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *NetworkTrafficAnalysisResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan NetworkTrafficAnalysis + var plan, initialState NetworkTrafficAnalysis // Read plan diags := req.Plan.Get(ctx, &plan) @@ -133,6 +133,14 @@ func (r *NetworkTrafficAnalysisResource) Create(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, NetworkTrafficAnalysis{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, NetworkTrafficAnalysis{}) @@ -243,6 +251,18 @@ func (r *NetworkTrafficAnalysisResource) Delete(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_organization_adaptive_policy_settings.go b/internal/provider/resource_meraki_organization_adaptive_policy_settings.go index fc794150..de94a921 100644 --- a/internal/provider/resource_meraki_organization_adaptive_policy_settings.go +++ b/internal/provider/resource_meraki_organization_adaptive_policy_settings.go @@ -98,7 +98,7 @@ func (r *OrganizationAdaptivePolicySettingsResource) Configure(_ context.Context // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *OrganizationAdaptivePolicySettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan OrganizationAdaptivePolicySettings + var plan, initialState OrganizationAdaptivePolicySettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -107,6 +107,14 @@ func (r *OrganizationAdaptivePolicySettingsResource) Create(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, OrganizationAdaptivePolicySettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, OrganizationAdaptivePolicySettings{}) @@ -217,6 +225,18 @@ func (r *OrganizationAdaptivePolicySettingsResource) Delete(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_organization_branding_policies_priorities.go b/internal/provider/resource_meraki_organization_branding_policies_priorities.go index f4222dde..10e10e73 100644 --- a/internal/provider/resource_meraki_organization_branding_policies_priorities.go +++ b/internal/provider/resource_meraki_organization_branding_policies_priorities.go @@ -98,7 +98,7 @@ func (r *OrganizationBrandingPoliciesPrioritiesResource) Configure(_ context.Con // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *OrganizationBrandingPoliciesPrioritiesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan OrganizationBrandingPoliciesPriorities + var plan, initialState OrganizationBrandingPoliciesPriorities // Read plan diags := req.Plan.Get(ctx, &plan) @@ -107,6 +107,14 @@ func (r *OrganizationBrandingPoliciesPrioritiesResource) Create(ctx context.Cont } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, OrganizationBrandingPoliciesPriorities{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, OrganizationBrandingPoliciesPriorities{}) @@ -217,6 +225,18 @@ func (r *OrganizationBrandingPoliciesPrioritiesResource) Delete(ctx context.Cont } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_organization_license.go b/internal/provider/resource_meraki_organization_license.go index 340f01b7..52503d80 100644 --- a/internal/provider/resource_meraki_organization_license.go +++ b/internal/provider/resource_meraki_organization_license.go @@ -103,7 +103,7 @@ func (r *OrganizationLicenseResource) Configure(_ context.Context, req resource. // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *OrganizationLicenseResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan OrganizationLicense + var plan, initialState OrganizationLicense // Read plan diags := req.Plan.Get(ctx, &plan) @@ -112,6 +112,14 @@ func (r *OrganizationLicenseResource) Create(ctx context.Context, req resource.C } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, OrganizationLicense{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, OrganizationLicense{}) @@ -222,6 +230,18 @@ func (r *OrganizationLicenseResource) Delete(ctx context.Context, req resource.D } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_organization_login_security.go b/internal/provider/resource_meraki_organization_login_security.go index a77d4be1..734a6d4b 100644 --- a/internal/provider/resource_meraki_organization_login_security.go +++ b/internal/provider/resource_meraki_organization_login_security.go @@ -160,7 +160,7 @@ func (r *OrganizationLoginSecurityResource) Configure(_ context.Context, req res // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *OrganizationLoginSecurityResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan OrganizationLoginSecurity + var plan, initialState OrganizationLoginSecurity // Read plan diags := req.Plan.Get(ctx, &plan) @@ -169,6 +169,14 @@ func (r *OrganizationLoginSecurityResource) Create(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, OrganizationLoginSecurity{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, OrganizationLoginSecurity{}) @@ -279,6 +287,18 @@ func (r *OrganizationLoginSecurityResource) Delete(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_organization_saml.go b/internal/provider/resource_meraki_organization_saml.go index 68e8e220..69bc4ccb 100644 --- a/internal/provider/resource_meraki_organization_saml.go +++ b/internal/provider/resource_meraki_organization_saml.go @@ -96,7 +96,7 @@ func (r *OrganizationSAMLResource) Configure(_ context.Context, req resource.Con // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *OrganizationSAMLResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan OrganizationSAML + var plan, initialState OrganizationSAML // Read plan diags := req.Plan.Get(ctx, &plan) @@ -105,6 +105,14 @@ func (r *OrganizationSAMLResource) Create(ctx context.Context, req resource.Crea } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, OrganizationSAML{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, OrganizationSAML{}) @@ -215,6 +223,18 @@ func (r *OrganizationSAMLResource) Delete(ctx context.Context, req resource.Dele } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_organization_snmp.go b/internal/provider/resource_meraki_organization_snmp.go index 782b5438..1fede594 100644 --- a/internal/provider/resource_meraki_organization_snmp.go +++ b/internal/provider/resource_meraki_organization_snmp.go @@ -130,7 +130,7 @@ func (r *OrganizationSNMPResource) Configure(_ context.Context, req resource.Con // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *OrganizationSNMPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan OrganizationSNMP + var plan, initialState OrganizationSNMP // Read plan diags := req.Plan.Get(ctx, &plan) @@ -139,6 +139,14 @@ func (r *OrganizationSNMPResource) Create(ctx context.Context, req resource.Crea } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, OrganizationSNMP{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, OrganizationSNMP{}) @@ -249,6 +257,18 @@ func (r *OrganizationSNMPResource) Delete(ctx context.Context, req resource.Dele } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_sensor_mqtt_broker.go b/internal/provider/resource_meraki_sensor_mqtt_broker.go index af5562ec..8086a9d0 100644 --- a/internal/provider/resource_meraki_sensor_mqtt_broker.go +++ b/internal/provider/resource_meraki_sensor_mqtt_broker.go @@ -103,7 +103,7 @@ func (r *SensorMQTTBrokerResource) Configure(_ context.Context, req resource.Con // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SensorMQTTBrokerResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SensorMQTTBroker + var plan, initialState SensorMQTTBroker // Read plan diags := req.Plan.Get(ctx, &plan) @@ -112,6 +112,14 @@ func (r *SensorMQTTBrokerResource) Create(ctx context.Context, req resource.Crea } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SensorMQTTBroker{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SensorMQTTBroker{}) @@ -222,10 +230,16 @@ func (r *SensorMQTTBrokerResource) Delete(ctx context.Context, req resource.Dele } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_sensor_mqtt_brokers.go b/internal/provider/resource_meraki_sensor_mqtt_brokers.go index 3639e7d5..7547cf19 100644 --- a/internal/provider/resource_meraki_sensor_mqtt_brokers.go +++ b/internal/provider/resource_meraki_sensor_mqtt_brokers.go @@ -234,7 +234,7 @@ func (r *SensorMQTTBrokersResource) Update(ctx context.Context, req resource.Upd actions = append(actions, meraki.ActionModel{ Operation: "update", Resource: plan.getItemPath(itemState.MqttBrokerId.ValueString()), - Body: plan.toDestroyBody(ctx), + Body: plan.addDeleteValues(ctx), }) } } @@ -304,7 +304,7 @@ func (r *SensorMQTTBrokersResource) Delete(ctx context.Context, req resource.Del actions[i] = meraki.ActionModel{ Operation: "update", Resource: state.getItemPath(item.MqttBrokerId.ValueString()), - Body: state.toDestroyBody(ctx), + Body: state.addDeleteValues(ctx), } } if len(actions) > 0 { diff --git a/internal/provider/resource_meraki_sensor_relationships.go b/internal/provider/resource_meraki_sensor_relationships.go index c50c5940..3863328a 100644 --- a/internal/provider/resource_meraki_sensor_relationships.go +++ b/internal/provider/resource_meraki_sensor_relationships.go @@ -104,7 +104,7 @@ func (r *SensorRelationshipsResource) Configure(_ context.Context, req resource. // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SensorRelationshipsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SensorRelationships + var plan, initialState SensorRelationships // Read plan diags := req.Plan.Get(ctx, &plan) @@ -113,6 +113,14 @@ func (r *SensorRelationshipsResource) Create(ctx context.Context, req resource.C } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SensorRelationships{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SensorRelationships{}) @@ -223,6 +231,18 @@ func (r *SensorRelationshipsResource) Delete(ctx context.Context, req resource.D } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_access_control_lists.go b/internal/provider/resource_meraki_switch_access_control_lists.go index 8215d311..3044cacc 100644 --- a/internal/provider/resource_meraki_switch_access_control_lists.go +++ b/internal/provider/resource_meraki_switch_access_control_lists.go @@ -147,7 +147,7 @@ func (r *SwitchAccessControlListsResource) Configure(_ context.Context, req reso // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchAccessControlListsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchAccessControlLists + var plan, initialState SwitchAccessControlLists // Read plan diags := req.Plan.Get(ctx, &plan) @@ -156,6 +156,14 @@ func (r *SwitchAccessControlListsResource) Create(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchAccessControlLists{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchAccessControlLists{}) @@ -266,10 +274,16 @@ func (r *SwitchAccessControlListsResource) Delete(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_switch_alternate_management_interface.go b/internal/provider/resource_meraki_switch_alternate_management_interface.go index 21451053..32ee2283 100644 --- a/internal/provider/resource_meraki_switch_alternate_management_interface.go +++ b/internal/provider/resource_meraki_switch_alternate_management_interface.go @@ -130,7 +130,7 @@ func (r *SwitchAlternateManagementInterfaceResource) Configure(_ context.Context // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchAlternateManagementInterfaceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchAlternateManagementInterface + var plan, initialState SwitchAlternateManagementInterface // Read plan diags := req.Plan.Get(ctx, &plan) @@ -139,6 +139,14 @@ func (r *SwitchAlternateManagementInterfaceResource) Create(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchAlternateManagementInterface{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchAlternateManagementInterface{}) @@ -249,6 +257,18 @@ func (r *SwitchAlternateManagementInterfaceResource) Delete(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_dhcp_server_policy.go b/internal/provider/resource_meraki_switch_dhcp_server_policy.go index f4118cfe..3b9f07ba 100644 --- a/internal/provider/resource_meraki_switch_dhcp_server_policy.go +++ b/internal/provider/resource_meraki_switch_dhcp_server_policy.go @@ -120,7 +120,7 @@ func (r *SwitchDHCPServerPolicyResource) Configure(_ context.Context, req resour // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchDHCPServerPolicyResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchDHCPServerPolicy + var plan, initialState SwitchDHCPServerPolicy // Read plan diags := req.Plan.Get(ctx, &plan) @@ -129,6 +129,14 @@ func (r *SwitchDHCPServerPolicyResource) Create(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchDHCPServerPolicy{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchDHCPServerPolicy{}) @@ -239,6 +247,18 @@ func (r *SwitchDHCPServerPolicyResource) Delete(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_dscp_to_cos_mappings.go b/internal/provider/resource_meraki_switch_dscp_to_cos_mappings.go index 9e45aa75..9107b2ad 100644 --- a/internal/provider/resource_meraki_switch_dscp_to_cos_mappings.go +++ b/internal/provider/resource_meraki_switch_dscp_to_cos_mappings.go @@ -112,7 +112,7 @@ func (r *SwitchDSCPToCoSMappingsResource) Configure(_ context.Context, req resou // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchDSCPToCoSMappingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchDSCPToCoSMappings + var plan, initialState SwitchDSCPToCoSMappings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -121,6 +121,14 @@ func (r *SwitchDSCPToCoSMappingsResource) Create(ctx context.Context, req resour } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchDSCPToCoSMappings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchDSCPToCoSMappings{}) @@ -231,10 +239,16 @@ func (r *SwitchDSCPToCoSMappingsResource) Delete(ctx context.Context, req resour } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_switch_mtu.go b/internal/provider/resource_meraki_switch_mtu.go index 74d02205..d4e50d6a 100644 --- a/internal/provider/resource_meraki_switch_mtu.go +++ b/internal/provider/resource_meraki_switch_mtu.go @@ -119,7 +119,7 @@ func (r *SwitchMTUResource) Configure(_ context.Context, req resource.ConfigureR // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchMTUResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchMTU + var plan, initialState SwitchMTU // Read plan diags := req.Plan.Get(ctx, &plan) @@ -128,6 +128,14 @@ func (r *SwitchMTUResource) Create(ctx context.Context, req resource.CreateReque } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchMTU{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchMTU{}) @@ -238,6 +246,18 @@ func (r *SwitchMTUResource) Delete(ctx context.Context, req resource.DeleteReque } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_port.go b/internal/provider/resource_meraki_switch_port.go index 93e34dd3..83d6443b 100644 --- a/internal/provider/resource_meraki_switch_port.go +++ b/internal/provider/resource_meraki_switch_port.go @@ -237,7 +237,7 @@ func (r *SwitchPortResource) Configure(_ context.Context, req resource.Configure // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchPortResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchPort + var plan, initialState SwitchPort // Read plan diags := req.Plan.Get(ctx, &plan) @@ -246,6 +246,14 @@ func (r *SwitchPortResource) Create(ctx context.Context, req resource.CreateRequ } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchPort{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchPort{}) @@ -356,10 +364,16 @@ func (r *SwitchPortResource) Delete(ctx context.Context, req resource.DeleteRequ } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_switch_ports.go b/internal/provider/resource_meraki_switch_ports.go index df9b1b03..1137d4c7 100644 --- a/internal/provider/resource_meraki_switch_ports.go +++ b/internal/provider/resource_meraki_switch_ports.go @@ -365,7 +365,7 @@ func (r *SwitchPortsResource) Update(ctx context.Context, req resource.UpdateReq actions = append(actions, meraki.ActionModel{ Operation: "update", Resource: plan.getItemPath(itemState.PortId.ValueString()), - Body: itemState.toDestroyBody(ctx), + Body: itemState.addDeleteValues(ctx), }) } } @@ -431,7 +431,7 @@ func (r *SwitchPortsResource) Delete(ctx context.Context, req resource.DeleteReq actions[i] = meraki.ActionModel{ Operation: "update", Resource: state.getItemPath(item.PortId.ValueString()), - Body: item.toDestroyBody(ctx), + Body: item.addDeleteValues(ctx), } } if len(actions) > 0 { diff --git a/internal/provider/resource_meraki_switch_qos_rule_order.go b/internal/provider/resource_meraki_switch_qos_rule_order.go index 50af5e9d..8e2b2cfe 100644 --- a/internal/provider/resource_meraki_switch_qos_rule_order.go +++ b/internal/provider/resource_meraki_switch_qos_rule_order.go @@ -98,7 +98,7 @@ func (r *SwitchQoSRuleOrderResource) Configure(_ context.Context, req resource.C // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchQoSRuleOrderResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchQoSRuleOrder + var plan, initialState SwitchQoSRuleOrder // Read plan diags := req.Plan.Get(ctx, &plan) @@ -107,6 +107,14 @@ func (r *SwitchQoSRuleOrderResource) Create(ctx context.Context, req resource.Cr } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchQoSRuleOrder{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchQoSRuleOrder{}) @@ -217,6 +225,18 @@ func (r *SwitchQoSRuleOrderResource) Delete(ctx context.Context, req resource.De } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_routing_interface_dhcp.go b/internal/provider/resource_meraki_switch_routing_interface_dhcp.go index bd58b2e1..90a6dc4f 100644 --- a/internal/provider/resource_meraki_switch_routing_interface_dhcp.go +++ b/internal/provider/resource_meraki_switch_routing_interface_dhcp.go @@ -208,7 +208,7 @@ func (r *SwitchRoutingInterfaceDHCPResource) Configure(_ context.Context, req re // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchRoutingInterfaceDHCPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchRoutingInterfaceDHCP + var plan, initialState SwitchRoutingInterfaceDHCP // Read plan diags := req.Plan.Get(ctx, &plan) @@ -217,6 +217,14 @@ func (r *SwitchRoutingInterfaceDHCPResource) Create(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchRoutingInterfaceDHCP{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchRoutingInterfaceDHCP{}) @@ -327,6 +335,18 @@ func (r *SwitchRoutingInterfaceDHCPResource) Delete(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_routing_multicast.go b/internal/provider/resource_meraki_switch_routing_multicast.go index 05b311f0..05857f86 100644 --- a/internal/provider/resource_meraki_switch_routing_multicast.go +++ b/internal/provider/resource_meraki_switch_routing_multicast.go @@ -132,7 +132,7 @@ func (r *SwitchRoutingMulticastResource) Configure(_ context.Context, req resour // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchRoutingMulticastResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchRoutingMulticast + var plan, initialState SwitchRoutingMulticast // Read plan diags := req.Plan.Get(ctx, &plan) @@ -141,6 +141,14 @@ func (r *SwitchRoutingMulticastResource) Create(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchRoutingMulticast{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchRoutingMulticast{}) @@ -251,6 +259,18 @@ func (r *SwitchRoutingMulticastResource) Delete(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_routing_ospf.go b/internal/provider/resource_meraki_switch_routing_ospf.go index aa5fc095..769237b0 100644 --- a/internal/provider/resource_meraki_switch_routing_ospf.go +++ b/internal/provider/resource_meraki_switch_routing_ospf.go @@ -176,7 +176,7 @@ func (r *SwitchRoutingOSPFResource) Configure(_ context.Context, req resource.Co // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchRoutingOSPFResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchRoutingOSPF + var plan, initialState SwitchRoutingOSPF // Read plan diags := req.Plan.Get(ctx, &plan) @@ -185,6 +185,14 @@ func (r *SwitchRoutingOSPFResource) Create(ctx context.Context, req resource.Cre } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchRoutingOSPF{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchRoutingOSPF{}) @@ -295,6 +303,18 @@ func (r *SwitchRoutingOSPFResource) Delete(ctx context.Context, req resource.Del } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_settings.go b/internal/provider/resource_meraki_switch_settings.go index 681e7420..1b8b8e9f 100644 --- a/internal/provider/resource_meraki_switch_settings.go +++ b/internal/provider/resource_meraki_switch_settings.go @@ -129,7 +129,7 @@ func (r *SwitchSettingsResource) Configure(_ context.Context, req resource.Confi // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchSettings + var plan, initialState SwitchSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -138,6 +138,14 @@ func (r *SwitchSettingsResource) Create(ctx context.Context, req resource.Create } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchSettings{}) @@ -248,6 +256,18 @@ func (r *SwitchSettingsResource) Delete(ctx context.Context, req resource.Delete } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_stack_routing_interface_dhcp.go b/internal/provider/resource_meraki_switch_stack_routing_interface_dhcp.go index 871b53bf..efd99592 100644 --- a/internal/provider/resource_meraki_switch_stack_routing_interface_dhcp.go +++ b/internal/provider/resource_meraki_switch_stack_routing_interface_dhcp.go @@ -215,7 +215,7 @@ func (r *SwitchStackRoutingInterfaceDHCPResource) Configure(_ context.Context, r // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchStackRoutingInterfaceDHCPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchStackRoutingInterfaceDHCP + var plan, initialState SwitchStackRoutingInterfaceDHCP // Read plan diags := req.Plan.Get(ctx, &plan) @@ -224,6 +224,14 @@ func (r *SwitchStackRoutingInterfaceDHCPResource) Create(ctx context.Context, re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchStackRoutingInterfaceDHCP{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchStackRoutingInterfaceDHCP{}) @@ -334,6 +342,18 @@ func (r *SwitchStackRoutingInterfaceDHCPResource) Delete(ctx context.Context, re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_storm_control.go b/internal/provider/resource_meraki_switch_storm_control.go index 575dec05..02cccbbf 100644 --- a/internal/provider/resource_meraki_switch_storm_control.go +++ b/internal/provider/resource_meraki_switch_storm_control.go @@ -110,7 +110,7 @@ func (r *SwitchStormControlResource) Configure(_ context.Context, req resource.C // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchStormControlResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchStormControl + var plan, initialState SwitchStormControl // Read plan diags := req.Plan.Get(ctx, &plan) @@ -119,6 +119,14 @@ func (r *SwitchStormControlResource) Create(ctx context.Context, req resource.Cr } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchStormControl{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchStormControl{}) @@ -229,6 +237,18 @@ func (r *SwitchStormControlResource) Delete(ctx context.Context, req resource.De } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_stp.go b/internal/provider/resource_meraki_switch_stp.go index d4fbab17..9a3fd9bc 100644 --- a/internal/provider/resource_meraki_switch_stp.go +++ b/internal/provider/resource_meraki_switch_stp.go @@ -124,7 +124,7 @@ func (r *SwitchSTPResource) Configure(_ context.Context, req resource.ConfigureR // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchSTPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchSTP + var plan, initialState SwitchSTP // Read plan diags := req.Plan.Get(ctx, &plan) @@ -133,6 +133,14 @@ func (r *SwitchSTPResource) Create(ctx context.Context, req resource.CreateReque } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchSTP{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchSTP{}) @@ -243,6 +251,18 @@ func (r *SwitchSTPResource) Delete(ctx context.Context, req resource.DeleteReque } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_switch_warm_spare.go b/internal/provider/resource_meraki_switch_warm_spare.go index dc6e310d..00b5230c 100644 --- a/internal/provider/resource_meraki_switch_warm_spare.go +++ b/internal/provider/resource_meraki_switch_warm_spare.go @@ -100,7 +100,7 @@ func (r *SwitchWarmSpareResource) Configure(_ context.Context, req resource.Conf // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *SwitchWarmSpareResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan SwitchWarmSpare + var plan, initialState SwitchWarmSpare // Read plan diags := req.Plan.Get(ctx, &plan) @@ -109,6 +109,14 @@ func (r *SwitchWarmSpareResource) Create(ctx context.Context, req resource.Creat } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, SwitchWarmSpare{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, SwitchWarmSpare{}) @@ -219,6 +227,18 @@ func (r *SwitchWarmSpareResource) Delete(ctx context.Context, req resource.Delet } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_air_marshal_settings.go b/internal/provider/resource_meraki_wireless_air_marshal_settings.go index 883389ad..1d3b1e8a 100644 --- a/internal/provider/resource_meraki_wireless_air_marshal_settings.go +++ b/internal/provider/resource_meraki_wireless_air_marshal_settings.go @@ -98,10 +98,8 @@ func (r *WirelessAirMarshalSettingsResource) Configure(_ context.Context, req re // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin create - func (r *WirelessAirMarshalSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessAirMarshalSettings + var plan, initialState WirelessAirMarshalSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -110,6 +108,22 @@ func (r *WirelessAirMarshalSettingsResource) Create(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + networkPath := fmt.Sprintf("/networks/%v", plan.NetworkId.ValueString()) + nres, err := r.client.Get(networkPath) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve network (GET), got error: %s, %s", err, nres.String())) + return + } + orgId := nres.Get("organizationId").String() + settingsPath := fmt.Sprintf("/organizations/%v/wireless/airMarshal/settings/byNetwork?networkIds[]=%v", orgId, plan.NetworkId.ValueString()) + gres, err := r.client.Get(settingsPath) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve rules (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, meraki.Res{Result: gres.Get("items.0")}) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessAirMarshalSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessAirMarshalSettings{}) @@ -129,8 +143,6 @@ func (r *WirelessAirMarshalSettingsResource) Create(ctx context.Context, req res helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end create - func (r *WirelessAirMarshalSettingsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state WirelessAirMarshalSettings @@ -231,6 +243,18 @@ func (r *WirelessAirMarshalSettingsResource) Delete(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_alternate_management_interface.go b/internal/provider/resource_meraki_wireless_alternate_management_interface.go index 268dca95..717aa063 100644 --- a/internal/provider/resource_meraki_wireless_alternate_management_interface.go +++ b/internal/provider/resource_meraki_wireless_alternate_management_interface.go @@ -138,7 +138,7 @@ func (r *WirelessAlternateManagementInterfaceResource) Configure(_ context.Conte // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessAlternateManagementInterfaceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessAlternateManagementInterface + var plan, initialState WirelessAlternateManagementInterface // Read plan diags := req.Plan.Get(ctx, &plan) @@ -147,6 +147,14 @@ func (r *WirelessAlternateManagementInterfaceResource) Create(ctx context.Contex } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessAlternateManagementInterface{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessAlternateManagementInterface{}) @@ -257,6 +265,18 @@ func (r *WirelessAlternateManagementInterfaceResource) Delete(ctx context.Contex } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_billing.go b/internal/provider/resource_meraki_wireless_billing.go index ed9ec60f..ee725dc9 100644 --- a/internal/provider/resource_meraki_wireless_billing.go +++ b/internal/provider/resource_meraki_wireless_billing.go @@ -125,7 +125,7 @@ func (r *WirelessBillingResource) Configure(_ context.Context, req resource.Conf // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessBillingResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessBilling + var plan, initialState WirelessBilling // Read plan diags := req.Plan.Get(ctx, &plan) @@ -134,6 +134,14 @@ func (r *WirelessBillingResource) Create(ctx context.Context, req resource.Creat } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessBilling{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessBilling{}) @@ -244,6 +252,18 @@ func (r *WirelessBillingResource) Delete(ctx context.Context, req resource.Delet } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_device_bluetooth_settings.go b/internal/provider/resource_meraki_wireless_device_bluetooth_settings.go index 4a13efd3..1e9f2589 100644 --- a/internal/provider/resource_meraki_wireless_device_bluetooth_settings.go +++ b/internal/provider/resource_meraki_wireless_device_bluetooth_settings.go @@ -104,7 +104,7 @@ func (r *WirelessDeviceBluetoothSettingsResource) Configure(_ context.Context, r // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessDeviceBluetoothSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessDeviceBluetoothSettings + var plan, initialState WirelessDeviceBluetoothSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -113,6 +113,14 @@ func (r *WirelessDeviceBluetoothSettingsResource) Create(ctx context.Context, re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessDeviceBluetoothSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessDeviceBluetoothSettings{}) @@ -223,6 +231,18 @@ func (r *WirelessDeviceBluetoothSettingsResource) Delete(ctx context.Context, re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_device_electronic_shelf_label.go b/internal/provider/resource_meraki_wireless_device_electronic_shelf_label.go index 191f2389..35353921 100644 --- a/internal/provider/resource_meraki_wireless_device_electronic_shelf_label.go +++ b/internal/provider/resource_meraki_wireless_device_electronic_shelf_label.go @@ -100,7 +100,7 @@ func (r *WirelessDeviceElectronicShelfLabelResource) Configure(_ context.Context // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessDeviceElectronicShelfLabelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessDeviceElectronicShelfLabel + var plan, initialState WirelessDeviceElectronicShelfLabel // Read plan diags := req.Plan.Get(ctx, &plan) @@ -109,6 +109,14 @@ func (r *WirelessDeviceElectronicShelfLabelResource) Create(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessDeviceElectronicShelfLabel{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessDeviceElectronicShelfLabel{}) @@ -219,6 +227,18 @@ func (r *WirelessDeviceElectronicShelfLabelResource) Delete(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_location_scanning.go b/internal/provider/resource_meraki_wireless_location_scanning.go index d0cce03b..c1722de8 100644 --- a/internal/provider/resource_meraki_wireless_location_scanning.go +++ b/internal/provider/resource_meraki_wireless_location_scanning.go @@ -98,10 +98,8 @@ func (r *WirelessLocationScanningResource) Configure(_ context.Context, req reso // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin create - func (r *WirelessLocationScanningResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessLocationScanning + var plan, initialState WirelessLocationScanning // Read plan diags := req.Plan.Get(ctx, &plan) @@ -110,6 +108,31 @@ func (r *WirelessLocationScanningResource) Create(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + networkPath := fmt.Sprintf("/networks/%v", plan.NetworkId.ValueString()) + nres, err := r.client.Get(networkPath) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve network (GET), got error: %s, %s", err, nres.String())) + return + } + orgId := nres.Get("organizationId").String() + getPath := fmt.Sprintf("/organizations/%v/wireless/location/scanning/byNetwork", orgId) + gres, err := r.client.Get(getPath) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve wireless location scanning (GET), got error: %s, %s", err, gres.String())) + return + } + if len(gres.Get("items").Array()) > 0 { + gres.Get("items").ForEach(func(k, v gjson.Result) bool { + if plan.NetworkId.ValueString() == v.Get("networkId").String() { + gres = meraki.Res{Result: v} + return false + } + return true + }) + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessLocationScanning{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessLocationScanning{}) @@ -129,8 +152,6 @@ func (r *WirelessLocationScanningResource) Create(ctx context.Context, req resou helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end create - func (r *WirelessLocationScanningResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state WirelessLocationScanning @@ -165,7 +186,7 @@ func (r *WirelessLocationScanningResource) Read(ctx context.Context, req resourc if len(res.Get("items").Array()) > 0 { res.Get("items").ForEach(func(k, v gjson.Result) bool { - if state.Id.ValueString() == v.Get("networkId").String() { + if state.NetworkId.ValueString() == v.Get("networkId").String() { res = meraki.Res{Result: v} return false } @@ -239,6 +260,18 @@ func (r *WirelessLocationScanningResource) Delete(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_network_bluetooth_settings.go b/internal/provider/resource_meraki_wireless_network_bluetooth_settings.go index e6cee7d4..d956355e 100644 --- a/internal/provider/resource_meraki_wireless_network_bluetooth_settings.go +++ b/internal/provider/resource_meraki_wireless_network_bluetooth_settings.go @@ -121,7 +121,7 @@ func (r *WirelessNetworkBluetoothSettingsResource) Configure(_ context.Context, // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessNetworkBluetoothSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessNetworkBluetoothSettings + var plan, initialState WirelessNetworkBluetoothSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -130,6 +130,14 @@ func (r *WirelessNetworkBluetoothSettingsResource) Create(ctx context.Context, r } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessNetworkBluetoothSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessNetworkBluetoothSettings{}) @@ -240,6 +248,18 @@ func (r *WirelessNetworkBluetoothSettingsResource) Delete(ctx context.Context, r } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_network_electronic_shelf_label.go b/internal/provider/resource_meraki_wireless_network_electronic_shelf_label.go index 73ceba85..c963bcf8 100644 --- a/internal/provider/resource_meraki_wireless_network_electronic_shelf_label.go +++ b/internal/provider/resource_meraki_wireless_network_electronic_shelf_label.go @@ -109,7 +109,7 @@ func (r *WirelessNetworkElectronicShelfLabelResource) Configure(_ context.Contex // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessNetworkElectronicShelfLabelResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessNetworkElectronicShelfLabel + var plan, initialState WirelessNetworkElectronicShelfLabel // Read plan diags := req.Plan.Get(ctx, &plan) @@ -118,6 +118,14 @@ func (r *WirelessNetworkElectronicShelfLabelResource) Create(ctx context.Context } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessNetworkElectronicShelfLabel{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessNetworkElectronicShelfLabel{}) @@ -228,6 +236,18 @@ func (r *WirelessNetworkElectronicShelfLabelResource) Delete(ctx context.Context } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_radio_settings.go b/internal/provider/resource_meraki_wireless_radio_settings.go index 593d9767..a2bed7ca 100644 --- a/internal/provider/resource_meraki_wireless_radio_settings.go +++ b/internal/provider/resource_meraki_wireless_radio_settings.go @@ -116,7 +116,7 @@ func (r *WirelessRadioSettingsResource) Configure(_ context.Context, req resourc // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessRadioSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessRadioSettings + var plan, initialState WirelessRadioSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -125,6 +125,14 @@ func (r *WirelessRadioSettingsResource) Create(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessRadioSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessRadioSettings{}) @@ -235,6 +243,18 @@ func (r *WirelessRadioSettingsResource) Delete(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_settings.go b/internal/provider/resource_meraki_wireless_settings.go index db249bbe..2c9ebc16 100644 --- a/internal/provider/resource_meraki_wireless_settings.go +++ b/internal/provider/resource_meraki_wireless_settings.go @@ -125,7 +125,7 @@ func (r *WirelessSettingsResource) Configure(_ context.Context, req resource.Con // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSettings + var plan, initialState WirelessSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -134,6 +134,14 @@ func (r *WirelessSettingsResource) Create(ctx context.Context, req resource.Crea } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSettings{}) @@ -244,6 +252,18 @@ func (r *WirelessSettingsResource) Delete(ctx context.Context, req resource.Dele } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_ssid.go b/internal/provider/resource_meraki_wireless_ssid.go index a85c7d54..203883d8 100644 --- a/internal/provider/resource_meraki_wireless_ssid.go +++ b/internal/provider/resource_meraki_wireless_ssid.go @@ -581,7 +581,7 @@ func (r *WirelessSSIDResource) Configure(_ context.Context, req resource.Configu // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSID + var plan, initialState WirelessSSID // Read plan diags := req.Plan.Get(ctx, &plan) @@ -590,6 +590,14 @@ func (r *WirelessSSIDResource) Create(ctx context.Context, req resource.CreateRe } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSID{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSID{}) @@ -700,10 +708,16 @@ func (r *WirelessSSIDResource) Delete(ctx context.Context, req resource.DeleteRe } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_wireless_ssid_bonjour_forwarding.go b/internal/provider/resource_meraki_wireless_ssid_bonjour_forwarding.go index 7fd5f370..8167dcb1 100644 --- a/internal/provider/resource_meraki_wireless_ssid_bonjour_forwarding.go +++ b/internal/provider/resource_meraki_wireless_ssid_bonjour_forwarding.go @@ -129,7 +129,7 @@ func (r *WirelessSSIDBonjourForwardingResource) Configure(_ context.Context, req // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDBonjourForwardingResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSIDBonjourForwarding + var plan, initialState WirelessSSIDBonjourForwarding // Read plan diags := req.Plan.Get(ctx, &plan) @@ -138,6 +138,14 @@ func (r *WirelessSSIDBonjourForwardingResource) Create(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSIDBonjourForwarding{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSIDBonjourForwarding{}) @@ -248,6 +256,18 @@ func (r *WirelessSSIDBonjourForwardingResource) Delete(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_ssid_device_type_group_policies.go b/internal/provider/resource_meraki_wireless_ssid_device_type_group_policies.go index d7989513..3d89d2d5 100644 --- a/internal/provider/resource_meraki_wireless_ssid_device_type_group_policies.go +++ b/internal/provider/resource_meraki_wireless_ssid_device_type_group_policies.go @@ -131,7 +131,7 @@ func (r *WirelessSSIDDeviceTypeGroupPoliciesResource) Configure(_ context.Contex // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDDeviceTypeGroupPoliciesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSIDDeviceTypeGroupPolicies + var plan, initialState WirelessSSIDDeviceTypeGroupPolicies // Read plan diags := req.Plan.Get(ctx, &plan) @@ -140,6 +140,14 @@ func (r *WirelessSSIDDeviceTypeGroupPoliciesResource) Create(ctx context.Context } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSIDDeviceTypeGroupPolicies{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSIDDeviceTypeGroupPolicies{}) @@ -250,6 +258,18 @@ func (r *WirelessSSIDDeviceTypeGroupPoliciesResource) Delete(ctx context.Context } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_ssid_eap_override.go b/internal/provider/resource_meraki_wireless_ssid_eap_override.go index 9329ca63..4b2f2e4d 100644 --- a/internal/provider/resource_meraki_wireless_ssid_eap_override.go +++ b/internal/provider/resource_meraki_wireless_ssid_eap_override.go @@ -123,7 +123,7 @@ func (r *WirelessSSIDEAPOverrideResource) Configure(_ context.Context, req resou // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDEAPOverrideResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSIDEAPOverride + var plan, initialState WirelessSSIDEAPOverride // Read plan diags := req.Plan.Get(ctx, &plan) @@ -132,6 +132,14 @@ func (r *WirelessSSIDEAPOverrideResource) Create(ctx context.Context, req resour } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSIDEAPOverride{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSIDEAPOverride{}) @@ -242,6 +250,18 @@ func (r *WirelessSSIDEAPOverrideResource) Delete(ctx context.Context, req resour } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_ssid_eap_override_test.go b/internal/provider/resource_meraki_wireless_ssid_eap_override_test.go index 84688ae1..8f48cda1 100644 --- a/internal/provider/resource_meraki_wireless_ssid_eap_override_test.go +++ b/internal/provider/resource_meraki_wireless_ssid_eap_override_test.go @@ -103,6 +103,11 @@ resource "meraki_wireless_ssid" "test" { name = "My SSID" network_id = meraki_network.test.id ip_assignment_mode = "Bridge mode" + auth_mode = "8021x-radius" + radius_servers = [{ + host = "1.2.3.4" + secret = "secret123" + }] } ` diff --git a/internal/provider/resource_meraki_wireless_ssid_hotspot_20.go b/internal/provider/resource_meraki_wireless_ssid_hotspot_20.go index ebbc4661..e14f7ad3 100644 --- a/internal/provider/resource_meraki_wireless_ssid_hotspot_20.go +++ b/internal/provider/resource_meraki_wireless_ssid_hotspot_20.go @@ -205,7 +205,7 @@ func (r *WirelessSSIDHotspot20Resource) Configure(_ context.Context, req resourc // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDHotspot20Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSIDHotspot20 + var plan, initialState WirelessSSIDHotspot20 // Read plan diags := req.Plan.Get(ctx, &plan) @@ -214,6 +214,14 @@ func (r *WirelessSSIDHotspot20Resource) Create(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSIDHotspot20{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSIDHotspot20{}) @@ -324,6 +332,18 @@ func (r *WirelessSSIDHotspot20Resource) Delete(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_ssid_l3_firewall_rules.go b/internal/provider/resource_meraki_wireless_ssid_l3_firewall_rules.go index 45a69c39..805837e9 100644 --- a/internal/provider/resource_meraki_wireless_ssid_l3_firewall_rules.go +++ b/internal/provider/resource_meraki_wireless_ssid_l3_firewall_rules.go @@ -146,7 +146,7 @@ func (r *WirelessSSIDL3FirewallRulesResource) Configure(_ context.Context, req r // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDL3FirewallRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSIDL3FirewallRules + var plan, initialState WirelessSSIDL3FirewallRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -155,6 +155,14 @@ func (r *WirelessSSIDL3FirewallRulesResource) Create(ctx context.Context, req re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSIDL3FirewallRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSIDL3FirewallRules{}) @@ -265,10 +273,16 @@ func (r *WirelessSSIDL3FirewallRulesResource) Delete(ctx context.Context, req re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_wireless_ssid_l7_firewall_rules.go b/internal/provider/resource_meraki_wireless_ssid_l7_firewall_rules.go index 43f3a0f5..c2beb425 100644 --- a/internal/provider/resource_meraki_wireless_ssid_l7_firewall_rules.go +++ b/internal/provider/resource_meraki_wireless_ssid_l7_firewall_rules.go @@ -127,7 +127,7 @@ func (r *WirelessSSIDL7FirewallRulesResource) Configure(_ context.Context, req r // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDL7FirewallRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSIDL7FirewallRules + var plan, initialState WirelessSSIDL7FirewallRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -136,6 +136,14 @@ func (r *WirelessSSIDL7FirewallRulesResource) Create(ctx context.Context, req re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSIDL7FirewallRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSIDL7FirewallRules{}) @@ -246,10 +254,16 @@ func (r *WirelessSSIDL7FirewallRulesResource) Delete(ctx context.Context, req re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_wireless_ssid_schedules.go b/internal/provider/resource_meraki_wireless_ssid_schedules.go index dc7d042b..e6fa34c8 100644 --- a/internal/provider/resource_meraki_wireless_ssid_schedules.go +++ b/internal/provider/resource_meraki_wireless_ssid_schedules.go @@ -143,7 +143,7 @@ func (r *WirelessSSIDSchedulesResource) Configure(_ context.Context, req resourc // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDSchedulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSIDSchedules + var plan, initialState WirelessSSIDSchedules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -152,6 +152,14 @@ func (r *WirelessSSIDSchedulesResource) Create(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSIDSchedules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSIDSchedules{}) @@ -262,6 +270,18 @@ func (r *WirelessSSIDSchedulesResource) Delete(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_ssid_splash_settings.go b/internal/provider/resource_meraki_wireless_ssid_splash_settings.go index d63fb09c..fd266259 100644 --- a/internal/provider/resource_meraki_wireless_ssid_splash_settings.go +++ b/internal/provider/resource_meraki_wireless_ssid_splash_settings.go @@ -253,7 +253,7 @@ func (r *WirelessSSIDSplashSettingsResource) Configure(_ context.Context, req re // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDSplashSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSIDSplashSettings + var plan, initialState WirelessSSIDSplashSettings // Read plan diags := req.Plan.Get(ctx, &plan) @@ -262,6 +262,14 @@ func (r *WirelessSSIDSplashSettingsResource) Create(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSIDSplashSettings{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSIDSplashSettings{}) @@ -372,6 +380,18 @@ func (r *WirelessSSIDSplashSettingsResource) Delete(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_ssid_traffic_shaping_rules.go b/internal/provider/resource_meraki_wireless_ssid_traffic_shaping_rules.go index 280b4ac4..f99696e4 100644 --- a/internal/provider/resource_meraki_wireless_ssid_traffic_shaping_rules.go +++ b/internal/provider/resource_meraki_wireless_ssid_traffic_shaping_rules.go @@ -156,7 +156,7 @@ func (r *WirelessSSIDTrafficShapingRulesResource) Configure(_ context.Context, r // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDTrafficShapingRulesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSIDTrafficShapingRules + var plan, initialState WirelessSSIDTrafficShapingRules // Read plan diags := req.Plan.Get(ctx, &plan) @@ -165,6 +165,14 @@ func (r *WirelessSSIDTrafficShapingRulesResource) Create(ctx context.Context, re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSIDTrafficShapingRules{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSIDTrafficShapingRules{}) @@ -275,10 +283,16 @@ func (r *WirelessSSIDTrafficShapingRulesResource) Delete(ctx context.Context, re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - body := state.toDestroyBody(ctx) - res, err := r.client.Put(state.getPath(), body) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } diff --git a/internal/provider/resource_meraki_wireless_ssid_vpn.go b/internal/provider/resource_meraki_wireless_ssid_vpn.go index f373ac2d..20959bda 100644 --- a/internal/provider/resource_meraki_wireless_ssid_vpn.go +++ b/internal/provider/resource_meraki_wireless_ssid_vpn.go @@ -156,7 +156,7 @@ func (r *WirelessSSIDVPNResource) Configure(_ context.Context, req resource.Conf // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessSSIDVPNResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessSSIDVPN + var plan, initialState WirelessSSIDVPN // Read plan diags := req.Plan.Get(ctx, &plan) @@ -165,6 +165,14 @@ func (r *WirelessSSIDVPNResource) Create(ctx context.Context, req resource.Creat } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessSSIDVPN{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessSSIDVPN{}) @@ -275,6 +283,18 @@ func (r *WirelessSSIDVPNResource) Delete(ctx context.Context, req resource.Delet } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_ssids.go b/internal/provider/resource_meraki_wireless_ssids.go index 47ac5ad6..be429436 100644 --- a/internal/provider/resource_meraki_wireless_ssids.go +++ b/internal/provider/resource_meraki_wireless_ssids.go @@ -694,27 +694,6 @@ func (r *WirelessSSIDsResource) Update(ctx context.Context, req resource.UpdateR tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) var actions []meraki.ActionModel - // If there are destroy values, we need to compare the plan and state to determine what to delete - for _, itemState := range state.Items { - found := false - for _, item := range plan.Items { - if item.Number.ValueString() != itemState.Number.ValueString() { - continue - } - - // If the item is present in both plan and state, we can skip it - found = true - break - } - if !found { - // If the item is present in state, but not in plan, we need to delete it - actions = append(actions, meraki.ActionModel{ - Operation: "update", - Resource: plan.getItemPath(itemState.Number.ValueString()), - Body: plan.toDestroyBody(ctx), - }) - } - } // Check for new and updated items for i := range plan.Items { found := false @@ -775,22 +754,6 @@ func (r *WirelessSSIDsResource) Delete(ctx context.Context, req resource.DeleteR } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - actions := make([]meraki.ActionModel, len(state.Items)) - - for i, item := range state.Items { - actions[i] = meraki.ActionModel{ - Operation: "update", - Resource: state.getItemPath(item.Number.ValueString()), - Body: state.toDestroyBody(ctx), - } - } - if len(actions) > 0 { - res, err := r.client.Batch(state.OrganizationId.ValueString(), actions) - if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure objects (Action Batch), got error: %s, %s", err, res.String())) - return - } - } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_zigbee.go b/internal/provider/resource_meraki_wireless_zigbee.go index 0a0f1b72..c84aeadf 100644 --- a/internal/provider/resource_meraki_wireless_zigbee.go +++ b/internal/provider/resource_meraki_wireless_zigbee.go @@ -122,10 +122,8 @@ func (r *WirelessZigbeeResource) Configure(_ context.Context, req resource.Confi // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin create - func (r *WirelessZigbeeResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessZigbee + var plan, initialState WirelessZigbee // Read plan diags := req.Plan.Get(ctx, &plan) @@ -134,6 +132,22 @@ func (r *WirelessZigbeeResource) Create(ctx context.Context, req resource.Create } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + networkPath := fmt.Sprintf("/networks/%v", plan.NetworkId.ValueString()) + nres, err := r.client.Get(networkPath) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve network (GET), got error: %s, %s", err, nres.String())) + return + } + orgId := nres.Get("organizationId").String() + settingsPath := fmt.Sprintf("/organizations/%v/wireless/zigbee/byNetwork?networkIds[]=%v", orgId, plan.NetworkId.ValueString()) + gres, err := r.client.Get(settingsPath) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve zigbee settings (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, meraki.Res{Result: gres.Get("items.0")}) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessZigbee{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessZigbee{}) @@ -153,8 +167,6 @@ func (r *WirelessZigbeeResource) Create(ctx context.Context, req resource.Create helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics) } -// End of section. //template:end create - func (r *WirelessZigbeeResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state WirelessZigbee @@ -255,6 +267,18 @@ func (r *WirelessZigbeeResource) Delete(ctx context.Context, req resource.Delete } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_zigbee_device.go b/internal/provider/resource_meraki_wireless_zigbee_device.go index 9ff93fd4..da2d2a79 100644 --- a/internal/provider/resource_meraki_wireless_zigbee_device.go +++ b/internal/provider/resource_meraki_wireless_zigbee_device.go @@ -107,7 +107,7 @@ func (r *WirelessZigbeeDeviceResource) Configure(_ context.Context, req resource // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessZigbeeDeviceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessZigbeeDevice + var plan, initialState WirelessZigbeeDevice // Read plan diags := req.Plan.Get(ctx, &plan) @@ -116,6 +116,14 @@ func (r *WirelessZigbeeDeviceResource) Create(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessZigbeeDevice{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessZigbeeDevice{}) @@ -226,6 +234,18 @@ func (r *WirelessZigbeeDeviceResource) Delete(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) diff --git a/internal/provider/resource_meraki_wireless_zigbee_door_lock.go b/internal/provider/resource_meraki_wireless_zigbee_door_lock.go index 3050cded..d9217a16 100644 --- a/internal/provider/resource_meraki_wireless_zigbee_door_lock.go +++ b/internal/provider/resource_meraki_wireless_zigbee_door_lock.go @@ -103,7 +103,7 @@ func (r *WirelessZigbeeDoorLockResource) Configure(_ context.Context, req resour // Section below is generated&owned by "gen/generator.go". //template:begin create func (r *WirelessZigbeeDoorLockResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan WirelessZigbeeDoorLock + var plan, initialState WirelessZigbeeDoorLock // Read plan diags := req.Plan.Get(ctx, &plan) @@ -112,6 +112,14 @@ func (r *WirelessZigbeeDoorLockResource) Create(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + // If the resource is a singleton, we need to read and save the initial state + gres, err := r.client.Get(plan.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, gres.String())) + return + } + initialState.fromBody(ctx, gres) + helpers.SetJsonInitialState(ctx, initialState.toBody(ctx, WirelessZigbeeDoorLock{}), resp.Private, &resp.Diagnostics) // Create object body := plan.toBody(ctx, WirelessZigbeeDoorLock{}) @@ -222,6 +230,18 @@ func (r *WirelessZigbeeDoorLockResource) Delete(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + // If the resource is a singleton, we need to restore the initial state + jsonInitialState, diags := helpers.GetJsonInitialState(ctx, req) + jsonInitialState = state.addDeleteValues(ctx, jsonInitialState) + if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { + return + } + + res, err := r.client.Put(state.getPath(), jsonInitialState) + if err != nil { + resp.Diagnostics.AddWarning("Failed to restore initial state", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString()))