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:
committed by
GitHub
parent
2bd736096a
commit
6572a92004
File diff suppressed because it is too large
Load Diff
109
kittycad/api/ml/create_proprietary_to_kcl.py
Normal file
109
kittycad/api/ml/create_proprietary_to_kcl.py
Normal 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
|
@ -27,11 +27,18 @@ def _get_kwargs(
|
||||
webrtc: bool,
|
||||
*,
|
||||
client: Client,
|
||||
api_call_id: Optional[str] = None,
|
||||
pool: Optional[str] = None,
|
||||
replay: Optional[str] = None,
|
||||
) -> Dict[str, Any]:
|
||||
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 "?" in url:
|
||||
url = url + "&fps=" + str(fps)
|
||||
@ -107,12 +114,14 @@ def sync(
|
||||
webrtc: bool,
|
||||
*,
|
||||
client: Client,
|
||||
api_call_id: Optional[str] = None,
|
||||
pool: Optional[str] = None,
|
||||
replay: Optional[str] = None,
|
||||
) -> 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
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
api_call_id=api_call_id,
|
||||
fps=fps,
|
||||
pool=pool,
|
||||
post_effect=post_effect,
|
||||
@ -143,12 +152,14 @@ async def asyncio(
|
||||
webrtc: bool,
|
||||
*,
|
||||
client: Client,
|
||||
api_call_id: Optional[str] = None,
|
||||
pool: Optional[str] = None,
|
||||
replay: Optional[str] = None,
|
||||
) -> 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
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
api_call_id=api_call_id,
|
||||
fps=fps,
|
||||
pool=pool,
|
||||
post_effect=post_effect,
|
||||
@ -184,6 +195,7 @@ class WebSocket:
|
||||
video_res_width: int,
|
||||
webrtc: bool,
|
||||
client: Client,
|
||||
api_call_id: Optional[str] = None,
|
||||
pool: Optional[str] = None,
|
||||
replay: Optional[str] = None,
|
||||
):
|
||||
@ -196,6 +208,7 @@ class WebSocket:
|
||||
video_res_width,
|
||||
webrtc,
|
||||
client=client,
|
||||
api_call_id=api_call_id,
|
||||
pool=pool,
|
||||
replay=replay,
|
||||
)
|
||||
|
@ -56,6 +56,7 @@ from kittycad.api.meta import (
|
||||
)
|
||||
from kittycad.api.ml import (
|
||||
create_kcl_code_completions,
|
||||
create_proprietary_to_kcl,
|
||||
create_text_to_cad,
|
||||
create_text_to_cad_iteration,
|
||||
create_text_to_cad_model_feedback,
|
||||
@ -188,6 +189,7 @@ from kittycad.models import (
|
||||
Invoice,
|
||||
IpAddrInfo,
|
||||
KclCodeCompletionResponse,
|
||||
KclModel,
|
||||
Metadata,
|
||||
MlPrompt,
|
||||
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
|
||||
def test_create_kcl_code_completions():
|
||||
# Create our client.
|
||||
@ -7493,6 +7538,7 @@ def test_modeling_commands_ws():
|
||||
video_res_height=10,
|
||||
video_res_width=10,
|
||||
webrtc=False,
|
||||
api_call_id=None, # Optional[str]
|
||||
pool=None, # Optional[str]
|
||||
replay=None, # Optional[str]
|
||||
) as websocket:
|
||||
@ -7530,6 +7576,7 @@ async def test_modeling_commands_ws_async():
|
||||
video_res_height=10,
|
||||
video_res_width=10,
|
||||
webrtc=False,
|
||||
api_call_id=None, # Optional[str]
|
||||
pool=None, # Optional[str]
|
||||
replay=None, # Optional[str]
|
||||
)
|
||||
|
@ -176,6 +176,7 @@ from .jetstream_stats import JetstreamStats
|
||||
from .kcl_code_completion_params import KclCodeCompletionParams
|
||||
from .kcl_code_completion_request import KclCodeCompletionRequest
|
||||
from .kcl_code_completion_response import KclCodeCompletionResponse
|
||||
from .kcl_model import KclModel
|
||||
from .leaf_node import LeafNode
|
||||
from .length_unit import LengthUnit
|
||||
from .loft import Loft
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
@ -6,6 +6,6 @@ from pydantic import BaseModel, ConfigDict
|
||||
class BooleanIntersection(BaseModel):
|
||||
"""The response from the 'BooleanIntersection'."""
|
||||
|
||||
extra_solid_ids: List[str]
|
||||
extra_solid_ids: Optional[List[str]] = None
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
@ -6,6 +6,6 @@ from pydantic import BaseModel, ConfigDict
|
||||
class BooleanSubtract(BaseModel):
|
||||
"""The response from the 'BooleanSubtract'."""
|
||||
|
||||
extra_solid_ids: List[str]
|
||||
extra_solid_ids: Optional[List[str]] = None
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
@ -6,6 +6,6 @@ from pydantic import BaseModel, ConfigDict
|
||||
class BooleanUnion(BaseModel):
|
||||
"""The response from the 'BooleanUnion'."""
|
||||
|
||||
extra_solid_ids: List[str]
|
||||
extra_solid_ids: Optional[List[str]] = None
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
@ -7,7 +7,7 @@ from ..models.transform_by_for_point4d import TransformByForPoint4d
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
9
kittycad/models/kcl_model.py
Normal file
9
kittycad/models/kcl_model.py
Normal 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=())
|
@ -170,6 +170,24 @@ class OptionPong(BaseModel):
|
||||
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[
|
||||
Annotated[
|
||||
Union[
|
||||
@ -182,6 +200,7 @@ OkWebSocketResponseData = RootModel[
|
||||
OptionMetricsRequest,
|
||||
OptionModelingSessionData,
|
||||
OptionPong,
|
||||
OptionDebug,
|
||||
],
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
@ -75,6 +75,14 @@ class OptionMetricsResponse(BaseModel):
|
||||
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):
|
||||
"""Authentication header request."""
|
||||
|
||||
@ -94,6 +102,7 @@ WebSocketRequest = RootModel[
|
||||
OptionModelingCmdBatchReq,
|
||||
OptionPing,
|
||||
OptionMetricsResponse,
|
||||
OptionDebug,
|
||||
OptionHeaders,
|
||||
],
|
||||
Field(discriminator="type"),
|
||||
|
69
spec.json
69
spec.json
@ -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.",
|
||||
"operationId": "modeling_commands_ws",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "query",
|
||||
"name": "api_call_id",
|
||||
"description": "API Call ID for distributed tracing",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "fps",
|
||||
@ -18646,10 +18655,7 @@
|
||||
"format": "uuid"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"extra_solid_ids"
|
||||
]
|
||||
}
|
||||
},
|
||||
"BooleanSubtract": {
|
||||
"description": "The response from the 'BooleanSubtract'.",
|
||||
@ -18663,10 +18669,7 @@
|
||||
"format": "uuid"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"extra_solid_ids"
|
||||
]
|
||||
}
|
||||
},
|
||||
"BooleanUnion": {
|
||||
"description": "The response from the 'BooleanUnion'.",
|
||||
@ -18680,10 +18683,7 @@
|
||||
"format": "uuid"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"extra_solid_ids"
|
||||
]
|
||||
}
|
||||
},
|
||||
"CacheMetadata": {
|
||||
"description": "Metadata about our cache.\n\nThis is mostly used for internal purposes and debugging.",
|
||||
@ -19209,7 +19209,7 @@
|
||||
]
|
||||
},
|
||||
"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",
|
||||
"properties": {
|
||||
"rotate_angle_axis": {
|
||||
@ -30525,6 +30525,34 @@
|
||||
"data",
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Return information about the connected instance",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"debug"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Authentication header request.",
|
||||
"type": "object",
|
||||
|
Reference in New Issue
Block a user