/** * Create an instance of {@link ReportedDevice } * */ public ReportedDevice createReportedDevice() { return new ReportedDevice(); }
private static List<ReportedDevice> getDevices(BackendResource resource, Guid vmId, String mac) { List<ReportedDevice> devices = new ArrayList<>(); for (VmGuestAgentInterface iface : getDevicesCollection(resource, vmId)) { if (StringUtils.equals(iface.getMacAddress(), mac)) { ReportedDevice device = LinkHelper.addLinks(ReportedDeviceMapper.map(iface, new ReportedDevice())); devices.add(device); } } return devices; }
@Override public ReportedDevices list() { ReportedDevices model = new ReportedDevices(); for (VmGuestAgentInterface device : getCollection()) { model.getReportedDevices().add(addLinks(ReportedDeviceMapper.map(device, new ReportedDevice()))); } return model; }
public ReportedDevice lookupReportedDevice(Guid deviceId) { VmGuestAgentInterface device = getReportedDeviceByDeviceId(deviceId); if (device == null) { return notFound(); } return addLinks(ReportedDeviceMapper.map(device, new ReportedDevice())); }
@Mapping(from = VmGuestAgentInterface.class, to = ReportedDevice.class) public static ReportedDevice map(VmGuestAgentInterface entity, ReportedDevice model) { model = model == null ? new ReportedDevice() : model; if (entity.getVmId() != null) { model.setVm(new Vm()); model.getVm().setId(entity.getVmId().toString()); } if (entity.getMacAddress() != null) { Mac mac = new Mac(); mac.setAddress(entity.getMacAddress()); model.setMac(mac); } model.setName(entity.getInterfaceName()); model.setDescription("guest reported data"); model.setId(generateDeviceId(entity).toString()); model.setType(ReportedDeviceType.NETWORK); mapIps(entity, model); return model; }
@Override public ReportedDevice adapt(V3ReportedDevice from) { ReportedDevice to = new ReportedDevice(); if (from.isSetLinks()) { to.getLinks().addAll(adaptIn(from.getLinks()));