Compare commits

..

6 Commits

Author SHA1 Message Date
79b977a55a fix test
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2024-04-05 13:30:47 -07:00
df9083c3e2 bump version
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2024-04-05 13:13:34 -07:00
f3e7f4f229 fix new spec bs
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2024-04-05 13:12:19 -07:00
12864cdb44 Merge remote-tracking branch 'origin/update-spec'
* origin/update-spec:
  YOYO NEW API SPEC!
2024-04-05 12:58:43 -07:00
671a0a8391 Bump softprops/action-gh-release from 1 to 2 (#209)
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 1 to 2.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v1...v2)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-05 12:58:12 -07:00
553b1c1fcd YOYO NEW API SPEC! 2024-04-04 20:49:25 +00:00
22 changed files with 1709 additions and 1046 deletions

View File

@ -28,4 +28,4 @@ jobs:
# TODO: generate a nice little doc for the release text like we do for the
# cli repo.
- name: Create a Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2

View File

@ -154,10 +154,19 @@ class WebSocket:
self.ws = sync(
{% for arg in args %}
{% if arg.in_query %}
{% if arg.is_optional == False %}
{{arg.name}},
{% endif %}
{% endif %}
{% endfor %}
client=client,
{% for arg in args %}
{% if arg.in_query %}
{% if arg.is_optional %}
{{arg.name}}={{arg.name}},
{% endif %}
{% endif %}
{% endfor %}
)
def __enter__(self,

View File

@ -478,11 +478,16 @@ from kittycad.types import Response
for endpoint_ref in endpoint_refs:
if endpoint_ref == "Error":
continue
example_imports = example_imports + (
"""from kittycad.models import """
+ endpoint_ref.replace("List[", "").replace("]", "")
+ "\n"
)
# For some reason, PrivacySettings is showing up twice so we want to skip
# it here. Obviously this is a hack and we should fix the root cause.
# When this happens again with another struct there might be a more obvious
# solution, but alas, I am lazy.
if endpoint_ref != "PrivacySettings":
example_imports = example_imports + (
"""from kittycad.models import """
+ endpoint_ref.replace("List[", "").replace("]", "")
+ "\n"
)
example_imports = (
example_imports + "from typing import Union, Any, Optional, List, Tuple\n"
)
@ -1677,8 +1682,9 @@ def getRefs(schema: dict) -> List[str]:
# do nothing
pass
else:
logging.error("unsupported type: ", schema)
raise Exception("unsupported type: ", schema)
# This is likely an empty object like above but with a description
# so we will just skip it.
pass
elif type_name == "array":
if "items" in schema:
schema_refs = getRefs(schema["items"])

File diff suppressed because it is too large Load Diff

View File

@ -41,9 +41,9 @@ def _get_kwargs(
def _parse_response(*, response: httpx.Response) -> Optional[Union[CodeOutput, Error]]:
if response.status_code == 200:
response_200 = CodeOutput(**response.json())
return response_200
if response.status_code == 201:
response_201 = CodeOutput(**response.json())
return response_201
if response.status_code == 400:
response_4XX = Error(**response.json())
return response_4XX

View File

@ -4,10 +4,12 @@ import httpx
from ...client import Client
from ...models.error import Error
from ...models.event import Event
from ...types import Response
def _get_kwargs(
body: Event,
*,
client: Client,
) -> Dict[str, Any]:
@ -23,6 +25,7 @@ def _get_kwargs(
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"content": body.model_dump_json(),
}
@ -47,10 +50,12 @@ def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
def sync_detailed(
body: Event,
*,
client: Client,
) -> Response[Optional[Error]]:
kwargs = _get_kwargs(
body=body,
client=client,
)
@ -63,21 +68,25 @@ def sync_detailed(
def sync(
body: Event,
*,
client: Client,
) -> Optional[Error]:
"""We collect anonymous telemetry data for improving our product.""" # noqa: E501
return sync_detailed(
body=body,
client=client,
).parsed
async def asyncio_detailed(
body: Event,
*,
client: Client,
) -> Response[Optional[Error]]:
kwargs = _get_kwargs(
body=body,
client=client,
)
@ -88,6 +97,7 @@ async def asyncio_detailed(
async def asyncio(
body: Event,
*,
client: Client,
) -> Optional[Error]:
@ -95,6 +105,7 @@ async def asyncio(
return (
await asyncio_detailed(
body=body,
client=client,
)
).parsed

View File

@ -1,23 +1,26 @@
import json
from typing import Any, Dict, Iterator
from typing import Any, Dict, Iterator, Optional
import bson
from websockets.client import WebSocketClientProtocol, connect as ws_connect_async
from websockets.sync.client import ClientConnection, connect as ws_connect
from ...client import Client
from ...models.post_effect_type import PostEffectType
from ...models.web_socket_request import WebSocketRequest
from ...models.web_socket_response import WebSocketResponse
def _get_kwargs(
fps: int,
post_effect: PostEffectType,
unlocked_framerate: bool,
video_res_height: int,
video_res_width: int,
webrtc: bool,
*,
client: Client,
pool: Optional[str] = None,
) -> Dict[str, Any]:
url = "{}/ws/modeling/commands".format(client.base_url) # noqa: E501
@ -28,6 +31,20 @@ def _get_kwargs(
else:
url = url + "?fps=" + str(fps)
if pool is not None:
if "?" in url:
url = url + "&pool=" + str(pool)
else:
url = url + "?pool=" + str(pool)
if post_effect is not None:
if "?" in url:
url = url + "&post_effect=" + str(post_effect)
else:
url = url + "?post_effect=" + str(post_effect)
if unlocked_framerate is not None:
if "?" in url:
@ -69,17 +86,21 @@ def _get_kwargs(
def sync(
fps: int,
post_effect: PostEffectType,
unlocked_framerate: bool,
video_res_height: int,
video_res_width: int,
webrtc: bool,
*,
client: Client,
pool: Optional[str] = None,
) -> ClientConnection:
"""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(
fps=fps,
pool=pool,
post_effect=post_effect,
unlocked_framerate=unlocked_framerate,
video_res_height=video_res_height,
video_res_width=video_res_width,
@ -92,17 +113,21 @@ def sync(
async def asyncio(
fps: int,
post_effect: PostEffectType,
unlocked_framerate: bool,
video_res_height: int,
video_res_width: int,
webrtc: bool,
*,
client: Client,
pool: Optional[str] = None,
) -> WebSocketClientProtocol:
"""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(
fps=fps,
pool=pool,
post_effect=post_effect,
unlocked_framerate=unlocked_framerate,
video_res_height=video_res_height,
video_res_width=video_res_width,
@ -126,19 +151,23 @@ class WebSocket:
def __init__(
self,
fps: int,
post_effect: PostEffectType,
unlocked_framerate: bool,
video_res_height: int,
video_res_width: int,
webrtc: bool,
client: Client,
pool: Optional[str] = None,
):
self.ws = sync(
fps,
post_effect,
unlocked_framerate,
video_res_height,
video_res_width,
webrtc,
client=client,
pool=pool,
)
def __enter__(

View File

@ -39,6 +39,7 @@ from .models import (
ModelingCmd,
ModelingCmdId,
Pong,
PostEffectType,
System,
TextToCad,
TextToCadCreateBody,
@ -356,6 +357,7 @@ def test_ws_simple():
with modeling_commands_ws.WebSocket(
client=client,
fps=30,
post_effect=PostEffectType.NOEFFECT,
unlocked_framerate=False,
video_res_height=360,
video_res_width=480,
@ -383,6 +385,7 @@ def test_ws_import():
with modeling_commands_ws.WebSocket(
client=client,
fps=30,
post_effect=PostEffectType.NOEFFECT,
unlocked_framerate=False,
video_res_height=360,
video_res_width=480,

View File

@ -187,7 +187,6 @@ from kittycad.models import (
PaymentIntent,
PaymentMethod,
Pong,
PrivacySettings,
SamlIdentityProvider,
ServiceAccount,
ServiceAccountResultsPage,
@ -222,11 +221,13 @@ from kittycad.models.billing_info import BillingInfo
from kittycad.models.code_language import CodeLanguage
from kittycad.models.created_at_sort_mode import CreatedAtSortMode
from kittycad.models.email_authentication_form import EmailAuthenticationForm
from kittycad.models.event import modeling_app_event
from kittycad.models.file_export_format import FileExportFormat
from kittycad.models.file_import_format import FileImportFormat
from kittycad.models.idp_metadata_source import base64_encoded_xml
from kittycad.models.kcl_code_completion_params import KclCodeCompletionParams
from kittycad.models.kcl_code_completion_request import KclCodeCompletionRequest
from kittycad.models.modeling_app_event_type import ModelingAppEventType
from kittycad.models.modeling_app_individual_subscription_tier import (
ModelingAppIndividualSubscriptionTier,
)
@ -235,6 +236,8 @@ from kittycad.models.modeling_app_organization_subscription_tier import (
)
from kittycad.models.org_details import OrgDetails
from kittycad.models.plan_interval import PlanInterval
from kittycad.models.post_effect_type import PostEffectType
from kittycad.models.privacy_settings import PrivacySettings
from kittycad.models.rtc_sdp_type import RtcSdpType
from kittycad.models.rtc_session_description import RtcSessionDescription
from kittycad.models.saml_identity_provider_create import SamlIdentityProviderCreate
@ -1279,6 +1282,13 @@ def test_create_event():
result: Optional[Error] = create_event.sync(
client=client,
body=modeling_app_event(
created_at="<string>",
event_type=ModelingAppEventType.SUCCESSFUL_COMPILE_BEFORE_CLOSE,
project_name="<string>",
source_id="<uuid>",
user_id="<string>",
),
)
if isinstance(result, Error) or result is None:
@ -1291,6 +1301,13 @@ def test_create_event():
# OR if you need more info (e.g. status_code)
response: Response[Optional[Error]] = create_event.sync_detailed(
client=client,
body=modeling_app_event(
created_at="<string>",
event_type=ModelingAppEventType.SUCCESSFUL_COMPILE_BEFORE_CLOSE,
project_name="<string>",
source_id="<uuid>",
user_id="<string>",
),
)
@ -1303,11 +1320,25 @@ async def test_create_event_async():
result: Optional[Error] = await create_event.asyncio(
client=client,
body=modeling_app_event(
created_at="<string>",
event_type=ModelingAppEventType.SUCCESSFUL_COMPILE_BEFORE_CLOSE,
project_name="<string>",
source_id="<uuid>",
user_id="<string>",
),
)
# OR run async with more info
response: Response[Optional[Error]] = await create_event.asyncio_detailed(
client=client,
body=modeling_app_event(
created_at="<string>",
event_type=ModelingAppEventType.SUCCESSFUL_COMPILE_BEFORE_CLOSE,
project_name="<string>",
source_id="<uuid>",
user_id="<string>",
),
)
@ -6732,10 +6763,12 @@ def test_modeling_commands_ws():
with modeling_commands_ws.WebSocket(
client=client,
fps=10,
post_effect=PostEffectType.PHOSPHOR,
unlocked_framerate=False,
video_res_height=10,
video_res_width=10,
webrtc=False,
pool=None, # Optional[str]
) as websocket:
# Send a message.
@ -6766,10 +6799,12 @@ async def test_modeling_commands_ws_async():
websocket = await modeling_commands_ws.asyncio(
client=client,
fps=10,
post_effect=PostEffectType.PHOSPHOR,
unlocked_framerate=False,
video_res_height=10,
video_res_width=10,
webrtc=False,
pool=None, # Optional[str]
)
# Send a message.

View File

@ -56,6 +56,7 @@ from .curve_get_type import CurveGetType
from .curve_type import CurveType
from .customer import Customer
from .customer_balance import CustomerBalance
from .default_camera_focus_on import DefaultCameraFocusOn
from .default_camera_get_settings import DefaultCameraGetSettings
from .default_camera_zoom import DefaultCameraZoom
from .density import Density
@ -80,6 +81,7 @@ from .entity_type import EntityType
from .environment import Environment
from .error import Error
from .error_code import ErrorCode
from .event import Event
from .export import Export
from .export_file import ExportFile
from .extended_user import ExtendedUser
@ -102,6 +104,7 @@ from .file_system_metadata import FileSystemMetadata
from .file_volume import FileVolume
from .gateway import Gateway
from .get_entity_type import GetEntityType
from .get_num_objects import GetNumObjects
from .get_sketch_mode_plane import GetSketchModePlane
from .global_axis import GlobalAxis
from .gltf_presentation import GltfPresentation
@ -112,6 +115,7 @@ from .idp_metadata_source import IdpMetadataSource
from .image_format import ImageFormat
from .import_file import ImportFile
from .import_files import ImportFiles
from .imported_geometry import ImportedGeometry
from .input_format import InputFormat
from .invoice import Invoice
from .invoice_line_item import InvoiceLineItem
@ -130,6 +134,7 @@ from .mass import Mass
from .meta_cluster_info import MetaClusterInfo
from .metadata import Metadata
from .method import Method
from .modeling_app_event_type import ModelingAppEventType
from .modeling_app_individual_subscription_tier import (
ModelingAppIndividualSubscriptionTier,
)
@ -174,6 +179,7 @@ from .ply_storage import PlyStorage
from .point2d import Point2d
from .point3d import Point3d
from .pong import Pong
from .post_effect_type import PostEffectType
from .privacy_settings import PrivacySettings
from .raw_file import RawFile
from .rtc_ice_candidate_init import RtcIceCandidateInit

View File

@ -0,0 +1,9 @@
from pydantic import BaseModel, ConfigDict
class DefaultCameraFocusOn(BaseModel):
"""The response from the `DefaultCameraFocusOn` command."""
model_config = ConfigDict(protected_namespaces=())

34
kittycad/models/event.py Normal file
View File

@ -0,0 +1,34 @@
import datetime
from typing import Literal, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel
from typing_extensions import Annotated
from ..models.modeling_app_event_type import ModelingAppEventType
class modeling_app_event(BaseModel):
"""An event related to modeling app files"""
attachment_uri: Optional[str] = None
created_at: datetime.datetime
event_type: ModelingAppEventType
last_compiled_at: Optional[datetime.datetime] = None
project_description: Optional[str] = None
project_name: str
source_id: str
type: Literal["modeling_app_event"] = "modeling_app_event"
user_id: str
model_config = ConfigDict(protected_namespaces=())
Event = RootModel[Annotated[Union[modeling_app_event,], Field(discriminator="type")]]

View File

@ -0,0 +1,11 @@
from pydantic import BaseModel, ConfigDict
class GetNumObjects(BaseModel):
"""The response from the `GetNumObjects` command."""
num_objects: int
model_config = ConfigDict(protected_namespaces=())

View File

@ -0,0 +1,14 @@
from typing import List
from pydantic import BaseModel, ConfigDict
class ImportedGeometry(BaseModel):
"""Data from importing the files"""
id: str
value: List[str]
model_config = ConfigDict(protected_namespaces=())

View File

@ -0,0 +1,11 @@
from enum import Enum
class ModelingAppEventType(str, Enum):
"""Type for modeling-app events""" # noqa: E501
"""# This event is sent before the modeling app or project is closed. The attachment should contain the contents of the most recent successful compile. """ # noqa: E501
SUCCESSFUL_COMPILE_BEFORE_CLOSE = "successful_compile_before_close"
def __str__(self) -> str:
return str(self.value)

View File

@ -3,6 +3,7 @@ from typing import List, Literal, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel
from typing_extensions import Annotated
from ..models.angle import Angle
from ..models.annotation_options import AnnotationOptions
from ..models.annotation_type import AnnotationType
from ..models.camera_drag_interaction_type import CameraDragInteractionType
@ -63,7 +64,7 @@ class extend_path(BaseModel):
class extrude(BaseModel):
"""Command for extruding a solid."""
"""Command for extruding a solid 2d."""
cap: bool
@ -76,6 +77,42 @@ class extrude(BaseModel):
model_config = ConfigDict(protected_namespaces=())
class revolve(BaseModel):
"""Command for revolving a solid 2d."""
angle: Angle
axis: Point3d
axis_is_2d: bool
origin: Point3d
target: ModelingCmdId
tolerance: LengthUnit
type: Literal["revolve"] = "revolve"
model_config = ConfigDict(protected_namespaces=())
class revolve_about_edge(BaseModel):
"""Command for revolving a solid 2d about a brep edge"""
angle: Angle
edge_id: str
target: ModelingCmdId
tolerance: LengthUnit
type: Literal["revolve_about_edge"] = "revolve_about_edge"
model_config = ConfigDict(protected_namespaces=())
class close_path(BaseModel):
"""Closes a path, converting it to a 2D solid."""
@ -221,8 +258,6 @@ class export(BaseModel):
format: OutputFormat
source_unit: UnitLength
type: Literal["export"] = "export"
model_config = ConfigDict(protected_namespaces=())
@ -285,7 +320,7 @@ class entity_get_distance(BaseModel):
class entity_linear_pattern(BaseModel):
"""Create a linear pattern using this entity (currently only valid for 3D solids)."""
"""Create a linear pattern using this entity."""
axis: Point3d
@ -301,7 +336,7 @@ class entity_linear_pattern(BaseModel):
class entity_circular_pattern(BaseModel):
"""Create a circular pattern using this entity (currently only valid for 3D solids)."""
"""Create a circular pattern using this entity."""
arc_degrees: float
@ -320,6 +355,24 @@ class entity_circular_pattern(BaseModel):
model_config = ConfigDict(protected_namespaces=())
class entity_make_helix(BaseModel):
"""Create a helix using the input cylinder and other specified parameters."""
cylinder_id: str
is_clockwise: bool
length: LengthUnit
revolutions: float
start_angle: Angle
type: Literal["entity_make_helix"] = "entity_make_helix"
model_config = ConfigDict(protected_namespaces=())
class edit_mode_enter(BaseModel):
"""Enter edit mode"""
@ -362,6 +415,14 @@ class select_remove(BaseModel):
model_config = ConfigDict(protected_namespaces=())
class scene_clear_all(BaseModel):
"""Removes all of the Objects in the scene"""
type: Literal["scene_clear_all"] = "scene_clear_all"
model_config = ConfigDict(protected_namespaces=())
class select_replace(BaseModel):
"""Replaces current selection with these entities (by UUID)."""
@ -764,6 +825,36 @@ class enable_sketch_mode(BaseModel):
model_config = ConfigDict(protected_namespaces=())
class set_background_color(BaseModel):
"""Set the background color of the scene."""
color: Color
type: Literal["set_background_color"] = "set_background_color"
model_config = ConfigDict(protected_namespaces=())
class set_current_tool_properties(BaseModel):
"""Set the properties of the tool lines for the scene."""
color: Optional[Color] = None
type: Literal["set_current_tool_properties"] = "set_current_tool_properties"
model_config = ConfigDict(protected_namespaces=())
class set_default_system_properties(BaseModel):
"""Set the default system properties used when a specific property isn't set."""
color: Optional[Color] = None
type: Literal["set_default_system_properties"] = "set_default_system_properties"
model_config = ConfigDict(protected_namespaces=())
class curve_get_type(BaseModel):
"""Get type of the given curve."""
@ -951,8 +1042,6 @@ class mass(BaseModel):
output_unit: UnitMass
source_unit: UnitLength
type: Literal["mass"] = "mass"
model_config = ConfigDict(protected_namespaces=())
@ -969,8 +1058,6 @@ class density(BaseModel):
output_unit: UnitDensity
source_unit: UnitLength
type: Literal["density"] = "density"
model_config = ConfigDict(protected_namespaces=())
@ -983,8 +1070,6 @@ class volume(BaseModel):
output_unit: UnitVolume
source_unit: UnitLength
type: Literal["volume"] = "volume"
model_config = ConfigDict(protected_namespaces=())
@ -997,8 +1082,6 @@ class center_of_mass(BaseModel):
output_unit: UnitLength
source_unit: UnitLength
type: Literal["center_of_mass"] = "center_of_mass"
model_config = ConfigDict(protected_namespaces=())
@ -1011,8 +1094,6 @@ class surface_area(BaseModel):
output_unit: UnitArea
source_unit: UnitLength
type: Literal["surface_area"] = "surface_area"
model_config = ConfigDict(protected_namespaces=())
@ -1102,6 +1183,14 @@ class select_get(BaseModel):
model_config = ConfigDict(protected_namespaces=())
class get_num_objects(BaseModel):
"""Get the number of objects in the scene"""
type: Literal["get_num_objects"] = "get_num_objects"
model_config = ConfigDict(protected_namespaces=())
ModelingCmd = RootModel[
Annotated[
Union[
@ -1109,6 +1198,8 @@ ModelingCmd = RootModel[
move_path_pen,
extend_path,
extrude,
revolve,
revolve_about_edge,
close_path,
camera_drag_start,
camera_drag_move,
@ -1127,10 +1218,12 @@ ModelingCmd = RootModel[
entity_get_distance,
entity_linear_pattern,
entity_circular_pattern,
entity_make_helix,
edit_mode_enter,
select_with_point,
select_add,
select_remove,
scene_clear_all,
select_replace,
highlight_set_entity,
highlight_set_entities,
@ -1163,6 +1256,9 @@ ModelingCmd = RootModel[
get_sketch_mode_plane,
curve_set_constraint,
enable_sketch_mode,
set_background_color,
set_current_tool_properties,
set_default_system_properties,
curve_get_type,
curve_get_control_points,
take_snapshot,
@ -1193,6 +1289,7 @@ ModelingCmd = RootModel[
edit_mode_exit,
select_clear,
select_get,
get_num_objects,
],
Field(discriminator="type"),
]

View File

@ -9,6 +9,7 @@ from ..models.center_of_mass import CenterOfMass
from ..models.curve_get_control_points import CurveGetControlPoints
from ..models.curve_get_end_points import CurveGetEndPoints
from ..models.curve_get_type import CurveGetType
from ..models.default_camera_focus_on import DefaultCameraFocusOn
from ..models.default_camera_get_settings import DefaultCameraGetSettings
from ..models.default_camera_zoom import DefaultCameraZoom
from ..models.density import Density
@ -25,9 +26,11 @@ from ..models.face_get_gradient import FaceGetGradient
from ..models.face_get_position import FaceGetPosition
from ..models.face_is_planar import FaceIsPlanar
from ..models.get_entity_type import GetEntityType
from ..models.get_num_objects import GetNumObjects
from ..models.get_sketch_mode_plane import GetSketchModePlane
from ..models.highlight_set_entity import HighlightSetEntity
from ..models.import_files import ImportFiles
from ..models.imported_geometry import ImportedGeometry
from ..models.mass import Mass
from ..models.mouse_click import MouseClick
from ..models.path_get_curve_uuids_for_vertices import PathGetCurveUuidsForVertices
@ -166,6 +169,26 @@ class default_camera_zoom(BaseModel):
model_config = ConfigDict(protected_namespaces=())
class get_num_objects(BaseModel):
"""The response to the 'GetNumObjects' endpoint"""
data: GetNumObjects
type: Literal["get_num_objects"] = "get_num_objects"
model_config = ConfigDict(protected_namespaces=())
class default_camera_focus_on(BaseModel):
"""The response to the 'DefaultCameraFocusOn' endpoint"""
data: DefaultCameraFocusOn
type: Literal["default_camera_focus_on"] = "default_camera_focus_on"
model_config = ConfigDict(protected_namespaces=())
class select_get(BaseModel):
"""The response to the 'SelectGet' endpoint"""
@ -378,6 +401,16 @@ class import_files(BaseModel):
model_config = ConfigDict(protected_namespaces=())
class imported_geometry(BaseModel):
"""The response to the 'ImportedGeometry' endpoint"""
data: ImportedGeometry
type: Literal["imported_geometry"] = "imported_geometry"
model_config = ConfigDict(protected_namespaces=())
class mass(BaseModel):
"""The response to the 'Mass' endpoint"""
@ -503,6 +536,8 @@ OkModelingCmdResponse = RootModel[
camera_drag_end,
default_camera_get_settings,
default_camera_zoom,
get_num_objects,
default_camera_focus_on,
select_get,
solid3d_get_all_edge_faces,
solid3d_get_all_opposite_edges,
@ -524,6 +559,7 @@ OkModelingCmdResponse = RootModel[
face_get_gradient,
plane_intersect_and_project,
import_files,
imported_geometry,
mass,
volume,
density,

View File

@ -0,0 +1,12 @@
from enum import Enum
class PostEffectType(str, Enum):
"""Post effect type""" # noqa: E501
PHOSPHOR = "phosphor"
SSAO = "ssao"
NOEFFECT = "noeffect"
def __str__(self) -> str:
return str(self.value)

View File

@ -2,7 +2,6 @@ import datetime
from pydantic import BaseModel, ConfigDict
from ..models.uuid import Uuid
class Session(BaseModel):
@ -10,14 +9,12 @@ class Session(BaseModel):
created_at: datetime.datetime
expires: datetime.datetime
expires_at: datetime.datetime
id: Uuid
session_token: Uuid
token: str
updated_at: datetime.datetime
user_id: Uuid
user_id: str
model_config = ConfigDict(protected_namespaces=())

View File

@ -1,4 +1,4 @@
from typing import List, Literal, Union
from typing import List, Literal, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel
from typing_extensions import Annotated
@ -46,8 +46,12 @@ class modeling_cmd_req(BaseModel):
class modeling_cmd_batch_req(BaseModel):
"""A sequence of modeling requests. If any request fails, following requests will not be tried."""
batch_id: ModelingCmdId
requests: List[ModelingCmdReq]
responses: Optional[bool] = None
type: Literal["modeling_cmd_batch_req"] = "modeling_cmd_batch_req"
model_config = ConfigDict(protected_namespaces=())

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "kittycad"
version = "0.6.8"
version = "0.6.10"
description = "A client library for accessing KittyCAD"
authors = []

661
spec.json
View File

@ -1756,11 +1756,11 @@
"description": "We collect anonymous telemetry data for improving our product.",
"operationId": "create_event",
"requestBody": {
"description": "Telemetry requests",
"content": {
"multipart/form-data": {
"schema": {
"type": "string",
"format": "binary"
"$ref": "#/components/schemas/Event"
}
}
},
@ -2380,8 +2380,8 @@
"required": true
},
"responses": {
"200": {
"description": "successful operation",
"201": {
"description": "successful creation",
"headers": {
"Access-Control-Allow-Credentials": {
"description": "Access-Control-Allow-Credentials header.",
@ -2950,77 +2950,6 @@
}
}
},
"/hidden/ws/modeling": {
"options": {
"tags": [
"hidden"
],
"summary": "Hidden endpoint for defining the modeling websocket types.",
"operationId": "hidden_ws_modeling_types",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/WebSocketRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "successful operation",
"headers": {
"Access-Control-Allow-Credentials": {
"description": "Access-Control-Allow-Credentials header.",
"style": "simple",
"required": true,
"schema": {
"type": "string"
}
},
"Access-Control-Allow-Headers": {
"description": "Access-Control-Allow-Headers header. This is a comma-separated list of headers.",
"style": "simple",
"required": true,
"schema": {
"type": "string"
}
},
"Access-Control-Allow-Methods": {
"description": "Access-Control-Allow-Methods header.",
"style": "simple",
"required": true,
"schema": {
"type": "string"
}
},
"Access-Control-Allow-Origin": {
"description": "Access-Control-Allow-Origin header.",
"style": "simple",
"required": true,
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/WebSocketResponse"
}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
}
}
},
"/internal/discord/api-token/{discord_id}": {
"get": {
"tags": [
@ -12272,6 +12201,23 @@
"minimum": 0
}
},
{
"in": "query",
"name": "pool",
"description": "An optional identifier for a pool of engine instances. The 'default' pool is used when none is specified.",
"schema": {
"nullable": true,
"type": "string"
}
},
{
"in": "query",
"name": "post_effect",
"description": "Engine Post effects (such as SSAO)",
"schema": {
"$ref": "#/components/schemas/PostEffectType"
}
},
{
"in": "query",
"name": "unlocked_framerate",
@ -15239,6 +15185,10 @@
"updated_at"
]
},
"DefaultCameraFocusOn": {
"description": "The response from the `DefaultCameraFocusOn` command.",
"type": "object"
},
"DefaultCameraGetSettings": {
"description": "The response from the `DefaultCameraGetSettings` command.",
"type": "object",
@ -15749,6 +15699,73 @@
}
]
},
"Event": {
"description": "Telemetry data we are collecting",
"oneOf": [
{
"description": "An event related to modeling app files",
"type": "object",
"properties": {
"attachment_uri": {
"nullable": true,
"description": "Attachment URI for where the attachment is stored.",
"type": "string"
},
"created_at": {
"description": "Time this event was created.",
"type": "string",
"format": "date-time"
},
"event_type": {
"description": "The specific event type from the modeling app.",
"allOf": [
{
"$ref": "#/components/schemas/ModelingAppEventType"
}
]
},
"last_compiled_at": {
"nullable": true,
"description": "Time the associated attachment was last compiled.",
"type": "string",
"format": "date-time"
},
"project_description": {
"nullable": true,
"description": "Project descriptino as given by the user.",
"type": "string"
},
"project_name": {
"description": "Project name as given by the user.",
"type": "string"
},
"source_id": {
"description": "The source app for this event, uuid that is unique to the app.",
"type": "string",
"format": "uuid"
},
"type": {
"type": "string",
"enum": [
"modeling_app_event"
]
},
"user_id": {
"description": "An anonymous user id generated client-side.",
"type": "string"
}
},
"required": [
"created_at",
"event_type",
"project_name",
"source_id",
"type",
"user_id"
]
}
]
},
"Export": {
"description": "The response from the `Export` endpoint.",
"type": "object",
@ -16894,6 +16911,21 @@
"entity_type"
]
},
"GetNumObjects": {
"description": "The response from the `GetNumObjects` command.",
"type": "object",
"properties": {
"num_objects": {
"description": "The number of objects in the scene.",
"type": "integer",
"format": "uint32",
"minimum": 0
}
},
"required": [
"num_objects"
]
},
"GetSketchModePlane": {
"description": "The plane for sketch mode.",
"type": "object",
@ -17150,6 +17182,28 @@
"object_id"
]
},
"ImportedGeometry": {
"description": "Data from importing the files",
"type": "object",
"properties": {
"id": {
"description": "ID of the imported 3D models within the scene.",
"type": "string",
"format": "uuid"
},
"value": {
"description": "The original file paths that held the geometry.",
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"id",
"value"
]
},
"InputFormat": {
"description": "Input format specifier.",
"oneOf": [
@ -18137,6 +18191,18 @@
}
]
},
"ModelingAppEventType": {
"description": "Type for modeling-app events",
"oneOf": [
{
"description": "This event is sent before the modeling app or project is closed. The attachment should contain the contents of the most recent successful compile.",
"type": "string",
"enum": [
"successful_compile_before_close"
]
}
]
},
"ModelingAppIndividualSubscriptionTier": {
"description": "The subscription tiers we offer for the Modeling App to individuals.",
"oneOf": [
@ -18374,7 +18440,7 @@
]
},
{
"description": "Command for extruding a solid.",
"description": "Command for extruding a solid 2d.",
"type": "object",
"properties": {
"cap": {
@ -18411,6 +18477,119 @@
"type"
]
},
{
"description": "Command for revolving a solid 2d.",
"type": "object",
"properties": {
"angle": {
"description": "The signed angle of revolution (in degrees, must be <= 360 in either direction)",
"allOf": [
{
"$ref": "#/components/schemas/Angle"
}
]
},
"axis": {
"description": "The axis of the extrusion (taken from the origin)",
"allOf": [
{
"$ref": "#/components/schemas/Point3d"
}
]
},
"axis_is_2d": {
"description": "If true, the axis is interpreted within the 2D space of the solid 2D's plane",
"type": "boolean"
},
"origin": {
"description": "The origin of the extrusion axis",
"allOf": [
{
"$ref": "#/components/schemas/Point3d"
}
]
},
"target": {
"description": "Which sketch to revolve. Must be a closed 2D solid.",
"allOf": [
{
"$ref": "#/components/schemas/ModelingCmdId"
}
]
},
"tolerance": {
"description": "The maximum acceptable surface gap computed between the revolution surface joints. Must be positive (i.e. greater than zero).",
"allOf": [
{
"$ref": "#/components/schemas/LengthUnit"
}
]
},
"type": {
"type": "string",
"enum": [
"revolve"
]
}
},
"required": [
"angle",
"axis",
"axis_is_2d",
"origin",
"target",
"tolerance",
"type"
]
},
{
"description": "Command for revolving a solid 2d about a brep edge",
"type": "object",
"properties": {
"angle": {
"description": "The signed angle of revolution (in degrees, must be <= 360 in either direction)",
"allOf": [
{
"$ref": "#/components/schemas/Angle"
}
]
},
"edge_id": {
"description": "The edge to use as the axis of revolution, must be linear and lie in the plane of the solid",
"type": "string",
"format": "uuid"
},
"target": {
"description": "Which sketch to revolve. Must be a closed 2D solid.",
"allOf": [
{
"$ref": "#/components/schemas/ModelingCmdId"
}
]
},
"tolerance": {
"description": "The maximum acceptable surface gap computed between the revolution surface joints. Must be positive (i.e. greater than zero).",
"allOf": [
{
"$ref": "#/components/schemas/LengthUnit"
}
]
},
"type": {
"type": "string",
"enum": [
"revolve_about_edge"
]
}
},
"required": [
"angle",
"edge_id",
"target",
"tolerance",
"type"
]
},
{
"description": "Closes a path, converting it to a 2D solid.",
"type": "object",
@ -18783,14 +18962,6 @@
}
]
},
"source_unit": {
"description": "Select the unit interpretation of exported objects.",
"allOf": [
{
"$ref": "#/components/schemas/UnitLength"
}
]
},
"type": {
"type": "string",
"enum": [
@ -18801,7 +18972,6 @@
"required": [
"entity_ids",
"format",
"source_unit",
"type"
]
},
@ -18933,11 +19103,11 @@
]
},
{
"description": "Create a linear pattern using this entity (currently only valid for 3D solids).",
"description": "Create a linear pattern using this entity.",
"type": "object",
"properties": {
"axis": {
"description": "Axis along which to make the copies",
"description": "Axis along which to make the copies. For Solid2d patterns, the z component is ignored.",
"allOf": [
{
"$ref": "#/components/schemas/Point3d"
@ -18979,7 +19149,7 @@
]
},
{
"description": "Create a circular pattern using this entity (currently only valid for 3D solids).",
"description": "Create a circular pattern using this entity.",
"type": "object",
"properties": {
"arc_degrees": {
@ -18988,7 +19158,7 @@
"format": "double"
},
"axis": {
"description": "Axis around which to make the copies",
"description": "Axis around which to make the copies. For Solid2d patterns, this is ignored.",
"allOf": [
{
"$ref": "#/components/schemas/Point3d"
@ -18996,7 +19166,7 @@
]
},
"center": {
"description": "Point around which to make the copies",
"description": "Point around which to make the copies. For Solid2d patterns, the z component is ignored.",
"allOf": [
{
"$ref": "#/components/schemas/Point3d"
@ -19035,6 +19205,56 @@
"type"
]
},
{
"description": "Create a helix using the input cylinder and other specified parameters.",
"type": "object",
"properties": {
"cylinder_id": {
"description": "ID of the cylinder.",
"type": "string",
"format": "uuid"
},
"is_clockwise": {
"description": "Is the helix rotation clockwise?",
"type": "boolean"
},
"length": {
"description": "Length of the helix.",
"allOf": [
{
"$ref": "#/components/schemas/LengthUnit"
}
]
},
"revolutions": {
"description": "Number of revolutions.",
"type": "number",
"format": "double"
},
"start_angle": {
"description": "Start angle (in degrees).",
"allOf": [
{
"$ref": "#/components/schemas/Angle"
}
]
},
"type": {
"type": "string",
"enum": [
"entity_make_helix"
]
}
},
"required": [
"cylinder_id",
"is_clockwise",
"length",
"revolutions",
"start_angle",
"type"
]
},
{
"description": "Enter edit mode",
"type": "object",
@ -19137,6 +19357,21 @@
"type"
]
},
{
"description": "Removes all of the Objects in the scene",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"scene_clear_all"
]
}
},
"required": [
"type"
]
},
{
"description": "Replaces current selection with these entities (by UUID).",
"type": "object",
@ -20115,6 +20350,78 @@
"type"
]
},
{
"description": "Set the background color of the scene.",
"type": "object",
"properties": {
"color": {
"description": "The color to set the background to.",
"allOf": [
{
"$ref": "#/components/schemas/Color"
}
]
},
"type": {
"type": "string",
"enum": [
"set_background_color"
]
}
},
"required": [
"color",
"type"
]
},
{
"description": "Set the properties of the tool lines for the scene.",
"type": "object",
"properties": {
"color": {
"nullable": true,
"description": "The color to set the tool line to.",
"allOf": [
{
"$ref": "#/components/schemas/Color"
}
]
},
"type": {
"type": "string",
"enum": [
"set_current_tool_properties"
]
}
},
"required": [
"type"
]
},
{
"description": "Set the default system properties used when a specific property isn't set.",
"type": "object",
"properties": {
"color": {
"nullable": true,
"description": "The default system color.",
"allOf": [
{
"$ref": "#/components/schemas/Color"
}
]
},
"type": {
"type": "string",
"enum": [
"set_default_system_properties"
]
}
},
"required": [
"type"
]
},
{
"description": "Get type of the given curve.",
"type": "object",
@ -20558,14 +20865,6 @@
}
]
},
"source_unit": {
"description": "Select the unit interpretation of distances in the scene.",
"allOf": [
{
"$ref": "#/components/schemas/UnitLength"
}
]
},
"type": {
"type": "string",
"enum": [
@ -20578,7 +20877,6 @@
"material_density",
"material_density_unit",
"output_unit",
"source_unit",
"type"
]
},
@ -20615,14 +20913,6 @@
}
]
},
"source_unit": {
"description": "Select the unit interpretation of distances in the scene.",
"allOf": [
{
"$ref": "#/components/schemas/UnitLength"
}
]
},
"type": {
"type": "string",
"enum": [
@ -20635,7 +20925,6 @@
"material_mass",
"material_mass_unit",
"output_unit",
"source_unit",
"type"
]
},
@ -20659,14 +20948,6 @@
}
]
},
"source_unit": {
"description": "Select the unit interpretation of distances in the scene.",
"allOf": [
{
"$ref": "#/components/schemas/UnitLength"
}
]
},
"type": {
"type": "string",
"enum": [
@ -20677,7 +20958,6 @@
"required": [
"entity_ids",
"output_unit",
"source_unit",
"type"
]
},
@ -20701,14 +20981,6 @@
}
]
},
"source_unit": {
"description": "Select the unit interpretation of distances in the scene.",
"allOf": [
{
"$ref": "#/components/schemas/UnitLength"
}
]
},
"type": {
"type": "string",
"enum": [
@ -20719,7 +20991,6 @@
"required": [
"entity_ids",
"output_unit",
"source_unit",
"type"
]
},
@ -20743,14 +21014,6 @@
}
]
},
"source_unit": {
"description": "Select the unit interpretation of distances in the scene.",
"allOf": [
{
"$ref": "#/components/schemas/UnitLength"
}
]
},
"type": {
"type": "string",
"enum": [
@ -20761,7 +21024,6 @@
"required": [
"entity_ids",
"output_unit",
"source_unit",
"type"
]
},
@ -20943,6 +21205,21 @@
"required": [
"type"
]
},
{
"description": "Get the number of objects in the scene",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"get_num_objects"
]
}
},
"required": [
"type"
]
}
]
},
@ -21261,6 +21538,44 @@
"type"
]
},
{
"description": "The response to the 'GetNumObjects' endpoint",
"type": "object",
"properties": {
"data": {
"$ref": "#/components/schemas/GetNumObjects"
},
"type": {
"type": "string",
"enum": [
"get_num_objects"
]
}
},
"required": [
"data",
"type"
]
},
{
"description": "The response to the 'DefaultCameraFocusOn' endpoint",
"type": "object",
"properties": {
"data": {
"$ref": "#/components/schemas/DefaultCameraFocusOn"
},
"type": {
"type": "string",
"enum": [
"default_camera_focus_on"
]
}
},
"required": [
"data",
"type"
]
},
{
"description": "The response to the 'SelectGet' endpoint",
"type": "object",
@ -21660,6 +21975,25 @@
"type"
]
},
{
"description": "The response to the 'ImportedGeometry' endpoint",
"type": "object",
"properties": {
"data": {
"$ref": "#/components/schemas/ImportedGeometry"
},
"type": {
"type": "string",
"enum": [
"imported_geometry"
]
}
},
"required": [
"data",
"type"
]
},
{
"description": "The response to the 'Mass' endpoint",
"type": "object",
@ -23187,6 +23521,15 @@
"message"
]
},
"PostEffectType": {
"description": "Post effect type",
"type": "string",
"enum": [
"phosphor",
"ssao",
"noeffect"
]
},
"PrivacySettings": {
"description": "Privacy settings for an org or user.",
"type": "object",
@ -23688,53 +24031,35 @@
"type": "object",
"properties": {
"created_at": {
"title": "DateTime",
"description": "The date and time the session was created.",
"type": "string",
"format": "date-time"
},
"expires": {
"title": "DateTime",
"expires_at": {
"description": "The date and time the session expires.",
"type": "string",
"format": "date-time"
},
"id": {
"description": "The unique identifier for the session.",
"allOf": [
{
"$ref": "#/components/schemas/Uuid"
}
]
},
"session_token": {
"token": {
"description": "The session token.",
"allOf": [
{
"$ref": "#/components/schemas/Uuid"
}
]
"type": "string",
"format": "uuid"
},
"updated_at": {
"title": "DateTime",
"description": "The date and time the session was last updated.",
"type": "string",
"format": "date-time"
},
"user_id": {
"description": "The user ID of the user that the session belongs to.",
"allOf": [
{
"$ref": "#/components/schemas/Uuid"
}
]
"type": "string",
"format": "uuid"
}
},
"required": [
"created_at",
"expires",
"id",
"session_token",
"expires_at",
"token",
"updated_at",
"user_id"
]
@ -26642,6 +26967,14 @@
"description": "A sequence of modeling requests. If any request fails, following requests will not be tried.",
"type": "object",
"properties": {
"batch_id": {
"description": "ID of batch being submitted. Each request has their own individual ModelingCmdId, but this is the ID of the overall batch.",
"allOf": [
{
"$ref": "#/components/schemas/ModelingCmdId"
}
]
},
"requests": {
"description": "A sequence of modeling requests. If any request fails, following requests will not be tried.",
"type": "array",
@ -26649,6 +26982,11 @@
"$ref": "#/components/schemas/ModelingCmdReq"
}
},
"responses": {
"description": "If false or omitted, responses to each batch command will just be Ok(()). If true, responses will be the actual response data for that modeling command.",
"default": false,
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
@ -26657,6 +26995,7 @@
}
},
"required": [
"batch_id",
"requests",
"type"
]