MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / schema

Method schema

unity_cli/api/dynamic_api.py:42–88  ·  view source on GitHub ↗

List available Unity static API methods. Args: namespace: Filter by namespace prefixes. type_name: Filter by type name. method_name: Filter by method name. limit: Maximum results per page. offset: Pagination offset. off

(
        self,
        namespace: list[str] | None = None,
        type_name: str | None = None,
        method_name: str | None = None,
        limit: int = 100,
        offset: int = 0,
        offline: bool = False,
        no_cache: bool = False,
        version: str | None = None,
    )

Source from the content-addressed store, hash-verified

40 )
41
42 def schema(
43 self,
44 namespace: list[str] | None = None,
45 type_name: str | None = None,
46 method_name: str | None = None,
47 limit: int = 100,
48 offset: int = 0,
49 offline: bool = False,
50 no_cache: bool = False,
51 version: str | None = None,
52 ) -> dict[str, Any]:
53 """List available Unity static API methods.
54
55 Args:
56 namespace: Filter by namespace prefixes.
57 type_name: Filter by type name.
58 method_name: Filter by method name.
59 limit: Maximum results per page.
60 offset: Pagination offset.
61 offline: Use cached schema only (no Relay).
62 no_cache: Skip cache, fetch from Relay.
63 version: Unity version override (for offline use).
64
65 Returns:
66 Dictionary with methods, total, and hasMore.
67 """
68 resolved_version = version or self._get_unity_version_safe()
69
70 # Try cache first (unless no_cache)
71 if not no_cache and resolved_version:
72 cached = self._cache.get(resolved_version)
73 if cached:
74 return self._filter_schema(cached, namespace, type_name, method_name, limit, offset)
75
76 if offline:
77 raise UnityCLIError(
78 "No cached schema available. Run 'u api schema' with Relay connected first, or specify --version.",
79 "CACHE_MISS",
80 )
81
82 # Fetch full schema from Relay and cache it
83 full = self._conn.send_request("api-schema", {"cache_all": True})
84 if resolved_version:
85 full["version"] = resolved_version
86 self._cache.put(resolved_version, full)
87
88 return self._filter_schema(full, namespace, type_name, method_name, limit, offset)
89
90 def _get_unity_version_safe(self) -> str | None:
91 """Get Unity version from connected instance, or None."""

Calls 6

_filter_schemaMethod · 0.95
UnityCLIErrorClass · 0.90
send_requestMethod · 0.80
putMethod · 0.80
getMethod · 0.45