

# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: blickfeld/secure/config/account.proto, blickfeld/secure/config/application_key.proto, blickfeld/secure/config/certificate.proto, blickfeld/secure/config/device_credentials.proto, blickfeld/secure/config/firewall.proto, blickfeld/secure/config/private_key.proto, blickfeld/secure/config/public_key.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import List

import blickfeld_qb2.betterproto as betterproto
import blickfeld_qb2.betterproto.lib.google.protobuf as betterproto_lib_google_protobuf

from ... import base as __base__


class AccountState(betterproto.Enum):
    """Account state"""

    STATE_UNSPECIFIED = 0
    """status is unspecified."""

    STATE_WAITING_FOR_ACTIVATION = 1
    """waiting for activation, account has to be activated by the user."""

    STATE_ACTIVE = 2
    """active, account can be used to authenticate."""

    STATE_BLOCKED = 3
    """blocked, account can not be used for authentication."""


@dataclass(eq=False, repr=False)
class ApplicationKey(betterproto.Message):
    """An application key is linked to a user account."""

    purpose: str = betterproto.string_field(1)
    """
    Human readable purpose for this application key. It is recommended to
    briefly describe the purpose of the application key here. The field should
    help users to quickly identify different application keys but can also be
    left empty.
    """

    access_level: "__base__.AccessControlLevel" = betterproto.enum_field(2)
    """Access level which is granted to this application key."""

    access_read_only: bool = betterproto.bool_field(7)
    """If true, this application key has read-only access permissions."""

    access_http: bool = betterproto.bool_field(8)
    """
    If true, allow http basic access authentication using this key. This option
    is required for ONVIF and RTSP video streaming.
    """


@dataclass(eq=False, repr=False)
class Account(betterproto.Message):
    """
    An account identifies a single user defined on the Qb2 device. By
    presenting credentials linked to an account a client can be authenticated.
    """

    name: str = betterproto.string_field(1)
    """Account name. This field is used as the username during login."""

    access_level: "__base__.AccessControlLevel" = betterproto.enum_field(2)
    """Access level which is granted to this account."""

    access_read_only: bool = betterproto.bool_field(8)
    """If true, this account has read-only access permissions."""

    failed_login_attempts: int = betterproto.uint32_field(5)
    """
    Counter for failed login attempts. If this value exceeds a configured
    threshold the account will be blocked.
    """

    state: "AccountState" = betterproto.enum_field(6)
    """The account state."""


@dataclass(eq=False, repr=False)
class Certificate(betterproto.Message):
    """Public key certificate during the TLS handshake process"""

    binary: bytes = betterproto.bytes_field(1)
    """Certificate bytes (DER format)"""

    type: str = betterproto.string_field(2)
    """
    String giving information about which key type was used for generation
    (e.g. RSA, key length)
    """

    serial: str = betterproto.string_field(3)
    """
    Serial number of certificate in padded hex format. Automatically assigned
    by the service when issued.
    """


@dataclass(eq=False, repr=False)
class PrivateKey(betterproto.Message):
    """
    Private device key which is deployed on the Qb2 device and used for TLS
    authentification by Daedalus Proxy
    """

    binary: bytes = betterproto.bytes_field(1)
    """Key bytes as binary"""

    type: str = betterproto.string_field(2)
    """String giving information about which key type is used"""


@dataclass(eq=False, repr=False)
class DeviceCredentials(betterproto.Message):
    """
    Cryptographic device credentials which are used to establish secure TLS
    connection between client and Qb2 and get access to its APIs
    """

    certificates: List["Certificate"] = betterproto.message_field(1)
    """
    Certificate chain which is deployed at Qb2 device and is used during the
    TLS handshake. Chain includes device certificate and corresponding issuer
    batch certificate.
    """

    key: "PrivateKey" = betterproto.message_field(2)
    """
    Device private key which is deployed at Qb2 device. Should never leave Qb2
    device after being deployed.
    """


@dataclass(eq=False, repr=False)
class Firewall(betterproto.Message):
    """Configuration options for the firewall"""

    disable_insecure_network_ports: bool = betterproto.bool_field(1)
    """
    Disable all insecure, unencrypted & unauthenticated, network interface
    ports.   [NOTE] This might break compatibility with client applications
    e.g. a normal  HTTP call to http://qb2-xxxxx will fail.
    """

    flow_port_forwardings: List["FirewallPortForwarding"] = betterproto.message_field(2)
    """
    The given ports are forwarded to custom applications in the blickfeld flow.
    """


@dataclass(eq=False, repr=False)
class FirewallPortForwarding(betterproto.Message):
    """Rule for port forwarding"""

    port: int = betterproto.uint32_field(1)
    """
    Port which should be forwarded.   NOTE: Due to security policies, only
    ports between 10000 to 10099 are allowed.
    """

    from_ip_network: str = betterproto.string_field(2)
    """
    The port forwarding is only allowed for the given IP address or subnet.
    The address should be specified in dot-decimal format (quad-dotted notation
    of four decimal integers, ranging from 0 to 255 each) including netmask
    prefix as follows "ip_address/prefix".
    """


@dataclass(eq=False, repr=False)
class PublicKey(betterproto.Message):
    """
    Public key which is used for verification or encryption. Verification keys
    are either hard-coded in applications or fused in hardware registers.
    """

    binary: bytes = betterproto.bytes_field(1)
    """Key bytes as binary"""

    type: str = betterproto.string_field(2)
    """String giving information about which key type is used"""
