async def execute_service(self, service: UserService, data: dict): self._check_authenticated() req = pb.ExecuteServiceRequest() req.key = service.key args = [] for arg_desc in service.args: arg = pb.ExecuteServiceArgument() val = data[arg_desc.name] int_type = 'int_' if self.api_version >= APIVersion( 1, 3) else 'legacy_int' map_single = { UserServiceArgType.BOOL: 'bool_', UserServiceArgType.INT: int_type, UserServiceArgType.FLOAT: 'float_', UserServiceArgType.STRING: 'string_', } map_array = { UserServiceArgType.BOOL_ARRAY: 'bool_array', UserServiceArgType.INT_ARRAY: 'int_array', UserServiceArgType.FLOAT_ARRAY: 'float_array', UserServiceArgType.STRING_ARRAY: 'string_array', } # pylint: disable=redefined-outer-name if arg_desc.type_ in map_array: attr = getattr(arg, map_array[arg_desc.type_]) attr.extend(val) else: setattr(arg, map_single[arg_desc.type_], val) args.append(arg) # pylint: disable=no-member req.args.extend(args) await self._connection.send_message(req)
async def execute_service(self, service: UserService, data: dict): self._check_authenticated() req = pb.ExecuteServiceRequest() req.key = service.key args = [] for arg_desc in service.args: arg = pb.ExecuteServiceArgument() val = data[arg_desc.name] attr_ = { USER_SERVICE_ARG_BOOL: 'bool_', USER_SERVICE_ARG_INT: 'int_', USER_SERVICE_ARG_FLOAT: 'float_', USER_SERVICE_ARG_STRING: 'string_', }[arg_desc.type_] setattr(arg, attr_, val) args.append(arg) req.args.extend(args) await self._connection.send_message(req)