# Code generated by tools/src/proto-codegen.ts DO NOT EDIT.
# Source of truth: proto/liteguard.proto  Run: make proto

"""Data-plane types. Generated from proto/liteguard.proto."""

from __future__ import annotations

from dataclasses import dataclass, field
from enum import Enum
from typing import Union

PropertyValue = Union[bool, str, float, int]
Properties = dict[str, PropertyValue]

class Operator(str, Enum):
    EQUALS = "EQUALS"
    NOT_EQUALS = "NOT_EQUALS"
    IN = "IN"
    NOT_IN = "NOT_IN"
    REGEX = "REGEX"
    GT = "GT"
    GTE = "GTE"
    LT = "LT"
    LTE = "LTE"

@dataclass
class Rule:
    property_name: str
    operator: Operator
    result: bool
    enabled: bool
    values: list[PropertyValue] = field(default_factory=list)

@dataclass
class Guard:
    name: str
    default_value: bool
    adopted: bool
    rate_limit_per_minute: int
    rules: list[Rule] = field(default_factory=list)
    rate_limit_properties: list[str] = field(default_factory=list)
    disable_measurement: bool = False

@dataclass
class ClientOptions:
    environment: str = ""
    fallback: bool = False
    refresh_rate_seconds: int = 30
    flush_rate_seconds: int = 10
    flush_size: int = 500
    backend_url: str = "https://api.liteguard.io"
    quiet: bool = True
    http_timeout_seconds: int = 4
    flush_buffer_multiplier: int = 4
    disable_measurement: bool = False

@dataclass
class Options:
    properties: dict[str, PropertyValue] = field(default_factory=dict)
    fallback: bool | None = None
    disable_measurement: bool = False

@dataclass
class ProtectedContext:
    signature: str
    properties: dict[str, str] = field(default_factory=dict)

@dataclass
class GetGuardsRequest:
    project_client_token: str
    environment: str
    protected_context: ProtectedContext | None = None

@dataclass
class GetGuardsResponse:
    refresh_rate_seconds: int
    etag: str
    guards: list[Guard] = field(default_factory=list)

@dataclass
class TraceContext:
    trace_id: str
    span_id: str
    parent_span_id: str

@dataclass
class GuardCheckPerformance:
    rss_bytes: int | None = None
    heap_used_bytes: int | None = None
    heap_total_bytes: int | None = None
    cpu_time_ns: int | None = None
    gc_count: int | None = None
    thread_count: int | None = None

@dataclass
class GuardExecutionPerformance:
    duration_ns: int
    completed: bool
    rss_end_bytes: int | None = None
    heap_used_end_bytes: int | None = None
    heap_total_end_bytes: int | None = None
    cpu_time_end_ns: int | None = None
    gc_count_end: int | None = None
    thread_count_end: int | None = None
    error_class: str | None = None

@dataclass
class SignalPerformance:
    guard_check: GuardCheckPerformance | None = None
    guard_execution: GuardExecutionPerformance | None = None

@dataclass
class Signal:
    guard_name: str
    result: bool
    timestamp_ms: int
    signal_id: str
    execution_id: str
    sequence_number: int
    callsite_id: str
    kind: str
    dropped_signals_since_last: int
    properties: dict[str, PropertyValue] = field(default_factory=dict)
    trace: TraceContext | None = None
    parent_signal_id: str | None = None
    measurement: SignalPerformance | None = None

@dataclass
class UnadoptedGuardObservation:
    guard_name: str
    first_seen_ms: int
    last_seen_ms: int
    check_count: int
    estimated_checks_per_minute: float

@dataclass
class SendUnadoptedGuardsRequest:
    project_client_token: str
    environment: str
    observations: list[UnadoptedGuardObservation] = field(default_factory=list)

@dataclass
class SendUnadoptedGuardsResponse:
    accepted: bool
