Update api spec (#427)

* YOYO NEW API SPEC!

* I have generated the latest API!

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
zoo-github-actions-auth[bot]
2025-05-01 11:42:30 -07:00
committed by GitHub
parent 2bd736096a
commit 6572a92004
13 changed files with 1162 additions and 904 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,109 @@
from typing import Any, Dict, Optional, Union
import httpx
from ...client import Client
from ...models.error import Error
from ...models.kcl_model import KclModel
from ...types import Response
def _get_kwargs(
*,
client: Client,
) -> Dict[str, Any]:
url = "{}/ml/convert/proprietary-to-kcl".format(
client.base_url,
) # noqa: E501
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
return {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
}
def _parse_response(*, response: httpx.Response) -> Optional[Union[KclModel, Error]]:
if response.status_code == 201:
response_201 = KclModel(**response.json())
return response_201
if response.status_code == 400:
response_4XX = Error(**response.json())
return response_4XX
if response.status_code == 500:
response_5XX = Error(**response.json())
return response_5XX
return Error(**response.json())
def _build_response(
*, response: httpx.Response
) -> Response[Optional[Union[KclModel, Error]]]:
return Response(
status_code=response.status_code,
content=response.content,
headers=response.headers,
parsed=_parse_response(response=response),
)
def sync_detailed(
*,
client: Client,
) -> Response[Optional[Union[KclModel, Error]]]:
kwargs = _get_kwargs(
client=client,
)
response = httpx.post(
verify=client.verify_ssl,
**kwargs,
)
return _build_response(response=response)
def sync(
*,
client: Client,
) -> Optional[Union[KclModel, Error]]:
"""This endpoint is used to convert a proprietary CAD format to KCL. The file passed MUST have feature tree data.
A STEP file does not have feature tree data, so it will not work. A sldprt file does have feature tree data, so it will work.""" # noqa: E501
return sync_detailed(
client=client,
).parsed
async def asyncio_detailed(
*,
client: Client,
) -> Response[Optional[Union[KclModel, Error]]]:
kwargs = _get_kwargs(
client=client,
)
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.post(**kwargs)
return _build_response(response=response)
async def asyncio(
*,
client: Client,
) -> Optional[Union[KclModel, Error]]:
"""This endpoint is used to convert a proprietary CAD format to KCL. The file passed MUST have feature tree data.
A STEP file does not have feature tree data, so it will not work. A sldprt file does have feature tree data, so it will work.""" # noqa: E501
return (
await asyncio_detailed(
client=client,
)
).parsed

View File

@ -27,11 +27,18 @@ def _get_kwargs(
webrtc: bool, webrtc: bool,
*, *,
client: Client, client: Client,
api_call_id: Optional[str] = None,
pool: Optional[str] = None, pool: Optional[str] = None,
replay: Optional[str] = None, replay: Optional[str] = None,
) -> Dict[str, Any]: ) -> Dict[str, Any]:
url = "{}/ws/modeling/commands".format(client.base_url) # noqa: E501 url = "{}/ws/modeling/commands".format(client.base_url) # noqa: E501
if api_call_id is not None:
if "?" in url:
url = url + "&api_call_id=" + str(api_call_id)
else:
url = url + "?api_call_id=" + str(api_call_id)
if fps is not None: if fps is not None:
if "?" in url: if "?" in url:
url = url + "&fps=" + str(fps) url = url + "&fps=" + str(fps)
@ -107,12 +114,14 @@ def sync(
webrtc: bool, webrtc: bool,
*, *,
client: Client, client: Client,
api_call_id: Optional[str] = None,
pool: Optional[str] = None, pool: Optional[str] = None,
replay: Optional[str] = None, replay: Optional[str] = None,
) -> ClientConnectionSync: ) -> ClientConnectionSync:
"""Pass those commands to the engine via websocket, and pass responses back to the client. Basically, this is a websocket proxy between the frontend/client and the engine.""" # noqa: E501 """Pass those commands to the engine via websocket, and pass responses back to the client. Basically, this is a websocket proxy between the frontend/client and the engine.""" # noqa: E501
kwargs = _get_kwargs( kwargs = _get_kwargs(
api_call_id=api_call_id,
fps=fps, fps=fps,
pool=pool, pool=pool,
post_effect=post_effect, post_effect=post_effect,
@ -143,12 +152,14 @@ async def asyncio(
webrtc: bool, webrtc: bool,
*, *,
client: Client, client: Client,
api_call_id: Optional[str] = None,
pool: Optional[str] = None, pool: Optional[str] = None,
replay: Optional[str] = None, replay: Optional[str] = None,
) -> ClientConnectionAsync: ) -> ClientConnectionAsync:
"""Pass those commands to the engine via websocket, and pass responses back to the client. Basically, this is a websocket proxy between the frontend/client and the engine.""" # noqa: E501 """Pass those commands to the engine via websocket, and pass responses back to the client. Basically, this is a websocket proxy between the frontend/client and the engine.""" # noqa: E501
kwargs = _get_kwargs( kwargs = _get_kwargs(
api_call_id=api_call_id,
fps=fps, fps=fps,
pool=pool, pool=pool,
post_effect=post_effect, post_effect=post_effect,
@ -184,6 +195,7 @@ class WebSocket:
video_res_width: int, video_res_width: int,
webrtc: bool, webrtc: bool,
client: Client, client: Client,
api_call_id: Optional[str] = None,
pool: Optional[str] = None, pool: Optional[str] = None,
replay: Optional[str] = None, replay: Optional[str] = None,
): ):
@ -196,6 +208,7 @@ class WebSocket:
video_res_width, video_res_width,
webrtc, webrtc,
client=client, client=client,
api_call_id=api_call_id,
pool=pool, pool=pool,
replay=replay, replay=replay,
) )

View File

@ -56,6 +56,7 @@ from kittycad.api.meta import (
) )
from kittycad.api.ml import ( from kittycad.api.ml import (
create_kcl_code_completions, create_kcl_code_completions,
create_proprietary_to_kcl,
create_text_to_cad, create_text_to_cad,
create_text_to_cad_iteration, create_text_to_cad_iteration,
create_text_to_cad_model_feedback, create_text_to_cad_model_feedback,
@ -188,6 +189,7 @@ from kittycad.models import (
Invoice, Invoice,
IpAddrInfo, IpAddrInfo,
KclCodeCompletionResponse, KclCodeCompletionResponse,
KclModel,
Metadata, Metadata,
MlPrompt, MlPrompt,
MlPromptResultsPage, MlPromptResultsPage,
@ -1899,6 +1901,49 @@ async def test_get_ml_prompt_async():
) )
@pytest.mark.skip
def test_create_proprietary_to_kcl():
# Create our client.
client = ClientFromEnv()
result: Optional[Union[KclModel, Error]] = create_proprietary_to_kcl.sync(
client=client,
)
if isinstance(result, Error) or result is None:
print(result)
raise Exception("Error in response")
body: KclModel = result
print(body)
# OR if you need more info (e.g. status_code)
response: Response[Optional[Union[KclModel, Error]]] = (
create_proprietary_to_kcl.sync_detailed(
client=client,
)
)
# OR run async
@pytest.mark.asyncio
@pytest.mark.skip
async def test_create_proprietary_to_kcl_async():
# Create our client.
client = ClientFromEnv()
result: Optional[Union[KclModel, Error]] = await create_proprietary_to_kcl.asyncio(
client=client,
)
# OR run async with more info
response: Response[
Optional[Union[KclModel, Error]]
] = await create_proprietary_to_kcl.asyncio_detailed(
client=client,
)
@pytest.mark.skip @pytest.mark.skip
def test_create_kcl_code_completions(): def test_create_kcl_code_completions():
# Create our client. # Create our client.
@ -7493,6 +7538,7 @@ def test_modeling_commands_ws():
video_res_height=10, video_res_height=10,
video_res_width=10, video_res_width=10,
webrtc=False, webrtc=False,
api_call_id=None, # Optional[str]
pool=None, # Optional[str] pool=None, # Optional[str]
replay=None, # Optional[str] replay=None, # Optional[str]
) as websocket: ) as websocket:
@ -7530,6 +7576,7 @@ async def test_modeling_commands_ws_async():
video_res_height=10, video_res_height=10,
video_res_width=10, video_res_width=10,
webrtc=False, webrtc=False,
api_call_id=None, # Optional[str]
pool=None, # Optional[str] pool=None, # Optional[str]
replay=None, # Optional[str] replay=None, # Optional[str]
) )

View File

@ -176,6 +176,7 @@ from .jetstream_stats import JetstreamStats
from .kcl_code_completion_params import KclCodeCompletionParams from .kcl_code_completion_params import KclCodeCompletionParams
from .kcl_code_completion_request import KclCodeCompletionRequest from .kcl_code_completion_request import KclCodeCompletionRequest
from .kcl_code_completion_response import KclCodeCompletionResponse from .kcl_code_completion_response import KclCodeCompletionResponse
from .kcl_model import KclModel
from .leaf_node import LeafNode from .leaf_node import LeafNode
from .length_unit import LengthUnit from .length_unit import LengthUnit
from .loft import Loft from .loft import Loft

View File

@ -1,4 +1,4 @@
from typing import List from typing import List, Optional
from pydantic import BaseModel, ConfigDict from pydantic import BaseModel, ConfigDict
@ -6,6 +6,6 @@ from pydantic import BaseModel, ConfigDict
class BooleanIntersection(BaseModel): class BooleanIntersection(BaseModel):
"""The response from the 'BooleanIntersection'.""" """The response from the 'BooleanIntersection'."""
extra_solid_ids: List[str] extra_solid_ids: Optional[List[str]] = None
model_config = ConfigDict(protected_namespaces=()) model_config = ConfigDict(protected_namespaces=())

View File

@ -1,4 +1,4 @@
from typing import List from typing import List, Optional
from pydantic import BaseModel, ConfigDict from pydantic import BaseModel, ConfigDict
@ -6,6 +6,6 @@ from pydantic import BaseModel, ConfigDict
class BooleanSubtract(BaseModel): class BooleanSubtract(BaseModel):
"""The response from the 'BooleanSubtract'.""" """The response from the 'BooleanSubtract'."""
extra_solid_ids: List[str] extra_solid_ids: Optional[List[str]] = None
model_config = ConfigDict(protected_namespaces=()) model_config = ConfigDict(protected_namespaces=())

View File

@ -1,4 +1,4 @@
from typing import List from typing import List, Optional
from pydantic import BaseModel, ConfigDict from pydantic import BaseModel, ConfigDict
@ -6,6 +6,6 @@ from pydantic import BaseModel, ConfigDict
class BooleanUnion(BaseModel): class BooleanUnion(BaseModel):
"""The response from the 'BooleanUnion'.""" """The response from the 'BooleanUnion'."""
extra_solid_ids: List[str] extra_solid_ids: Optional[List[str]] = None
model_config = ConfigDict(protected_namespaces=()) model_config = ConfigDict(protected_namespaces=())

View File

@ -7,7 +7,7 @@ from ..models.transform_by_for_point4d import TransformByForPoint4d
class ComponentTransform(BaseModel): class ComponentTransform(BaseModel):
"""Container that holds a translate, rotate and scale.""" """Container that holds a translate, rotate and scale. Defaults to no change, everything stays the same (i.e. the identity function)."""
rotate_angle_axis: Optional[TransformByForPoint4d] = None rotate_angle_axis: Optional[TransformByForPoint4d] = None

View File

@ -0,0 +1,9 @@
from pydantic import BaseModel, ConfigDict
class KclModel(BaseModel):
"""The response containing the KCL code."""
code: str
model_config = ConfigDict(protected_namespaces=())

View File

@ -170,6 +170,24 @@ class OptionPong(BaseModel):
model_config = ConfigDict(protected_namespaces=()) model_config = ConfigDict(protected_namespaces=())
class DebugData(BaseModel):
""""""
name: str
model_config = ConfigDict(protected_namespaces=())
class OptionDebug(BaseModel):
"""Information about the connected instance"""
data: DebugData
type: Literal["debug"] = "debug"
model_config = ConfigDict(protected_namespaces=())
OkWebSocketResponseData = RootModel[ OkWebSocketResponseData = RootModel[
Annotated[ Annotated[
Union[ Union[
@ -182,6 +200,7 @@ OkWebSocketResponseData = RootModel[
OptionMetricsRequest, OptionMetricsRequest,
OptionModelingSessionData, OptionModelingSessionData,
OptionPong, OptionPong,
OptionDebug,
], ],
Field(discriminator="type"), Field(discriminator="type"),
] ]

View File

@ -75,6 +75,14 @@ class OptionMetricsResponse(BaseModel):
model_config = ConfigDict(protected_namespaces=()) model_config = ConfigDict(protected_namespaces=())
class OptionDebug(BaseModel):
"""Return information about the connected instance"""
type: Literal["debug"] = "debug"
model_config = ConfigDict(protected_namespaces=())
class OptionHeaders(BaseModel): class OptionHeaders(BaseModel):
"""Authentication header request.""" """Authentication header request."""
@ -94,6 +102,7 @@ WebSocketRequest = RootModel[
OptionModelingCmdBatchReq, OptionModelingCmdBatchReq,
OptionPing, OptionPing,
OptionMetricsResponse, OptionMetricsResponse,
OptionDebug,
OptionHeaders, OptionHeaders,
], ],
Field(discriminator="type"), Field(discriminator="type"),

View File

@ -16427,6 +16427,15 @@
"description": "Pass those commands to the engine via websocket, and pass responses back to the client. Basically, this is a websocket proxy between the frontend/client and the engine.", "description": "Pass those commands to the engine via websocket, and pass responses back to the client. Basically, this is a websocket proxy between the frontend/client and the engine.",
"operationId": "modeling_commands_ws", "operationId": "modeling_commands_ws",
"parameters": [ "parameters": [
{
"in": "query",
"name": "api_call_id",
"description": "API Call ID for distributed tracing",
"schema": {
"nullable": true,
"type": "string"
}
},
{ {
"in": "query", "in": "query",
"name": "fps", "name": "fps",
@ -18646,10 +18655,7 @@
"format": "uuid" "format": "uuid"
} }
} }
}, }
"required": [
"extra_solid_ids"
]
}, },
"BooleanSubtract": { "BooleanSubtract": {
"description": "The response from the 'BooleanSubtract'.", "description": "The response from the 'BooleanSubtract'.",
@ -18663,10 +18669,7 @@
"format": "uuid" "format": "uuid"
} }
} }
}, }
"required": [
"extra_solid_ids"
]
}, },
"BooleanUnion": { "BooleanUnion": {
"description": "The response from the 'BooleanUnion'.", "description": "The response from the 'BooleanUnion'.",
@ -18680,10 +18683,7 @@
"format": "uuid" "format": "uuid"
} }
} }
}, }
"required": [
"extra_solid_ids"
]
}, },
"CacheMetadata": { "CacheMetadata": {
"description": "Metadata about our cache.\n\nThis is mostly used for internal purposes and debugging.", "description": "Metadata about our cache.\n\nThis is mostly used for internal purposes and debugging.",
@ -19209,7 +19209,7 @@
] ]
}, },
"ComponentTransform": { "ComponentTransform": {
"description": "Container that holds a translate, rotate and scale.", "description": "Container that holds a translate, rotate and scale. Defaults to no change, everything stays the same (i.e. the identity function).",
"type": "object", "type": "object",
"properties": { "properties": {
"rotate_angle_axis": { "rotate_angle_axis": {
@ -30525,6 +30525,34 @@
"data", "data",
"type" "type"
] ]
},
{
"description": "Information about the connected instance",
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"name": {
"description": "Instance name. This may or may not mean something.",
"type": "string"
}
},
"required": [
"name"
]
},
"type": {
"type": "string",
"enum": [
"debug"
]
}
},
"required": [
"data",
"type"
]
} }
] ]
}, },
@ -36313,6 +36341,21 @@
"type" "type"
] ]
}, },
{
"description": "Return information about the connected instance",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"debug"
]
}
},
"required": [
"type"
]
},
{ {
"description": "Authentication header request.", "description": "Authentication header request.",
"type": "object", "type": "object",