mchades commented on code in PR #13804:
URL: https://github.com/apache/gravitino/pull/13804#discussion_r4255448666


##########
mcp-server/mcp_server/client/plain/plain_rest_client_semantic_model_operation.py:
##########
@@ -0,0 +1,113 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from typing import Optional
+
+from httpx import AsyncClient
+
+from mcp_server.client.plain.utils import (
+    encode_path_segment,
+    extract_content_from_response,
+)
+from mcp_server.client.semantic_model_operation import SemanticModelOperation
+
+
+class PlainRESTClientSemanticModelOperation(SemanticModelOperation):
+    """Access Semantic Models through Gravitino's native REST API."""
+
+    def __init__(self, metalake_name: str, rest_client: AsyncClient):
+        self.metalake_name = metalake_name
+        self.rest_client = rest_client
+
+    async def list_of_semantic_models(
+        self, catalog_name: str, schema_name: str
+    ) -> str:
+        response = await self.rest_client.get(
+            self._models_path(catalog_name, schema_name)
+        )
+        return extract_content_from_response(response, "identifiers", [])
+
+    async def load_semantic_model(
+        self, catalog_name: str, schema_name: str, semantic_model_name: str
+    ) -> str:
+        response = await self.rest_client.get(
+            self._model_path(catalog_name, schema_name, semantic_model_name)
+        )
+        return extract_content_from_response(response, "semanticModel", {})
+
+    # pylint: disable=too-many-positional-arguments
+    async def create_semantic_model(
+        self,
+        catalog_name: str,
+        schema_name: str,
+        name: str,
+        definition: dict,
+        comment: Optional[str] = None,
+        properties: Optional[dict[str, str]] = None,
+    ) -> str:
+        body = {"name": name, "definition": definition}

Review Comment:
   The backend already rejects `.` and `..` on both create and rename through 
`SemanticModelNormalizeDispatcher`, using `Capability.DEFAULT` name validation. 
These names are rejected before persistence, so they cannot leave an 
inaccessible model.
   
   `ossie` remains addressable: the import route is POST-only, while GET, PUT 
and DELETE still match `/{semanticModel}`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to