// 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"
	"net/url"
	"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 InterfaceOSPF struct {
	Device                       types.String                     `tfsdk:"device"`
	Id                           types.String                     `tfsdk:"id"`
	DeleteMode                   types.String                     `tfsdk:"delete_mode"`
	Type                         types.String                     `tfsdk:"type"`
	Name                         types.String                     `tfsdk:"name"`
	Cost                         types.Int64                      `tfsdk:"cost"`
	DeadInterval                 types.Int64                      `tfsdk:"dead_interval"`
	HelloInterval                types.Int64                      `tfsdk:"hello_interval"`
	MtuIgnore                    types.Bool                       `tfsdk:"mtu_ignore"`
	NetworkTypeBroadcast         types.Bool                       `tfsdk:"network_type_broadcast"`
	NetworkTypeNonBroadcast      types.Bool                       `tfsdk:"network_type_non_broadcast"`
	NetworkTypePointToMultipoint types.Bool                       `tfsdk:"network_type_point_to_multipoint"`
	NetworkTypePointToPoint      types.Bool                       `tfsdk:"network_type_point_to_point"`
	Priority                     types.Int64                      `tfsdk:"priority"`
	TtlSecurityHops              types.Int64                      `tfsdk:"ttl_security_hops"`
	ProcessIds                   []InterfaceOSPFProcessIds        `tfsdk:"process_ids"`
	MessageDigestKeys            []InterfaceOSPFMessageDigestKeys `tfsdk:"message_digest_keys"`
}

type InterfaceOSPFData struct {
	Device                       types.String                     `tfsdk:"device"`
	Id                           types.String                     `tfsdk:"id"`
	Type                         types.String                     `tfsdk:"type"`
	Name                         types.String                     `tfsdk:"name"`
	Cost                         types.Int64                      `tfsdk:"cost"`
	DeadInterval                 types.Int64                      `tfsdk:"dead_interval"`
	HelloInterval                types.Int64                      `tfsdk:"hello_interval"`
	MtuIgnore                    types.Bool                       `tfsdk:"mtu_ignore"`
	NetworkTypeBroadcast         types.Bool                       `tfsdk:"network_type_broadcast"`
	NetworkTypeNonBroadcast      types.Bool                       `tfsdk:"network_type_non_broadcast"`
	NetworkTypePointToMultipoint types.Bool                       `tfsdk:"network_type_point_to_multipoint"`
	NetworkTypePointToPoint      types.Bool                       `tfsdk:"network_type_point_to_point"`
	Priority                     types.Int64                      `tfsdk:"priority"`
	TtlSecurityHops              types.Int64                      `tfsdk:"ttl_security_hops"`
	ProcessIds                   []InterfaceOSPFProcessIds        `tfsdk:"process_ids"`
	MessageDigestKeys            []InterfaceOSPFMessageDigestKeys `tfsdk:"message_digest_keys"`
}
type InterfaceOSPFProcessIds struct {
	Id    types.Int64                    `tfsdk:"id"`
	Areas []InterfaceOSPFProcessIdsAreas `tfsdk:"areas"`
}
type InterfaceOSPFMessageDigestKeys struct {
	Id          types.Int64  `tfsdk:"id"`
	Md5AuthKey  types.String `tfsdk:"md5_auth_key"`
	Md5AuthType types.Int64  `tfsdk:"md5_auth_type"`
}
type InterfaceOSPFProcessIdsAreas struct {
	AreaId types.String `tfsdk:"area_id"`
}

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

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

func (data InterfaceOSPF) getPath() string {
	return fmt.Sprintf("Cisco-IOS-XE-native:native/interface/%s=%v/ip/Cisco-IOS-XE-ospf:router-ospf/ospf", url.QueryEscape(fmt.Sprintf("%v", data.Type.ValueString())), url.QueryEscape(fmt.Sprintf("%v", data.Name.ValueString())))
}

func (data InterfaceOSPFData) getPath() string {
	return fmt.Sprintf("Cisco-IOS-XE-native:native/interface/%s=%v/ip/Cisco-IOS-XE-ospf:router-ospf/ospf", url.QueryEscape(fmt.Sprintf("%v", data.Type.ValueString())), url.QueryEscape(fmt.Sprintf("%v", data.Name.ValueString())))
}

// if last path element has a key -> remove it
func (data InterfaceOSPF) 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 InterfaceOSPF) toBody(ctx context.Context) string {
	body := `{"` + helpers.LastElement(data.getPath()) + `":{}}`
	if !data.Cost.IsNull() && !data.Cost.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"cost", strconv.FormatInt(data.Cost.ValueInt64(), 10))
	}
	if !data.DeadInterval.IsNull() && !data.DeadInterval.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"dead-interval", strconv.FormatInt(data.DeadInterval.ValueInt64(), 10))
	}
	if !data.HelloInterval.IsNull() && !data.HelloInterval.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"hello-interval", strconv.FormatInt(data.HelloInterval.ValueInt64(), 10))
	}
	if !data.MtuIgnore.IsNull() && !data.MtuIgnore.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"mtu-ignore", data.MtuIgnore.ValueBool())
	}
	if !data.NetworkTypeBroadcast.IsNull() && !data.NetworkTypeBroadcast.IsUnknown() {
		if data.NetworkTypeBroadcast.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"network.broadcast", map[string]string{})
		}
	}
	if !data.NetworkTypeNonBroadcast.IsNull() && !data.NetworkTypeNonBroadcast.IsUnknown() {
		if data.NetworkTypeNonBroadcast.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"network.non-broadcast", map[string]string{})
		}
	}
	if !data.NetworkTypePointToMultipoint.IsNull() && !data.NetworkTypePointToMultipoint.IsUnknown() {
		if data.NetworkTypePointToMultipoint.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"network.point-to-multipoint", map[string]string{})
		}
	}
	if !data.NetworkTypePointToPoint.IsNull() && !data.NetworkTypePointToPoint.IsUnknown() {
		if data.NetworkTypePointToPoint.ValueBool() {
			body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"network.point-to-point", map[string]string{})
		}
	}
	if !data.Priority.IsNull() && !data.Priority.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"priority", strconv.FormatInt(data.Priority.ValueInt64(), 10))
	}
	if !data.TtlSecurityHops.IsNull() && !data.TtlSecurityHops.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ttl-security.hops", strconv.FormatInt(data.TtlSecurityHops.ValueInt64(), 10))
	}
	if len(data.ProcessIds) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"process-id", []interface{}{})
		for index, item := range data.ProcessIds {
			if !item.Id.IsNull() && !item.Id.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"process-id"+"."+strconv.Itoa(index)+"."+"id", strconv.FormatInt(item.Id.ValueInt64(), 10))
			}
			if len(item.Areas) > 0 {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"process-id"+"."+strconv.Itoa(index)+"."+"area", []interface{}{})
				for cindex, citem := range item.Areas {
					if !citem.AreaId.IsNull() && !citem.AreaId.IsUnknown() {
						body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"process-id"+"."+strconv.Itoa(index)+"."+"area"+"."+strconv.Itoa(cindex)+"."+"area-id", citem.AreaId.ValueString())
					}
				}
			}
		}
	}
	if len(data.MessageDigestKeys) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"message-digest-key", []interface{}{})
		for index, item := range data.MessageDigestKeys {
			if !item.Id.IsNull() && !item.Id.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"message-digest-key"+"."+strconv.Itoa(index)+"."+"id", strconv.FormatInt(item.Id.ValueInt64(), 10))
			}
			if !item.Md5AuthKey.IsNull() && !item.Md5AuthKey.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"message-digest-key"+"."+strconv.Itoa(index)+"."+"md5.auth-key", item.Md5AuthKey.ValueString())
			}
			if !item.Md5AuthType.IsNull() && !item.Md5AuthType.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"message-digest-key"+"."+strconv.Itoa(index)+"."+"md5.auth-type", strconv.FormatInt(item.Md5AuthType.ValueInt64(), 10))
			}
		}
	}
	return body
}

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

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

func (data *InterfaceOSPF) 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 + "cost"); value.Exists() && !data.Cost.IsNull() {
		data.Cost = types.Int64Value(value.Int())
	} else {
		data.Cost = types.Int64Null()
	}
	if value := res.Get(prefix + "dead-interval"); value.Exists() && !data.DeadInterval.IsNull() {
		data.DeadInterval = types.Int64Value(value.Int())
	} else {
		data.DeadInterval = types.Int64Null()
	}
	if value := res.Get(prefix + "hello-interval"); value.Exists() && !data.HelloInterval.IsNull() {
		data.HelloInterval = types.Int64Value(value.Int())
	} else {
		data.HelloInterval = types.Int64Null()
	}
	if value := res.Get(prefix + "mtu-ignore"); !data.MtuIgnore.IsNull() {
		if value.Exists() {
			data.MtuIgnore = types.BoolValue(value.Bool())
		}
	} else {
		data.MtuIgnore = types.BoolNull()
	}
	if value := res.Get(prefix + "network.broadcast"); !data.NetworkTypeBroadcast.IsNull() {
		if value.Exists() {
			data.NetworkTypeBroadcast = types.BoolValue(true)
		} else {
			data.NetworkTypeBroadcast = types.BoolValue(false)
		}
	} else {
		data.NetworkTypeBroadcast = types.BoolNull()
	}
	if value := res.Get(prefix + "network.non-broadcast"); !data.NetworkTypeNonBroadcast.IsNull() {
		if value.Exists() {
			data.NetworkTypeNonBroadcast = types.BoolValue(true)
		} else {
			data.NetworkTypeNonBroadcast = types.BoolValue(false)
		}
	} else {
		data.NetworkTypeNonBroadcast = types.BoolNull()
	}
	if value := res.Get(prefix + "network.point-to-multipoint"); !data.NetworkTypePointToMultipoint.IsNull() {
		if value.Exists() {
			data.NetworkTypePointToMultipoint = types.BoolValue(true)
		} else {
			data.NetworkTypePointToMultipoint = types.BoolValue(false)
		}
	} else {
		data.NetworkTypePointToMultipoint = types.BoolNull()
	}
	if value := res.Get(prefix + "network.point-to-point"); !data.NetworkTypePointToPoint.IsNull() {
		if value.Exists() {
			data.NetworkTypePointToPoint = types.BoolValue(true)
		} else {
			data.NetworkTypePointToPoint = types.BoolValue(false)
		}
	} else {
		data.NetworkTypePointToPoint = types.BoolNull()
	}
	if value := res.Get(prefix + "priority"); value.Exists() && !data.Priority.IsNull() {
		data.Priority = types.Int64Value(value.Int())
	} else {
		data.Priority = types.Int64Null()
	}
	if value := res.Get(prefix + "ttl-security.hops"); value.Exists() && !data.TtlSecurityHops.IsNull() {
		data.TtlSecurityHops = types.Int64Value(value.Int())
	} else {
		data.TtlSecurityHops = types.Int64Null()
	}
	for i := range data.ProcessIds {
		keys := [...]string{"id"}
		keyValues := [...]string{strconv.FormatInt(data.ProcessIds[i].Id.ValueInt64(), 10)}

		var r gjson.Result
		res.Get(prefix + "process-id").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.ProcessIds[i].Id.IsNull() {
			data.ProcessIds[i].Id = types.Int64Value(value.Int())
		} else {
			data.ProcessIds[i].Id = types.Int64Null()
		}
		for ci := range data.ProcessIds[i].Areas {
			keys := [...]string{"area-id"}
			keyValues := [...]string{data.ProcessIds[i].Areas[ci].AreaId.ValueString()}

			var cr gjson.Result
			r.Get("area").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("area-id"); value.Exists() && !data.ProcessIds[i].Areas[ci].AreaId.IsNull() {
				data.ProcessIds[i].Areas[ci].AreaId = types.StringValue(value.String())
			} else {
				data.ProcessIds[i].Areas[ci].AreaId = types.StringNull()
			}
		}
	}
	for i := range data.MessageDigestKeys {
		keys := [...]string{"id"}
		keyValues := [...]string{strconv.FormatInt(data.MessageDigestKeys[i].Id.ValueInt64(), 10)}

		var r gjson.Result
		res.Get(prefix + "message-digest-key").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.MessageDigestKeys[i].Id.IsNull() {
			data.MessageDigestKeys[i].Id = types.Int64Value(value.Int())
		} else {
			data.MessageDigestKeys[i].Id = types.Int64Null()
		}
	}
}

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

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

func (data *InterfaceOSPF) 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 + "cost"); value.Exists() {
		data.Cost = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "dead-interval"); value.Exists() {
		data.DeadInterval = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "hello-interval"); value.Exists() {
		data.HelloInterval = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "mtu-ignore"); value.Exists() {
		data.MtuIgnore = types.BoolValue(value.Bool())
	} else {
		data.MtuIgnore = types.BoolNull()
	}
	if value := res.Get(prefix + "network.broadcast"); value.Exists() {
		data.NetworkTypeBroadcast = types.BoolValue(true)
	} else {
		data.NetworkTypeBroadcast = types.BoolValue(false)
	}
	if value := res.Get(prefix + "network.non-broadcast"); value.Exists() {
		data.NetworkTypeNonBroadcast = types.BoolValue(true)
	} else {
		data.NetworkTypeNonBroadcast = types.BoolValue(false)
	}
	if value := res.Get(prefix + "network.point-to-multipoint"); value.Exists() {
		data.NetworkTypePointToMultipoint = types.BoolValue(true)
	} else {
		data.NetworkTypePointToMultipoint = types.BoolValue(false)
	}
	if value := res.Get(prefix + "network.point-to-point"); value.Exists() {
		data.NetworkTypePointToPoint = types.BoolValue(true)
	} else {
		data.NetworkTypePointToPoint = types.BoolValue(false)
	}
	if value := res.Get(prefix + "priority"); value.Exists() {
		data.Priority = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "ttl-security.hops"); value.Exists() {
		data.TtlSecurityHops = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "process-id"); value.Exists() {
		data.ProcessIds = make([]InterfaceOSPFProcessIds, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := InterfaceOSPFProcessIds{}
			if cValue := v.Get("id"); cValue.Exists() {
				item.Id = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("area"); cValue.Exists() {
				item.Areas = make([]InterfaceOSPFProcessIdsAreas, 0)
				cValue.ForEach(func(ck, cv gjson.Result) bool {
					cItem := InterfaceOSPFProcessIdsAreas{}
					if ccValue := cv.Get("area-id"); ccValue.Exists() {
						cItem.AreaId = types.StringValue(ccValue.String())
					}
					item.Areas = append(item.Areas, cItem)
					return true
				})
			}
			data.ProcessIds = append(data.ProcessIds, item)
			return true
		})
	}
	if value := res.Get(prefix + "message-digest-key"); value.Exists() {
		data.MessageDigestKeys = make([]InterfaceOSPFMessageDigestKeys, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := InterfaceOSPFMessageDigestKeys{}
			if cValue := v.Get("id"); cValue.Exists() {
				item.Id = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("md5.auth-key"); cValue.Exists() {
				item.Md5AuthKey = types.StringValue(cValue.String())
			}
			if cValue := v.Get("md5.auth-type"); cValue.Exists() {
				item.Md5AuthType = types.Int64Value(cValue.Int())
			}
			data.MessageDigestKeys = append(data.MessageDigestKeys, item)
			return true
		})
	}
}

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

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

func (data *InterfaceOSPFData) 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 + "cost"); value.Exists() {
		data.Cost = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "dead-interval"); value.Exists() {
		data.DeadInterval = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "hello-interval"); value.Exists() {
		data.HelloInterval = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "mtu-ignore"); value.Exists() {
		data.MtuIgnore = types.BoolValue(value.Bool())
	} else {
		data.MtuIgnore = types.BoolNull()
	}
	if value := res.Get(prefix + "network.broadcast"); value.Exists() {
		data.NetworkTypeBroadcast = types.BoolValue(true)
	} else {
		data.NetworkTypeBroadcast = types.BoolValue(false)
	}
	if value := res.Get(prefix + "network.non-broadcast"); value.Exists() {
		data.NetworkTypeNonBroadcast = types.BoolValue(true)
	} else {
		data.NetworkTypeNonBroadcast = types.BoolValue(false)
	}
	if value := res.Get(prefix + "network.point-to-multipoint"); value.Exists() {
		data.NetworkTypePointToMultipoint = types.BoolValue(true)
	} else {
		data.NetworkTypePointToMultipoint = types.BoolValue(false)
	}
	if value := res.Get(prefix + "network.point-to-point"); value.Exists() {
		data.NetworkTypePointToPoint = types.BoolValue(true)
	} else {
		data.NetworkTypePointToPoint = types.BoolValue(false)
	}
	if value := res.Get(prefix + "priority"); value.Exists() {
		data.Priority = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "ttl-security.hops"); value.Exists() {
		data.TtlSecurityHops = types.Int64Value(value.Int())
	}
	if value := res.Get(prefix + "process-id"); value.Exists() {
		data.ProcessIds = make([]InterfaceOSPFProcessIds, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := InterfaceOSPFProcessIds{}
			if cValue := v.Get("id"); cValue.Exists() {
				item.Id = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("area"); cValue.Exists() {
				item.Areas = make([]InterfaceOSPFProcessIdsAreas, 0)
				cValue.ForEach(func(ck, cv gjson.Result) bool {
					cItem := InterfaceOSPFProcessIdsAreas{}
					if ccValue := cv.Get("area-id"); ccValue.Exists() {
						cItem.AreaId = types.StringValue(ccValue.String())
					}
					item.Areas = append(item.Areas, cItem)
					return true
				})
			}
			data.ProcessIds = append(data.ProcessIds, item)
			return true
		})
	}
	if value := res.Get(prefix + "message-digest-key"); value.Exists() {
		data.MessageDigestKeys = make([]InterfaceOSPFMessageDigestKeys, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := InterfaceOSPFMessageDigestKeys{}
			if cValue := v.Get("id"); cValue.Exists() {
				item.Id = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("md5.auth-key"); cValue.Exists() {
				item.Md5AuthKey = types.StringValue(cValue.String())
			}
			if cValue := v.Get("md5.auth-type"); cValue.Exists() {
				item.Md5AuthType = types.Int64Value(cValue.Int())
			}
			data.MessageDigestKeys = append(data.MessageDigestKeys, item)
			return true
		})
	}
}

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

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

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

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

		found := false
		for j := range data.MessageDigestKeys {
			found = true
			if state.MessageDigestKeys[i].Id.ValueInt64() != data.MessageDigestKeys[j].Id.ValueInt64() {
				found = false
			}
			if found {
				if !state.MessageDigestKeys[i].Md5AuthKey.IsNull() && data.MessageDigestKeys[j].Md5AuthKey.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/message-digest-key=%v/md5/auth-key", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/message-digest-key=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.ProcessIds {
		stateKeyValues := [...]string{strconv.FormatInt(state.ProcessIds[i].Id.ValueInt64(), 10)}

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

		found := false
		for j := range data.ProcessIds {
			found = true
			if state.ProcessIds[i].Id.ValueInt64() != data.ProcessIds[j].Id.ValueInt64() {
				found = false
			}
			if found {
				for ci := range state.ProcessIds[i].Areas {
					cstateKeyValues := [...]string{state.ProcessIds[i].Areas[ci].AreaId.ValueString()}

					cemptyKeys := true
					if !reflect.ValueOf(state.ProcessIds[i].Areas[ci].AreaId.ValueString()).IsZero() {
						cemptyKeys = false
					}
					if cemptyKeys {
						continue
					}

					found := false
					for cj := range data.ProcessIds[j].Areas {
						found = true
						if state.ProcessIds[i].Areas[ci].AreaId.ValueString() != data.ProcessIds[j].Areas[cj].AreaId.ValueString() {
							found = false
						}
						if found {
							break
						}
					}
					if !found {
						deletedItems = append(deletedItems, fmt.Sprintf("%v/process-id=%v/area=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
					}
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/process-id=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	if !state.TtlSecurityHops.IsNull() && data.TtlSecurityHops.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/ttl-security/hops", state.getPath()))
	}
	if !state.Priority.IsNull() && data.Priority.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/priority", state.getPath()))
	}
	if !state.NetworkTypePointToPoint.IsNull() && data.NetworkTypePointToPoint.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/network/point-to-point", state.getPath()))
	}
	if !state.NetworkTypePointToMultipoint.IsNull() && data.NetworkTypePointToMultipoint.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/network/point-to-multipoint", state.getPath()))
	}
	if !state.NetworkTypeNonBroadcast.IsNull() && data.NetworkTypeNonBroadcast.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/network/non-broadcast", state.getPath()))
	}
	if !state.NetworkTypeBroadcast.IsNull() && data.NetworkTypeBroadcast.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/network/broadcast", state.getPath()))
	}
	if !state.MtuIgnore.IsNull() && data.MtuIgnore.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/mtu-ignore", state.getPath()))
	}
	if !state.HelloInterval.IsNull() && data.HelloInterval.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/hello-interval", state.getPath()))
	}
	if !state.DeadInterval.IsNull() && data.DeadInterval.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/dead-interval", state.getPath()))
	}
	if !state.Cost.IsNull() && data.Cost.IsNull() {
		deletedItems = append(deletedItems, fmt.Sprintf("%v/cost", state.getPath()))
	}

	return deletedItems
}

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

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

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

	if !data.NetworkTypePointToPoint.IsNull() && !data.NetworkTypePointToPoint.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/network/point-to-point", data.getPath()))
	}
	if !data.NetworkTypePointToMultipoint.IsNull() && !data.NetworkTypePointToMultipoint.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/network/point-to-multipoint", data.getPath()))
	}
	if !data.NetworkTypeNonBroadcast.IsNull() && !data.NetworkTypeNonBroadcast.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/network/non-broadcast", data.getPath()))
	}
	if !data.NetworkTypeBroadcast.IsNull() && !data.NetworkTypeBroadcast.ValueBool() {
		emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/network/broadcast", data.getPath()))
	}

	return emptyLeafsDelete
}

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

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

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

		deletePaths = append(deletePaths, fmt.Sprintf("%v/message-digest-key=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.ProcessIds {
		keyValues := [...]string{strconv.FormatInt(data.ProcessIds[i].Id.ValueInt64(), 10)}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/process-id=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	if !data.TtlSecurityHops.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/ttl-security/hops", data.getPath()))
	}
	if !data.Priority.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/priority", data.getPath()))
	}
	if !data.NetworkTypePointToPoint.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/network/point-to-point", data.getPath()))
	}
	if !data.NetworkTypePointToMultipoint.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/network/point-to-multipoint", data.getPath()))
	}
	if !data.NetworkTypeNonBroadcast.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/network/non-broadcast", data.getPath()))
	}
	if !data.NetworkTypeBroadcast.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/network/broadcast", data.getPath()))
	}
	if !data.MtuIgnore.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/mtu-ignore", data.getPath()))
	}
	if !data.HelloInterval.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/hello-interval", data.getPath()))
	}
	if !data.DeadInterval.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/dead-interval", data.getPath()))
	}
	if !data.Cost.IsNull() {
		deletePaths = append(deletePaths, fmt.Sprintf("%v/cost", data.getPath()))
	}

	return deletePaths
}

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