30 lines
785 B
Python
30 lines
785 B
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import Any, Dict, Optional
|
|
|
|
|
|
@dataclass
|
|
class RegistryEntry:
|
|
adapter_id: str
|
|
contract_version: str
|
|
data_contract: Dict[str, Any] = field(default_factory=dict)
|
|
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
|
|
|
|
class GraphRegistry:
|
|
def __init__(self) -> None:
|
|
self._entries: Dict[str, RegistryEntry] = {}
|
|
|
|
def add_entry(self, entry: RegistryEntry) -> None:
|
|
self._entries[entry.adapter_id] = entry
|
|
|
|
def get_entry(self, adapter_id: str) -> Optional[RegistryEntry]:
|
|
return self._entries.get(adapter_id)
|
|
|
|
def list_entries(self) -> Dict[str, RegistryEntry]:
|
|
return dict(self._entries)
|
|
|
|
|
|
__all__ = ["GraphRegistry", "RegistryEntry"]
|