8784: Fix test for latest firefox.
[arvados.git] / doc / sdk / perl / example.html.textile.liquid
1 ---
2 layout: default
3 navsection: sdk
4 navmenu: Perl
5 title: "Examples"
6 ...
7
8 h2. Initialize SDK
9
10 Set up an API client user agent:
11
12 <notextile>
13 <pre><code class="userinput">
14 use Arvados;
15 my $arv = Arvados->new('apiVersion' => 'v1');
16 </code></pre>
17 </notextile>
18
19 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.
20
21 h2. create
22
23 Create an object:
24
25 <notextile>
26 <pre><code class="userinput">my $test_link = $arv->{'links'}->{'create'}->execute('link' => { 'link_class' => 'test', 'name' => 'test' });
27 </code></pre>
28 </notextile>
29
30 h2. delete
31
32 <notextile>
33 <pre><code class="userinput">my $some_user = $arv->{'collections'}->{'get'}->execute('uuid' => $collection_uuid);
34 </code></pre>
35 </notextile>
36
37 h2. get
38
39 Retrieve an object by ID:
40
41 <notextile>
42 <pre><code class="userinput">my $some_user = $arv->{'users'}->{'get'}->execute('uuid' => $current_user_uuid);
43 </code></pre>
44 </notextile>
45
46 Get the UUID of an object that was retrieved using the SDK:
47
48 <notextile>
49 <pre><code class="userinput">my $current_user_uuid = $current_user->{'uuid'}
50 </code></pre>
51 </notextile>
52
53 h2. list
54
55 Get a list of objects:
56
57 <notextile>
58 <pre><code class="userinput">my $repos = $arv->{'repositories'}->{'list'}->execute;
59 print ("UUID of first repo returned is ", $repos->{'items'}->[0], "\n");
60 </code></pre>
61 </notextile>
62
63 h2. update
64
65 Update an object:
66
67 <notextile>
68 <pre><code class="userinput">my $test_link = $arv->{'links'}->{'update'}->execute(
69         'uuid' => $test_link->{'uuid'},
70         'link' => { 'properties' => { 'foo' => 'bar' } });
71 </code></pre>
72 </notextile>
73
74 h2. Get current user
75
76 Get the User object for the current user:
77
78 <notextile>
79 <pre><code class="userinput">my $current_user = $arv->{'users'}->{'current'}->execute;
80 </code></pre>
81 </notextile>