if (input.getVncPassword() != null) {
serverObject.addProperty("vnc_password", input.getVncPassword());
}
if (input.getNics() != null) {
JsonArray nics = new JsonArray();
for (NIC nic : input.getNics()) {
JsonObject nicObject = new JsonObject();
if (nic.getFirewallPolicy() != null) {
nicObject.addProperty("firewall_policy", nic.getFirewallPolicy().getUuid());
}
if (nic.getVlan() != null) {
nicObject.addProperty("vlan", nic.getVlan().getUuid());
} else if (nic.getIpV4Configuration() != null) {
nicObject.add("ip_v4_conf", ipConfigurationToJsonObject(nic.getIpV4Configuration()));
if (nic.getModel() != null) {
nicObject.addProperty("model", nic.getModel().value());
}
if (nic.getMac() != null) {
nicObject.addProperty("mac", nic.getMac());
}
} else if (nic.getIpV6Configuration() != null) {
nicObject.add("ip_v6_conf", ipConfigurationToJsonObject(nic.getIpV6Configuration()));
if (nic.getModel() != null) {
nicObject.addProperty("model", nic.getModel().value());
}
if (nic.getMac() != null) {
nicObject.addProperty("mac", nic.getMac());
}
}
nics.add(nicObject);
}
serverObject.add("nics", nics);
}
if (input.getDrives() != null) {
JsonArray serverDrives = new JsonArray();
for (ServerDrive serverDrive : input.getDrives()) {
JsonObject driveObject = new JsonObject();
driveObject.addProperty("boot_order", serverDrive.getBootOrder());
if (serverDrive.getDeviceChannel() != null) {
driveObject.addProperty("dev_channel", serverDrive.getDeviceChannel());
}
if (serverDrive.getDeviceEmulationType() != null) {
driveObject.addProperty("device", serverDrive.getDeviceEmulationType().value());
}
if (serverDrive.getDriveUuid() != null) {
driveObject.addProperty("drive", serverDrive.getDriveUuid());
} else if (serverDrive.getDrive() != null) {
driveObject.addProperty("drive", serverDrive.getDrive().getUuid());
}
serverDrives.add(driveObject);
}
serverObject.add("drives", serverDrives);
}
return serverObject;