DigitalOcean API Client in Java

com.myjeeva.digitalocean.impl
Class DigitalOceanClient

java.lang.Object
  extended by com.myjeeva.digitalocean.impl.DigitalOceanClient
All Implemented Interfaces:
Constants, DigitalOcean

public class DigitalOceanClient
extends Object
implements DigitalOcean, Constants

DigitalOcean API client wrapper methods Implementation

Author:
Jeevanandam M. ([email protected])

Field Summary
 
Fields inherited from interface com.myjeeva.digitalocean.Constants
HTTPS_SCHEME, PARAM_API_KEY, PARAM_CLIENT_ID, PARAM_IMAGE_ID, PARAM_NAME, PARAM_REGION_ID, PARAM_SIDE_ID, PARAM_SSH_KEY_IDS, STATUS
 
Constructor Summary
DigitalOceanClient(String clientId, String apiKey)
          Constructor for initializing DigitalOcean Client
 
Method Summary
 SshKey addSshKey(String sshKeyName, String sshPublicKey)
          To be release in v1.2
 Domain createDomain(String domainName, String ipAddress)
          To be release in v1.1
 DomainRecord createDomainRecord(DomainRecord domainRecord)
          To be release in v1.1
 Droplet createDroplet(Droplet droplet)
           Method allows you to create a new droplet.
 Droplet createDroplet(Droplet droplet, String sshKeyIds)
           Method allows you to create a new droplet.
 Domain deleteDomain(Integer domainId)
          To be release in v1.1
 Response deleteDomainRecord(Integer domainId, Integer recordId)
          To be release in v1.1
 Response deleteDroplet(Integer dropletId)
          Method destroys one of your droplets - this is irreversible.
 Response deleteImage(Integer imageId)
          Method allows you to deletes an image.
 Response deleteSshKey(Integer sshKeyId)
          To be release in v1.2
 Response disableDropletBackups(Integer dropletId)
          Method disables automatic backups from running to backup your droplet's data.
 DomainRecord editDomainRecord(DomainRecord domainRecord)
          To be release in v1.1
 SshKey editSshKey(Integer sshKeyId, String sshPublicKey)
          To be release in v1.2
 Response enableDropletBackups(Integer dropletId)
          Method enables automatic backups which run in the background daily to backup your droplet's data.
 List<Domain> getAvailableDomains()
          To be release in v1.1
 List<Droplet> getAvailableDroplets()
          Method returns all active droplets that are currently running in your account.
 List<DropletImage> getAvailableImages()
          Method returns all the available images that can be accessed by your client ID.
 List<Region> getAvailableRegions()
          Method will return all the available regions within the DigitalOcean cloud.
 List<DropletSize> getAvailableSizes()
          Method returns all the available sizes that can be used to create a droplet.
 List<SshKey> getAvailableSshKeys()
          To be release in v1.2
 Domain getDomainInfo(Integer domainId)
          To be release in v1.1
 DomainRecord getDomainRecord(Integer domainId, Integer recordId)
          To be release in v1.1
 List<DomainRecord> getDomainRecords(Integer domainId)
          To be release in v1.1
 Droplet getDropletInfo(Integer dropletId)
          Method returns full information for a specific droplet ID that is passed in the URL.
 DropletImage getImageInfo(Integer imageId)
          Method retrieves the attributes of an image.
 SshKey getSshKeyInfo(Integer sshKeyId)
          To be release in v1.2
 Response powerCyleDroplet(Integer dropletId)
          Method allows you to power cycle a droplet.
 Response powerOffDroplet(Integer dropletId)
          Method allows you to poweroff a running droplet.
 Response powerOnDroplet(Integer dropletId)
          Method allows you to poweron a powered off droplet.
 Response rebootDroplet(Integer dropletId)
          Method allows you to reboot a droplet.
 Response rebuildDroplet(Integer dropletId, Integer imageId)
          Method allows you to reinstall a droplet with a default image.
 Response renameDroplet(Integer dropletId, String name)
          Method renames the droplet to the specified name.
 Response resetDropletPassword(Integer dropletId)
          Method will reset the root password for a droplet.
 Response resizeDroplet(Integer dropletId, Integer sizeId)
          Method allows you to resize a specific droplet to a different size.
 Response restoreDroplet(Integer dropletId, Integer imageId)
          Method allows you to restore a droplet with a previous image or snapshot.
 Response shutdownDroplet(Integer dropletId)
          Method allows you to shutdown a running droplet.
 Response takeDropletSnapshot(Integer dropletId)
          Method allows you to take a snapshot of the running droplet, which can later be restored or used to create a new droplet from the same image.
 Response takeDropletSnapshot(Integer dropletId, String snapshotName)
          Method allows you to take a snapshot of the running droplet, which can later be restored or used to create a new droplet from the same image.
 Response transerImage(Integer imageId, Integer regionId)
          Method allows you to transfer an image to a specified region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigitalOceanClient

public DigitalOceanClient(String clientId,
                          String apiKey)
Constructor for initializing DigitalOcean Client

Parameters:
clientId - a String object
apiKey - a String object
Throws:
ResourceNotFoundException
Method Detail

getAvailableDroplets

public List<Droplet> getAvailableDroplets()
                                   throws AccessDeniedException,
                                          ResourceNotFoundException,
                                          RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method returns all active droplets that are currently running in your account. All available API information is presented for each droplet.

Specified by:
getAvailableDroplets in interface DigitalOcean
Returns:
List<Droplet>
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

createDroplet

public Droplet createDroplet(Droplet droplet)
                      throws AccessDeniedException,
                             ResourceNotFoundException,
                             RequestUnsuccessfulException
Description copied from interface: DigitalOcean

Method allows you to create a new droplet. See the required parameters section below for an explanation of the variables that are needed to create a new droplet.

Create a instance of Droplet object and populate following values

Specified by:
createDroplet in interface DigitalOcean
Parameters:
droplet - a Droplet object
Returns:
Droplet
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

createDroplet

public Droplet createDroplet(Droplet droplet,
                             String sshKeyIds)
                      throws AccessDeniedException,
                             ResourceNotFoundException,
                             RequestUnsuccessfulException
Description copied from interface: DigitalOcean

Method allows you to create a new droplet. See the required parameters section below for an explanation of the variables that are needed to create a new droplet.

Create a instance of Droplet object and populate following values

Specified by:
createDroplet in interface DigitalOcean
Parameters:
droplet - a Droplet object
sshKeyIds - a String object - Numeric CSV, comma separated list of ssh_key_ids that you would like to be added to the server
Returns:
Droplet
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

getDropletInfo

public Droplet getDropletInfo(Integer dropletId)
                       throws AccessDeniedException,
                              ResourceNotFoundException,
                              RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method returns full information for a specific droplet ID that is passed in the URL.

Specified by:
getDropletInfo in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Droplet
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

rebootDroplet

public Response rebootDroplet(Integer dropletId)
                       throws AccessDeniedException,
                              ResourceNotFoundException,
                              RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to reboot a droplet. This is the preferred method to use if a server is not responding.

Specified by:
rebootDroplet in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

powerCyleDroplet

public Response powerCyleDroplet(Integer dropletId)
                          throws AccessDeniedException,
                                 ResourceNotFoundException,
                                 RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to power cycle a droplet. This will turn off the droplet and then turn it back on.

Specified by:
powerCyleDroplet in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

shutdownDroplet

public Response shutdownDroplet(Integer dropletId)
                         throws AccessDeniedException,
                                ResourceNotFoundException,
                                RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to shutdown a running droplet. The droplet will remain in your account.

Specified by:
shutdownDroplet in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

powerOffDroplet

public Response powerOffDroplet(Integer dropletId)
                         throws AccessDeniedException,
                                ResourceNotFoundException,
                                RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to poweroff a running droplet. The droplet will remain in your account.

Specified by:
powerOffDroplet in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

powerOnDroplet

public Response powerOnDroplet(Integer dropletId)
                        throws AccessDeniedException,
                               ResourceNotFoundException,
                               RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to poweron a powered off droplet.

Specified by:
powerOnDroplet in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

resetDropletPassword

public Response resetDropletPassword(Integer dropletId)
                              throws AccessDeniedException,
                                     ResourceNotFoundException,
                                     RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method will reset the root password for a droplet. Please be aware that this will reboot the droplet to allow resetting the password.

Specified by:
resetDropletPassword in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

resizeDroplet

public Response resizeDroplet(Integer dropletId,
                              Integer sizeId)
                       throws AccessDeniedException,
                              ResourceNotFoundException,
                              RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to resize a specific droplet to a different size. This will affect the number of processors and memory allocated to the droplet.

Specified by:
resizeDroplet in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

takeDropletSnapshot

public Response takeDropletSnapshot(Integer dropletId)
                             throws AccessDeniedException,
                                    ResourceNotFoundException,
                                    RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to take a snapshot of the running droplet, which can later be restored or used to create a new droplet from the same image. Please be aware this may cause a reboot.

Specified by:
takeDropletSnapshot in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

takeDropletSnapshot

public Response takeDropletSnapshot(Integer dropletId,
                                    String snapshotName)
                             throws AccessDeniedException,
                                    ResourceNotFoundException,
                                    RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to take a snapshot of the running droplet, which can later be restored or used to create a new droplet from the same image. Please be aware this may cause a reboot.

Specified by:
takeDropletSnapshot in interface DigitalOcean
Parameters:
dropletId - a Integer object
snapshotName - a String object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

restoreDroplet

public Response restoreDroplet(Integer dropletId,
                               Integer imageId)
                        throws AccessDeniedException,
                               ResourceNotFoundException,
                               RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to restore a droplet with a previous image or snapshot. This will be a mirror copy of the image or snapshot to your droplet. Be sure you have backed up any necessary information prior to restore.

Specified by:
restoreDroplet in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

rebuildDroplet

public Response rebuildDroplet(Integer dropletId,
                               Integer imageId)
                        throws AccessDeniedException,
                               ResourceNotFoundException,
                               RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to reinstall a droplet with a default image. This is useful if you want to start again but retain the same IP address for your droplet.

Specified by:
rebuildDroplet in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

enableDropletBackups

public Response enableDropletBackups(Integer dropletId)
                              throws AccessDeniedException,
                                     ResourceNotFoundException,
                                     RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method enables automatic backups which run in the background daily to backup your droplet's data.

Specified by:
enableDropletBackups in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

disableDropletBackups

public Response disableDropletBackups(Integer dropletId)
                               throws AccessDeniedException,
                                      ResourceNotFoundException,
                                      RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method disables automatic backups from running to backup your droplet's data.

Specified by:
disableDropletBackups in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

renameDroplet

public Response renameDroplet(Integer dropletId,
                              String name)
                       throws AccessDeniedException,
                              ResourceNotFoundException,
                              RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method renames the droplet to the specified name.

Specified by:
renameDroplet in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

deleteDroplet

public Response deleteDroplet(Integer dropletId)
                       throws AccessDeniedException,
                              ResourceNotFoundException,
                              RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method destroys one of your droplets - this is irreversible.

Specified by:
deleteDroplet in interface DigitalOcean
Parameters:
dropletId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

getAvailableRegions

public List<Region> getAvailableRegions()
                                 throws AccessDeniedException,
                                        ResourceNotFoundException,
                                        RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method will return all the available regions within the DigitalOcean cloud.

Specified by:
getAvailableRegions in interface DigitalOcean
Returns:
List<Region>
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

getAvailableImages

public List<DropletImage> getAvailableImages()
                                      throws AccessDeniedException,
                                             ResourceNotFoundException,
                                             RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method returns all the available images that can be accessed by your client ID. You will have access to all public images by default, and any snapshots or backups that you have created in your own account.

Specified by:
getAvailableImages in interface DigitalOcean
Returns:
List<DropletImage>
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

getImageInfo

public DropletImage getImageInfo(Integer imageId)
                          throws AccessDeniedException,
                                 ResourceNotFoundException,
                                 RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method retrieves the attributes of an image.

Specified by:
getImageInfo in interface DigitalOcean
Parameters:
imageId - a Integer object
Returns:
DropletImage
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

deleteImage

public Response deleteImage(Integer imageId)
                     throws AccessDeniedException,
                            ResourceNotFoundException,
                            RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to deletes an image. There is no way to restore a deleted image so be careful and ensure your data is properly backed up.

Specified by:
deleteImage in interface DigitalOcean
Parameters:
imageId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

transerImage

public Response transerImage(Integer imageId,
                             Integer regionId)
                      throws AccessDeniedException,
                             ResourceNotFoundException,
                             RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method allows you to transfer an image to a specified region.

Specified by:
transerImage in interface DigitalOcean
Parameters:
imageId - a Integer object
regionId - a Integer object
Returns:
Response
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

getAvailableSshKeys

public List<SshKey> getAvailableSshKeys()
Description copied from interface: DigitalOcean
To be release in v1.2

Specified by:
getAvailableSshKeys in interface DigitalOcean

getSshKeyInfo

public SshKey getSshKeyInfo(Integer sshKeyId)
Description copied from interface: DigitalOcean
To be release in v1.2

Specified by:
getSshKeyInfo in interface DigitalOcean

addSshKey

public SshKey addSshKey(String sshKeyName,
                        String sshPublicKey)
Description copied from interface: DigitalOcean
To be release in v1.2

Specified by:
addSshKey in interface DigitalOcean

editSshKey

public SshKey editSshKey(Integer sshKeyId,
                         String sshPublicKey)
Description copied from interface: DigitalOcean
To be release in v1.2

Specified by:
editSshKey in interface DigitalOcean

deleteSshKey

public Response deleteSshKey(Integer sshKeyId)
Description copied from interface: DigitalOcean
To be release in v1.2

Specified by:
deleteSshKey in interface DigitalOcean

getAvailableSizes

public List<DropletSize> getAvailableSizes()
                                    throws AccessDeniedException,
                                           ResourceNotFoundException,
                                           RequestUnsuccessfulException
Description copied from interface: DigitalOcean
Method returns all the available sizes that can be used to create a droplet.

Specified by:
getAvailableSizes in interface DigitalOcean
Returns:
List<DropletSize>
Throws:
AccessDeniedException
ResourceNotFoundException
RequestUnsuccessfulException

getAvailableDomains

public List<Domain> getAvailableDomains()
Description copied from interface: DigitalOcean
To be release in v1.1

Specified by:
getAvailableDomains in interface DigitalOcean

getDomainInfo

public Domain getDomainInfo(Integer domainId)
Description copied from interface: DigitalOcean
To be release in v1.1

Specified by:
getDomainInfo in interface DigitalOcean

createDomain

public Domain createDomain(String domainName,
                           String ipAddress)
Description copied from interface: DigitalOcean
To be release in v1.1

Specified by:
createDomain in interface DigitalOcean

deleteDomain

public Domain deleteDomain(Integer domainId)
Description copied from interface: DigitalOcean
To be release in v1.1

Specified by:
deleteDomain in interface DigitalOcean

getDomainRecords

public List<DomainRecord> getDomainRecords(Integer domainId)
Description copied from interface: DigitalOcean
To be release in v1.1

Specified by:
getDomainRecords in interface DigitalOcean

getDomainRecord

public DomainRecord getDomainRecord(Integer domainId,
                                    Integer recordId)
Description copied from interface: DigitalOcean
To be release in v1.1

Specified by:
getDomainRecord in interface DigitalOcean

createDomainRecord

public DomainRecord createDomainRecord(DomainRecord domainRecord)
Description copied from interface: DigitalOcean
To be release in v1.1

Specified by:
createDomainRecord in interface DigitalOcean

editDomainRecord

public DomainRecord editDomainRecord(DomainRecord domainRecord)
Description copied from interface: DigitalOcean
To be release in v1.1

Specified by:
editDomainRecord in interface DigitalOcean

deleteDomainRecord

public Response deleteDomainRecord(Integer domainId,
                                   Integer recordId)
Description copied from interface: DigitalOcean
To be release in v1.1

Specified by:
deleteDomainRecord in interface DigitalOcean

DigitalOcean API Client in Java

Copyright © 2013 myjeeva.com, All rights reserved.

The copyright of the pages and contents on this website is with myjeeva.com and the content is licensed under Creative Commons Attribution-Share Alike 3.0 Unported License. Libraries and code snippets on myjeeva.com has license information.