private void validateForwardingRule(ForwardingRules rule) { if (null == rule || null == rule.getEntryProtocol() || null == rule.getEntryPort() || null == rule.getTargetProtocol() || null == rule.getTargetPort()) { throw new IllegalArgumentException( "Missing required parameters [Entry Protocol, Entry Port, Target Protocol, Target Port] for forwarding rules."); } }
private void validateHealthCheck(HealthCheck healthCheck) { if (null != healthCheck && (null == healthCheck.getProtocol() || null == healthCheck.getPort())) { throw new IllegalArgumentException( "Missing required parameters [Protocol, Port] for health check"); } }
@Override public Droplet createDroplet(Droplet droplet) throws DigitalOceanException, RequestUnsuccessfulException { if (null == droplet || StringUtils.isBlank(droplet.getName()) || null == droplet.getRegion() || null == droplet.getSize() || (null == droplet.getImage() || (null == droplet.getImage().getId() && null == droplet.getImage().getSlug()))) { throw new IllegalArgumentException( "Missing required parameters [Name, Region Slug, Size Slug, Image Id/Slug] for create droplet."); } return (Droplet) perform(new ApiRequest(ApiAction.CREATE_DROPLET, droplet)).getData(); }
@Override public Action resizeDroplet(Integer dropletId, String size, Boolean disk) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); Object[] params = {dropletId}; DropletAction action = new DropletAction(ActionType.RESIZE); action.setSize(size); action.setDisk(disk); return (Action) perform(new ApiRequest(ApiAction.RESIZE_DROPLET, action, params)).getData(); }
@Override public Action rebuildDroplet(Integer dropletId, Integer imageId) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); Object[] params = {dropletId}; DropletAction action = new DropletAction(ActionType.REBUILD); action.setImage(imageId); return (Action) perform(new ApiRequest(ApiAction.REBUILD_DROPLET, action, params)).getData(); }
@Override public Action renameDroplet(Integer dropletId, String name) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); Object[] params = {dropletId}; DropletAction action = new DropletAction(ActionType.RENAME); action.setName(name); return (Action) perform(new ApiRequest(ApiAction.RENAME_DROPLET, action, params)).getData(); }
@Override public Action changeDropletKernel(Integer dropletId, Integer kernelId) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); Object[] params = {dropletId}; DropletAction action = new DropletAction(ActionType.CHANGE_KERNEL); action.setKernel(kernelId); return (Action) perform(new ApiRequest(ApiAction.CHANGE_DROPLET_KERNEL, action, params)) .getData(); }
@Override public Domain createDomain(Domain domain) throws DigitalOceanException, RequestUnsuccessfulException { checkBlankAndThrowError(domain.getName(), "Missing required parameter - domainName."); checkBlankAndThrowError(domain.getIpAddress(), "Missing required parameter - ipAddress."); return (Domain) perform(new ApiRequest(ApiAction.CREATE_DOMAIN, domain)).getData(); }
@Override public Action enableDropletIpv6(Integer dropletId) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); Object[] params = {dropletId}; return (Action) perform(new ApiRequest(ApiAction.ENABLE_DROPLET_IPV6, new DropletAction(ActionType.ENABLE_IPV6), params)).getData(); }
@Override public Action attachVolumeByName(Integer dropletId, String volumeName, String regionSlug) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); checkBlankAndThrowError(volumeName, "Missing required parameter - volumeName."); checkBlankAndThrowError(regionSlug, "Missing required parameter - regionSlug."); return (Action) perform(new ApiRequest(ApiAction.ACTIONS_VOLUME_BY_NAME, new VolumeAction(ActionType.ATTACH, dropletId, regionSlug, volumeName, null))).getData(); }
@Override public Action assignFloatingIP(Integer dropletId, String ipAddress) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); checkBlankAndThrowError(ipAddress, "Missing required parameter - ipAddress."); Object[] params = {ipAddress}; return (Action) perform(new ApiRequest(ApiAction.ASSIGN_FLOATING_IP, new FloatingIPAction(dropletId, "assign"), params)).getData(); }
@Override public Droplet createDroplet(Droplet droplet) throws DigitalOceanException, RequestUnsuccessfulException { if (null == droplet || StringUtils.isBlank(droplet.getName()) || null == droplet.getRegion() || null == droplet.getSize() || (null == droplet.getImage() || (null == droplet.getImage().getId() && null == droplet.getImage().getSlug()))) { throw new IllegalArgumentException( "Missing required parameters [Name, Region Slug, Size Slug, Image Id/Slug] for create droplet."); } return (Droplet) perform(new ApiRequest(ApiAction.CREATE_DROPLET, droplet)).getData(); }
private void validateForwardingRule(ForwardingRules rule) { if (null == rule || null == rule.getEntryProtocol() || null == rule.getEntryPort() || null == rule.getTargetProtocol() || null == rule.getTargetPort()) { throw new IllegalArgumentException( "Missing required parameters [Entry Protocol, Entry Port, Target Protocol, Target Port] for forwarding rules."); } }
private void validateHealthCheck(HealthCheck healthCheck) { if (null != healthCheck && (null == healthCheck.getProtocol() || null == healthCheck.getPort())) { throw new IllegalArgumentException( "Missing required parameters [Protocol, Port] for health check"); } }
@Override public Action rebuildDroplet(Integer dropletId, Integer imageId) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); Object[] params = {dropletId}; DropletAction action = new DropletAction(ActionType.REBUILD); action.setImage(imageId); return (Action) perform(new ApiRequest(ApiAction.REBUILD_DROPLET, action, params)).getData(); }
@Override public Action renameDroplet(Integer dropletId, String name) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); Object[] params = {dropletId}; DropletAction action = new DropletAction(ActionType.RENAME); action.setName(name); return (Action) perform(new ApiRequest(ApiAction.RENAME_DROPLET, action, params)).getData(); }
@Override public Action powerOnDroplet(Integer dropletId) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); Object[] params = {dropletId}; return (Action) perform( new ApiRequest(ApiAction.POWER_ON_DROPLET, new DropletAction(ActionType.POWER_ON), params)) .getData(); }
@Override public Action attachVolume(Integer dropletId, String volumeId, String regionSlug) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); checkBlankAndThrowError(volumeId, "Missing required parameter - volumeId."); checkBlankAndThrowError(regionSlug, "Missing required parameter - regionSlug."); Object[] params = {volumeId}; return (Action) perform(new ApiRequest(ApiAction.ACTIONS_VOLUME, new VolumeAction(ActionType.ATTACH, dropletId, regionSlug), params)).getData(); }
@Override public Action takeDropletSnapshot(Integer dropletId) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); Object[] params = {dropletId}; return (Action) perform( new ApiRequest(ApiAction.SNAPSHOT_DROPLET, new DropletAction(ActionType.SNAPSHOT), params)) .getData(); }
@Override public Action disableDropletBackups(Integer dropletId) throws DigitalOceanException, RequestUnsuccessfulException { validateDropletId(dropletId); Object[] params = {dropletId}; return (Action) perform(new ApiRequest(ApiAction.DISABLE_DROPLET_BACKUPS, new DropletAction(ActionType.DISABLE_BACKUPS), params)).getData(); }