| | |
| | | { |
| | | try |
| | | { |
| | | simulator.addDevice(command.ip(), command.channelCount()); |
| | | if (command.model() == null || command.model().isBlank()) |
| | | simulator.addDevice(command.ip(), command.channelCount()); |
| | | else |
| | | simulator.addNewareDevice(command.ip(), command.model()); |
| | | return simulator.snapshot(); |
| | | } |
| | | catch (IllegalArgumentException exception) |
| | |
| | | try |
| | | { |
| | | simulator.updateDevice(deviceId, command.ip(), command.channelCount(), command.online()); |
| | | if (command.model() != null && !command.model().isBlank()) |
| | | simulator.configureNewareProfile(deviceId, command.model()); |
| | | return simulator.snapshot(); |
| | | } |
| | | catch (IllegalArgumentException exception) |
| | |
| | | return new ResponseStatusException(HttpStatus.BAD_REQUEST, exception.getMessage(), exception); |
| | | } |
| | | |
| | | public record CreateDeviceCommand(String ip, int channelCount) { } |
| | | public record CreateDeviceCommand(String ip, int channelCount, String model) |
| | | { |
| | | public CreateDeviceCommand(String ip, int channelCount) |
| | | { |
| | | this(ip, channelCount, null); |
| | | } |
| | | } |
| | | |
| | | public record SimulatorPowerCommand(Boolean poweredOn) { } |
| | | |
| | | public record DeviceStateCommand(String ip, int channelCount, boolean online) { } |
| | | public record DeviceStateCommand(String ip, int channelCount, boolean online, String model) |
| | | { |
| | | public DeviceStateCommand(String ip, int channelCount, boolean online) |
| | | { |
| | | this(ip, channelCount, online, null); |
| | | } |
| | | } |
| | | |
| | | public record ChannelStateCommand(boolean online, DeviceWorkStatus workStatus) { } |
| | | |