// 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 StaticRoute struct {
	Device            types.String                   `tfsdk:"device"`
	Id                types.String                   `tfsdk:"id"`
	Prefix            types.String                   `tfsdk:"prefix"`
	Mask              types.String                   `tfsdk:"mask"`
	NextHops          []StaticRouteNextHops          `tfsdk:"next_hops"`
	NextHopsWithTrack []StaticRouteNextHopsWithTrack `tfsdk:"next_hops_with_track"`
}

type StaticRouteData struct {
	Device            types.String                   `tfsdk:"device"`
	Id                types.String                   `tfsdk:"id"`
	Prefix            types.String                   `tfsdk:"prefix"`
	Mask              types.String                   `tfsdk:"mask"`
	NextHops          []StaticRouteNextHops          `tfsdk:"next_hops"`
	NextHopsWithTrack []StaticRouteNextHopsWithTrack `tfsdk:"next_hops_with_track"`
}
type StaticRouteNextHops struct {
	NextHop   types.String `tfsdk:"next_hop"`
	Distance  types.Int64  `tfsdk:"distance"`
	Global    types.Bool   `tfsdk:"global"`
	Name      types.String `tfsdk:"name"`
	Permanent types.Bool   `tfsdk:"permanent"`
	Tag       types.Int64  `tfsdk:"tag"`
}
type StaticRouteNextHopsWithTrack struct {
	NextHop     types.String `tfsdk:"next_hop"`
	Name        types.String `tfsdk:"name"`
	TrackIdName types.Int64  `tfsdk:"track_id_name"`
	Distance    types.Int64  `tfsdk:"distance"`
	Tag         types.Int64  `tfsdk:"tag"`
	Permanent   types.Bool   `tfsdk:"permanent"`
}

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

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

func (data StaticRoute) getPath() string {
	return fmt.Sprintf("Cisco-IOS-XE-native:native/ip/route/ip-route-interface-forwarding-list=%s,%s", url.QueryEscape(fmt.Sprintf("%v", data.Prefix.ValueString())), url.QueryEscape(fmt.Sprintf("%v", data.Mask.ValueString())))
}

func (data StaticRouteData) getPath() string {
	return fmt.Sprintf("Cisco-IOS-XE-native:native/ip/route/ip-route-interface-forwarding-list=%s,%s", url.QueryEscape(fmt.Sprintf("%v", data.Prefix.ValueString())), url.QueryEscape(fmt.Sprintf("%v", data.Mask.ValueString())))
}

// if last path element has a key -> remove it
func (data StaticRoute) 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 StaticRoute) toBody(ctx context.Context) string {
	body := `{"` + helpers.LastElement(data.getPath()) + `":{}}`
	if !data.Prefix.IsNull() && !data.Prefix.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"prefix", data.Prefix.ValueString())
	}
	if !data.Mask.IsNull() && !data.Mask.IsUnknown() {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"mask", data.Mask.ValueString())
	}
	if len(data.NextHops) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list", []interface{}{})
		for index, item := range data.NextHops {
			if !item.NextHop.IsNull() && !item.NextHop.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list"+"."+strconv.Itoa(index)+"."+"fwd", item.NextHop.ValueString())
			}
			if !item.Distance.IsNull() && !item.Distance.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list"+"."+strconv.Itoa(index)+"."+"metric", strconv.FormatInt(item.Distance.ValueInt64(), 10))
			}
			if !item.Global.IsNull() && !item.Global.IsUnknown() {
				if item.Global.ValueBool() {
					body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list"+"."+strconv.Itoa(index)+"."+"global", map[string]string{})
				}
			}
			if !item.Name.IsNull() && !item.Name.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
			}
			if !item.Permanent.IsNull() && !item.Permanent.IsUnknown() {
				if item.Permanent.ValueBool() {
					body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list"+"."+strconv.Itoa(index)+"."+"permanent", map[string]string{})
				}
			}
			if !item.Tag.IsNull() && !item.Tag.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list"+"."+strconv.Itoa(index)+"."+"tag", strconv.FormatInt(item.Tag.ValueInt64(), 10))
			}
		}
	}
	if len(data.NextHopsWithTrack) > 0 {
		body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list-with-track", []interface{}{})
		for index, item := range data.NextHopsWithTrack {
			if !item.NextHop.IsNull() && !item.NextHop.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list-with-track"+"."+strconv.Itoa(index)+"."+"fwd", item.NextHop.ValueString())
			}
			if !item.Name.IsNull() && !item.Name.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list-with-track"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
			}
			if !item.TrackIdName.IsNull() && !item.TrackIdName.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list-with-track"+"."+strconv.Itoa(index)+"."+"track-id-name.id", strconv.FormatInt(item.TrackIdName.ValueInt64(), 10))
			}
			if !item.Distance.IsNull() && !item.Distance.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list-with-track"+"."+strconv.Itoa(index)+"."+"metric", strconv.FormatInt(item.Distance.ValueInt64(), 10))
			}
			if !item.Tag.IsNull() && !item.Tag.IsUnknown() {
				body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list-with-track"+"."+strconv.Itoa(index)+"."+"tag", strconv.FormatInt(item.Tag.ValueInt64(), 10))
			}
			if !item.Permanent.IsNull() && !item.Permanent.IsUnknown() {
				if item.Permanent.ValueBool() {
					body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"fwd-list-with-track"+"."+strconv.Itoa(index)+"."+"permanent", 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 *StaticRoute) 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 + "prefix"); value.Exists() && !data.Prefix.IsNull() {
		data.Prefix = types.StringValue(value.String())
	} else {
		data.Prefix = types.StringNull()
	}
	if value := res.Get(prefix + "mask"); value.Exists() && !data.Mask.IsNull() {
		data.Mask = types.StringValue(value.String())
	} else {
		data.Mask = types.StringNull()
	}
	for i := range data.NextHops {
		keys := [...]string{"fwd"}
		keyValues := [...]string{data.NextHops[i].NextHop.ValueString()}

		var r gjson.Result
		res.Get(prefix + "fwd-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("fwd"); value.Exists() && !data.NextHops[i].NextHop.IsNull() {
			data.NextHops[i].NextHop = types.StringValue(value.String())
		} else {
			data.NextHops[i].NextHop = types.StringNull()
		}
		if value := r.Get("metric"); value.Exists() && !data.NextHops[i].Distance.IsNull() {
			data.NextHops[i].Distance = types.Int64Value(value.Int())
		} else {
			data.NextHops[i].Distance = types.Int64Null()
		}
		if value := r.Get("global"); !data.NextHops[i].Global.IsNull() {
			if value.Exists() {
				data.NextHops[i].Global = types.BoolValue(true)
			} else {
				data.NextHops[i].Global = types.BoolValue(false)
			}
		} else {
			data.NextHops[i].Global = types.BoolNull()
		}
		if value := r.Get("name"); value.Exists() && !data.NextHops[i].Name.IsNull() {
			data.NextHops[i].Name = types.StringValue(value.String())
		} else {
			data.NextHops[i].Name = types.StringNull()
		}
		if value := r.Get("permanent"); !data.NextHops[i].Permanent.IsNull() {
			if value.Exists() {
				data.NextHops[i].Permanent = types.BoolValue(true)
			} else {
				data.NextHops[i].Permanent = types.BoolValue(false)
			}
		} else {
			data.NextHops[i].Permanent = types.BoolNull()
		}
		if value := r.Get("tag"); value.Exists() && !data.NextHops[i].Tag.IsNull() {
			data.NextHops[i].Tag = types.Int64Value(value.Int())
		} else {
			data.NextHops[i].Tag = types.Int64Null()
		}
	}
	for i := range data.NextHopsWithTrack {
		keys := [...]string{"fwd"}
		keyValues := [...]string{data.NextHopsWithTrack[i].NextHop.ValueString()}

		var r gjson.Result
		res.Get(prefix + "fwd-list-with-track").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("fwd"); value.Exists() && !data.NextHopsWithTrack[i].NextHop.IsNull() {
			data.NextHopsWithTrack[i].NextHop = types.StringValue(value.String())
		} else {
			data.NextHopsWithTrack[i].NextHop = types.StringNull()
		}
		if value := r.Get("name"); value.Exists() && !data.NextHopsWithTrack[i].Name.IsNull() {
			data.NextHopsWithTrack[i].Name = types.StringValue(value.String())
		} else {
			data.NextHopsWithTrack[i].Name = types.StringNull()
		}
		if value := r.Get("track-id-name.id"); value.Exists() && !data.NextHopsWithTrack[i].TrackIdName.IsNull() {
			data.NextHopsWithTrack[i].TrackIdName = types.Int64Value(value.Int())
		} else {
			data.NextHopsWithTrack[i].TrackIdName = types.Int64Null()
		}
		if value := r.Get("metric"); value.Exists() && !data.NextHopsWithTrack[i].Distance.IsNull() {
			data.NextHopsWithTrack[i].Distance = types.Int64Value(value.Int())
		} else {
			data.NextHopsWithTrack[i].Distance = types.Int64Null()
		}
		if value := r.Get("tag"); value.Exists() && !data.NextHopsWithTrack[i].Tag.IsNull() {
			data.NextHopsWithTrack[i].Tag = types.Int64Value(value.Int())
		} else {
			data.NextHopsWithTrack[i].Tag = types.Int64Null()
		}
		if value := r.Get("permanent"); !data.NextHopsWithTrack[i].Permanent.IsNull() {
			if value.Exists() {
				data.NextHopsWithTrack[i].Permanent = types.BoolValue(true)
			} else {
				data.NextHopsWithTrack[i].Permanent = types.BoolValue(false)
			}
		} else {
			data.NextHopsWithTrack[i].Permanent = types.BoolNull()
		}
	}
}

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

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

func (data *StaticRoute) 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 + "fwd-list"); value.Exists() {
		data.NextHops = make([]StaticRouteNextHops, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := StaticRouteNextHops{}
			if cValue := v.Get("fwd"); cValue.Exists() {
				item.NextHop = types.StringValue(cValue.String())
			}
			if cValue := v.Get("metric"); cValue.Exists() {
				item.Distance = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("global"); cValue.Exists() {
				item.Global = types.BoolValue(true)
			} else {
				item.Global = types.BoolValue(false)
			}
			if cValue := v.Get("name"); cValue.Exists() {
				item.Name = types.StringValue(cValue.String())
			}
			if cValue := v.Get("permanent"); cValue.Exists() {
				item.Permanent = types.BoolValue(true)
			} else {
				item.Permanent = types.BoolValue(false)
			}
			if cValue := v.Get("tag"); cValue.Exists() {
				item.Tag = types.Int64Value(cValue.Int())
			}
			data.NextHops = append(data.NextHops, item)
			return true
		})
	}
	if value := res.Get(prefix + "fwd-list-with-track"); value.Exists() {
		data.NextHopsWithTrack = make([]StaticRouteNextHopsWithTrack, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := StaticRouteNextHopsWithTrack{}
			if cValue := v.Get("fwd"); cValue.Exists() {
				item.NextHop = types.StringValue(cValue.String())
			}
			if cValue := v.Get("name"); cValue.Exists() {
				item.Name = types.StringValue(cValue.String())
			}
			if cValue := v.Get("track-id-name.id"); cValue.Exists() {
				item.TrackIdName = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("metric"); cValue.Exists() {
				item.Distance = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("tag"); cValue.Exists() {
				item.Tag = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("permanent"); cValue.Exists() {
				item.Permanent = types.BoolValue(true)
			} else {
				item.Permanent = types.BoolValue(false)
			}
			data.NextHopsWithTrack = append(data.NextHopsWithTrack, item)
			return true
		})
	}
}

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

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

func (data *StaticRouteData) 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 + "fwd-list"); value.Exists() {
		data.NextHops = make([]StaticRouteNextHops, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := StaticRouteNextHops{}
			if cValue := v.Get("fwd"); cValue.Exists() {
				item.NextHop = types.StringValue(cValue.String())
			}
			if cValue := v.Get("metric"); cValue.Exists() {
				item.Distance = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("global"); cValue.Exists() {
				item.Global = types.BoolValue(true)
			} else {
				item.Global = types.BoolValue(false)
			}
			if cValue := v.Get("name"); cValue.Exists() {
				item.Name = types.StringValue(cValue.String())
			}
			if cValue := v.Get("permanent"); cValue.Exists() {
				item.Permanent = types.BoolValue(true)
			} else {
				item.Permanent = types.BoolValue(false)
			}
			if cValue := v.Get("tag"); cValue.Exists() {
				item.Tag = types.Int64Value(cValue.Int())
			}
			data.NextHops = append(data.NextHops, item)
			return true
		})
	}
	if value := res.Get(prefix + "fwd-list-with-track"); value.Exists() {
		data.NextHopsWithTrack = make([]StaticRouteNextHopsWithTrack, 0)
		value.ForEach(func(k, v gjson.Result) bool {
			item := StaticRouteNextHopsWithTrack{}
			if cValue := v.Get("fwd"); cValue.Exists() {
				item.NextHop = types.StringValue(cValue.String())
			}
			if cValue := v.Get("name"); cValue.Exists() {
				item.Name = types.StringValue(cValue.String())
			}
			if cValue := v.Get("track-id-name.id"); cValue.Exists() {
				item.TrackIdName = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("metric"); cValue.Exists() {
				item.Distance = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("tag"); cValue.Exists() {
				item.Tag = types.Int64Value(cValue.Int())
			}
			if cValue := v.Get("permanent"); cValue.Exists() {
				item.Permanent = types.BoolValue(true)
			} else {
				item.Permanent = types.BoolValue(false)
			}
			data.NextHopsWithTrack = append(data.NextHopsWithTrack, item)
			return true
		})
	}
}

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

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

func (data *StaticRoute) getDeletedItems(ctx context.Context, state StaticRoute) []string {
	deletedItems := make([]string, 0)
	for i := range state.NextHopsWithTrack {
		stateKeyValues := [...]string{state.NextHopsWithTrack[i].NextHop.ValueString()}

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

		found := false
		for j := range data.NextHopsWithTrack {
			found = true
			if state.NextHopsWithTrack[i].NextHop.ValueString() != data.NextHopsWithTrack[j].NextHop.ValueString() {
				found = false
			}
			if found {
				if !state.NextHopsWithTrack[i].Permanent.IsNull() && data.NextHopsWithTrack[j].Permanent.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list-with-track=%v/permanent", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.NextHopsWithTrack[i].Tag.IsNull() && data.NextHopsWithTrack[j].Tag.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list-with-track=%v/tag", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.NextHopsWithTrack[i].Distance.IsNull() && data.NextHopsWithTrack[j].Distance.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list-with-track=%v/metric", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.NextHopsWithTrack[i].TrackIdName.IsNull() && data.NextHopsWithTrack[j].TrackIdName.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list-with-track=%v/track-id-name/id", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.NextHopsWithTrack[i].Name.IsNull() && data.NextHopsWithTrack[j].Name.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list-with-track=%v/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list-with-track=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}
	for i := range state.NextHops {
		stateKeyValues := [...]string{state.NextHops[i].NextHop.ValueString()}

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

		found := false
		for j := range data.NextHops {
			found = true
			if state.NextHops[i].NextHop.ValueString() != data.NextHops[j].NextHop.ValueString() {
				found = false
			}
			if found {
				if !state.NextHops[i].Tag.IsNull() && data.NextHops[j].Tag.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list=%v/tag", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.NextHops[i].Permanent.IsNull() && data.NextHops[j].Permanent.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list=%v/permanent", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.NextHops[i].Name.IsNull() && data.NextHops[j].Name.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list=%v/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.NextHops[i].Global.IsNull() && data.NextHops[j].Global.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list=%v/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				if !state.NextHops[i].Distance.IsNull() && data.NextHops[j].Distance.IsNull() {
					deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list=%v/metric", state.getPath(), strings.Join(stateKeyValues[:], ",")))
				}
				break
			}
		}
		if !found {
			deletedItems = append(deletedItems, fmt.Sprintf("%v/fwd-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
		}
	}

	return deletedItems
}

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

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

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

	for i := range data.NextHopsWithTrack {
		keyValues := [...]string{data.NextHopsWithTrack[i].NextHop.ValueString()}
		if !data.NextHopsWithTrack[i].Permanent.IsNull() && !data.NextHopsWithTrack[i].Permanent.ValueBool() {
			emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/fwd-list-with-track=%v/permanent", data.getPath(), strings.Join(keyValues[:], ",")))
		}
	}

	for i := range data.NextHops {
		keyValues := [...]string{data.NextHops[i].NextHop.ValueString()}
		if !data.NextHops[i].Permanent.IsNull() && !data.NextHops[i].Permanent.ValueBool() {
			emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/fwd-list=%v/permanent", data.getPath(), strings.Join(keyValues[:], ",")))
		}
		if !data.NextHops[i].Global.IsNull() && !data.NextHops[i].Global.ValueBool() {
			emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/fwd-list=%v/global", data.getPath(), strings.Join(keyValues[:], ",")))
		}
	}

	return emptyLeafsDelete
}

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

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

func (data *StaticRoute) getDeletePaths(ctx context.Context) []string {
	var deletePaths []string
	for i := range data.NextHopsWithTrack {
		keyValues := [...]string{data.NextHopsWithTrack[i].NextHop.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/fwd-list-with-track=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}
	for i := range data.NextHops {
		keyValues := [...]string{data.NextHops[i].NextHop.ValueString()}

		deletePaths = append(deletePaths, fmt.Sprintf("%v/fwd-list=%v", data.getPath(), strings.Join(keyValues[:], ",")))
	}

	return deletePaths
}

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