// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://mozilla.org/MPL/2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: MPL-2.0

// Code generated by "gen/generator.go"; DO NOT EDIT.

package provider

// Section below is generated&owned by "gen/generator.go". //template:begin imports
import (
	"context"
	"fmt"
	"reflect"
	"regexp"
	"strconv"
	"strings"

	"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
	"github.com/hashicorp/terraform-plugin-framework/types"
	"github.com/tidwall/gjson"
	"github.com/tidwall/sjson"
)

// End of section. //template:end imports

// Section below is generated&owned by "gen/generator.go". //template:begin types
type DHCP struct {
	Device                                          types.String              `tfsdk:"device"`
	Id                                              types.String              `tfsdk:"id"`
	DeleteMode                                      types.String              `tfsdk:"delete_mode"`
	CompatibilitySuboptionLinkSelection             types.String              `tfsdk:"compatibility_suboption_link_selection"`
	CompatibilitySuboptionServerOverride            types.String              `tfsdk:"compatibility_suboption_server_override"`
	RelayInformationTrustAll                        types.Bool                `tfsdk:"relay_information_trust_all"`
	RelayInformationOptionDefault                   types.Bool                `tfsdk:"relay_information_option_default"`
	RelayInformationOptionVpn                       types.Bool                `tfsdk:"relay_information_option_vpn"`
	Snooping                                        types.Bool                `tfsdk:"snooping"`
	SnoopingInformationOptionFormatRemoteIdHostname types.Bool                `tfsdk:"snooping_information_option_format_remote_id_hostname"`
	SnoopingVlansLegacy                             []DHCPSnoopingVlansLegacy `tfsdk:"snooping_vlans_legacy"`
	SnoopingVlans                                   []DHCPSnoopingVlans       `tfsdk:"snooping_vlans"`
}

type DHCPData struct {
	Device                                          types.String              `tfsdk:"device"`
	Id                                              types.String              `tfsdk:"id"`
	CompatibilitySuboptionLinkSelection             types.String              `tfsdk:"compatibility_suboption_link_selection"`
	CompatibilitySuboptionServerOverride            types.String              `tfsdk:"compatibility_suboption_server_override"`
	RelayInformationTrustAll                        types.Bool                `tfsdk:"relay_information_trust_all"`
	RelayInformationOptionDefault                   types.Bool                `tfsdk:"relay_information_option_default"`
	RelayInformationOptionVpn                       types.Bool                `tfsdk:"relay_information_option_vpn"`
	Snooping                                        types.Bool                `tfsdk:"snooping"`
	SnoopingInformationOptionFormatRemoteIdHostname types.Bool                `tfsdk:"snooping_information_option_format_remote_id_hostname"`
	SnoopingVlansLegacy                             []DHCPSnoopingVlansLegacy `tfsdk:"snooping_vlans_legacy"`
	SnoopingVlans                                   []DHCPSnoopingVlans       `tfsdk:"snooping_vlans"`
}
type DHCPSnoopingVlansLegacy struct {
	VlanId types.String `tfsdk:"vlan_id"`
}
type DHCPSnoopingVlans struct {
	VlanId types.Int64 `tfsdk:"vlan_id"`
}

// End of section. //template:end types

// Section below is generated&owned by "gen/generator.go". //template:begin getPath

func (data DHCP) getPath() string {
	return "Cisco-IOS-XE-native:native/ip/dhcp"
}

func (data DHCPData) getPath() string {
	return "Cisco-IOS-XE-native:native/ip/dhcp"
}

// if last path element has a key -> remove it
func (data DHCP) getPathShort() string {
	path := data.getPath()
	re := regexp.MustCompile(`(.*)=[^\/]*$`)
	matches := re.FindStringSubmatch(path)
	if len(matches) <= 1 {
		return path
	}
	return matches[1]
}

// End of section. //template:end getPath

// Section below is generated&owned by "gen/generator.go". //template:begin toBody

func (data DHCP) toBody(ctx context.Context) string {
	body := `{"` + helpers.LastElement(data.getPath()) + `":{}}`
	if !data.CompatibilitySuboptionLinkSelection.IsNull() && !data.CompatibilitySuboptionLinkSelection.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:compatibility.suboption.link-selection", data.CompatibilitySuboptionLinkSelection.ValueString())
	}
	if !data.CompatibilitySuboptionServerOverride.IsNull() && !data.CompatibilitySuboptionServerOverride.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:compatibility.suboption.server-override", data.CompatibilitySuboptionServerOverride.ValueString())
	}
	if !data.RelayInformationTrustAll.IsNull() && !data.RelayInformationTrustAll.IsUnknown() {
		if data.RelayInformationTrustAll.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:relay.information.trust-all", map[string]string{})
		}
	}
	if !data.RelayInformationOptionDefault.IsNull() && !data.RelayInformationOptionDefault.IsUnknown() {
		if data.RelayInformationOptionDefault.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:relay.information.option.option-default", map[string]string{})
		}
	}
	if !data.RelayInformationOptionVpn.IsNull() && !data.RelayInformationOptionVpn.IsUnknown() {
		if data.RelayInformationOptionVpn.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:relay.information.option.vpn", map[string]string{})
		}
	}
	if !data.Snooping.IsNull() && !data.Snooping.IsUnknown() {
		if data.Snooping.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:snooping", map[string]string{})
		}
	}
	if !data.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() && !data.SnoopingInformationOptionFormatRemoteIdHostname.IsUnknown() {
		if data.SnoopingInformationOptionFormatRemoteIdHostname.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:snooping-conf.snooping.information.options.option.format.remote-id.hostname", map[string]string{})
		}
	}
	if len(data.SnoopingVlansLegacy) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:snooping-conf.snooping.vlan-list", []interface{}{})
		for index, item := range data.SnoopingVlansLegacy {
			if !item.VlanId.IsNull() && !item.VlanId.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:snooping-conf.snooping.vlan-list"+"."+strconv.Itoa(index)+"."+"id", item.VlanId.ValueString())
			}
		}
	}
	if len(data.SnoopingVlans) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:snooping-conf.snooping.vlan-v2", []interface{}{})
		for index, item := range data.SnoopingVlans {
			if !item.VlanId.IsNull() && !item.VlanId.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-dhcp:snooping-conf.snooping.vlan-v2"+"."+strconv.Itoa(index)+"."+"id", strconv.FormatInt(item.VlanId.ValueInt64(), 10))
			}
		}
	}
	return body
}

// End of section. //template:end toBody

// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody

func (data *DHCP) updateFromBody(ctx context.Context, res gjson.Result) {
	prefix := helpers.LastElement(data.getPath()) + "."
	if res.Get(helpers.LastElement(data.getPath())).IsArray() {
		prefix += "0."
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:compatibility.suboption.link-selection"); value.Exists() && !data.CompatibilitySuboptionLinkSelection.IsNull() {
		data.CompatibilitySuboptionLinkSelection = types.StringValue(value.String())
	} else {
		data.CompatibilitySuboptionLinkSelection = types.StringNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:compatibility.suboption.server-override"); value.Exists() && !data.CompatibilitySuboptionServerOverride.IsNull() {
		data.CompatibilitySuboptionServerOverride = types.StringValue(value.String())
	} else {
		data.CompatibilitySuboptionServerOverride = types.StringNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:relay.information.trust-all"); !data.RelayInformationTrustAll.IsNull() {
		if value.Exists() {
			data.RelayInformationTrustAll = types.BoolValue(true)
		} else {
			data.RelayInformationTrustAll = types.BoolValue(false)
		}
	} else {
		data.RelayInformationTrustAll = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:relay.information.option.option-default"); !data.RelayInformationOptionDefault.IsNull() {
		if value.Exists() {
			data.RelayInformationOptionDefault = types.BoolValue(true)
		} else {
			data.RelayInformationOptionDefault = types.BoolValue(false)
		}
	} else {
		data.RelayInformationOptionDefault = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:relay.information.option.vpn"); !data.RelayInformationOptionVpn.IsNull() {
		if value.Exists() {
			data.RelayInformationOptionVpn = types.BoolValue(true)
		} else {
			data.RelayInformationOptionVpn = types.BoolValue(false)
		}
	} else {
		data.RelayInformationOptionVpn = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping"); !data.Snooping.IsNull() {
		if value.Exists() {
			data.Snooping = types.BoolValue(true)
		} else {
			data.Snooping = types.BoolValue(false)
		}
	} else {
		data.Snooping = types.BoolNull()
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping-conf.snooping.information.options.option.format.remote-id.hostname"); !data.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() {
		if value.Exists() {
			data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(true)
		} else {
			data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(false)
		}
	} else {
		data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolNull()
	}
	for i := range data.SnoopingVlansLegacy {
		keys := [...]string{"id"}
		keyValues := [...]string{data.SnoopingVlansLegacy[i].VlanId.ValueString()}

		var r gjson.Result
		res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping-conf.snooping.vlan-list").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("id"); value.Exists() && !data.SnoopingVlansLegacy[i].VlanId.IsNull() {
			data.SnoopingVlansLegacy[i].VlanId = types.StringValue(value.String())
		} else {
			data.SnoopingVlansLegacy[i].VlanId = types.StringNull()
		}
	}
	for i := range data.SnoopingVlans {
		keys := [...]string{"id"}
		keyValues := [...]string{strconv.FormatInt(data.SnoopingVlans[i].VlanId.ValueInt64(), 10)}

		var r gjson.Result
		res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping-conf.snooping.vlan-v2").ForEach(
			func(_, v gjson.Result) bool {
				found := false
				for ik := range keys {
					if v.Get(keys[ik]).String() == keyValues[ik] {
						found = true
						continue
					}
					found = false
					break
				}
				if found {
					r = v
					return false
				}
				return true
			},
		)
		if value := r.Get("id"); value.Exists() && !data.SnoopingVlans[i].VlanId.IsNull() {
			data.SnoopingVlans[i].VlanId = types.Int64Value(value.Int())
		} else {
			data.SnoopingVlans[i].VlanId = types.Int64Null()
		}
	}
}

// End of section. //template:end updateFromBody

// Section below is generated&owned by "gen/generator.go". //template:begin fromBody

func (data *DHCP) fromBody(ctx context.Context, res gjson.Result) {
	prefix := helpers.LastElement(data.getPath()) + "."
	if res.Get(helpers.LastElement(data.getPath())).IsArray() {
		prefix += "0."
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:compatibility.suboption.link-selection"); value.Exists() {
		data.CompatibilitySuboptionLinkSelection = types.StringValue(value.String())
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:compatibility.suboption.server-override"); value.Exists() {
		data.CompatibilitySuboptionServerOverride = types.StringValue(value.String())
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:relay.information.trust-all"); value.Exists() {
		data.RelayInformationTrustAll = types.BoolValue(true)
	} else {
		data.RelayInformationTrustAll = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:relay.information.option.option-default"); value.Exists() {
		data.RelayInformationOptionDefault = types.BoolValue(true)
	} else {
		data.RelayInformationOptionDefault = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:relay.information.option.vpn"); value.Exists() {
		data.RelayInformationOptionVpn = types.BoolValue(true)
	} else {
		data.RelayInformationOptionVpn = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping"); value.Exists() {
		data.Snooping = types.BoolValue(true)
	} else {
		data.Snooping = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping-conf.snooping.information.options.option.format.remote-id.hostname"); value.Exists() {
		data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(true)
	} else {
		data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping-conf.snooping.vlan-list"); value.Exists() {
		data.SnoopingVlansLegacy = make([]DHCPSnoopingVlansLegacy, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := DHCPSnoopingVlansLegacy{}
			if cValue := v.Get("id"); cValue.Exists() {
				item.VlanId = types.StringValue(cValue.String())
			}
			data.SnoopingVlansLegacy = append(data.SnoopingVlansLegacy, item)
			return true
		})
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping-conf.snooping.vlan-v2"); value.Exists() {
		data.SnoopingVlans = make([]DHCPSnoopingVlans, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := DHCPSnoopingVlans{}
			if cValue := v.Get("id"); cValue.Exists() {
				item.VlanId = types.Int64Value(cValue.Int())
			}
			data.SnoopingVlans = append(data.SnoopingVlans, item)
			return true
		})
	}
}

// End of section. //template:end fromBody

// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData

func (data *DHCPData) fromBody(ctx context.Context, res gjson.Result) {
	prefix := helpers.LastElement(data.getPath()) + "."
	if res.Get(helpers.LastElement(data.getPath())).IsArray() {
		prefix += "0."
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:compatibility.suboption.link-selection"); value.Exists() {
		data.CompatibilitySuboptionLinkSelection = types.StringValue(value.String())
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:compatibility.suboption.server-override"); value.Exists() {
		data.CompatibilitySuboptionServerOverride = types.StringValue(value.String())
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:relay.information.trust-all"); value.Exists() {
		data.RelayInformationTrustAll = types.BoolValue(true)
	} else {
		data.RelayInformationTrustAll = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:relay.information.option.option-default"); value.Exists() {
		data.RelayInformationOptionDefault = types.BoolValue(true)
	} else {
		data.RelayInformationOptionDefault = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:relay.information.option.vpn"); value.Exists() {
		data.RelayInformationOptionVpn = types.BoolValue(true)
	} else {
		data.RelayInformationOptionVpn = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping"); value.Exists() {
		data.Snooping = types.BoolValue(true)
	} else {
		data.Snooping = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping-conf.snooping.information.options.option.format.remote-id.hostname"); value.Exists() {
		data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(true)
	} else {
		data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(false)
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping-conf.snooping.vlan-list"); value.Exists() {
		data.SnoopingVlansLegacy = make([]DHCPSnoopingVlansLegacy, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := DHCPSnoopingVlansLegacy{}
			if cValue := v.Get("id"); cValue.Exists() {
				item.VlanId = types.StringValue(cValue.String())
			}
			data.SnoopingVlansLegacy = append(data.SnoopingVlansLegacy, item)
			return true
		})
	}
	if value := res.Get(prefix + "Cisco-IOS-XE-dhcp:snooping-conf.snooping.vlan-v2"); value.Exists() {
		data.SnoopingVlans = make([]DHCPSnoopingVlans, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := DHCPSnoopingVlans{}
			if cValue := v.Get("id"); cValue.Exists() {
				item.VlanId = types.Int64Value(cValue.Int())
			}
			data.SnoopingVlans = append(data.SnoopingVlans, item)
			return true
		})
	}
}

// End of section. //template:end fromBodyData

// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems

func (data *DHCP) getDeletedItems(ctx context.Context, state DHCP) []string {
	deletedItems := make([]string, 0)
	for i := range state.SnoopingVlans {
		stateKeyValues := [...]string{strconv.FormatInt(state.SnoopingVlans[i].VlanId.ValueInt64(), 10)}

		emptyKeys := true
		if !reflect.ValueOf(state.SnoopingVlans[i].VlanId.ValueInt64()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.SnoopingVlans {
			found = true
			if state.SnoopingVlans[i].VlanId.ValueInt64() != data.SnoopingVlans[j].VlanId.ValueInt64() {
				found = false
			}
			if found {
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-v2=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.SnoopingVlansLegacy {
		stateKeyValues := [...]string{state.SnoopingVlansLegacy[i].VlanId.ValueString()}

		emptyKeys := true
		if !reflect.ValueOf(state.SnoopingVlansLegacy[i].VlanId.ValueString()).IsZero() {
			emptyKeys = false
		}
		if emptyKeys {
			continue
		}

		found := false
		for j := range data.SnoopingVlansLegacy {
			found = true
			if state.SnoopingVlansLegacy[i].VlanId.ValueString() != data.SnoopingVlansLegacy[j].VlanId.ValueString() {
				found = false
			}
			if found {
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	if !state.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() && data.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/hostname", state.getPath()))
	}
	if !state.Snooping.IsNull() && data.Snooping.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:snooping", state.getPath()))
	}
	if !state.RelayInformationOptionVpn.IsNull() && data.RelayInformationOptionVpn.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:relay/information/option/vpn", state.getPath()))
	}
	if !state.RelayInformationOptionDefault.IsNull() && data.RelayInformationOptionDefault.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:relay/information/option/option-default", state.getPath()))
	}
	if !state.RelayInformationTrustAll.IsNull() && data.RelayInformationTrustAll.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:relay/information/trust-all", state.getPath()))
	}
	if !state.CompatibilitySuboptionServerOverride.IsNull() && data.CompatibilitySuboptionServerOverride.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:compatibility/suboption/server-override", state.getPath()))
	}
	if !state.CompatibilitySuboptionLinkSelection.IsNull() && data.CompatibilitySuboptionLinkSelection.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:compatibility/suboption/link-selection", state.getPath()))
	}

	return deletedItems
}

// End of section. //template:end getDeletedItems

// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete

func (data *DHCP) getEmptyLeafsDelete(ctx context.Context) []string {
	emptyLeafsDelete := make([]string, 0)

	if !data.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() && !data.SnoopingInformationOptionFormatRemoteIdHostname.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/hostname", data.getPath()))
	}
	if !data.Snooping.IsNull() && !data.Snooping.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:snooping", data.getPath()))
	}
	if !data.RelayInformationOptionVpn.IsNull() && !data.RelayInformationOptionVpn.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:relay/information/option/vpn", data.getPath()))
	}
	if !data.RelayInformationOptionDefault.IsNull() && !data.RelayInformationOptionDefault.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:relay/information/option/option-default", data.getPath()))
	}
	if !data.RelayInformationTrustAll.IsNull() && !data.RelayInformationTrustAll.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:relay/information/trust-all", data.getPath()))
	}

	return emptyLeafsDelete
}

// End of section. //template:end getEmptyLeafsDelete

// Section below is generated&owned by "gen/generator.go". //template:begin getDeletePaths

func (data *DHCP) getDeletePaths(ctx context.Context) []string {
	var deletePaths []string
	for i := range data.SnoopingVlans {
		keyValues := [...]string{strconv.FormatInt(data.SnoopingVlans[i].VlanId.ValueInt64(), 10)}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-v2=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.SnoopingVlansLegacy {
		keyValues := [...]string{data.SnoopingVlansLegacy[i].VlanId.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-list=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	if !data.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/hostname", data.getPath()))
	}
	if !data.Snooping.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:snooping", data.getPath()))
	}
	if !data.RelayInformationOptionVpn.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:relay/information/option/vpn", data.getPath()))
	}
	if !data.RelayInformationOptionDefault.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:relay/information/option/option-default", data.getPath()))
	}
	if !data.RelayInformationTrustAll.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:relay/information/trust-all", data.getPath()))
	}
	if !data.CompatibilitySuboptionServerOverride.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:compatibility/suboption/server-override", data.getPath()))
	}
	if !data.CompatibilitySuboptionLinkSelection.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dhcp:compatibility/suboption/link-selection", data.getPath()))
	}

	return deletePaths
}

// End of section. //template:end getDeletePaths
