package extnet

import "time"

// List external networks
type ListExtNet []ExternalNetworkResponse

type ExternalNetworkResponse struct {
	// Name of the bridge network
	BridgeNetworkName string `json:"bridge_network_name"`

	// IPv4 default gateway address
	DefaultGatewayIPv4 string `json:"default_gateway_ipv4"`

	// IPv6 default gateway address
	DefaultGatewayIPv6 string `json:"default_gateway_ipv6"`

	// Detailed description of the external network
	Description string `json:"description"`

	// List of external network ports
	ExternalNetworkPorts []ExternalNetworkPort `json:"external_network_ports"`

	// List of hypervisor names
	Hypervisors []string `json:"hypervisors"`

	// Extnet ID
	ID string `json:"id"`

	// Status
	Status Status `json:"status"`

	// ID of version
	VersionID uint64 `json:"version_id"`

	// IPv4 subnet in CIDR notation
	SubnetV4 string `json:"subnet_v4"`

	// IPv6 subnet in CIDR notation
	SubnetV6 string `json:"subnet_v6"`

	// Creation time
	CreatedAt time.Time `json:"created_at"`

	// Update time
	UpdatedAt time.Time `json:"updated_at"`

	// VLAN tag identifier
	VLANTag int64 `json:"vlan_tag"`
}

type ExternalNetworkPort struct {
	// Access group ID
	AccessGroupID string `json:"access_group_id"`

	// Access group name
	AccessGroupName string `json:"access_group_name"`

	// Comment for the external network port
	Comment string `json:"comment"`

	// User-friendly name for the external network port
	DisplayName string `json:"display_name"`

	// Whether the network port is enabled
	Enabled bool `json:"enabled"`

	// IPv4
	IPv4 string `json:"ipv4"`

	// IPv6
	IPv6 string `json:"ipv6"`

	// IPv6 Config
	IPv6Config IPv6Config `json:"ipv6_config"`

	// MAC address
	MAC string `json:"mac"`

	// Router gateway port
	RouterGatewayPort RouterGatewayPort `json:"router_gateway_port"`

	// Floating IP
	FloatingIP FloatingIP `json:"floating_ip"`
}

type IPv6Config struct {
	// Address mode
	AddressMode string `json:"address_mode"`

	// If true, the port will periodically send RA packets.
	EnablePeriodicRa bool `json:"enable_periodic_ra"`

	// The number of waiting seconds between sending periodic RA
	IntervalRa int64 `json:"interval_ra"`

	// The Default Router Preference (PRF) indicates whether this router should be preferred over other default routers.
	RouterPreference string `json:"router_preference"`
}

type RouterGatewayPort struct {
	// Creation time
	CreatedAt time.Time `json:"created_at"`

	// Description
	Description string `json:"description"`

	// Port ID
	ID string `json:"id"`

	// User-friendly name for the external network port
	RouterDisplayName string `json:"router_display_name"`

	// Router ID
	RouterID string `json:"router_id"`

	// SNAT Enabled
	SNATEnabled bool `json:"snat_enabled"`

	// Update time
	UpdatedAt time.Time `json:"updated_at"`
}

type FloatingIP struct {
	// Access group ID
	AccessGroupID string `json:"access_group_id"`

	// Access group name
	AccessGroupName string `json:"access_group_name"`

	// Created time
	CreatedAt time.Time `json:"created_at"`

	// External network port
	ExternalNetworkPort string `json:"external_network_port"`

	// ID of floating IP
	ID string `json:"id"`

	// Logical Port
	LogicalPort LogicalPort `json:"logical_port"`

	// Router
	Router Router `json:"router"`

	// Update time
	UpdatedAt time.Time `json:"updated_at"`

	// ID of version
	VersionID uint64 `json:"version_id"`
}

type LogicalPort struct {
	// Logical Port ID
	ID string `json:"id"`

	// Access group ID
	AccessGroupID string `json:"access_group_id"`

	// Access group name
	AccessGroupName string `json:"access_group_name"`

	// MAC of adapter
	AdapterMAC string `json:"adapter_mac"`

	// Address detection
	AddressDetection bool `json:"address_detection"`

	// Description
	Description string `json:"description"`

	// Created time
	CreatedAt time.Time `json:"created_at"`

	// User-friendly name for router
	DisplayName string `json:"display_name"`

	// Whether the logical port is enabled
	Enabled bool `json:"enabled"`

	// External Network ID
	ExternalNetworkID string `json:"external_network_id"`

	// Hypervisor name
	Hypervisor string `json:"hypervisor"`

	// User-friendly name for hypervisor
	HypervisorDisplayName string `json:"hypervisor_display_name"`

	// Live Migration Target Hv
	LiveMigrationTargetHV string `json:"live_migration_target_hv"`

	// Status
	Status Status `json:"status"`

	// Bindings struct
	Bindings PortBindings `json:"bindings"`

	// Unique Identifier
	UniqueIDentifier string `json:"unique_identifier"`

	// Updated time
	UpdatedAt time.Time `json:"updated_at"`

	// ID of version
	VersionID uint64 `json:"version_id"`
}

type PortBindings struct {
	// Binding ID
	ID string `json:"id"`

	// User-friendly name for segment
	SegmentDisplayName string `json:"segment_display_name"`

	// Segment ID
	SegmentID string `json:"segment_id"`

	// Port security
	PortSecurity bool `json:"port_security"`

	// Address detection
	AddressDetection bool `json:"address_detection"`

	// Is Exclude From Firewall
	IsExcludedFromFirewall bool `json:"is_excluded_from_firewall"`

	// ID of version
	VersionID uint64 `json:"version_id"`

	// Created time
	CreatedAt time.Time `json:"created_at"`

	// Update time
	UpdatedAt time.Time `json:"updated_at"`

	// Logical port addresses
	LogicalPortAddresses []LogicalPortAddress `json:"logical_port_addresses"`
}

type LogicalPortAddress struct {
	// IP of port
	IP string `json:"ip"`

	// IP type (IPv4 or IPv6)
	IPType string `json:"ip_type"`

	// Is discovered
	IsDiscovered bool `json:"is_discovered"`

	// Is primary
	IsPrimary bool `json:"is_primary"`

	// MAC
	MAC string `json:"mac"`

	// ID
	ID string `json:"id"`

	// Logical port id
	LogicalPortID string `json:"logical_port_id"`

	// Assigned time
	AssignedAt time.Time `json:"assigned_at"`
}

type Router struct {
	// Access group ID
	AccessGroupID string `json:"access_group_id"`

	// Access group name
	AccessGroupName string `json:"access_group_name"`

	// Created time
	CreatedAt time.Time `json:"created_at"`

	// Detailed description of the router
	Description string `json:"description"`

	// User-friendly name for the router
	DisplayName string `json:"display_name"`

	// Whether the router is enabled
	Enabled bool `json:"enabled"`

	// Gateway ports
	GatewayPorts []GatewayPort `json:"gateway_ports"`

	// ID of router
	ID string `json:"id"`

	// Policies
	Policies []RouterPolicy `json:"policies"`

	// Ports
	Ports []RouterPort `json:"ports"`

	// Status
	Status Status `json:"status"`

	// Update time
	UpdatedAt time.Time `json:"updated_at"`

	// ID of version
	VersionID uint64 `json:"version_id"`
}

type GatewayPort struct {
	// Created time
	CreatedAt time.Time `json:"created_at"`

	// Description
	Description string `json:"description"`

	// L4 port max
	ExternalL4PortMax int64 `json:"external_l4_port_max"`

	// L4 port min
	ExternalL4PortMin int64 `json:"external_l4_port_min"`

	// External network port
	ExternalNetworkPort interface{} `json:"external_network_port"`

	// ID of port
	ID string `json:"id"`

	// SNAT Enabled
	SNATEnabled bool `json:"snat_enabled"`

	// Status
	Status Status `json:"status"`

	// Update time
	UpdatedAt time.Time `json:"updated_at"`

	// ID of version
	VersionID uint64 `json:"version_id"`
}

type RouterPolicy struct {
	// Action
	Action string `json:"action"`

	// Created time
	CreatedAt time.Time `json:"created_at"`

	// User-friendly name for the policy
	DisplayName string `json:"display_name"`

	// Whether the policy is enabled
	Enabled bool `json:"enabled"`

	// ID of router policy
	ID string `json:"id"`

	// Match
	Match interface{} `json:"match"`

	// Next IPv4 address
	NextIPv4Address []string `json:"next_ipv4_address"`

	// Next IPv6 address
	NextIPv6Address []string `json:"next_ipv6_address"`

	// Priority number
	Priority int64 `json:"priority"`

	// Update time
	UpdatedAt time.Time `json:"updated_at"`

	// ID of version
	VersionID uint64 `json:"version_id"`
}

type RouterPort struct {
	// Created at
	CreatedAt time.Time `json:"created_at"`

	// Detailed description of the router port
	Description string `json:"description"`

	// Whether the router port is enabled
	Enabled bool `json:"enabled"`

	// ID of router port
	ID string `json:"id"`

	// Next IPv4 address
	IPv4Address string `json:"ipv4_address"`

	// Next IPv6 address
	IPv6Address string `json:"ipv6_address"`

	// IPv6 Config
	IPv6Config IPv6Config `json:"ipv6_config"`

	// MAC address
	MAC string `json:"mac"`

	// Segment
	Segment Segment `json:"segment"`

	// Segment ID
	SegmentID string `json:"segment_id"`

	// Status
	Status Status `json:"status"`

	// Update time
	UpdatedAt time.Time `json:"updated_at"`

	// ID of version
	VersionID uint64 `json:"version_id"`
}

type Segment struct {
	// Access group ID
	AccessGroupID string `json:"access_group_id"`

	// Access group name
	AccessGroupName string `json:"access_group_name"`

	// Created time
	CreatedAt time.Time `json:"created_at"`

	// Detailed description of the router port
	Description string `json:"description"`

	// DHCP IPv4
	DHCPv4 DHCPv4Config `json:"dhcp_v4"`

	// DHCP IPv6
	DHCPv6 DHCPv6Config `json:"dhcp_v6"`

	// User-friendly name for the segment
	DisplayName string `json:"display_name"`

	// Whether the segment is enabled
	Enabled bool `json:"enabled"`

	// ID of segment
	ID string `json:"id"`

	// Logical ports info
	LogicalPortsInfo []EntityInfo `json:"logical_ports_info"`

	// Routers info
	RoutersInfo []EntityInfo `json:"routers_info"`

	// Status
	Status Status `json:"status"`

	// IPv4 subnet in CIDR notation
	SubnetV4 string `json:"subnet_v4"`

	// IPv6 subnet in CIDR notation
	SubnetV6 string `json:"subnet_v6"`

	// Update time
	UpdatedAt time.Time `json:"updated_at"`

	// ID of version
	VersionID uint64 `json:"version_id"`
}

type DHCPv4Config struct {
	// DNS
	DNS []string `json:"dns"`

	// Excluded address ranges
	ExcludedAddressRanges []string `json:"excluded_address_ranges"`

	// Gateway
	Gateway string `json:"gateway"`

	// ID of config
	ID string `json:"id"`

	// Lease time
	LeaseTime int64 `json:"lease_time"`

	// Server IP
	ServerIP string `json:"server_ip"`

	// Server MAC
	ServerMAC string `json:"server_mac"`

	// Whether the config is enabled
	Enabled bool `json:"enabled"`
}

type DHCPv6Config struct {
	// Address prefix
	AddressPrefix string `json:"address_prefix"`

	// DNS
	DNS []string `json:"dns"`

	// ID of config
	ID string `json:"id"`

	// Lease time
	LeaseTime int64 `json:"lease_time"`

	// Server MAC
	ServerMAC string `json:"server_mac"`

	// Whether the config is enabled
	Enabled bool `json:"enabled"`
}

type EntityInfo struct {
	// User-friendly name for the entity
	DisplayName string `json:"display_name"`

	// ID of entity
	ID string `json:"id"`
}

type Status struct {
	// Common
	Common string `json:"common"`

	// Hypervisors status
	Hypervisors []HypervisorStatus `json:"hypervisors"`
}

type HypervisorStatus struct {
	// Status
	Status string `json:"status"`

	// Name of hypervisor
	Name string `json:"name"`

	// User-friendly name for the hypervisor
	DisplayName string `json:"display_name"`

	// Hypervisor status
	HypervisorStatus string `json:"hypervisor_status"`

	// Synced time
	SyncedAt time.Time `json:"synced_at"`
}

type ExternalNetworkAddPortsResponce struct {
	// ID of extnet port
	ID string `json:"id"`

	// ID of extnet
	ExtNetID string `json:"external_network_id"`

	// User-friendly name for the external network port
	DisplayName string `json:"display_name"`

	// Comment
	Comment string `json:"comment"`

	// Mac
	MAC string `json:"mac"`

	// IPv4  gateway address
	IPv4 string `json:"ipv4"`

	// IPv6  gateway address
	IPv6 string `json:"ipv6"`

	// IPv6 config
	IPv6Config IPv6Config `json:"ipv6_config"`

	// Whether the network port is enabled
	Enabled bool `json:"enabled"`

	// ID of version
	VersionID uint64 `json:"version_id"`

	// Router gateway port
	RouterGatewayPort RouterGatewayPort `json:"router_gateway_port"`
}
