Coder Social home page Coder Social logo

digitalocean's Introduction

digitalocean

Scala wrapper around Digital Ocean's API, version 2

This API is entirely asynchronous, so you'll want to know how to use Futures. Some classes have a "complete" method that perform several operations for you so that you can know if an operation such as Droplet.create or an action have completed. "complete" methods also return futures.

##Scaladoc

http://www.jeffshaw.me/digitalocean/

##Instructions

###Dependency

This project is now in Maven Central for Scala 2.10 and 2.11. You can add it to your dependencies in your project's sbt file.

libraryDependencies += "me.jeffshaw" %% "digitalocean" % "1.0"

Or, for a maven project:

<dependency>
  <groupId>me.jeffshaw</groupId>
  <artifactId>digitalocean_2.11</artifactId>
  <version>1.0</version>
</dependency>

###Local Compilation

Install SBT, clone this repository, and cd to it.

sbt

console
//use :paste if you want to copy-paste the following, but be sure to set your api token first.

import scala.concurrent._, duration._, ExecutionContext.Implicits._
import me.jeffshaw.digitalocean._

implicit val client = DigitalOceanClient(
  token = "",
  maxWaitPerRequest = 5 seconds,
  //The following is used for polling action completion.
  actionCheckInterval = 15 seconds
)

//List all the regions.
val regions = Await.result(Region.list, 5 seconds)

//Create a small CentOS 6.5 32-bit droplet.
val droplet =
  Await.result(
    Droplet.create(
      name = "test",
      region = NewYork2,
      size = `512mb`,
      image = 11523060,
      sshKeys = Seq.empty,
      backups = false,
      ipv6 = false,
      privateNetworking = false,
      userData = None
    ),
    atMost = 10 seconds
  )

//Wait for the droplet to become active.
Await.result(droplet.complete, 2 minutes)

//Do stuff with the droplet.

//Run the delete the command, and then wait for the droplet to stop existing.

Await.result(droplet.delete.flatMap(_.complete), 2 minutes)

//CTRL-D if you used :paste.

To run tests, set your api token in src/test/resources/application.conf, and then run test in the sbt console.

##Changelog

1.0

  • Add Frankfurt1 to the Region enumeration.
  • OAuth support may come in a future 2.0 release.

0.8

  • Update to account for March 20 changes.
  • Fix SSH key functionality, and added tests for SshKey thanks to bass3t.

0.7

Droplet creation has changed to return less information about the droplet. My solution is to just read the ID, and then ask for all the information in a second request.

0.6

Metadata functionality added to the metadata package.

0.5

DNS functionality added to the dns package.

0.2

List functions now return iterators that support paged responses.

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.