Skip to content

Commit ca2a5bd

Browse files
committed
stubs and request update for materials grpc call
The SpaceClaim material has been renamed cad_material in the API server in order to avoid confusion with the Discovery definition of materials
1 parent 38324c1 commit ca2a5bd

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/ansys/geometry/core/_grpc/_services/v1/materials.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
from ansys.geometry.core.errors import protect_grpc
2727

2828
from ..base.materials import GRPCMaterialsService
29+
from .conversions import from_material_to_grpc_material
2930

3031

31-
class GRPCMaterialsServiceV1(GRPCMaterialsService): # pragma: no cover
32+
class GRPCMaterialsServiceV1(GRPCMaterialsService):
3233
"""Materials service for gRPC communication with the Geometry server.
3334
3435
This class provides methods to interact with the Geometry server's
@@ -43,14 +44,36 @@ class GRPCMaterialsServiceV1(GRPCMaterialsService): # pragma: no cover
4344

4445
@protect_grpc
4546
def __init__(self, channel: grpc.Channel): # noqa: D102
46-
from ansys.api.geometry.v1.materials_pb2_grpc import MaterialsStub
47+
from ansys.api.discovery.v1.design.data.cadmaterial_pb2_grpc import MaterialsStub
4748

4849
self.stub = MaterialsStub(channel)
4950

5051
@protect_grpc
5152
def add_material(self, **kwargs) -> dict: # noqa: D102
52-
raise NotImplementedError
53+
from ansys.api.discovery.v1.design.data.cadmaterial_pb2_grpc import CreateRequest
54+
55+
# Create the request - assumes all inputs are valid and of the proper type
56+
request = CreateRequest(
57+
request_data=from_material_to_grpc_material(kwargs["material"]),
58+
)
59+
60+
# Call the gRPC service
61+
_ = self.stub.Create(request=request)
62+
63+
# Convert the response to a dictionary
64+
return {}
5365

5466
@protect_grpc
5567
def remove_material(self, **kwargs) -> dict: # noqa: D102
56-
raise NotImplementedError
68+
from ansys.api.discovery.v1.design.data.cadmaterial_pb2_grpc import DeleteRequest
69+
70+
# Create the request - assumes all inputs are valid and of the proper type
71+
request = DeleteRequest(
72+
request_data=[from_material_to_grpc_material(mat) for mat in kwargs["materials"]]
73+
)
74+
75+
# Call the gRPC service
76+
_ = self.stub.Delete(request=request)
77+
78+
# Convert the response to a dictionary
79+
return {}

0 commit comments

Comments
 (0)