Lines 10 and 11 simply pass our username and password variables – RestClient will automatically convert these to base64 for us and include them in the headers of the call with basic authentication – something which we would normally have to do manually (another reason I chose RestClient). Line 9 defines the URI and resource we want to retrieve the data from, in our case, the vmware/vm resource from the Rubrik cluster – passing our vmname variable within the URI narrows down the results to only those which match. As shown, we can see that Line 8 defines the method of the API request, in our case GET – meaning we are going to GET some information. So let’s break this down a little bit – Lines 7 through 13 encompass our actual API request.
To install RestClient it’s as simple as running gem install rest-client. RestClient is a Ruby gem – a gem is basically a library that contains specific pieces of functionality – think of it like an SDK almost, or in. Now there is no right or wrong package to chose, but in my experience, RestClient seemed to be the easiest to work with (that said I haven’t had the chance to check out all of the Ruby packages related to REST).
So, without further ado – here’s a quick hit on how to consume APIs using Ruby…īefore we get too far I want to mention that like almost anything there are many ways to consume an API within Ruby – I explored a few of them – net/http, HTTParty, and RestClient. net and java to other languages – with the first being Ruby. It’s quick to learn, quick to pick up, and quick to execute – so with that, I decided to expand my development horizon beyond just. That said, I love to learn new things, new languages, new ways of accomplishing similar goals – and the standard RESTful architecture provides a pretty good breeding ground for just that. In fact, my college education set me on a path to become a developer – 3 years of Java and some real-world experience changed my mind though – while I find the challenge of development rewarding, I hate when projects turn into these long drawn out time development time suckers. For those that don’t know me, I have somewhat of a love/hate relationship when it comes to development – I love doing it – I really do. One area that I love about Rubrik is its openness as it pertains their API implementation – and with that comes some amazing inline documentation on how to consume them. That said we are really encouraged as TME’s at Rubrik to expand – to learn new things, pick up new skills – even to the point where we can carve off time to do so. See or the accompanying file.Over the past four months at Rubrik I’ve got the chance to do a lot of things – presentations, content creation, webinars – all the normal enabling Tech Marketing things one would expect.
This is free and unencumbered public domain software. Note that the agreement applies to all repos in the Ruby RDF organization. Which you will be asked to agree to on the first commit to a repo within the organization. Of thumb, additions larger than about 15 lines of code), we need anĮxplicit public domain dedication on record from you,
Tutorial or just look at the existing code for examples. Do document every method you add using YARD annotations.Don’t use hard tabs, and don’t leave trailing whitespace on any line.Do your best to adhere to the existing coding conventions and idioms.All submissions must be on a feature branch based on the develop branch to ease staging and integration. This repository uses Git Flow to mange development and release activity.