feat(settings): add get_schema_name() to SiloSettings, remove hardcoded defaults
Add get_schema_name() to SiloSettings base class with default 'kindred-rd'. Update get_schema(), get_schema_form(), and get_property_schema() to fall back to settings instead of hardcoding the schema name. Add category query parameter support to get_property_schema(). Closes #28
This commit is contained in:
@@ -61,6 +61,10 @@ class SiloSettings:
|
||||
"""Remove all stored authentication credentials."""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_schema_name(self) -> str:
|
||||
"""Return the active part-numbering schema name (default ``"kindred-rd"``)."""
|
||||
return "kindred-rd"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# SiloClient
|
||||
@@ -621,21 +625,27 @@ class SiloClient:
|
||||
"""List all available schemas."""
|
||||
return self._request("GET", "/schemas")
|
||||
|
||||
def get_schema(self, name: str = "kindred-rd") -> Dict[str, Any]:
|
||||
def get_schema(self, name: str = "") -> Dict[str, Any]:
|
||||
if not name:
|
||||
name = self._settings.get_schema_name()
|
||||
return self._request("GET", f"/schemas/{urllib.parse.quote(name, safe='')}")
|
||||
|
||||
def get_schema_form(self, name: str) -> Dict[str, Any]:
|
||||
def get_schema_form(self, name: str = "") -> Dict[str, Any]:
|
||||
"""Get form descriptor for a schema (field groups, widgets, category picker)."""
|
||||
if not name:
|
||||
name = self._settings.get_schema_name()
|
||||
return self._request(
|
||||
"GET",
|
||||
f"/schemas/{urllib.parse.quote(name, safe='')}/form",
|
||||
)
|
||||
|
||||
def get_property_schema(self, name: str = "kindred-rd") -> Dict[str, Any]:
|
||||
return self._request(
|
||||
"GET",
|
||||
f"/schemas/{urllib.parse.quote(name, safe='')}/properties",
|
||||
)
|
||||
def get_property_schema(self, name: str = "", category: str = "") -> Dict[str, Any]:
|
||||
if not name:
|
||||
name = self._settings.get_schema_name()
|
||||
path = f"/schemas/{urllib.parse.quote(name, safe='')}/properties"
|
||||
if category:
|
||||
path += f"?category={urllib.parse.quote(category)}"
|
||||
return self._request("GET", path)
|
||||
|
||||
def add_enum_value(
|
||||
self, schema: str, segment: str, code: str, label: str = ""
|
||||
|
||||
Reference in New Issue
Block a user