mirror of
https://github.com/langgenius/dify.git
synced 2026-11-13 14:51:39 +08:00
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
103 lines
2.4 KiB
Python
103 lines
2.4 KiB
Python
"""Immutable application values, independent of SaaS wire names and HTTP DTOs."""
|
|
|
|
from dataclasses import dataclass
|
|
from datetime import datetime
|
|
from typing import Literal, NamedTuple
|
|
|
|
NetworkAccessPoint = Literal["webapp", "service_api", "mcp", "trigger"]
|
|
|
|
|
|
class NetworkAccessGroupAppRecord(NamedTuple):
|
|
id: str
|
|
mode: str
|
|
name: str
|
|
icon: str | None
|
|
icon_type: str | None
|
|
icon_background: str | None
|
|
bound_agent_id: str | None = None
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class NetworkAccessGroup:
|
|
id: str
|
|
tenant_id: str
|
|
name: str
|
|
description: str
|
|
allowed_cidrs: tuple[str, ...]
|
|
version: int
|
|
used_by_count: int
|
|
enforcing_count: int
|
|
app_ids: tuple[str, ...]
|
|
updated_by_account_id: str | None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
apps: tuple[NetworkAccessGroupAppRecord, ...] = ()
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class NetworkAccessBinding:
|
|
id: str
|
|
tenant_id: str
|
|
app_id: str
|
|
enabled: bool
|
|
group_id: str | None
|
|
# Preserve legacy/future scope names at the port; the service owns capabilities.
|
|
access_points: tuple[str, ...]
|
|
version: int
|
|
updated_by_account_id: str | None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class NetworkAccessGroupList:
|
|
tenant_id: str
|
|
entitled: bool
|
|
groups: tuple[NetworkAccessGroup, ...]
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class NetworkAccessAppConfig:
|
|
tenant_id: str
|
|
app_id: str
|
|
entitled: bool
|
|
effective_enabled: bool
|
|
binding: NetworkAccessBinding | None
|
|
available_access_points: tuple[NetworkAccessPoint, ...] = ()
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class NetworkAccessAppStatusSnapshot:
|
|
"""Control-plane entry state without policy identity or configuration."""
|
|
|
|
entitled: bool
|
|
configured: bool
|
|
enabled: bool
|
|
# Preserve legacy/future scopes so the service can project current App capabilities.
|
|
access_points: tuple[str, ...]
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class NetworkAccessAppStatus:
|
|
"""Public entry status without policy identity or configuration."""
|
|
|
|
entitled: bool
|
|
configured: bool
|
|
enabled: bool
|
|
covered_count: int
|
|
available_count: int
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class NetworkAccessBindingUpdate:
|
|
binding: NetworkAccessBinding
|
|
effective_enabled: bool
|
|
available_access_points: tuple[NetworkAccessPoint, ...] = ()
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class NetworkAccessCurrentIPCheck:
|
|
client_ip: str
|
|
allowed: bool
|
|
policy_version: int
|