def make_calculate_position_command(self): def handler(correlation_id, args): site_id = args.get_as_string("site_id") udis = args.get_as_nullable_string("udis") return self._controller.calculate_position(correlation_id, site_id, udis) return Command("calculate_position", ObjectSchema().with_required_property("site_id", "String") .with_required_property("udis", ArraySchema("String")), handler)
def make_get_beacons_command(self): def handler(correlation_id, args): filter = FilterParams.from_value(args.get("filter")) paging = PagingParams.from_value(args.get("paging")) return self._controller.get_beacons_by_filter(correlation_id, filter, paging) return Command("get_beacons", ObjectSchema().with_optional_property("filter", FilterParamsSchema()) .with_optional_property("paging", PagingParamsSchema()), handler)
def make_delete_beacon_by_id_command(self): def handler(correlation_id, args): id = args.get_as_string("id") return self._controller.delete_beacon_by_id(correlation_id, id) return Command("delete_beacon_by_id", ObjectSchema().with_required_property("id", "String"), handler)
def make_get_beacon_by_udi_command(self): def handler(correlation_id, args): id = args.get_as_string("udi") return self._controller.get_beacon_by_udi(correlation_id, id) return Command("get_beacon_by_udi", ObjectSchema().with_required_property("udi", "String"), handler)
def _make_get_page_by_filter_command(self): def handler(correlation_id, args): filter = FilterParams.from_value(args.get("filter")) paging = PagingParams.from_value(args.get("paging")) return self._controller.get_page_by_filter(correlation_id, filter, paging) return Command("get_dummies", None, handler)
def make_update_beacon_command(self): def handler(correlation_id, args): entity = args.get("beacon") return self._controller.update_beacon(correlation_id, entity) return Command( "update_beacon", ObjectSchema().with_optional_property("beacon", BeaconV1Schema()), handler)
def __make_get_beacon_by_id_command(self) -> ICommand: def handler(correlation_id, args): id = args.get_as_string("id") return self.__controller.get_beacon_by_id(correlation_id, id) return Command( "get_beacon_by_id", ObjectSchema().with_required_property("id", TypeCode.String), handler)
def _make_delete_by_id_command(self) -> ICommand: def handler(correlation_id: Optional[str], args: Parameters): id = args.get_as_string("dummy_id") return self._controller.delete_by_id(correlation_id, id) return Command( "delete_dummy", ObjectSchema(True).with_required_property("dummy_id", TypeCode.String), handler)
def _make_update_command(self) -> ICommand: def handler(correlation_id: Optional[str], args: Parameters): entity = args.get("dummy") if isinstance(entity, dict): entity = Dummy.from_json(entity) return self._controller.update(correlation_id, entity) return Command( "update_dummy", ObjectSchema(True).with_required_property("dummy", DummySchema()), handler)
def _make_get_page_by_filter_command(self) -> ICommand: def handler(correlation_id: Optional[str], args: Parameters): filter = FilterParams.from_value(args.get("filter")) paging = PagingParams.from_value(args.get("paging")) page = self._controller.get_page_by_filter(correlation_id, filter, paging) return page return Command( "get_dummies", ObjectSchema(True).with_optional_property( "filter", FilterParamsSchema()).with_optional_property( "paging", PagingParamsSchema()), handler)
def make_echo_command(self, name): return Command(name, None, self.get_value)
def test_get_name(self): command = Command('name', None, CommandExecTest()) assert command is not None assert command.get_name() == 'name'
def _make_delete_by_id_command(self): def handler(correlation_id, args): id = args.get_as_string("dummy_id") return self._controller.delete_by_id(correlation_id, id) return Command("delete_dummy_by_id", None, handler)
def _make_update_command(self): def handler(correlation_id, args): entity = args.get("dummy") return self._controller.update(correlation_id, entity) return Command("update_dummy", None, handler)
def _make_check_correlation_id(self) -> ICommand: def handler(correlation_id: Optional[str], args: Parameters): value = self._controller.check_correlation_id(correlation_id) return {'correlation_id': value} return Command("check_correlation_id", ObjectSchema(True), handler)