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