9 The Ruby SDK provides a generic set of wrappers so you can make API calls easily.
13 If you are logged in to an Arvados VM, the Ruby SDK should be installed.
15 To use it elsewhere, you can either install the @arvados@ gem via RubyGems or build and install the package using the arvados source tree.
17 h4. Prerequisites: Ruby >= 2.0.0
19 You can use "RVM":http://rvm.io/rvm/install to install and manage Ruby versions.
21 h4. Option 1: install with RubyGems
25 $ <code class="userinput">sudo gem install arvados</code>
29 h4. Option 2: build and install from source
33 $ <code class="userinput">git clone https://github.com/curoverse/arvados.git</code>
34 $ <code class="userinput">cd arvados/sdk/ruby</code>
35 $ <code class="userinput">gem build arvados.gemspec</code>
36 $ <code class="userinput">sudo gem install arvados-*.gem</code>
42 If the SDK is installed, @ruby -r arvados -e 'puts "OK!"'@ should produce no errors.
44 If your @ARVADOS_API_HOST@ and @ARVADOS_API_TOKEN@ environment variables are set up correctly (see "api-tokens":{{site.baseurl}}/user/reference/api-tokens.html for details), the following test script should work:
47 <pre>$ <code class="userinput">ruby -r arvados <<'EOF'
48 arv = Arvados.new api_version: 'v1'
49 my_full_name = arv.user.current[:full_name]
50 puts "arvados.v1.users.current.full_name = '#{my_full_name}'"
52 arvados.v1.users.current.full_name = 'Your Name'
58 Import the module (we skipped this step above by using "ruby -r arvados"):
61 <pre><code class="userinput">require 'arvados'
65 Set up an API client user agent:
68 <pre><code class="userinput">arv = Arvados.new(apiVersion: 'v1')
72 Get the User object for the current user:
75 <pre><code class="userinput">current_user = arv.user.current
79 Get the UUID of an object that was retrieved using the SDK:
82 <pre><code class="userinput">current_user_uuid = current_user[:uuid]
86 Retrieve an object by ID:
89 <pre><code class="userinput">some_user = arv.user.get(uuid: current_user_uuid)
96 <pre><code class="userinput">new_link = arv.link.create(link: {link_class: 'test', name: 'test'})
103 <pre><code class="userinput">updated_link = arv.link.update(uuid: new_link[:uuid],
104 link: {properties: {foo: 'bar'}})
111 <pre><code class="userinput">arv.link.delete(uuid: new_link[:uuid])
115 Get a list of objects:
118 <pre><code class="userinput">repos = arv.repository.list
119 first_repo = repos[:items][0]
120 puts "UUID of first repo returned is #{first_repo[:uuid]}"</code>
121 UUID of first repo returned is qr1hi-s0uqq-b1bnybpx3u5temz
125 The SDK retrieves the list of API methods from the server at run time. Therefore, the set of available methods is determined by the server version rather than the SDK version.