def _call_pdm_method(self, method_name, **kwargs): pb2_params = PdmObject_pb2.PdmObject(class_keyword=method_name) for key, value in kwargs.items(): pb2_params.parameters[snake_to_camel(key)] = self.__convert_to_grpc_value(value) request = PdmObject_pb2.PdmObjectMethodRequest( object=self._pb2_object, method=method_name, params=pb2_params) pb2_object = self._pdm_object_stub.CallPdmObjectMethod(request) child_class_definition = class_from_keyword(pb2_object.class_keyword) if child_class_definition is None: return None pdm_object = child_class_definition(pb2_object=pb2_object, channel=self.channel()) return pdm_object
def __custom_init__(self, pb2_object, channel): self.__warnings = [] self.__chunk_size = 8160 self._channel = channel # Create stubs if self._channel: self._pdm_object_stub = PdmObject_pb2_grpc.PdmObjectServiceStub(self._channel) self._commands = CmdRpc.CommandsStub(self._channel) if pb2_object is not None: # Copy parameters from ResInsight assert(not isinstance(pb2_object, PdmObject)) self._pb2_object = pb2_object for camel_keyword in self._pb2_object.parameters: snake_keyword = camel_to_snake(camel_keyword) setattr(self, snake_keyword, self.__get_grpc_value(camel_keyword)) else: # Copy parameters from PdmObject defaults self._pb2_object = PdmObject_pb2.PdmObject(class_keyword=self.__class__.__name__) self.__copy_to_pb2()
def _call_pdm_method(self, method_name, **kwargs): pb2_params = PdmObject_pb2.PdmObject(class_keyword=method_name) for key, value in kwargs.items(): pb2_params.parameters[snake_to_camel(key)] = self.__convert_to_grpc_value(value) request = PdmObject_pb2.PdmObjectMethodRequest(object=self._pb2_object, method=method_name, params=pb2_params) return self._pdm_object_stub.CallPdmObjectMethod(request)