Add 'apps/arv-web/' from commit 'f9732ad8460d013c2f28363655d0d1b91894dca5'
[arvados.git] / doc / sdk / perl / index.html.textile.liquid
1 ---
2 layout: default
3 navsection: sdk
4 navmenu: Perl
5 title: "Perl SDK"
6
7 ...
8
9 The Perl SDK provides a generic set of wrappers so you can make API calls easily.
10
11 It should be treated as alpha/experimental. Currently, limitations include:
12 * Verbose syntax.
13 * No native Keep client.
14 * No CPAN package.
15
16 h3. Installation
17
18 <notextile>
19 <pre>
20 $ <code class="userinput">sudo apt-get install libjson-perl libio-socket-ssl-perl libwww-perl libipc-system-simple-perl</code>
21 $ <code class="userinput">git clone https://github.com/curoverse/arvados.git</code>
22 $ <code class="userinput">cd arvados/sdk/perl</code>
23 $ <code class="userinput">perl Makefile.PL</code>
24 $ <code class="userinput">sudo make install</code>
25 </pre>
26 </notextile>
27
28 h4. Test installation
29
30 If the SDK is installed, @perl -MArvados -e ''@ should produce no errors.
31
32 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:
33
34 <notextile>
35 <pre>$ <code class="userinput">perl &lt;&lt;'EOF'
36 use Arvados;
37 my $arv = Arvados-&gt;new('apiVersion' => 'v1');
38 my $me = $arv-&gt;{'users'}-&gt;{'current'}-&gt;execute;
39 print ("arvados.v1.users.current.full_name = '", $me-&gt;{'full_name'}, "'\n");
40 EOF</code>
41 arvados.v1.users.current.full_name = 'Your Name'
42 </pre>
43 </notextile>
44
45 h3. Examples
46
47 Set up an API client user agent:
48
49 <notextile>
50 <pre><code class="userinput">my $arv = Arvados->new('apiVersion' => 'v1');
51 </code></pre>
52 </notextile>
53
54 Get the User object for the current user:
55
56 <notextile>
57 <pre><code class="userinput">my $current_user = $arv->{'users'}->{'current'}->execute;
58 </code></pre>
59 </notextile>
60
61 Get the UUID of an object that was retrieved using the SDK:
62
63 <notextile>
64 <pre><code class="userinput">my $current_user_uuid = $current_user->{'uuid'}
65 </code></pre>
66 </notextile>
67
68 Retrieve an object by ID:
69
70 <notextile>
71 <pre><code class="userinput">my $some_user = $arv->{'users'}->{'get'}->execute('uuid' => $current_user_uuid);
72 </code></pre>
73 </notextile>
74
75 Create an object:
76
77 <notextile>
78 <pre><code class="userinput">my $test_link = $arv->{'links'}->{'create'}->execute('link' => { 'link_class' => 'test', 'name' => 'test' });
79 </code></pre>
80 </notextile>
81
82 Update an object:
83
84 <notextile>
85 <pre><code class="userinput">my $test_link = $arv->{'links'}->{'update'}->execute(
86         'uuid' => $test_link->{'uuid'},
87         'link' => { 'properties' => { 'foo' => 'bar' } });
88 </code></pre>
89 </notextile>
90
91 Get a list of objects:
92
93 <notextile>
94 <pre><code class="userinput">my $repos = $arv->{'repositories'}->{'list'}->execute;
95 print ("UUID of first repo returned is ", $repos->{'items'}->[0], "\n");
96 </code></pre>
97 </notextile>
98
99 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.