Connecting to the REST API using Ruby
The beauty of RESTful services and using JSON or XML to communicate over the web is that you can use any modern language (and many not-so-modern languages) to quickly and efficiently talk to OneOps. Since, so far, all our coding has been in Ruby, or to be specific in Chef, we will be using Ruby as an example language for this chapter. However, since the resources are idempotent, the language itself rarely matters. Before we can start using Ruby though, let's make sure that the appropriate dependencies are satisfied. Since we will be building our own custom REST client, we will be using a Ruby gem named rest-client
. You can install it using the command:
gem install rest-client
Also, make sure that gem json
is installed. You can install it by running the following command:
gem install json
For rest-client
, you should have MRI Ruby 2.0 or higher installed. If you are trying this from a OneOps instance, then Ruby 2.0 or higher should already...