97 lines
3.4 KiB
Python
97 lines
3.4 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Any
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class ProviderCapability:
|
|
provider_name: str
|
|
display_name: str
|
|
authority_level: str
|
|
supported_layers: list[str]
|
|
supported_geometry_types: list[str]
|
|
supported_query_modes: list[str]
|
|
fetch_signature: str
|
|
configured: bool
|
|
status: str
|
|
limitation_message: str
|
|
attribution: str
|
|
license_note: str
|
|
not_configured_reason: str | None = None
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
return {
|
|
"provider_name": self.provider_name,
|
|
"display_name": self.display_name,
|
|
"authority_level": self.authority_level,
|
|
"supported_layers": self.supported_layers,
|
|
"supported_geometry_types": self.supported_geometry_types,
|
|
"supported_query_modes": self.supported_query_modes,
|
|
"fetch_signature": self.fetch_signature,
|
|
"configured": self.configured,
|
|
"status": self.status,
|
|
"limitation_message": self.limitation_message,
|
|
"attribution": self.attribution,
|
|
"license_note": self.license_note,
|
|
"not_configured_reason": self.not_configured_reason,
|
|
}
|
|
|
|
|
|
class BaseReferenceProvider:
|
|
def __init__(
|
|
self,
|
|
provider_name: str,
|
|
display_name: str,
|
|
authority_level: str,
|
|
supported_layers: list[str],
|
|
supported_geometry_types: list[str],
|
|
supported_query_modes: list[str],
|
|
fetch_signature: str,
|
|
limitation_message: str,
|
|
attribution: str,
|
|
license_note: str,
|
|
configured: bool = False,
|
|
) -> None:
|
|
self.provider_name = provider_name
|
|
self.display_name = display_name
|
|
self.authority_level = authority_level
|
|
self.supported_layers = supported_layers
|
|
self.supported_geometry_types = supported_geometry_types
|
|
self.supported_query_modes = supported_query_modes
|
|
self.fetch_signature = fetch_signature
|
|
self.limitation_message = limitation_message
|
|
self.attribution = attribution
|
|
self.license_note = license_note
|
|
self._configured = configured
|
|
|
|
@property
|
|
def capability(self) -> ProviderCapability:
|
|
return ProviderCapability(
|
|
provider_name=self.provider_name,
|
|
display_name=self.display_name,
|
|
authority_level=self.authority_level,
|
|
supported_layers=self.supported_layers,
|
|
supported_geometry_types=self.supported_geometry_types,
|
|
supported_query_modes=self.supported_query_modes,
|
|
fetch_signature=self.fetch_signature,
|
|
configured=self.is_configured,
|
|
status="configured" if self.is_configured else "not_configured",
|
|
limitation_message=self.limitation_message,
|
|
attribution=self.attribution,
|
|
license_note=self.license_note,
|
|
not_configured_reason=None if self.is_configured else "Provider integration is not configured yet",
|
|
)
|
|
|
|
@property
|
|
def is_configured(self) -> bool:
|
|
return self._configured
|
|
|
|
def fetch(self, project_id: str, area_id: str | None, layers: list[str]) -> dict[str, Any]:
|
|
del project_id, area_id, layers
|
|
return {
|
|
"provider": self.provider_name,
|
|
"status": "not_configured",
|
|
"message": "Provider integration is not configured yet",
|
|
}
|