8784: Fix test for latest firefox.
[arvados.git] / doc / sdk / ruby / example.html.textile.liquid
1 ---
2 layout: default
3 navsection: sdk
4 navmenu: Python
5 title: Examples
6 ...
7
8 h2.  Initialize SDK
9
10 Import the module and set up an API client user agent:
11
12 <pre>
13 require 'arvados'
14 arv = Arvados.new(apiVersion: 'v1')
15 </pre>
16
17 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.
18
19 h2. create
20
21 Create an object:
22
23 <pre>
24 new_link = arv.link.create(link: {link_class: 'test', name: 'test'})
25 </pre>
26
27 h2. delete
28
29 Delete an object:
30
31 <pre>
32 arv.link.delete(uuid: new_link[:uuid])
33 </pre>
34
35 h2. get
36
37 Retrieve an object by ID:
38
39 <pre>
40 some_user = arv.user.get(uuid: current_user_uuid)
41 </pre>
42
43 h2. list
44
45 Get a list of objects:
46
47 <pre>
48 repos = arv.repository.list
49 first_repo = repos[:items][0]
50 puts "UUID of first repo returned is #{first_repo[:uuid]}"</code>
51 UUID of first repo returned is qr1hi-s0uqq-b1bnybpx3u5temz
52 </pre>
53
54 h2. update
55
56 Update an object:
57
58 <pre>
59 updated_link = arv.link.update(uuid: new_link[:uuid],
60                                link: {properties: {foo: 'bar'}})
61 </pre>
62
63 h2. Get current user
64
65 Get the User object for the current user:
66
67 <pre>
68 current_user = arv.user.current
69 </pre>
70
71 Get the UUID of an object that was retrieved using the SDK:
72
73 <pre>
74 current_user_uuid = current_user[:uuid]
75 </pre>