RubyMotion library for version 2 of DigitalOcean's API
Please note that version 2 of DigitalOcean's API is in beta, and is still being developed. Everything is subject to change.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install motion_ocean
client = MotionOcean::Client.new(access_token: 'token')
client = MotionOcean::Client.new do |config| config.access_token = 'token' end
The API client is based on NSURLSession and every request is executed asynchronously. Every MotionOcean method call therefore requires a block, which yields a
MotionOcean pretty much implements the DO API 1:1, so please check their documentation for the available functions and options.
The response object
You can use
success? to check if a successful HTTP status code was returned:
client.droplet.create(options) do |result| result.success? # => true end
The response data is assigned to the
data-property of the response object. This is a
corresponds with the returned JSON by DigitalOcean.
client.droplet.create(options) do |result| result.data # => Hash with the JSON response end
MotionOcean uses NSURLSession. You can use
response to get to the original response
client.droplet.create(options) do |result| result.response # => NSHTTPURLResponse end
When there is an error you can check this for the specific error. If you think it is a bug in MotionOcean, please open an issue or even better: submit a Pull Request with the fix!
- Fork it ( https://github.com/datarift/motion_ocean/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request