Giter VIP home page Giter VIP logo

digitalocean-api-java's Introduction

DigitalOcean API Client Build Status License

Welcome to DigitalOcean API Client written in Java. Simple and meaningful wrapper methods for DigitalOcean RESTful APIs. You can use this library with project based (JVM hosted languages) on Java, Groovy, Scala, Clojure, etc.

Simple and Lightweight Library for Enterprise Application or Utilities Integration

Give your support by clicking Hearts here DigitalOcean API Client in Java :)

Getting Started

DigitalOcean API Client library's few project dependency definition mentioned below or Download it, master branch maps to V2 APIs since v1 is no longer active.

Maven dependency

<dependency>
    <groupId>com.myjeeva.digitalocean</groupId>
    <artifactId>digitalocean-api-client</artifactId>
    <version>2.3</version>
</dependency>

Gradle/Grails dependency

compile 'com.myjeeva.digitalocean:digitalocean-api-client:2.3'

Groovy Grape

@Grapes( 
@Grab(group='com.myjeeva.digitalocean', module='digitalocean-api-client', version='2.3') 
)

Scala SBT

libraryDependencies += "com.myjeeva.digitalocean" % "digitalocean-api-client" % "2.3"

Note: For Android projects, kindly indlude the httpclient-android library explicitly in your project dependencies.


Getting Help

For API documentation see:

For Example usage see:

Samples

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. Note: 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();

Reporting Issues

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:

  • Before you log a bug, please search the issue tracker to see if someone has already reported the problem. If the issue doesn’t already exist, create a new issue.
  • Please provide as much information as possible with the issue report, we like to know the version of DigitalOcean API Client that you are using.
  • If you need to paste code, or include a stack trace use Markdown ``` escapes before and after your text.

Supported API's and Revision Logs

  • Released in v2.3
    • Action enableDropletBackups(Integer dropletId)
    • Droplets createDroplets(Droplet droplet)
    • Added floating_ip_limit attribute into Account class
    • updateDomainRecord() method accepts DomainRecord as an input parameter
    • per_page parameter added to all the supported APIs
    • Floating IPs
      FloatingIPs getAvailableFloatingIPs(Integer pageNo, Integer perPage)
      FloatingIP createFloatingIP(Integer dropletId)
      FloatingIP createFloatingIP(String region)
      FloatingIP getFloatingIPInfo(String ipAddress)
      Delete deleteFloatingIP(String ipAddress)
      
    • Floating IPs Actions
      Action assignFloatingIP(Integer dropletId, String ipAddress)
      Action unassignFloatingIP(String ipAddress)
      Actions getAvailableFloatingIPActions(String ipAddress, Integer pageNo, Integer perPage)
      Action getFloatingIPActionInfo(String ipAddress, Integer actionId)
      
  • Released in v2.2
  • Released in v2.1
    • Enhancements
      • Libs version upgraded to latest
      • Less objects generation
  • Released in v2.0
    • Account
    Account getAccountInfo()
    • Actions
      Actions getAvailableActions(Integer pageNo, Integer perPage)
      Actions getAvailableDropletActions(Integer dropletId, Integer pageNo, Integer perPage)
      Actions getAvailableImageActions(Integer imageId, Integer pageNo, Integer perPage)
      Action getActionInfo(Integer actionId)
    • Droplets
      Droplets getAvailableDroplets(Integer pageNo, Integer perPage)
      Kernels getAvailableKernels(Integer dropletId, Integer pageNo, Integer perPage)
      Snapshots getAvailableSnapshots(Integer dropletId, Integer pageNo, Integer perPage)
      Backups	getAvailableBackups(Integer dropletId, Integer pageNo)
      Droplet	getDropletInfo(Integer dropletId)
      Droplet	createDroplet(Droplet droplet)
      Delete deleteDroplet(Integer dropletId)
      Droplets getDropletNeighbors(Integer dropletId, Integer pageNo)
      Neighbors getAllDropletNeighbors(Integer pageNo)
      
    • Droplet Actions
      Action powerCycleDroplet(Integer dropletId)
      Action powerOffDroplet(Integer dropletId)
      Action powerOnDroplet(Integer dropletId)
      Action rebootDroplet(Integer dropletId)
      Action rebuildDroplet(Integer dropletId, Integer imageId)
      Action renameDroplet(Integer dropletId, String name)
      Action resetDropletPassword(Integer dropletId)
      Action resizeDroplet(Integer dropletId, String size)
      Action restoreDroplet(Integer dropletId, Integer imageId)
      Action shutdownDroplet(Integer dropletId)
      Action takeDropletSnapshot(Integer dropletId)
      Action takeDropletSnapshot(Integer dropletId, String snapshotName)
      Action disableDropletBackups(Integer dropletId)
      Action enableDropletIpv6(Integer dropletId)
      Action enableDropletPrivateNetworking(Integer dropletId)
      Action changeDropletKernel(Integer dropletId, Integer kernelId)
      
    • Images
      Images getAvailableImages(Integer pageNo, Integer perPage)
      Images getAvailableImages(Integer pageNo, Integer perPage, ActionType type)
      Image getImageInfo(Integer imageId)
      Image getImageInfo(String slug)
      Image updateImage(Image image)
      Delete deleteImage(Integer imageId)
      Action transferImage(Integer imageId, String regionSlug)
      Action convertImage(Integer imageId)
      Images getUserImages(Integer pageNo, Integer perPage)
      
    • Sizes
    Sizes getAvailableSizes(Integer pageNo)
    • Regions
    Regions getAvailableRegions(Integer pageNo)
    • Domains
      Domains	getAvailableDomains(Integer pageNo)
      Domain getDomainInfo(String domainName)
      Domain createDomain(Domain domain)
      Delete deleteDomain(String domainName)
      
    • Domain Records
      DomainRecords getDomainRecords(String domainName)
      DomainRecord getDomainRecordInfo(String domainName, Integer recordId)
      DomainRecord createDomainRecord(String domainName, DomainRecord domainRecord)
      DomainRecord updateDomainRecord(String domainName, Integer recordId, String name)
      Delete deleteDomainRecord(String domainName, Integer recordId)
      
    • Keys
      Keys getAvailableKeys(Integer pageNo)
      Key	getKeyInfo(Integer sshKeyId)
      Key	getKeyInfo(String fingerprint)
      Key	createKey(Key newKey)
      Key	updateKey(Integer sshKeyId, String newSshKeyName)
      Key	updateKey(String fingerprint, String newSshKeyName)
      Delete deleteKey(Integer sshKeyId)
      Delete deleteKey(String fingerprint)
      

Author

Jeevanandam M. - [email protected]

Contributing

  1. Fork it
  2. Create your feature branch - git checkout -b my-new-feature
  3. Implement your changes and apply Google Java Code Formatter
  4. Commit your changes - git commit -am 'Add some feature'
  5. Push to the branch - git push origin my-new-feature
  6. Create new Pull Request

License

DigitalOcean API Client - MIT License.

digitalocean-api-java's People

Contributors

jeevatkm avatar pulse00 avatar behrica avatar emanuell avatar beolnix avatar zacorich avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.