Lampros - Weird Bricks

Accessing the Atlantic.net API through Ruby

02 January, 2015 | Atlantic.net

So I'm using Atlantic.net more and more and I figured it'd be nice to be able to access their API using Ruby.

At the moment they have Bash scripts to access their API (unfortunately the Bash scripts also have some Perl requirements) and a PHP example - so here's a little piece of code that allows you to list your instances using the API through Ruby.

In the future as time allows I hope to implement the rest of the functions and release the whole thing as a gem.

To get this running on a FreeBSD 10 instance:

1. Install Ruby 2.0 and the required gems:

env ASSUME_ALWAYS_YES=YES pkg install ruby ruby20-gems rubygem-uuidtools rubygem-rest-client

2. Get the code:

fetch https://gist.githubusercontent.com/weirdbricks/1fc0b7563a14fcbbdcaa/raw/44d102608c04d591dbff942d41d18a09c6cd44f4/script.rb --no-verify-peer

3. Edit the file 'script.rb' and replace the 'ACSAccessKeyId' and 'api_private_key ' with your Access key and Private key.

4. Run it:

ruby script.rb

You'll get the list of your running servers formatted in JSON.