pydantic cleanup

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-01-06 18:32:21 -08:00
parent b233f94a24
commit 8d476bbec6
140 changed files with 1122 additions and 540 deletions

View File

@ -1,6 +1,6 @@
from typing import List, Literal, Optional, Union
from pydantic import BaseModel, Field, RootModel
from pydantic import BaseModel, ConfigDict, Field, RootModel
from typing_extensions import Annotated
from ..models.annotation_options import AnnotationOptions
@ -34,6 +34,8 @@ class start_path(BaseModel):
type: Literal["start_path"] = "start_path"
model_config = ConfigDict(protected_namespaces=())
class move_path_pen(BaseModel):
"""Move the path's "pen"."""
@ -44,6 +46,8 @@ class move_path_pen(BaseModel):
type: Literal["move_path_pen"] = "move_path_pen"
model_config = ConfigDict(protected_namespaces=())
class extend_path(BaseModel):
"""Extend a path by adding a new segment which starts at the path's "pen". If no "pen" location has been set before (via `MovePen`), then the pen is at the origin."""
@ -54,6 +58,8 @@ class extend_path(BaseModel):
type: Literal["extend_path"] = "extend_path"
model_config = ConfigDict(protected_namespaces=())
class extrude(BaseModel):
"""Extrude a 2D solid."""
@ -66,6 +72,8 @@ class extrude(BaseModel):
type: Literal["extrude"] = "extrude"
model_config = ConfigDict(protected_namespaces=())
class close_path(BaseModel):
"""Closes a path, converting it to a 2D solid."""
@ -74,6 +82,8 @@ class close_path(BaseModel):
type: Literal["close_path"] = "close_path"
model_config = ConfigDict(protected_namespaces=())
class camera_drag_start(BaseModel):
"""Camera drag started."""
@ -84,6 +94,8 @@ class camera_drag_start(BaseModel):
window: Point2d
model_config = ConfigDict(protected_namespaces=())
class camera_drag_move(BaseModel):
"""Camera drag continued."""
@ -96,6 +108,8 @@ class camera_drag_move(BaseModel):
window: Point2d
model_config = ConfigDict(protected_namespaces=())
class camera_drag_end(BaseModel):
"""Camera drag ended."""
@ -106,6 +120,8 @@ class camera_drag_end(BaseModel):
window: Point2d
model_config = ConfigDict(protected_namespaces=())
class default_camera_look_at(BaseModel):
"""Change what the default camera is looking at."""
@ -118,6 +134,8 @@ class default_camera_look_at(BaseModel):
vantage: Point3d
model_config = ConfigDict(protected_namespaces=())
class default_camera_zoom(BaseModel):
"""Adjust zoom of the default camera."""
@ -126,6 +144,8 @@ class default_camera_zoom(BaseModel):
type: Literal["default_camera_zoom"] = "default_camera_zoom"
model_config = ConfigDict(protected_namespaces=())
class default_camera_enable_sketch_mode(BaseModel):
"""Enable sketch mode, where users can sketch 2D geometry. Users choose a plane to sketch on."""
@ -146,6 +166,8 @@ class default_camera_enable_sketch_mode(BaseModel):
y_axis: Point3d
model_config = ConfigDict(protected_namespaces=())
class default_camera_disable_sketch_mode(BaseModel):
"""Disable sketch mode, from the default camera."""
@ -154,6 +176,8 @@ class default_camera_disable_sketch_mode(BaseModel):
"default_camera_disable_sketch_mode"
] = "default_camera_disable_sketch_mode"
model_config = ConfigDict(protected_namespaces=())
class default_camera_focus_on(BaseModel):
"""Focus default camera on object."""
@ -162,6 +186,8 @@ class default_camera_focus_on(BaseModel):
uuid: str
model_config = ConfigDict(protected_namespaces=())
class export(BaseModel):
"""Export the scene to a file."""
@ -174,6 +200,8 @@ class export(BaseModel):
type: Literal["export"] = "export"
model_config = ConfigDict(protected_namespaces=())
class entity_get_parent_id(BaseModel):
"""What is this entity's parent?"""
@ -182,6 +210,8 @@ class entity_get_parent_id(BaseModel):
type: Literal["entity_get_parent_id"] = "entity_get_parent_id"
model_config = ConfigDict(protected_namespaces=())
class entity_get_num_children(BaseModel):
"""How many children does the entity have?"""
@ -190,6 +220,8 @@ class entity_get_num_children(BaseModel):
type: Literal["entity_get_num_children"] = "entity_get_num_children"
model_config = ConfigDict(protected_namespaces=())
class entity_get_child_uuid(BaseModel):
"""What is the UUID of this entity's n-th child?"""
@ -200,6 +232,8 @@ class entity_get_child_uuid(BaseModel):
type: Literal["entity_get_child_uuid"] = "entity_get_child_uuid"
model_config = ConfigDict(protected_namespaces=())
class entity_get_all_child_uuids(BaseModel):
"""What are all UUIDs of this entity's children?"""
@ -208,6 +242,8 @@ class entity_get_all_child_uuids(BaseModel):
type: Literal["entity_get_all_child_uuids"] = "entity_get_all_child_uuids"
model_config = ConfigDict(protected_namespaces=())
class edit_mode_enter(BaseModel):
"""Enter edit mode"""
@ -216,12 +252,16 @@ class edit_mode_enter(BaseModel):
type: Literal["edit_mode_enter"] = "edit_mode_enter"
model_config = ConfigDict(protected_namespaces=())
class edit_mode_exit(BaseModel):
"""Exit edit mode"""
type: Literal["edit_mode_exit"] = "edit_mode_exit"
model_config = ConfigDict(protected_namespaces=())
class select_with_point(BaseModel):
"""Modifies the selection by simulating a "mouse click" at the given x,y window coordinate Returns ID of whatever was selected."""
@ -232,12 +272,16 @@ class select_with_point(BaseModel):
type: Literal["select_with_point"] = "select_with_point"
model_config = ConfigDict(protected_namespaces=())
class select_clear(BaseModel):
"""Clear the selection"""
type: Literal["select_clear"] = "select_clear"
model_config = ConfigDict(protected_namespaces=())
class select_add(BaseModel):
"""Adds one or more entities (by UUID) to the selection."""
@ -246,6 +290,8 @@ class select_add(BaseModel):
type: Literal["select_add"] = "select_add"
model_config = ConfigDict(protected_namespaces=())
class select_remove(BaseModel):
"""Removes one or more entities (by UUID) from the selection."""
@ -254,6 +300,8 @@ class select_remove(BaseModel):
type: Literal["select_remove"] = "select_remove"
model_config = ConfigDict(protected_namespaces=())
class select_replace(BaseModel):
"""Replaces the current selection with these new entities (by UUID). Equivalent to doing SelectClear then SelectAdd."""
@ -262,12 +310,16 @@ class select_replace(BaseModel):
type: Literal["select_replace"] = "select_replace"
model_config = ConfigDict(protected_namespaces=())
class select_get(BaseModel):
"""Find all IDs of selected entities"""
type: Literal["select_get"] = "select_get"
model_config = ConfigDict(protected_namespaces=())
class highlight_set_entity(BaseModel):
"""Changes the current highlighted entity to whichever one is at the given window coordinate. If there's no entity at this location, clears the highlight."""
@ -278,6 +330,8 @@ class highlight_set_entity(BaseModel):
type: Literal["highlight_set_entity"] = "highlight_set_entity"
model_config = ConfigDict(protected_namespaces=())
class highlight_set_entities(BaseModel):
"""Changes the current highlighted entity to these entities."""
@ -286,6 +340,8 @@ class highlight_set_entities(BaseModel):
type: Literal["highlight_set_entities"] = "highlight_set_entities"
model_config = ConfigDict(protected_namespaces=())
class new_annotation(BaseModel):
"""Create a new annotation"""
@ -298,6 +354,8 @@ class new_annotation(BaseModel):
type: Literal["new_annotation"] = "new_annotation"
model_config = ConfigDict(protected_namespaces=())
class update_annotation(BaseModel):
"""Update an annotation"""
@ -308,6 +366,8 @@ class update_annotation(BaseModel):
type: Literal["update_annotation"] = "update_annotation"
model_config = ConfigDict(protected_namespaces=())
class object_visible(BaseModel):
"""Hide or show an object"""
@ -318,6 +378,8 @@ class object_visible(BaseModel):
type: Literal["object_visible"] = "object_visible"
model_config = ConfigDict(protected_namespaces=())
class object_bring_to_front(BaseModel):
"""Bring an object to the front of the scene"""
@ -326,6 +388,8 @@ class object_bring_to_front(BaseModel):
type: Literal["object_bring_to_front"] = "object_bring_to_front"
model_config = ConfigDict(protected_namespaces=())
class get_entity_type(BaseModel):
"""What type of entity is this?"""
@ -334,6 +398,8 @@ class get_entity_type(BaseModel):
type: Literal["get_entity_type"] = "get_entity_type"
model_config = ConfigDict(protected_namespaces=())
class solid2d_add_hole(BaseModel):
"""Add a hole to a Solid2d object before extruding it."""
@ -344,6 +410,8 @@ class solid2d_add_hole(BaseModel):
type: Literal["solid2d_add_hole"] = "solid2d_add_hole"
model_config = ConfigDict(protected_namespaces=())
class solid3d_get_all_edge_faces(BaseModel):
"""Gets all faces which use the given edge."""
@ -354,6 +422,8 @@ class solid3d_get_all_edge_faces(BaseModel):
type: Literal["solid3d_get_all_edge_faces"] = "solid3d_get_all_edge_faces"
model_config = ConfigDict(protected_namespaces=())
class solid3d_get_all_opposite_edges(BaseModel):
"""Gets all edges which are opposite the given edge, across all possible faces."""
@ -366,6 +436,8 @@ class solid3d_get_all_opposite_edges(BaseModel):
type: Literal["solid3d_get_all_opposite_edges"] = "solid3d_get_all_opposite_edges"
model_config = ConfigDict(protected_namespaces=())
class solid3d_get_opposite_edge(BaseModel):
"""Gets the edge opposite the given edge, along the given face."""
@ -378,6 +450,8 @@ class solid3d_get_opposite_edge(BaseModel):
type: Literal["solid3d_get_opposite_edge"] = "solid3d_get_opposite_edge"
model_config = ConfigDict(protected_namespaces=())
class solid3d_get_next_adjacent_edge(BaseModel):
"""Gets the next adjacent edge for the given edge, along the given face."""
@ -390,6 +464,8 @@ class solid3d_get_next_adjacent_edge(BaseModel):
type: Literal["solid3d_get_next_adjacent_edge"] = "solid3d_get_next_adjacent_edge"
model_config = ConfigDict(protected_namespaces=())
class solid3d_get_prev_adjacent_edge(BaseModel):
"""Gets the previous adjacent edge for the given edge, along the given face."""
@ -402,6 +478,8 @@ class solid3d_get_prev_adjacent_edge(BaseModel):
type: Literal["solid3d_get_prev_adjacent_edge"] = "solid3d_get_prev_adjacent_edge"
model_config = ConfigDict(protected_namespaces=())
class send_object(BaseModel):
"""Sends object to front or back."""
@ -412,6 +490,8 @@ class send_object(BaseModel):
type: Literal["send_object"] = "send_object"
model_config = ConfigDict(protected_namespaces=())
class entity_set_opacity(BaseModel):
"""Set opacity of the entity."""
@ -422,6 +502,8 @@ class entity_set_opacity(BaseModel):
type: Literal["entity_set_opacity"] = "entity_set_opacity"
model_config = ConfigDict(protected_namespaces=())
class entity_fade(BaseModel):
"""Fade the entity in or out."""
@ -434,6 +516,8 @@ class entity_fade(BaseModel):
type: Literal["entity_fade"] = "entity_fade"
model_config = ConfigDict(protected_namespaces=())
class make_plane(BaseModel):
"""Make a plane."""
@ -452,6 +536,8 @@ class make_plane(BaseModel):
y_axis: Point3d
model_config = ConfigDict(protected_namespaces=())
class plane_set_color(BaseModel):
"""Set the plane's color."""
@ -462,6 +548,8 @@ class plane_set_color(BaseModel):
type: Literal["plane_set_color"] = "plane_set_color"
model_config = ConfigDict(protected_namespaces=())
class set_tool(BaseModel):
"""Set the active tool."""
@ -470,6 +558,8 @@ class set_tool(BaseModel):
type: Literal["set_tool"] = "set_tool"
model_config = ConfigDict(protected_namespaces=())
class mouse_move(BaseModel):
"""Send a mouse move event."""
@ -480,6 +570,8 @@ class mouse_move(BaseModel):
window: Point2d
model_config = ConfigDict(protected_namespaces=())
class mouse_click(BaseModel):
"""Send a mouse click event. Updates modified/selected entities."""
@ -488,6 +580,8 @@ class mouse_click(BaseModel):
window: Point2d
model_config = ConfigDict(protected_namespaces=())
class sketch_mode_enable(BaseModel):
"""Enable sketch mode on the given plane."""
@ -502,12 +596,16 @@ class sketch_mode_enable(BaseModel):
type: Literal["sketch_mode_enable"] = "sketch_mode_enable"
model_config = ConfigDict(protected_namespaces=())
class sketch_mode_disable(BaseModel):
"""Disable sketch mode."""
type: Literal["sketch_mode_disable"] = "sketch_mode_disable"
model_config = ConfigDict(protected_namespaces=())
class curve_get_type(BaseModel):
"""Get type of a given curve."""
@ -516,6 +614,8 @@ class curve_get_type(BaseModel):
type: Literal["curve_get_type"] = "curve_get_type"
model_config = ConfigDict(protected_namespaces=())
class curve_get_control_points(BaseModel):
"""Get control points of a given curve."""
@ -524,6 +624,8 @@ class curve_get_control_points(BaseModel):
type: Literal["curve_get_control_points"] = "curve_get_control_points"
model_config = ConfigDict(protected_namespaces=())
class take_snapshot(BaseModel):
"""Take a snapshot."""
@ -532,6 +634,8 @@ class take_snapshot(BaseModel):
type: Literal["take_snapshot"] = "take_snapshot"
model_config = ConfigDict(protected_namespaces=())
class make_axes_gizmo(BaseModel):
"""Add a gizmo showing the axes."""
@ -542,6 +646,8 @@ class make_axes_gizmo(BaseModel):
type: Literal["make_axes_gizmo"] = "make_axes_gizmo"
model_config = ConfigDict(protected_namespaces=())
class path_get_info(BaseModel):
"""Query the given path"""
@ -550,6 +656,8 @@ class path_get_info(BaseModel):
type: Literal["path_get_info"] = "path_get_info"
model_config = ConfigDict(protected_namespaces=())
class path_get_curve_uuids_for_vertices(BaseModel):
"""Get curves for vertices within a path"""
@ -562,6 +670,8 @@ class path_get_curve_uuids_for_vertices(BaseModel):
vertex_ids: List[str]
model_config = ConfigDict(protected_namespaces=())
class path_get_vertex_uuids(BaseModel):
"""Get vertices within a path"""
@ -570,6 +680,8 @@ class path_get_vertex_uuids(BaseModel):
type: Literal["path_get_vertex_uuids"] = "path_get_vertex_uuids"
model_config = ConfigDict(protected_namespaces=())
class handle_mouse_drag_start(BaseModel):
"""Start dragging mouse."""
@ -578,6 +690,8 @@ class handle_mouse_drag_start(BaseModel):
window: Point2d
model_config = ConfigDict(protected_namespaces=())
class handle_mouse_drag_move(BaseModel):
"""Continue dragging mouse."""
@ -588,6 +702,8 @@ class handle_mouse_drag_move(BaseModel):
window: Point2d
model_config = ConfigDict(protected_namespaces=())
class handle_mouse_drag_end(BaseModel):
"""Stop dragging mouse."""
@ -596,6 +712,8 @@ class handle_mouse_drag_end(BaseModel):
window: Point2d
model_config = ConfigDict(protected_namespaces=())
class remove_scene_objects(BaseModel):
"""Remove scene objects."""
@ -604,6 +722,8 @@ class remove_scene_objects(BaseModel):
type: Literal["remove_scene_objects"] = "remove_scene_objects"
model_config = ConfigDict(protected_namespaces=())
class plane_intersect_and_project(BaseModel):
"""Utility method. Performs both a ray cast and projection to plane-local coordinates. Returns the plane coordinates for the given window coordinates."""
@ -614,6 +734,8 @@ class plane_intersect_and_project(BaseModel):
window: Point2d
model_config = ConfigDict(protected_namespaces=())
class curve_get_end_points(BaseModel):
"""Find the start and end of a curve."""
@ -622,6 +744,8 @@ class curve_get_end_points(BaseModel):
type: Literal["curve_get_end_points"] = "curve_get_end_points"
model_config = ConfigDict(protected_namespaces=())
class reconfigure_stream(BaseModel):
"""Reconfigure the stream."""
@ -634,6 +758,8 @@ class reconfigure_stream(BaseModel):
width: int
model_config = ConfigDict(protected_namespaces=())
class import_files(BaseModel):
"""Import files to the current model."""
@ -644,6 +770,8 @@ class import_files(BaseModel):
type: Literal["import_files"] = "import_files"
model_config = ConfigDict(protected_namespaces=())
class mass(BaseModel):
"""Get the mass of entities in the scene or the default scene."""
@ -660,6 +788,8 @@ class mass(BaseModel):
type: Literal["mass"] = "mass"
model_config = ConfigDict(protected_namespaces=())
class density(BaseModel):
"""Get the density of entities in the scene or the default scene."""
@ -676,6 +806,8 @@ class density(BaseModel):
type: Literal["density"] = "density"
model_config = ConfigDict(protected_namespaces=())
class volume(BaseModel):
"""Get the volume of entities in the scene or the default scene."""
@ -688,6 +820,8 @@ class volume(BaseModel):
type: Literal["volume"] = "volume"
model_config = ConfigDict(protected_namespaces=())
class center_of_mass(BaseModel):
"""Get the center of mass of entities in the scene or the default scene."""
@ -700,6 +834,8 @@ class center_of_mass(BaseModel):
type: Literal["center_of_mass"] = "center_of_mass"
model_config = ConfigDict(protected_namespaces=())
class surface_area(BaseModel):
"""Get the surface area of entities in the scene or the default scene."""
@ -712,12 +848,16 @@ class surface_area(BaseModel):
type: Literal["surface_area"] = "surface_area"
model_config = ConfigDict(protected_namespaces=())
class get_sketch_mode_plane(BaseModel):
"""Get the plane of the sketch mode. This is useful for getting the normal of the plane after a user selects a plane."""
type: Literal["get_sketch_mode_plane"] = "get_sketch_mode_plane"
model_config = ConfigDict(protected_namespaces=())
class curve_set_constraint(BaseModel):
"""Constrain a curve."""
@ -730,6 +870,8 @@ class curve_set_constraint(BaseModel):
type: Literal["curve_set_constraint"] = "curve_set_constraint"
model_config = ConfigDict(protected_namespaces=())
class enable_sketch_mode(BaseModel):
"""Sketch on some entity (e.g. a plane, a face)"""
@ -742,6 +884,8 @@ class enable_sketch_mode(BaseModel):
type: Literal["enable_sketch_mode"] = "enable_sketch_mode"
model_config = ConfigDict(protected_namespaces=())
class object_set_material_params_pbr(BaseModel):
"""Set the material properties of an object"""
@ -758,6 +902,8 @@ class object_set_material_params_pbr(BaseModel):
type: Literal["object_set_material_params_pbr"] = "object_set_material_params_pbr"
model_config = ConfigDict(protected_namespaces=())
class entity_get_distance(BaseModel):
"""What is the distance between these two entities?"""
@ -770,6 +916,8 @@ class entity_get_distance(BaseModel):
type: Literal["entity_get_distance"] = "entity_get_distance"
model_config = ConfigDict(protected_namespaces=())
class entity_linear_pattern(BaseModel):
"""Duplicate the given entity, evenly spaced along the chosen axis."""
@ -784,6 +932,8 @@ class entity_linear_pattern(BaseModel):
type: Literal["entity_linear_pattern"] = "entity_linear_pattern"
model_config = ConfigDict(protected_namespaces=())
class set_selection_type(BaseModel):
"""When you select some entity with the current tool, what should happen to the entity?"""
@ -792,6 +942,8 @@ class set_selection_type(BaseModel):
type: Literal["set_selection_type"] = "set_selection_type"
model_config = ConfigDict(protected_namespaces=())
class set_selection_filter(BaseModel):
"""What kind of entities can be selected?"""
@ -800,12 +952,16 @@ class set_selection_filter(BaseModel):
type: Literal["set_selection_filter"] = "set_selection_filter"
model_config = ConfigDict(protected_namespaces=())
class default_camera_set_orthographic(BaseModel):
"""Use orthographic projection."""
type: Literal["default_camera_set_orthographic"] = "default_camera_set_orthographic"
model_config = ConfigDict(protected_namespaces=())
class default_camera_set_perspective(BaseModel):
"""Use perspective projection."""
@ -814,6 +970,8 @@ class default_camera_set_perspective(BaseModel):
type: Literal["default_camera_set_perspective"] = "default_camera_set_perspective"
model_config = ConfigDict(protected_namespaces=())
ModelingCmd = RootModel[
Annotated[