Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/2402.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
V1 implementation of coordinate system stub
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ansys.geometry.core.errors import protect_grpc

from ..base.coordinate_systems import GRPCCoordinateSystemService
from .conversions import from_frame_to_grpc_frame, from_grpc_frame_to_frame


class GRPCCoordinateSystemServiceV1(GRPCCoordinateSystemService): # pragma: no cover
Expand All @@ -43,10 +44,38 @@ class GRPCCoordinateSystemServiceV1(GRPCCoordinateSystemService): # pragma: no

@protect_grpc
def __init__(self, channel: grpc.Channel): # noqa: D102
from ansys.api.geometry.v1.coordinatesystems_pb2_grpc import CoordinateSystemsStub
from ansys.api.discovery.v1.design.constructs.coordinatesystem_pb2_grpc import (
CoordinateSystemStub,
)

self.stub = CoordinateSystemsStub(channel)
self.stub = CoordinateSystemStub(channel)

@protect_grpc
def create(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.design.constructs.coordinatesystem_pb2 import (
CreateRequest,
CreateRequestData,
)

# Create the request data - assumes all inputs are valid and of the proper type
request = CreateRequest(
request_data=[
CreateRequestData(
parent_id=kwargs["parent_id"],
name=kwargs["name"],
frame=from_frame_to_grpc_frame(kwargs["frame"]),
)
]
)

# Call the gRPC service
response = self.stub.Create(request=request)

# Return the response - formatted as a dictionary
# Note: response.coordinate_systems is a repeated field, we return the first one
coord_system = response.coordinate_systems[0]
return {
"id": coord_system.id,
"name": coord_system.name,
"frame": from_grpc_frame_to_frame(coord_system.frame),
}
Loading