{
	"$schema": "http://json-schema.org/draft-07/schema",
	"$id": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/networkConnection.json",
	"type": "object",
	"title": "Network connection detail",
	"additionalProperties": false,
	"required": [
		"name",
		"type",
		"interface",
		"autoConnect",
		"ipv4",
		"ipv6"
	],
	"properties": {
		"name": {
			"$id": "#/properties/name",
			"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/networkConnection.json#/definitions/name"
		},
		"uuid": {
			"$id": "#/properties/uuid",
			"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/networkConnection.json#/definitions/uuid"
		},
		"type": {
			"$id": "#/properties/type",
			"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/networkConnection.json#/definitions/type"
		},
		"interface": {
			"$id": "#/properties/interface",
			"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/networkConnection.json#/definitions/interfaceName"
		},
		"autoConnect": {
			"$id": "#/properties/autoConnect",
			"type": "object",
			"title": "Automatic connecting",
			"example": {
				"enabled": true,
				"priority": 0,
				"retries": -1
			},
			"additionalProperties": false,
			"required": [
				"enabled",
				"priority",
				"retries"
			],
			"properties": {
				"enabled": {
					"$id": "#/properties/autoConnect/properties/enabled",
					"type": "boolean",
					"title": "Automatic connecting enablement",
					"example": true
				},
				"priority": {
					"$id": "#/properties/autoConnect/properties/priority",
					"type": "integer",
					"title": "Connection priority",
					"example": 0
				},
				"retries": {
					"$id": "#/properties/autoConnect/properties/retries",
					"type": "integer",
					"title": "Connection retries",
					"example": -1
				}
			}
		},
		"ipv4": {
			"$id": "#/properties/ipv4",
			"type": "object",
			"title": "IPv4 connection",
			"example": {
				"dns": [
					{
						"address": "192.168.1.1"
					}
				],
				"addresses": [
					{
						"mask": "255.255.255.0",
						"prefix": 24,
						"address": "192.168.1.198"
					}
				],
				"gateway": "192.168.1.1",
				"method": "manual"
			},
			"additionalProperties": false,
			"required": [
				"method",
				"addresses",
				"gateway",
				"dns"
			],
			"properties": {
				"method": { "$ref": "#/definitions/ipv4/method" },
				"addresses": { "$ref": "#/definitions/ipv4/addresses" },
				"gateway": {
					"oneOf": [
						{ "$ref": "#/definitions/ipv4/gateway" },
						{ "type": "null" }
					]
				},
				"dns": { "$ref": "#/definitions/ipv4/dns" },
				"current": {
					"title": "Current (in-use) IPv4 connection configuration",
					"type": "object",
					"required": [
						"method",
						"addresses",
						"gateway",
						"dns"
					],
					"additionalProperties": false,
					"properties": {
						"method": { "$ref": "#/definitions/ipv4/method" },
						"addresses": { "$ref": "#/definitions/ipv4/addresses" },
						"gateway": { "$ref": "#/definitions/ipv4/gateway" },
						"dns": { "$ref": "#/definitions/ipv4/dns" }
					}
				}
			}
		},
		"ipv6": {
			"$id": "#/properties/ipv6",
			"type": "object",
			"title": "IPv6 connection",
			"example": {
				"method": "manual",
				"addresses": [
					{
						"prefix": 64,
						"address": "2001:470:5bb2::671"
					}
				],
				"gateway": "fe80::6f0:21ff:fe24:1e53",
				"dns": [
					{
						"address": "2606:4700:4700::1111"
					}
				]
			},
			"additionalProperties": false,
			"required": [
				"method",
				"addresses",
				"gateway",
				"dns"
			],
			"properties": {
				"method": { "$ref": "#/definitions/ipv6/method" },
				"addresses": { "$ref": "#/definitions/ipv6/addresses" },
				"gateway": { "$ref": "#/definitions/ipv6/gateway" },
				"dns": { "$ref": "#/definitions/ipv6/dns" },
				"current": {
					"title": "Current (in-use) IPv6 connection configuration",
					"type": "object",
					"required": [
						"method",
						"addresses",
						"gateway",
						"dns"
					],
					"additionalProperties": false,
					"properties": {
						"method": { "$ref": "#/definitions/ipv6/method" },
						"addresses": { "$ref": "#/definitions/ipv6/addresses" },
						"gateway": { "$ref": "#/definitions/ipv6/gateway" },
						"dns": { "$ref": "#/definitions/ipv6/dns" }
					}
				}
			}
		},
		"wifi": {
			"$id": "#/properties/wifi",
			"type": "object",
			"title": "WiFi connection",
			"example": {
				"ssid": "WIFI MAGDA",
				"mode": "infrastructure",
				"security": {
					"keyManagement": "wpa-psk",
					"psk": "password"
				}
			},
			"additionalProperties": false,
			"required": [
				"ssid",
				"mode",
				"security"
			],
			"properties": {
				"bssids": {
					"$id": "#/properties/wifi/properties/bssids",
					"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/networkConnection.json#/definitions/wifi/bssids"
				},
				"ssid": {
					"$id": "#/properties/wifi/properties/ssid",
					"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/networkConnection.json#/definitions/wifi/ssid"
				},
				"mode": {
					"$id": "#/properties/wifi/properties/mode",
					"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/networkConnection.json#/definitions/wifi/mode"
				},
				"security": {
					"$id": "#/properties/wifi/security",
					"type": "object",
					"title": "WiFi connection security",
					"example": {
						"type": "wpa-psk",
						"psk": "password"
					},
					"additionalProperties": false,
					"required": [
						"type"
					],
					"properties": {
						"eap": {
							"$id": "#/properties/wifi/properties/security/properties/eap",
							"type": "object",
							"title": "EAP",
							"additionalProperties": false,
							"required": [
								"phaseOneMethod"
							],
							"properties": {
								"anonymousIdentity": {
									"$id": "#/properties/wifi/properties/security/properties/eap/anonymousIdentity",
									"type": "string",
									"title": "EAP anonymous identity",
									"example": "anonymous"
								},
								"cert": {
									"$id": "#/properties/wifi/properties/security/properties/eap/cert",
									"type": "string",
									"title": "EAP CA certificate",
									"example": "/root/certificate.pem"
								},
								"identity": {
									"$id": "#/properties/wifi/properties/security/properties/eap/identity",
									"type": "string",
									"title": "EAP identity",
									"example": "username"
								},
								"password": {
									"$id": "#/properties/wifi/properties/security/properties/eap/password",
									"type": "string",
									"title": "EAP password",
									"example": "password"
								},
								"phaseOneMethod": {
									"$id": "#/properties/wifi/properties/security/properties/eap/phaseOneMethod",
									"type": "string",
									"title": "EAP phase one method",
									"enum": [
										"fast",
										"leap",
										"md5",
										"peap",
										"pwd",
										"tls",
										"ttls"
									],
									"example": "peap"
								},
								"phaseTwoMethod": {
									"$id": "#/properties/wifi/properties/security/properties/eap/phaseTwoMethod",
									"type": "string",
									"title": "EAP phase two method",
									"enum": [
										"gtc",
										"md5",
										"mschapv2"
									],
									"example": "mschapv2"
								}
							}
						},
						"type": {
							"$id": "#/properties/wifi/properties/security/properties/type",
							"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/networkConnection.json#/definitions/wifi/security/type"
						},
						"leap": {
							"$id": "#/properties/wifi/properties/security/properties/leap",
							"type": "object",
							"title": "Cisco LEAP",
							"additionalProperties": false,
							"required": [
								"username",
								"password"
							],
							"properties": {
								"username": {
									"$id": "#/properties/wifi/properties/security/properties/leap/username",
									"type": "string",
									"title": "Cisco LEAP username",
									"example": "username"
								},
								"password": {
									"$id": "#/properties/wifi/properties/security/properties/leap/password",
									"type": "string",
									"title": "Cisco LEAP password",
									"example": "password"
								}
							}
						},
						"wep": {
							"$id": "#/properties/wifi/properties/security/properties/wep",
							"type": "object",
							"title": "WEP",
							"additionalProperties": false,
							"required": [
								"type",
								"index",
								"keys"
							],
							"properties": {
								"type": {
									"$id": "#/properties/wifi/properties/security/properties/wep/type",
									"type": "string",
									"title": "WEP key type",
									"enum": [
										"key",
										"passphrase",
										"unknown"
									],
									"example": "key"
								},
								"index": {
									"$id": "#/properties/wifi/properties/security/properties/wep/index",
									"type": "integer",
									"title": "WEP transfer key index",
									"minimum": 0,
									"maximum": 3,
									"example": 0
								},
								"keys": {
									"$id": "#/properties/wifi/properties/security/properties/wep/keys",
									"type": "array",
									"title": "WEP keys",
									"minItems": 4,
									"maximum": 4,
									"additionalItems": false,
									"items": {
										"$id": "#/properties/wifi/properties/security/properties/wep/keys/items",
										"type": "string",
										"title": "WEP key",
										"example": "4b70797e57534a5c4833493352"
									}
								}
							}
						},
						"psk": {
							"$id": "#/properties/wifi/properties/security/properties/psk",
							"type": "string",
							"title": "Pre-shared key",
							"example": "password"
						}
					},
					"allOf": [
						{
							"if": {
								"properties": {
									"type": {
										"const": "wpa-eap-suite-b-192"
									}
								}
							},
							"then": {
								"required": [
									"type",
									"eap"
								]
							}
						},
						{
							"if": {
								"properties": {
									"type": {
										"const": "wpa-eap"
									}
								}
							},
							"then": {
								"required": [
									"type",
									"eap"
								]
							}
						},
						{
							"if": {
								"properties": {
									"type": {
										"const": "leap"
									}
								}
							},
							"then": {
								"required": [
									"type",
									"leap"
								]
							}
						},
						{
							"if": {
								"properties": {
									"type": {
										"const": "wep"
									}
								}
							},
							"then": {
								"required": [
									"type",
									"wep"
								]
							}
						},
						{
							"if": {
								"properties": {
									"type": {
										"const": "wpa-psk"
									}
								}
							},
							"then": {
								"required": [
									"type",
									"psk"
								]
							}
						},
						{
							"if": {
								"properties": {
									"type": {
										"const": "sae"
									}
								}
							},
							"then": {
								"required": [
									"type",
									"psk"
								]
							}
						}
					]
				}
			}
		},
		"gsm": {
			"$id": "#/properties/gsm",
			"title": "GSM connection",
			"type": "object",
			"example": {
				"apn": "internet",
				"pin": "1234",
				"username": "gsmuser",
				"password": "gsmpassword"
			},
			"required": [
				"apn",
				"pin",
				"username",
				"password"
			],
			"additionalProperties": false,
			"properties": {
				"apn": {
					"$id": "#/properties/gsm/properties/apn",
					"title": "Access point name",
					"type": "string",
					"example": "internet"
				},
				"pin": {
					"$id": "#/properties/gsm/properties/pin",
					"title": "SIM PIN",
					"type": "string",
					"oneOf": [
						{
							"pattern": "^\\d{4}$"
						},
						{
							"const": ""
						}
					],
					"example": "1234"
				},
				"username": {
					"$id": "#/properties/gsm/properties/username",
					"title": "Username",
					"type": "string",
					"example": "gsmuser"
				},
				"password": {
					"$id": "#/properties/gsm/properties/password",
					"title": "Password",
					"type": "string",
					"example": "gsmpassword"
				}
			}
		},
		"serial": {
			"$id": "#/properties/serial",
			"title": "Serial link connection",
			"type": "object",
			"example": {
				"baudRate": 57600,
				"bits": 8,
				"parity": "",
				"sendDelay": 0,
				"stopBits": 1
			},
			"required": [
				"baudRate",
				"bits",
				"parity",
				"sendDelay",
				"stopBits"
			],
			"additionalProperties": false,
			"properties": {
				"baudRate": {
					"$id": "#/properties/serial/properties/baudRate",
					"title": "Baud rate",
					"type": "integer",
					"minimum": 0,
					"example": 57600
				},
				"bits": {
					"$id": "#/properties/serial/properties/bits",
					"title": "Byte-width",
					"type": "integer",
					"minimum": 0,
					"example": 8
				},
				"parity": {
					"$id": "#/properties/serial/properties/parity",
					"title": "Parity",
					"type": "string",
					"enum": [
						"even",
						"odd",
						"none"
					],
					"example": "none"
				},
				"sendDelay": {
					"$id": "#/properties/serial/properties/sendDelay",
					"title": "Delay between bytes in microseconds",
					"type": "integer",
					"minimum": 0,
					"example": 0
				},
				"stopBits": {
					"$id": "#/properties/serial/properties/stopBits",
					"title": "Stop bits",
					"type": "integer",
					"enum": [
						1,
						2
					]
				}
			}
		},
		"vlan": {
			"$id": "#/properties/vlan",
			"title": "VLAN configuration",
			"type": "object",
			"example": {
				"parentInterface": "eth0",
				"id": 10,
				"flags": {
					"reorderHeaders": true,
					"gvrp": false,
					"looseBinding": false,
					"mvrp": false
				}
			},
			"required": [
				"parentInterface",
				"id",
				"flags"
			],
			"additionalProperties": false,
			"properties": {
				"parentInterface": {
					"$id": "#/properties/serial/properties/parentInterface",
					"title": "Parent Ethernet interface",
					"type": "string",
					"example": "eth0"
				},
				"id": {
					"$id": "#/properties/serial/properties/id",
					"title": "VLAN ID",
					"type": "integer",
					"minimum": 1,
					"example": 10
				},
				"flags": {
					"$id": "#/properties/serial/properties/flags",
					"title": "VLAN flags",
					"type": "object",
					"additionalProperties": false,
					"properties": {
						"reorderHeaders": {
							"$id": "#/properties/serial/properties/flags/reorderHeaders",
							"title": "Reorder headers",
							"type": "boolean",
							"example": true
						},
						"gvrp": {
							"$id": "#/properties/serial/properties/flags/gvrp",
							"title": "GVRP",
							"type": "boolean",
							"example": false
						},
						"looseBinding": {
							"$id": "#/properties/serial/properties/flags/looseBinding",
							"title": "Loose binding",
							"type": "boolean",
							"example": false
						},
						"mvrp": {
							"$id": "#/properties/serial/properties/flags/mvrp",
							"title": "MVRP",
							"type": "boolean",
							"example": false
						}
					},
					"example": {
						"reorderHeaders": true,
						"gvrp": false,
						"looseBinding": false,
						"mvrp": false
					}
				}
			}
		},
		"wireGuard": {
			"$id": "#/properties/wireGuard",
			"title": "WireGuard tunnel configuration",
			"type": "object",
			"example": {
				"privateKey": "uHjCXprATG+woFX/i2a6WxcVb6t0CUnC5x/CbQWWpU0=",
				"listenPort": 0,
				"peers": [
					{
						"publicKey": "9NuqIH/JQesoW8RJnffkz6zyGoeXkuO03mFRl4EohWI=",
						"endpoint": "vpn.example.com:51820",
						"allowedIps": [
							{
								"address": "10.0.0.0",
								"prefix": 24
							},
							{
								"address": "fd86:ea04:1115::",
								"prefix": 64
							}
						],
						"persistentKeepalive": 25,
						"presharedKey": null
					}
				],
				"mtu": 0
			},
			"required": [
				"privateKey",
				"listenPort",
				"peers",
				"mtu"
			],
			"additionalProperties": false,
			"properties": {
				"privateKey": {
					"$id": "#/properties/wireGuard/properties/privateKey",
					"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/wireGuard.json#/definitions/privateKey"
				},
				"listenPort": {
					"$id": "#/properties/wireGuard/properties/listenPort",
					"title": "WireGuard listen port",
					"type": "integer",
					"minimum": 0,
					"maximum": 65535,
					"example": 0
				},
				"peers": {
					"$id": "#/properties/wireGuard/properties/peers",
					"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/wireGuard.json#/definitions/peers"
				},
				"mtu": {
					"$id": "#/properties/wireGuard/properties/mtu",
					"$ref": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/schemas/definitions/wireGuard.json#/definitions/mtu"
				}
			}
		}
	},
	"allOf": [
		{
			"if": {
				"properties": {
					"type": {
						"const": "802-11-wireless"
					}
				}
			},
			"then": {
				"required": [
					"name",
					"uuid",
					"type",
					"interface",
					"ipv4",
					"ipv6",
					"wifi"
				]
			}
		},
		{
			"if": {
				"properties": {
					"type": {
						"const": "gsm"
					}
				}
			},
			"then": {
				"required": [
					"name",
					"uuid",
					"type",
					"interface",
					"ipv4",
					"ipv6",
					"gsm"
				]
			}
		},
		{
			"if": {
				"properties": {
					"type": {
						"const": "vlan"
					}
				}
			},
			"then": {
				"required": [
					"name",
					"uuid",
					"type",
					"interface",
					"ipv4",
					"ipv6",
					"vlan"
				]
			}
		},
		{
			"if": {
				"properties": {
					"type": {
						"const": "wireguard"
					}
				}
			},
			"then": {
				"required": [
					"name",
					"uuid",
					"type",
					"interface",
					"ipv4",
					"ipv6",
					"wireGuard"
				]
			}
		}
	],
	"definitions": {
		"ipv4": {
			"method": {
				"title": "IPv4 connection method",
				"type": "string",
				"example": "manual",
				"enum": [
					"auto",
					"disabled",
					"link-local",
					"manual",
					"shared"
				]
			},
			"addresses": {
				"title": "IPv4 addresses",
				"type": "array",
				"additionalItems": false,
				"items": {
					"title": "IPv4 address",
					"type": "object",
					"additionalProperties": false,
					"anyOf": [
						{
							"required": [
								"address",
								"prefix"
							]
						},
						{
							"required": [
								"address",
								"mask"
							]
						}
					],
					"properties": {
						"address": {
							"title": "IPv4 address",
							"type": "string",
							"format": "ipv4",
							"example": "192.168.1.198"
						},
						"prefix": {
							"title": "IPv4 network prefix",
							"type": "integer",
							"minimum": 1,
							"maximum": 32,
							"example": 24
						},
						"mask": {
							"title": "IPv4 network mask",
							"type": "string",
							"format": "ipv4",
							"example": "255.255.255.0"
						}
					},
					"example": {
						"address": "192.168.1.198",
						"mask": "255.255.255.0",
						"prefix": 24
					}
				},
				"example": [
					{
						"prefix": 24,
						"address": "192.168.1.198",
						"mask": "255.255.255.0"
					}
				]
			},
			"gateway": {
				"title": "IPv4 gateway address",
				"type": "string",
				"format": "ipv4",
				"example": "192.168.1.1"
			},
			"dns": {
				"title": "DNS IPv4 addresses",
				"type": "array",
				"additionalItems": false,
				"items": {
					"title": "DNS IPv4 address",
					"type": "object",
					"additionalProperties": false,
					"required": [
						"address"
					],
					"properties": {
						"address": {
							"title": "IPv4 address",
							"type": "string",
							"format": "ipv4",
							"example": "1.1.1.1"
						}
					},
					"example": {
						"address": "192.168.1.1"
					}
				},
				"example": [
					{
						"address": "192.168.1.1"
					}
				]
			}
		},
		"ipv6": {
			"method": {
				"title": "IPv6 connection method",
				"type": "string",
				"enum": [
					"auto",
					"disabled",
					"dhcp",
					"ignore",
					"link-local",
					"manual",
					"shared"
				],
				"example": "manual"
			},
			"addresses": {
				"title": "IPv6 addresses",
				"type": "array",
				"additionalItems": false,
				"items": {
					"title": "IPv6 address",
					"type": "object",
					"additionalProperties": false,
					"required": [
						"address",
						"prefix"
					],
					"properties": {
						"address": {
							"title": "IPv6 address",
							"type": "string",
							"example": "2001:470:5bb2::671"
						},
						"prefix": {
							"title": "IPv6 network prefix",
							"type": "integer",
							"example": 64
						}
					},
					"examples": [
						{
							"prefix": 64,
							"address": "2001:470:5bb2::671"
						}
					]
				},
				"example": [
					{
						"prefix": 64,
						"address": "2001:470:5bb2::671"
					}
				]
			},
			"gateway": {
				"title": "IPv6 gateway address",
				"oneOf": [
					{
						"type": "string",
						"format": "ipv6"
					},
					{
						"type": "null"
					}
				],
				"example": "fe80::6f0:21ff:fe24:1e53"
			},
			"dns": {
				"title": "DNS IPv6 addresses",
				"type": "array",
				"additionalItems": false,
				"items": {
					"title": "DNS IPv6 address",
					"type": "object",
					"additionalProperties": false,
					"required": [
						"address"
					],
					"properties": {
						"address": {
							"title": "IPv6 address",
							"type": "string",
							"format": "ipv6",
							"example": "2606:4700:4700::1111"
						}
					},
					"example": {
						"address": "2606:4700:4700::1111"
					}
				},
				"examples": [
					{
						"address": "2606:4700:4700::1111"
					}
				]
			}
		}
	}
}
