// 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 ARP struct {
	Device                          types.String           `tfsdk:"device"`
	Id                              types.String           `tfsdk:"id"`
	DeleteMode                      types.String           `tfsdk:"delete_mode"`
	IncompleteEntries               types.Int64            `tfsdk:"incomplete_entries"`
	ProxyDisable                    types.Bool             `tfsdk:"proxy_disable"`
	EntryLearn                      types.Int64            `tfsdk:"entry_learn"`
	InspectionFilters               []ARPInspectionFilters `tfsdk:"inspection_filters"`
	InspectionValidateSrcMac        types.Bool             `tfsdk:"inspection_validate_src_mac"`
	InspectionValidateDstMac        types.Bool             `tfsdk:"inspection_validate_dst_mac"`
	InspectionValidateIp            types.Bool             `tfsdk:"inspection_validate_ip"`
	InspectionValidateAllowZeros    types.Bool             `tfsdk:"inspection_validate_allow_zeros"`
	InspectionLogBufferEntries      types.Int64            `tfsdk:"inspection_log_buffer_entries"`
	InspectionLogBufferLogsEntries  types.Int64            `tfsdk:"inspection_log_buffer_logs_entries"`
	InspectionLogBufferLogsInterval types.Int64            `tfsdk:"inspection_log_buffer_logs_interval"`
	InspectionVlan                  types.String           `tfsdk:"inspection_vlan"`
}

type ARPData struct {
	Device                          types.String           `tfsdk:"device"`
	Id                              types.String           `tfsdk:"id"`
	IncompleteEntries               types.Int64            `tfsdk:"incomplete_entries"`
	ProxyDisable                    types.Bool             `tfsdk:"proxy_disable"`
	EntryLearn                      types.Int64            `tfsdk:"entry_learn"`
	InspectionFilters               []ARPInspectionFilters `tfsdk:"inspection_filters"`
	InspectionValidateSrcMac        types.Bool             `tfsdk:"inspection_validate_src_mac"`
	InspectionValidateDstMac        types.Bool             `tfsdk:"inspection_validate_dst_mac"`
	InspectionValidateIp            types.Bool             `tfsdk:"inspection_validate_ip"`
	InspectionValidateAllowZeros    types.Bool             `tfsdk:"inspection_validate_allow_zeros"`
	InspectionLogBufferEntries      types.Int64            `tfsdk:"inspection_log_buffer_entries"`
	InspectionLogBufferLogsEntries  types.Int64            `tfsdk:"inspection_log_buffer_logs_entries"`
	InspectionLogBufferLogsInterval types.Int64            `tfsdk:"inspection_log_buffer_logs_interval"`
	InspectionVlan                  types.String           `tfsdk:"inspection_vlan"`
}
type ARPInspectionFilters struct {
	Name  types.String                `tfsdk:"name"`
	Vlans []ARPInspectionFiltersVlans `tfsdk:"vlans"`
}
type ARPInspectionFiltersVlans struct {
	VlanRange types.String `tfsdk:"vlan_range"`
	Static    types.Bool   `tfsdk:"static"`
}

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

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

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

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

// if last path element has a key -> remove it
func (data ARP) 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 ARP) toBody(ctx context.Context) string {
	body := `{"` + helpers.LastElement(data.getPath()) + `":{}}`
	if !data.IncompleteEntries.IsNull() && !data.IncompleteEntries.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"incomplete.entries", strconv.FormatInt(data.IncompleteEntries.ValueInt64(), 10))
	}
	if !data.ProxyDisable.IsNull() && !data.ProxyDisable.IsUnknown() {
		if data.ProxyDisable.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"proxy.disable", map[string]string{})
		}
	}
	if !data.EntryLearn.IsNull() && !data.EntryLearn.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"entry.learn", strconv.FormatInt(data.EntryLearn.ValueInt64(), 10))
	}
	if !data.InspectionValidateSrcMac.IsNull() && !data.InspectionValidateSrcMac.IsUnknown() {
		if data.InspectionValidateSrcMac.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.validate.src-mac", map[string]string{})
		}
	}
	if !data.InspectionValidateDstMac.IsNull() && !data.InspectionValidateDstMac.IsUnknown() {
		if data.InspectionValidateDstMac.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.validate.dst-mac", map[string]string{})
		}
	}
	if !data.InspectionValidateIp.IsNull() && !data.InspectionValidateIp.IsUnknown() {
		if data.InspectionValidateIp.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.validate.ip", map[string]string{})
		}
	}
	if !data.InspectionValidateAllowZeros.IsNull() && !data.InspectionValidateAllowZeros.IsUnknown() {
		if data.InspectionValidateAllowZeros.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.validate.allow.zeros", map[string]string{})
		}
	}
	if !data.InspectionLogBufferEntries.IsNull() && !data.InspectionLogBufferEntries.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.log-buffer.entries", strconv.FormatInt(data.InspectionLogBufferEntries.ValueInt64(), 10))
	}
	if !data.InspectionLogBufferLogsEntries.IsNull() && !data.InspectionLogBufferLogsEntries.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.log-buffer.logs.entries", strconv.FormatInt(data.InspectionLogBufferLogsEntries.ValueInt64(), 10))
	}
	if !data.InspectionLogBufferLogsInterval.IsNull() && !data.InspectionLogBufferLogsInterval.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.log-buffer.logs.interval", strconv.FormatInt(data.InspectionLogBufferLogsInterval.ValueInt64(), 10))
	}
	if !data.InspectionVlan.IsNull() && !data.InspectionVlan.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.vlan", data.InspectionVlan.ValueString())
	}
	if len(data.InspectionFilters) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.filter", []interface{}{})
		for index, item := range data.InspectionFilters {
			if !item.Name.IsNull() && !item.Name.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.filter"+"."+strconv.Itoa(index)+"."+"arpacl", item.Name.ValueString())
			}
			if len(item.Vlans) > 0 {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.filter"+"."+strconv.Itoa(index)+"."+"vlan", []interface{}{})
				for cindex, citem := range item.Vlans {
					if !citem.VlanRange.IsNull() && !citem.VlanRange.IsUnknown() {
						body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.filter"+"."+strconv.Itoa(index)+"."+"vlan"+"."+strconv.Itoa(cindex)+"."+"vlan-range", citem.VlanRange.ValueString())
					}
					if !citem.Static.IsNull() && !citem.Static.IsUnknown() {
						if citem.Static.ValueBool() {
							body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"inspection.filter"+"."+strconv.Itoa(index)+"."+"vlan"+"."+strconv.Itoa(cindex)+"."+"static", map[string]string{})
						}
					}
				}
			}
		}
	}
	return body
}

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

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

func (data *ARP) 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 + "incomplete.entries"); value.Exists() && !data.IncompleteEntries.IsNull() {
		data.IncompleteEntries = types.Int64Value(value.Int())
	} else {
		data.IncompleteEntries = types.Int64Null()
	}
	if value := res.Get(prefix + "proxy.disable"); !data.ProxyDisable.IsNull() {
		if value.Exists() {
			data.ProxyDisable = types.BoolValue(true)
		} else {
			data.ProxyDisable = types.BoolValue(false)
		}
	} else {
		data.ProxyDisable = types.BoolNull()
	}
	if value := res.Get(prefix + "entry.learn"); value.Exists() && !data.EntryLearn.IsNull() {
		data.EntryLearn = types.Int64Value(value.Int())
	} else {
		data.EntryLearn = types.Int64Null()
	}
	for i := range data.InspectionFilters {
		keys := [...]string{"arpacl"}
		keyValues := [...]string{data.InspectionFilters[i].Name.ValueString()}

		var r gjson.Result
		res.Get(prefix + "inspection.filter").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("arpacl"); value.Exists() && !data.InspectionFilters[i].Name.IsNull() {
			data.InspectionFilters[i].Name = types.StringValue(value.String())
		} else {
			data.InspectionFilters[i].Name = types.StringNull()
		}
		for ci := range data.InspectionFilters[i].Vlans {
			keys := [...]string{"vlan-range"}
			keyValues := [...]string{data.InspectionFilters[i].Vlans[ci].VlanRange.ValueString()}

			var cr gjson.Result
			r.Get("vlan").ForEach(
				func(_, v gjson.Result) bool {
					found := false
					for ik := range keys {
						if v.Get(keys[ik]).String() == keyValues[ik] {
							found = true
							continue
						}
						found = false
						break
					}
					if found {
						cr = v
						return false
					}
					return true
				},
			)
			if value := cr.Get("vlan-range"); value.Exists() && !data.InspectionFilters[i].Vlans[ci].VlanRange.IsNull() {
				data.InspectionFilters[i].Vlans[ci].VlanRange = types.StringValue(value.String())
			} else {
				data.InspectionFilters[i].Vlans[ci].VlanRange = types.StringNull()
			}
			if value := cr.Get("static"); !data.InspectionFilters[i].Vlans[ci].Static.IsNull() {
				if value.Exists() {
					data.InspectionFilters[i].Vlans[ci].Static = types.BoolValue(true)
				} else {
					data.InspectionFilters[i].Vlans[ci].Static = types.BoolValue(false)
				}
			} else {
				data.InspectionFilters[i].Vlans[ci].Static = types.BoolNull()
			}
		}
	}
	if value := res.Get(prefix + "inspection.validate.src-mac"); !data.InspectionValidateSrcMac.IsNull() {
		if value.Exists() {
			data.InspectionValidateSrcMac = types.BoolValue(true)
		} else {
			data.InspectionValidateSrcMac = types.BoolValue(false)
		}
	} else {
		data.InspectionValidateSrcMac = types.BoolNull()
	}
	if value := res.Get(prefix + "inspection.validate.dst-mac"); !data.InspectionValidateDstMac.IsNull() {
		if value.Exists() {
			data.InspectionValidateDstMac = types.BoolValue(true)
		} else {
			data.InspectionValidateDstMac = types.BoolValue(false)
		}
	} else {
		data.InspectionValidateDstMac = types.BoolNull()
	}
	if value := res.Get(prefix + "inspection.validate.ip"); !data.InspectionValidateIp.IsNull() {
		if value.Exists() {
			data.InspectionValidateIp = types.BoolValue(true)
		} else {
			data.InspectionValidateIp = types.BoolValue(false)
		}
	} else {
		data.InspectionValidateIp = types.BoolNull()
	}
	if value := res.Get(prefix + "inspection.validate.allow.zeros"); !data.InspectionValidateAllowZeros.IsNull() {
		if value.Exists() {
			data.InspectionValidateAllowZeros = types.BoolValue(true)
		} else {
			data.InspectionValidateAllowZeros = types.BoolValue(false)
		}
	} else {
		data.InspectionValidateAllowZeros = types.BoolNull()
	}
	if value := res.Get(prefix + "inspection.log-buffer.entries"); value.Exists() && !data.InspectionLogBufferEntries.IsNull() {
		data.InspectionLogBufferEntries = types.Int64Value(value.Int())
	} else {
		data.InspectionLogBufferEntries = types.Int64Null()
	}
	if value := res.Get(prefix + "inspection.log-buffer.logs.entries"); value.Exists() && !data.InspectionLogBufferLogsEntries.IsNull() {
		data.InspectionLogBufferLogsEntries = types.Int64Value(value.Int())
	} else {
		data.InspectionLogBufferLogsEntries = types.Int64Null()
	}
	if value := res.Get(prefix + "inspection.log-buffer.logs.interval"); value.Exists() && !data.InspectionLogBufferLogsInterval.IsNull() {
		data.InspectionLogBufferLogsInterval = types.Int64Value(value.Int())
	} else {
		data.InspectionLogBufferLogsInterval = types.Int64Null()
	}
	if value := res.Get(prefix + "inspection.vlan"); value.Exists() && !data.InspectionVlan.IsNull() {
		data.InspectionVlan = types.StringValue(value.String())
	} else {
		data.InspectionVlan = types.StringNull()
	}
}

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

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

func (data *ARP) 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 + "incomplete.entries"); value.Exists() {
		data.IncompleteEntries = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "proxy.disable"); value.Exists() {
		data.ProxyDisable = types.BoolValue(true)
	} else {
		data.ProxyDisable = types.BoolValue(false)
	}
	if value := res.Get(prefix + "entry.learn"); value.Exists() {
		data.EntryLearn = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "inspection.filter"); value.Exists() {
		data.InspectionFilters = make([]ARPInspectionFilters, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := ARPInspectionFilters{}
			if cValue := v.Get("arpacl"); cValue.Exists() {
				item.Name = types.StringValue(cValue.String())
			}
			if cValue := v.Get("vlan"); cValue.Exists() {
				item.Vlans = make([]ARPInspectionFiltersVlans, 0)
				cValue.ForEach(func(ck, cv gjson.Result) bool {
					cItem := ARPInspectionFiltersVlans{}
					if ccValue := cv.Get("vlan-range"); ccValue.Exists() {
						cItem.VlanRange = types.StringValue(ccValue.String())
					}
					if ccValue := cv.Get("static"); ccValue.Exists() {
						cItem.Static = types.BoolValue(true)
					} else {
						cItem.Static = types.BoolValue(false)
					}
					item.Vlans = append(item.Vlans, cItem)
					return true
				})
			}
			data.InspectionFilters = append(data.InspectionFilters, item)
			return true
		})
	}
	if value := res.Get(prefix + "inspection.validate.src-mac"); value.Exists() {
		data.InspectionValidateSrcMac = types.BoolValue(true)
	} else {
		data.InspectionValidateSrcMac = types.BoolValue(false)
	}
	if value := res.Get(prefix + "inspection.validate.dst-mac"); value.Exists() {
		data.InspectionValidateDstMac = types.BoolValue(true)
	} else {
		data.InspectionValidateDstMac = types.BoolValue(false)
	}
	if value := res.Get(prefix + "inspection.validate.ip"); value.Exists() {
		data.InspectionValidateIp = types.BoolValue(true)
	} else {
		data.InspectionValidateIp = types.BoolValue(false)
	}
	if value := res.Get(prefix + "inspection.validate.allow.zeros"); value.Exists() {
		data.InspectionValidateAllowZeros = types.BoolValue(true)
	} else {
		data.InspectionValidateAllowZeros = types.BoolValue(false)
	}
	if value := res.Get(prefix + "inspection.log-buffer.entries"); value.Exists() {
		data.InspectionLogBufferEntries = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "inspection.log-buffer.logs.entries"); value.Exists() {
		data.InspectionLogBufferLogsEntries = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "inspection.log-buffer.logs.interval"); value.Exists() {
		data.InspectionLogBufferLogsInterval = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "inspection.vlan"); value.Exists() {
		data.InspectionVlan = types.StringValue(value.String())
	}
}

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

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

func (data *ARPData) 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 + "incomplete.entries"); value.Exists() {
		data.IncompleteEntries = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "proxy.disable"); value.Exists() {
		data.ProxyDisable = types.BoolValue(true)
	} else {
		data.ProxyDisable = types.BoolValue(false)
	}
	if value := res.Get(prefix + "entry.learn"); value.Exists() {
		data.EntryLearn = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "inspection.filter"); value.Exists() {
		data.InspectionFilters = make([]ARPInspectionFilters, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := ARPInspectionFilters{}
			if cValue := v.Get("arpacl"); cValue.Exists() {
				item.Name = types.StringValue(cValue.String())
			}
			if cValue := v.Get("vlan"); cValue.Exists() {
				item.Vlans = make([]ARPInspectionFiltersVlans, 0)
				cValue.ForEach(func(ck, cv gjson.Result) bool {
					cItem := ARPInspectionFiltersVlans{}
					if ccValue := cv.Get("vlan-range"); ccValue.Exists() {
						cItem.VlanRange = types.StringValue(ccValue.String())
					}
					if ccValue := cv.Get("static"); ccValue.Exists() {
						cItem.Static = types.BoolValue(true)
					} else {
						cItem.Static = types.BoolValue(false)
					}
					item.Vlans = append(item.Vlans, cItem)
					return true
				})
			}
			data.InspectionFilters = append(data.InspectionFilters, item)
			return true
		})
	}
	if value := res.Get(prefix + "inspection.validate.src-mac"); value.Exists() {
		data.InspectionValidateSrcMac = types.BoolValue(true)
	} else {
		data.InspectionValidateSrcMac = types.BoolValue(false)
	}
	if value := res.Get(prefix + "inspection.validate.dst-mac"); value.Exists() {
		data.InspectionValidateDstMac = types.BoolValue(true)
	} else {
		data.InspectionValidateDstMac = types.BoolValue(false)
	}
	if value := res.Get(prefix + "inspection.validate.ip"); value.Exists() {
		data.InspectionValidateIp = types.BoolValue(true)
	} else {
		data.InspectionValidateIp = types.BoolValue(false)
	}
	if value := res.Get(prefix + "inspection.validate.allow.zeros"); value.Exists() {
		data.InspectionValidateAllowZeros = types.BoolValue(true)
	} else {
		data.InspectionValidateAllowZeros = types.BoolValue(false)
	}
	if value := res.Get(prefix + "inspection.log-buffer.entries"); value.Exists() {
		data.InspectionLogBufferEntries = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "inspection.log-buffer.logs.entries"); value.Exists() {
		data.InspectionLogBufferLogsEntries = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "inspection.log-buffer.logs.interval"); value.Exists() {
		data.InspectionLogBufferLogsInterval = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "inspection.vlan"); value.Exists() {
		data.InspectionVlan = types.StringValue(value.String())
	}
}

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

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

func (data *ARP) getDeletedItems(ctx context.Context, state ARP) []string {
	deletedItems := make([]string, 0)
	if !state.InspectionVlan.IsNull() && data.InspectionVlan.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/vlan", state.getPath()))
	}
	if !state.InspectionLogBufferLogsInterval.IsNull() && data.InspectionLogBufferLogsInterval.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/log-buffer/logs", state.getPath()))
	}
	if !state.InspectionLogBufferLogsEntries.IsNull() && data.InspectionLogBufferLogsEntries.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/log-buffer/logs", state.getPath()))
	}
	if !state.InspectionLogBufferEntries.IsNull() && data.InspectionLogBufferEntries.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/log-buffer/entries", state.getPath()))
	}
	if !state.InspectionValidateAllowZeros.IsNull() && data.InspectionValidateAllowZeros.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/validate/allow", state.getPath()))
	}
	if !state.InspectionValidateIp.IsNull() && data.InspectionValidateIp.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/validate", state.getPath()))
	}
	if !state.InspectionValidateDstMac.IsNull() && data.InspectionValidateDstMac.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/validate", state.getPath()))
	}
	if !state.InspectionValidateSrcMac.IsNull() && data.InspectionValidateSrcMac.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/validate", state.getPath()))
	}
	for i := range state.InspectionFilters {
		stateKeyValues := [...]string{state.InspectionFilters[i].Name.ValueString()}

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

		found := false
		for j := range data.InspectionFilters {
			found = true
			if state.InspectionFilters[i].Name.ValueString() != data.InspectionFilters[j].Name.ValueString() {
				found = false
			}
			if found {
				for ci := range state.InspectionFilters[i].Vlans {
					cstateKeyValues := [...]string{state.InspectionFilters[i].Vlans[ci].VlanRange.ValueString()}

					cemptyKeys := true
					if !reflect.ValueOf(state.InspectionFilters[i].Vlans[ci].VlanRange.ValueString()).IsZero() {
						cemptyKeys = false
					}
					if cemptyKeys {
						continue
					}

					found := false
					for cj := range data.InspectionFilters[j].Vlans {
						found = true
						if state.InspectionFilters[i].Vlans[ci].VlanRange.ValueString() != data.InspectionFilters[j].Vlans[cj].VlanRange.ValueString() {
							found = false
						}
						if found {
							if !state.InspectionFilters[i].Vlans[ci].Static.IsNull() && data.InspectionFilters[j].Vlans[cj].Static.IsNull() {
								deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/filter=%v/vlan=%v/static", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
							}
							break
						}
					}
					if !found {
						deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/filter=%v/vlan=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
					}
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/inspection/filter=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	if !state.EntryLearn.IsNull() && data.EntryLearn.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/entry/learn", state.getPath()))
	}
	if !state.ProxyDisable.IsNull() && data.ProxyDisable.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/proxy/disable", state.getPath()))
	}
	if !state.IncompleteEntries.IsNull() && data.IncompleteEntries.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/incomplete/entries", state.getPath()))
	}

	return deletedItems
}

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

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

func (data *ARP) getEmptyLeafsDelete(ctx context.Context) []string {
	emptyLeafsDelete := make([]string, 0)
	if !data.InspectionValidateAllowZeros.IsNull() && !data.InspectionValidateAllowZeros.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/inspection/validate/allow/zeros", data.getPath()))
	}
	if !data.InspectionValidateIp.IsNull() && !data.InspectionValidateIp.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/inspection/validate/ip", data.getPath()))
	}
	if !data.InspectionValidateDstMac.IsNull() && !data.InspectionValidateDstMac.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/inspection/validate/dst-mac", data.getPath()))
	}
	if !data.InspectionValidateSrcMac.IsNull() && !data.InspectionValidateSrcMac.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/inspection/validate/src-mac", data.getPath()))
	}

	for i := range data.InspectionFilters {
		keyValues := [...]string{data.InspectionFilters[i].Name.ValueString()}

		for ci := range data.InspectionFilters[i].Vlans {
			ckeyValues := [...]string{data.InspectionFilters[i].Vlans[ci].VlanRange.ValueString()}
			if !data.InspectionFilters[i].Vlans[ci].Static.IsNull() && !data.InspectionFilters[i].Vlans[ci].Static.ValueBool() {
				emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/inspection/filter=%v/vlan=%v/static", data.getPath(), strings.Join(keyValues[:], ","), strings.Join(ckeyValues[:], ",")))
			}
		}
	}
	if !data.ProxyDisable.IsNull() && !data.ProxyDisable.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/proxy/disable", data.getPath()))
	}

	return emptyLeafsDelete
}

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

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

func (data *ARP) getDeletePaths(ctx context.Context) []string {
	var deletePaths []string
	if !data.InspectionVlan.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/inspection/vlan", data.getPath()))
	}
	if !data.InspectionLogBufferLogsInterval.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/inspection/log-buffer/logs", data.getPath()))
	}
	if !data.InspectionLogBufferLogsEntries.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/inspection/log-buffer/logs", data.getPath()))
	}
	if !data.InspectionLogBufferEntries.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/inspection/log-buffer/entries", data.getPath()))
	}
	if !data.InspectionValidateAllowZeros.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/inspection/validate/allow", data.getPath()))
	}
	if !data.InspectionValidateIp.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/inspection/validate", data.getPath()))
	}
	if !data.InspectionValidateDstMac.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/inspection/validate", data.getPath()))
	}
	if !data.InspectionValidateSrcMac.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/inspection/validate", data.getPath()))
	}
	for i := range data.InspectionFilters {
		keyValues := [...]string{data.InspectionFilters[i].Name.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/inspection/filter=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	if !data.EntryLearn.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/entry/learn", data.getPath()))
	}
	if !data.ProxyDisable.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/proxy/disable", data.getPath()))
	}
	if !data.IncompleteEntries.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/incomplete/entries", data.getPath()))
	}

	return deletePaths
}

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