// 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"
	"regexp"
	"strings"

	"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
	"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
	"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
	"github.com/hashicorp/terraform-plugin-framework/path"
	"github.com/hashicorp/terraform-plugin-framework/resource"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
	"github.com/hashicorp/terraform-plugin-framework/schema/validator"
	"github.com/hashicorp/terraform-plugin-framework/types"
	"github.com/hashicorp/terraform-plugin-log/tflog"
	"github.com/netascode/go-restconf"
)

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

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

// Ensure provider defined types fully satisfy framework interfaces
var (
	_ resource.Resource                = &SystemResource{}
	_ resource.ResourceWithImportState = &SystemResource{}
)

func NewSystemResource() resource.Resource {
	return &SystemResource{}
}

type SystemResource struct {
	data *IosxeProviderData
}

func (r *SystemResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
	resp.TypeName = req.ProviderTypeName + "_system"
}

func (r *SystemResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
	resp.Schema = schema.Schema{
		// This description is used by the documentation generator and the language server.
		MarkdownDescription: "This resource can manage the System configuration.",

		Attributes: map[string]schema.Attribute{
			"device": schema.StringAttribute{
				MarkdownDescription: "A device name from the provider configuration.",
				Optional:            true,
			},
			"id": schema.StringAttribute{
				MarkdownDescription: "The path of the object.",
				Computed:            true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.UseStateForUnknown(),
				},
			},
			"hostname": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set system's network name").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.LengthBetween(1, 246),
					stringvalidator.RegexMatches(regexp.MustCompile(`([0-9.]*[A-Za-z\-_]+[A-Za-z0-9.\-_]*)`), ""),
				},
			},
			"ip_bgp_community_new_format": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("select aa:nn format for BGP community").String,
				Optional:            true,
			},
			"ip_routing": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable or disable IP routing").String,
				Optional:            true,
			},
			"ipv6_unicast_routing": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable unicast routing").String,
				Optional:            true,
			},
			"mtu": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("").AddIntegerRangeDescription(1500, 9198).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1500, 9198),
				},
			},
			"ip_source_route": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Process packets with source routing header options").String,
				Optional:            true,
			},
			"ip_domain_lookup": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable IP Domain Name System hostname translation").String,
				Optional:            true,
			},
			"ip_domain_name": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Define the default domain name").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.LengthBetween(1, 236),
				},
			},
			"login_delay": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set delay between successive fail login").AddIntegerRangeDescription(1, 10).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 10),
				},
			},
			"login_on_failure": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set options for failed login attempt").String,
				Optional:            true,
			},
			"login_on_failure_log": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Generate syslogs on failure logins").String,
				Optional:            true,
			},
			"login_on_success": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set options for successful login attempt").String,
				Optional:            true,
			},
			"login_on_success_log": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Generate syslogs on successful logins").String,
				Optional:            true,
			},
			"ip_multicast_routing": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable IP multicast forwarding").String,
				Optional:            true,
			},
			"multicast_routing_switch": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable IP multicast forwarding, some XE devices use this option instead of `multicast_routing`.").String,
				Optional:            true,
			},
			"ip_multicast_routing_distributed": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Distributed multicast switching").String,
				Optional:            true,
			},
			"multicast_routing_vrfs": schema.ListNestedAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Select VPN Routing/Forwarding instance").String,
				Optional:            true,
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"vrf": schema.StringAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("").String,
							Required:            true,
						},
						"distributed": schema.BoolAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("Distributed multicast switching").String,
							Optional:            true,
						},
					},
				},
			},
			"ip_http_access_class": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Restrict http server access by access-class").AddIntegerRangeDescription(1, 99).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 99),
				},
			},
			"ip_http_authentication_aaa": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Use AAA access control methods").String,
				Optional:            true,
			},
			"ip_http_authentication_aaa_exec_authorization": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set method list for exec authorization").String,
				Optional:            true,
			},
			"ip_http_authentication_aaa_login_authentication": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set method list for login authentication").String,
				Optional:            true,
			},
			"ip_http_authentication_aaa_command_authorization": schema.ListNestedAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set method list for command authorization").String,
				Optional:            true,
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"level": schema.Int64Attribute{
							MarkdownDescription: helpers.NewAttributeDescription("Enable level").AddIntegerRangeDescription(0, 15).String,
							Required:            true,
							Validators: []validator.Int64{
								int64validator.Between(0, 15),
							},
						},
						"name": schema.StringAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("Use an authorization list with this name").String,
							Optional:            true,
						},
					},
				},
			},
			"ip_http_authentication_local": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Use local username and passwords").String,
				Optional:            true,
			},
			"ip_http_server": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable http server").String,
				Optional:            true,
			},
			"ip_http_secure_server": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable HTTP secure server").String,
				Optional:            true,
			},
			"ip_http_secure_trustpoint": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set http secure server certificate trustpoint").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.LengthBetween(1, 226),
				},
			},
			"ip_http_tls_version": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set TLS version for HTTP secure server").AddStringEnumDescription("TLSv1.0", "TLSv1.1", "TLSv1.2", "TLSv1.3").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.OneOf("TLSv1.0", "TLSv1.1", "TLSv1.2", "TLSv1.3"),
				},
			},
			"ip_http_client_secure_trustpoint": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set http client certificate secure trustpoint").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.LengthBetween(1, 219),
				},
			},
			"ip_http_client_source_interface": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Specify interface for source address in all HTTP(S) client connections").String,
				Optional:            true,
			},
			"ip_http_secure_active_session_modules": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set secure active session modules").String,
				Optional:            true,
			},
			"ip_http_max_connections": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("max http connections").AddIntegerRangeDescription(1, 50).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 50),
				},
			},
			"ip_http_active_session_modules": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set active session modules").String,
				Optional:            true,
			},
			"ip_name_servers": schema.ListAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Domain server IPv4/IPv6 address (maximum of 6)").String,
				ElementType:         types.StringType,
				Optional:            true,
			},
			"ip_name_servers_vrf": schema.ListNestedAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").String,
				Optional:            true,
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"vrf": schema.StringAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("Specify VRF Name").String,
							Required:            true,
						},
						"servers": schema.ListAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("Domain server IPv4/IPv6 address (maximum of 6)").String,
							ElementType:         types.StringType,
							Optional:            true,
						},
					},
				},
			},
			"ip_domain_lookup_source_interface_loopback": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Loopback interface").AddIntegerRangeDescription(0, 2147483647).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 2147483647),
				},
			},
			"ip_domain_lookup_source_interface_vlan": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Iosxr Vlans").AddIntegerRangeDescription(0, 65535).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 65535),
				},
			},
			"ip_domain_lookup_source_interface_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("GigabitEthernet IEEE 802.3z").String,
				Optional:            true,
			},
			"ip_domain_lookup_source_interface_two_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Two GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_domain_lookup_source_interface_five_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Five GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_domain_lookup_source_interface_ten_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Ten Gigabit Ethernet").String,
				Optional:            true,
			},
			"ip_domain_lookup_source_interface_twenty_five_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Twenty Five GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_domain_lookup_source_interface_forty_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Forty GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_domain_lookup_source_interface_hundred_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Hundred GigabitEthernet").String,
				Optional:            true,
			},
			"cisp_enable": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable CISP").String,
				Optional:            true,
			},
			"epm_logging": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable EPM logging").String,
				Optional:            true,
			},
			"access_session_mac_move_deny": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Deny MAC moves (clears existing session)").String,
				Optional:            true,
			},
			"diagnostic_bootup_level": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Select diagnostic level").AddStringEnumDescription("complete", "minimal").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.OneOf("complete", "minimal"),
				},
			},
			"memory_free_low_watermark_processor": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("low water mark of memory in KB").AddIntegerRangeDescription(1, 3994575).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 3994575),
				},
			},
			"archive_path": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("path for backups").String,
				Optional:            true,
			},
			"archive_maximum": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("maximum number of backup copies").AddIntegerRangeDescription(1, 14).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 14),
				},
			},
			"archive_write_memory": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable automatic backup generation during write memory").String,
				Optional:            true,
			},
			"archive_time_period": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Period of time in minutes to automatically archive the running-config").AddIntegerRangeDescription(1, 525600).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 525600),
				},
			},
			"archive_log_config_logging_enable": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable the config logger").String,
				Optional:            true,
			},
			"archive_log_config_logging_size": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Maximum number of logged commands that will be kept by the config log").AddIntegerRangeDescription(1, 1000).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 1000),
				},
			},
			"redundancy": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enter redundancy mode").String,
				Optional:            true,
			},
			"redundancy_mode": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("redundancy mode for this chassis").AddStringEnumDescription("none", "rpr", "rpr-plus", "sso").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.OneOf("none", "rpr", "rpr-plus", "sso"),
				},
			},
			"transceiver_type_all_monitoring": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable/disable monitoring").String,
				Optional:            true,
			},
			"ip_forward_protocol_nd": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Sun's Network Disk protocol").String,
				Optional:            true,
			},
			"ip_scp_server_enable": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Enable server side of SCP").String,
				Optional:            true,
			},
			"ip_ssh_version": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Specify protocol version supported").AddStringEnumDescription("2").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.OneOf("2"),
				},
			},
			"ip_ssh_version_legacy": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Specify protocol version supported. DEPRECATED, Use ssh-version instead").AddIntegerRangeDescription(1, 2).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 2),
				},
			},
			"ip_ssh_time_out": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Specify SSH time-out interval").AddIntegerRangeDescription(1, 120).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 120),
				},
			},
			"ip_ssh_authentication_retries": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Specify number of authentication retries").AddIntegerRangeDescription(0, 5).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 5),
				},
			},
			"ip_ssh_source_interface_loopback": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Loopback interface").AddIntegerRangeDescription(0, 2147483647).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 2147483647),
				},
			},
			"ip_ssh_source_interface_vlan": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Iosxr Vlans").AddIntegerRangeDescription(0, 65535).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 65535),
				},
			},
			"ip_ssh_source_interface_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("GigabitEthernet IEEE 802.3z").String,
				Optional:            true,
			},
			"ip_ssh_source_interface_two_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Two GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_ssh_source_interface_five_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Five GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_ssh_source_interface_ten_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Ten Gigabit Ethernet").String,
				Optional:            true,
			},
			"ip_ssh_source_interface_twenty_five_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Twenty Five GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_ssh_source_interface_forty_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Forty GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_ssh_source_interface_hundred_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Hundred GigabitEthernet").String,
				Optional:            true,
			},
			"control_plane_service_policy_input": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Assign policy-map to the input of an interface").String,
				Optional:            true,
			},
			"pnp_profiles": schema.ListNestedAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("PNP profile").String,
				Optional:            true,
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"name": schema.StringAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("").String,
							Required:            true,
						},
						"transport_https_ipv4_ipv4_address": schema.StringAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("IPv4 address of the server").String,
							Optional:            true,
							Validators: []validator.String{
								stringvalidator.RegexMatches(regexp.MustCompile(`(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?`), ""),
							},
						},
						"transport_https_ipv4_port": schema.Int64Attribute{
							MarkdownDescription: helpers.NewAttributeDescription("port number").AddIntegerRangeDescription(1, 65535).String,
							Optional:            true,
							Validators: []validator.Int64{
								int64validator.Between(1, 65535),
							},
						},
					},
				},
			},
			"ip_tacacs_source_interface_loopback": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Loopback interface").AddIntegerRangeDescription(0, 2147483647).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 2147483647),
				},
			},
			"ip_tacacs_source_interface_vlan": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Iosxr Vlans").AddIntegerRangeDescription(0, 65535).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 65535),
				},
			},
			"ip_tacacs_source_interface_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("GigabitEthernet IEEE 802.3z").String,
				Optional:            true,
			},
			"ip_tacacs_source_interface_two_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Two GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_tacacs_source_interface_five_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Five GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_tacacs_source_interface_ten_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Ten Gigabit Ethernet").String,
				Optional:            true,
			},
			"ip_tacacs_source_interface_twenty_five_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Twenty Five GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_tacacs_source_interface_forty_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Forty GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_tacacs_source_interface_hundred_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Hundred GigabitEthernet").String,
				Optional:            true,
			},
			"ip_tacacs_source_interface_vrf": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("VPN Routing/Forwarding parameters").String,
				Optional:            true,
			},
			"ip_radius_source_interface_loopback": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Loopback interface").AddIntegerRangeDescription(0, 2147483647).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 2147483647),
				},
			},
			"ip_radius_source_interface_vlan": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Iosxr Vlans").AddIntegerRangeDescription(0, 65535).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 65535),
				},
			},
			"ip_radius_source_interface_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("GigabitEthernet IEEE 802.3z").String,
				Optional:            true,
			},
			"ip_radius_source_interface_two_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Two GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_radius_source_interface_five_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Five GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_radius_source_interface_ten_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Ten Gigabit Ethernet").String,
				Optional:            true,
			},
			"ip_radius_source_interface_twenty_five_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Twenty Five GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_radius_source_interface_forty_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Forty GigabitEthernet ").String,
				Optional:            true,
			},
			"ip_radius_source_interface_hundred_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Hundred GigabitEthernet").String,
				Optional:            true,
			},
			"ip_radius_source_interface_vrf": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("VPN Routing/Forwarding parameters").String,
				Optional:            true,
			},
			"boot_system_flash_files": schema.ListNestedAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").String,
				Optional:            true,
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"path": schema.StringAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("").String,
							Required:            true,
						},
					},
				},
			},
			"boot_system_bootfiles": schema.ListNestedAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").String,
				Optional:            true,
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"path": schema.StringAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("WORD - TFTP filename or URL").String,
							Required:            true,
						},
					},
				},
			},
			"enable_secret": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").String,
				Optional:            true,
				Sensitive:           true,
			},
			"enable_secret_type": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("0", "4", "5", "8", "9").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.OneOf("0", "4", "5", "8", "9"),
				},
			},
			"enable_secret_level": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Set exec level password").AddIntegerRangeDescription(0, 255).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 255),
				},
			},
			"ip_hosts": schema.ListNestedAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").String,
				Optional:            true,
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"name": schema.StringAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("Name of host").String,
							Required:            true,
						},
						"ips": schema.ListAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("Host IP address").String,
							ElementType:         types.StringType,
							Optional:            true,
						},
					},
				},
			},
			"ip_hosts_vrf": schema.ListNestedAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Specify VRF").String,
				Optional:            true,
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"vrf": schema.StringAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("VRF name").String,
							Required:            true,
						},
						"hosts": schema.ListNestedAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("Name of host").String,
							Optional:            true,
							NestedObject: schema.NestedAttributeObject{
								Attributes: map[string]schema.Attribute{
									"name": schema.StringAttribute{
										MarkdownDescription: helpers.NewAttributeDescription("Name of host").String,
										Required:            true,
									},
									"ips": schema.ListAttribute{
										MarkdownDescription: helpers.NewAttributeDescription("Host IP address").String,
										ElementType:         types.StringType,
										Optional:            true,
									},
								},
							},
						},
					},
				},
			},
			"diagnostic_event_log_size": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Configure event log size Number of entries <1-10000>").AddIntegerRangeDescription(1, 10000).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 10000),
				},
			},
			"subscriber_templating": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Configure subscriber templating").String,
				Optional:            true,
			},
			"call_home_contact_email": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Use email address").String,
				Optional:            true,
			},
			"call_home_cisco_tac_1_profile_active": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Activate the current profile").String,
				Optional:            true,
			},
			"call_home_cisco_tac_1_destination_transport_method": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("To specify transport method for this profile").AddStringEnumDescription("email", "http").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.OneOf("email", "http"),
				},
			},
			"ip_ftp_passive": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Connect using passive mode").String,
				Optional:            true,
			},
			"tftp_source_interface_gigabit_ethernet": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("GigabitEthernet IEEE 802.3z").String,
				Optional:            true,
			},
			"tftp_source_interface_loopback": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Loopback interface").AddIntegerRangeDescription(0, 2147483647).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(0, 2147483647),
				},
			},
			"multilink_ppp_bundle_name": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Select method for naming multilink bundles").AddStringEnumDescription("authenticated", "both", "endpoint", "rfc").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.OneOf("authenticated", "both", "endpoint", "rfc"),
				},
			},
			"version": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("Version").String,
				Optional:            true,
			},
			"track_objects": schema.ListNestedAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").String,
				Optional:            true,
				NestedObject: schema.NestedAttributeObject{
					Attributes: map[string]schema.Attribute{
						"number": schema.StringAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("Tracked object").String,
							Required:            true,
						},
						"ip_sla_number": schema.Int64Attribute{
							MarkdownDescription: helpers.NewAttributeDescription("Entry number").AddIntegerRangeDescription(0, 4294967295).String,
							Optional:            true,
							Validators: []validator.Int64{
								int64validator.Between(0, 4294967295),
							},
						},
						"ip_sla_reachability": schema.BoolAttribute{
							MarkdownDescription: helpers.NewAttributeDescription("Reachability").String,
							Optional:            true,
						},
					},
				},
			},
			"ip_nbar_classification_dns_classify_by_domain": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("dns classification by domain").String,
				Optional:            true,
			},
			"ip_multicast_route_limit": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Maximum number of multicast routes").AddIntegerRangeDescription(1, 2147483647).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 2147483647),
				},
			},
			"security_passwords_min_length": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("Minimum length of passwords").AddIntegerRangeDescription(1, 16).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(1, 16),
				},
			},
			"ip_domain_list_names": schema.ListAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").String,
				ElementType:         types.StringType,
				Optional:            true,
			},
			"ip_domain_list_vrf_domain": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").String,
				Optional:            true,
			},
			"ip_domain_list_vrf": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").String,
				Optional:            true,
			},
			"ethernet_cfm_alarm_config_delay": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("msec (default 2500 msec)").AddIntegerRangeDescription(2500, 10000).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(2500, 10000),
				},
			},
			"ethernet_cfm_alarm_config_reset": schema.Int64Attribute{
				MarkdownDescription: helpers.NewAttributeDescription("msec (default 10000 msec)").AddIntegerRangeDescription(2500, 10000).String,
				Optional:            true,
				Validators: []validator.Int64{
					int64validator.Between(2500, 10000),
				},
			},
			"standby_redirects": schema.BoolAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").String,
				Optional:            true,
			},
			"standby_redirects_enable_disable": schema.StringAttribute{
				MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("disable", "enable").String,
				Optional:            true,
				Validators: []validator.String{
					stringvalidator.OneOf("disable", "enable"),
				},
			},
		},
	}
}

func (r *SystemResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) {
	if req.ProviderData == nil {
		return
	}

	r.data = req.ProviderData.(*IosxeProviderData)
}

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

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

func (r *SystemResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
	var plan System

	// Read plan
	diags := req.Plan.Get(ctx, &plan)
	resp.Diagnostics.Append(diags...)
	if resp.Diagnostics.HasError() {
		return
	}

	tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.getPath()))

	device, ok := r.data.Devices[plan.Device.ValueString()]
	if !ok {
		resp.Diagnostics.AddAttributeError(path.Root("device"), "Invalid device", fmt.Sprintf("Device '%s' does not exist in provider configuration.", plan.Device.ValueString()))
		return
	}

	if device.Managed {
		// Create object
		body := plan.toBody(ctx)

		emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
		tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))

		if YangPatch {
			edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
			for _, i := range emptyLeafsDelete {
				edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
			}
			_, err := device.Client.YangPatchData("", "1", "", edits)
			if err != nil {
				resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
				return
			}
		} else {
			res, err := device.Client.PatchData(plan.getPathShort(), body)
			if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
				_, err = device.Client.PutData(plan.getPath(), body)
			}
			if err != nil {
				resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
				return
			}
			for _, i := range emptyLeafsDelete {
				res, err := device.Client.DeleteData(i)
				if err != nil && res.StatusCode != 404 {
					resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
					return
				}
			}
		}
	}

	plan.Id = types.StringValue(plan.getPath())

	tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.getPath()))

	diags = resp.State.Set(ctx, &plan)
	resp.Diagnostics.Append(diags...)

	helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics)
}

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

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

func (r *SystemResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
	var state System

	// Read state
	diags := req.State.Get(ctx, &state)
	resp.Diagnostics.Append(diags...)
	if resp.Diagnostics.HasError() {
		return
	}

	tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.ValueString()))

	device, ok := r.data.Devices[state.Device.ValueString()]
	if !ok {
		resp.Diagnostics.AddAttributeError(path.Root("device"), "Invalid device", fmt.Sprintf("Device '%s' does not exist in provider configuration.", state.Device.ValueString()))
		return
	}

	if device.Managed {
		res, err := device.Client.GetData(state.Id.ValueString())
		if res.StatusCode == 404 {
			state = System{Device: state.Device, Id: state.Id}
		} else {
			if err != nil {
				resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
				return
			}

			imp, diags := helpers.IsFlagImporting(ctx, req)
			if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
				return
			}

			// After `terraform import` we switch to a full read.
			if imp {
				state.fromBody(ctx, res.Res)
			} else {
				state.updateFromBody(ctx, res.Res)
			}
		}
	}

	tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Id.ValueString()))

	diags = resp.State.Set(ctx, &state)
	resp.Diagnostics.Append(diags...)

	helpers.SetFlagImporting(ctx, false, resp.Private, &resp.Diagnostics)
}

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

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

func (r *SystemResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
	var plan, state System

	// Read plan
	diags := req.Plan.Get(ctx, &plan)
	resp.Diagnostics.Append(diags...)
	if resp.Diagnostics.HasError() {
		return
	}

	// Read state
	diags = req.State.Get(ctx, &state)
	resp.Diagnostics.Append(diags...)
	if resp.Diagnostics.HasError() {
		return
	}

	tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString()))

	device, ok := r.data.Devices[plan.Device.ValueString()]
	if !ok {
		resp.Diagnostics.AddAttributeError(path.Root("device"), "Invalid device", fmt.Sprintf("Device '%s' does not exist in provider configuration.", plan.Device.ValueString()))
		return
	}

	if device.Managed {
		body := plan.toBody(ctx)

		deletedItems := plan.getDeletedItems(ctx, state)
		tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))

		emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
		tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))

		if YangPatch {
			var edits []restconf.YangPatchEdit
			for _, i := range deletedItems {
				edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
			}
			edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
			for _, i := range emptyLeafsDelete {
				edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
			}
			_, err := device.Client.YangPatchData("", "1", "", edits)
			if err != nil {
				resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
				return
			}
		} else {
			for _, i := range deletedItems {
				res, err := device.Client.DeleteData(i)
				if err != nil && res.StatusCode != 404 {
					resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
					return
				}
			}
			res, err := device.Client.PatchData(plan.getPathShort(), body)
			if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
				_, err = device.Client.PutData(plan.getPath(), body)
			}
			if err != nil {
				resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
				return
			}
			for _, i := range emptyLeafsDelete {
				res, err := device.Client.DeleteData(i)
				if err != nil && res.StatusCode != 404 {
					resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
					return
				}
			}
		}
	}

	tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Id.ValueString()))

	diags = resp.State.Set(ctx, &plan)
	resp.Diagnostics.Append(diags...)
}

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

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

func (r *SystemResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
	var state System

	// Read state
	diags := req.State.Get(ctx, &state)
	resp.Diagnostics.Append(diags...)
	if resp.Diagnostics.HasError() {
		return
	}

	tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString()))

	device, ok := r.data.Devices[state.Device.ValueString()]
	if !ok {
		resp.Diagnostics.AddAttributeError(path.Root("device"), "Invalid device", fmt.Sprintf("Device '%s' does not exist in provider configuration.", state.Device.ValueString()))
		return
	}

	if device.Managed {
		deleteMode := "attributes"

		if deleteMode == "all" {
			res, err := device.Client.DeleteData(state.Id.ValueString())
			if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
				resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
				return
			}
		} else {
			deletePaths := state.getDeletePaths(ctx)
			tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))

			if YangPatch {
				edits := []restconf.YangPatchEdit{}
				for _, i := range deletePaths {
					edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
				}
				_, err := device.Client.YangPatchData("", "1", "", edits)
				if err != nil {
					resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
					return
				}
			} else {
				for _, i := range deletePaths {
					res, err := device.Client.DeleteData(i)
					if err != nil && res.StatusCode != 404 {
						resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
					}
				}
			}
		}
	}

	tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString()))

	resp.State.RemoveResource(ctx)
}

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

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

func (r *SystemResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
	idParts := strings.Split(req.ID, ",")
	idParts = helpers.RemoveEmptyStrings(idParts)

	if len(idParts) != 0 && len(idParts) != 1 {
		expectedIdentifier := "Expected import identifier with format: ''"
		expectedIdentifier += " or '<device>'"
		resp.Diagnostics.AddError(
			"Unexpected Import Identifier",
			fmt.Sprintf("%s. Got: %q", expectedIdentifier, req.ID),
		)
		return
	}
	if len(idParts) == 1 {
		resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("device"), idParts[len(idParts)-1])...)
	}

	// construct path for 'id' attribute
	var state System
	resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), state.getPath())...)

	helpers.SetFlagImporting(ctx, true, resp.Private, &resp.Diagnostics)
}

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