final JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("id", volume.getId()); jsonObject.addProperty("name", volume.getName()); if (StringUtils.isNotBlank(volume.getDescription())) { jsonObject.addProperty("description", volume.getDescription()); if (StringUtils.isNotBlank(volume.getRegion().getSlug())) { jsonObject.addProperty("region", volume.getRegion().getSlug()); if (StringUtils.isNotBlank(volume.getSnapshotId())) { jsonObject.addProperty("snapshot_id", volume.getSnapshotId()); if (null != volume.getSize()) { jsonObject.addProperty("size_gigabytes", volume.getSize()); if (StringUtils.isNotBlank(volume.getFileSystemType())) { jsonObject.addProperty("filesystem_type", volume.getFileSystemType()); if (StringUtils.isNotBlank(volume.getFileSystemLabel())) { jsonObject.addProperty("filesystem_label", volume.getFileSystemLabel()); if (null != volume.getTags() && !volume.getTags().isEmpty()) { JsonArray tags = new JsonArray(); for (String tag : volume.getTags()) { tags.add(context.serialize(tag));
@Override public Volume createVolume(Volume volume) throws DigitalOceanException, RequestUnsuccessfulException { if (null == volume || StringUtils.isBlank(volume.getName()) || null == volume.getRegion() || null == volume.getSize()) { throw new IllegalArgumentException( "Missing required parameters [Name, Region Slug, Size] for create volume."); } return (Volume) perform(new ApiRequest(ApiAction.CREATE_VOLUME, volume)).getData(); }
private void createVolume(Exchange exchange) throws Exception { Message in = exchange.getIn(); Volume volume = new Volume(); if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES))) { volume.setSize(in.getHeader(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES, Double.class)); } else { throw new IllegalArgumentException(DigitalOceanHeaders.VOLUME_SIZE_GIGABYTES + " must be specified"); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.NAME))) { volume.setName(in.getHeader(DigitalOceanHeaders.NAME, String.class)); } else { throw new IllegalArgumentException(DigitalOceanHeaders.NAME + " must be specified"); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.REGION))) { volume.setRegion(new Region(in.getHeader(DigitalOceanHeaders.REGION, String.class))); } else { throw new IllegalArgumentException(DigitalOceanHeaders.REGION + " must be specified"); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.DESCRIPTION))) { volume.setDescription(in.getHeader(DigitalOceanHeaders.DESCRIPTION, String.class)); } else { throw new IllegalArgumentException(DigitalOceanHeaders.DESCRIPTION + " must be specified"); } volume = getEndpoint().getDigitalOceanClient().createVolume(volume); LOG.trace("Volume created {}", volume); exchange.getOut().setBody(volume); }
@Override public Volume createVolume(Volume volume) throws DigitalOceanException, RequestUnsuccessfulException { if (null == volume || StringUtils.isBlank(volume.getName()) || null == volume.getRegion() || null == volume.getSize()) { throw new IllegalArgumentException( "Missing required parameters [Name, Region Slug, Size] for create volume."); } return (Volume) perform(new ApiRequest(ApiAction.CREATE_VOLUME, volume)).getData(); }
final JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("id", volume.getId()); jsonObject.addProperty("name", volume.getName()); if (StringUtils.isNotBlank(volume.getDescription())) { jsonObject.addProperty("description", volume.getDescription()); if (StringUtils.isNotBlank(volume.getRegion().getSlug())) { jsonObject.addProperty("region", volume.getRegion().getSlug()); if (StringUtils.isNotBlank(volume.getSnapshotId())) { jsonObject.addProperty("snapshot_id", volume.getSnapshotId()); if (null != volume.getSize()) { jsonObject.addProperty("size_gigabytes", volume.getSize()); if (StringUtils.isNotBlank(volume.getFileSystemType())) { jsonObject.addProperty("filesystem_type", volume.getFileSystemType()); if (StringUtils.isNotBlank(volume.getFileSystemLabel())) { jsonObject.addProperty("filesystem_label", volume.getFileSystemLabel()); if (null != volume.getTags() && !volume.getTags().isEmpty()) { JsonArray tags = new JsonArray(); for (String tag : volume.getTags()) { tags.add(context.serialize(tag));