Simple & Lightweight API client library for Enterprise Application or Utilities Integration around DigitalOcean RESTful APIs. You can use this library with project based (JVM hosted languages) on Java, Groovy, Scala, Clojure, etc.
Give your support by clicking Hearts on DigitalOcean Developers Community.
For handy use, DigitalOcean API Client library project dependency definition provided below or you wanna jar Download it from Maven central repo.
Note: master branch maps to v2 APIs and digitalocean turned off v1 APIs as on Nov 9, 2015 .
Maven dependency
<dependency>
<groupId>com.myjeeva.digitalocean</groupId>
<artifactId>digitalocean-api-client</artifactId>
<version>2.17</version>
</dependency>
Gradle/Grails dependency
compile 'com.myjeeva.digitalocean:digitalocean-api-client:2.17'
Groovy Grape
@Grapes(
@Grab(group='com.myjeeva.digitalocean', module='digitalocean-api-client', version='2.17')
)
Scala SBT
libraryDependencies += "com.myjeeva.digitalocean" % "digitalocean-api-client" % "2.17"
Note:
httpclient-android
library explicitly in your project dependencies.vx.x-SNAPSHOT
is available between the release version. Snapshot is update to with master
branch.For API documentation see:
For Example usage see:
Creating a DigitalOcean Client in three simple ways!
// Way one, just pass on authToken
DigitalOcean apiClient = new DigitalOceanClient(authToken);
// Way two, pass on version number & authToken
DigitalOcean apiClient = new DigitalOceanClient("v2", authToken);
// Way three, pass on version number, authToken & httpClient
// Go ahead and customize httpClient attributes for requirements
CloseableHttpClient httpClient = HttpClients.createDefault();
DigitalOcean apiClient = new DigitalOceanClient("v2", authToken, httpClient);
Let's invoke the method(s) as per need via apiClient
// Fetching all the available droplets from control panel
Droplets droplets = apiClient.getAvailableDroplets(pageNo, perPage);
// Fetching all the available kernels for droplet
Kernels kernels = apiClient.getAvailableKernels(dropletId, pageNo, perPage);
// Create a new droplet
Droplet newDroplet = new Droplet();
newDroplet.setName("api-client-test-host");
newDroplet.setSize(new Size("512mb")); // setting size by slug value
newDroplet.setRegion(new Region("sgp1")); // setting region by slug value; sgp1 => Singapore 1 Data center
newDroplet.setImage(new Image(1601)); // setting by Image Id 1601 => centos-5-8-x64 also available in image slug value
newDroplet.setEnableBackup(Boolean.TRUE);
newDroplet.setEnableIpv6(Boolean.TRUE);
newDroplet.setEnablePrivateNetworking(Boolean.TRUE);
// Adding SSH key info
List<Key> keys = new ArrayList<Key>();
keys.add(new Key(6536653));
keys.add(new Key(6536654));
newDroplet.setKeys(keys);
// Adding Metadata API - User Data
newDroplet.setUserData(" < YAML Content > "); // Follow DigitalOcean documentation to prepare user_data value
Droplet droplet = apiClient.createDroplet(newDroplet);
// Creating multiple droplets
Droplet droplet = new Droplet();
droplet.setNames(Arrays.asList("sub-01.example.com", "sub-02.example.com"));
droplet.setSize("512mb");
droplet.setImage(new Image("ubuntu-14-04-x64"));
droplet.setRegion(new Region("nyc1"));
Droplets droplets = apiClient.createDroplets(droplet);
// Fetch droplet information
Droplet droplet = apiClient.getDropletInfo(dropletId);
// Fetch Available Plans/Sizes supported by DigitalOcean
Sizes sizes = apiClient.getAvailableSizes(pageNo);
// Fetch Available Regions supported by DigitalOcean
Regions regions = apiClient.getAvailableRegions(pageNo);
Accessing RateLimit
header values from return object. This is applicable for all requests.
Droplets droplets = getAvailableDroplets(1, 20);
RateLimit rateLimit = droplets.getRateLimit();
Actions actions = getAvailableActions(2, 40);
RateLimit rateLimit = actions.getRateLimit();
Domain domain = getDomainInfo("myjeeva.com");
RateLimit rateLimit = domain.getRateLimit();
Droplet droplet = getDropletInfo(10000001);
RateLimit rateLimit = droplet.getRateLimit();
DigitalOcean API Client uses GitHub’s integrated issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations bellow:
Refer to CHANGELOG.md
Jeevanandam M. - [email protected]
Please refer to https://github.com/jeevatkm/digitalocean-api-java/graphs/contributors
git checkout -b my-new-feature
./mvnw com.coveo:fmt-maven-plugin:format
./mvnw verify
git commit -am 'Added feature'
git push origin my-new-feature
DigitalOcean API Client - MIT License.