{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "vpn-profile",
  "oneOf": [
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "address_family": {
          "enum": [
            "ipv4",
            "ipv6"
          ]
        },
        "protocol": {
          "const": "wireguard"
        },
        "endpoint_host": {
          "type": "string",
          "minLength": 1,
          "maxLength": 253
        },
        "endpoint_port": {
          "type": "integer",
          "minimum": 1,
          "maximum": 65535
        },
        "private_key_secret_id": {
          "type": "string",
          "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
        },
        "peer_public_key": {
          "type": "string",
          "minLength": 44,
          "maxLength": 44
        },
        "preshared_key_secret_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "addresses": {
          "type": "array",
          "minItems": 1,
          "maxItems": 8,
          "items": {
            "type": "string",
            "maxLength": 64
          }
        },
        "allowed_ips": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {
            "type": "string",
            "maxLength": 64
          }
        },
        "persistent_keepalive_seconds": {
          "type": "integer",
          "minimum": 0,
          "maximum": 65535
        },
        "dns_servers": {
          "type": "array",
          "maxItems": 4,
          "items": {
            "oneOf": [
              {
                "type": "string",
                "format": "ipv4"
              },
              {
                "type": "string",
                "format": "ipv6"
              }
            ]
          }
        },
        "mtu": {
          "type": "integer",
          "minimum": 576,
          "maximum": 9000
        }
      },
      "required": [
        "name",
        "address_family",
        "protocol",
        "endpoint_host",
        "endpoint_port",
        "private_key_secret_id",
        "peer_public_key",
        "preshared_key_secret_id",
        "addresses",
        "allowed_ips",
        "persistent_keepalive_seconds"
      ]
    },
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "address_family": {
          "enum": [
            "ipv4",
            "ipv6"
          ]
        },
        "protocol": {
          "const": "openvpn"
        },
        "remote_host": {
          "type": "string",
          "minLength": 1,
          "maxLength": 253
        },
        "remote_port": {
          "type": "integer",
          "minimum": 1,
          "maximum": 65535
        },
        "transport": {
          "enum": [
            "udp",
            "tcp-client"
          ]
        },
        "ca_secret_id": {
          "type": "string",
          "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
        },
        "client_certificate_secret_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "client_key_secret_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "auth_user_pass_secret_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "tls_secret_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "tls_mode": {
          "enum": [
            "tls-auth",
            "tls-crypt",
            "none"
          ]
        },
        "verify_server_name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 253
        },
        "remote_cert_tls_server": {
          "const": true
        },
        "data_ciphers": {
          "type": "array",
          "minItems": 1,
          "maxItems": 8,
          "items": {
            "enum": [
              "AES-256-GCM",
              "AES-128-GCM",
              "CHACHA20-POLY1305"
            ]
          }
        },
        "tls_key_direction": {
          "type": [
            "integer",
            "null"
          ],
          "enum": [
            0,
            1,
            null
          ]
        },
        "dns_servers": {
          "type": "array",
          "maxItems": 4,
          "items": {
            "oneOf": [
              {
                "type": "string",
                "format": "ipv4"
              },
              {
                "type": "string",
                "format": "ipv6"
              }
            ]
          }
        },
        "key_passphrase_secret_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "name",
        "address_family",
        "protocol",
        "remote_host",
        "remote_port",
        "transport",
        "ca_secret_id",
        "client_certificate_secret_id",
        "client_key_secret_id",
        "auth_user_pass_secret_id",
        "tls_secret_id",
        "tls_mode",
        "verify_server_name",
        "remote_cert_tls_server",
        "data_ciphers",
        "tls_key_direction"
      ]
    }
  ]
}
