Add perl-Crypt-SSLeay as a Perl SDK dependency on Red Hat.
[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 h4. Option 1: Install from distribution packages
19
20 First, "add the appropriate package repository for your distribution":{{ site.baseurl }}/install/install-manual-prerequisites.html#repos.
21
22 On Debian-based systems:
23
24 <notextile>
25 <pre><code>~$ <span class="userinput">sudo apt-get install libjson-perl libio-socket-ssl-perl libwww-perl libipc-system-simple-perl libarvados-perl</code>
26 </code></pre>
27 </notextile>
28
29 On Red Hat-based systems:
30
31 <notextile>
32 <pre><code>~$ <span class="userinput">sudo yum install perl-ExtUtils-MakeMaker perl-JSON perl-IO-Socket-SSL perl-Crypt-SSLeay perl-WWW-Curl libarvados-perl</code>
33 </code></pre>
34 </notextile>
35
36 h4. Option 2: Install from source
37
38 First, install dependencies from your distribution.  Refer to the package lists above, but don't install @libarvados-perl@.
39
40 Then run the following:
41
42 <notextile>
43 <pre><code>~$ <span class="userinput">git clone https://github.com/curoverse/arvados.git</span>
44 ~$ <span class="userinput">cd arvados/sdk/perl</span>
45 ~$ <span class="userinput">perl Makefile.PL</span>
46 ~$ <span class="userinput">sudo make install</span>
47 </code></pre>
48 </notextile>
49
50 h3. Test installation
51
52 If the SDK is installed, @perl -MArvados -e ''@ should produce no errors.
53
54 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:
55
56 <notextile>
57 <pre>~$ <code class="userinput">perl &lt;&lt;'EOF'
58 use Arvados;
59 my $arv = Arvados-&gt;new('apiVersion' => 'v1');
60 my $me = $arv-&gt;{'users'}-&gt;{'current'}-&gt;execute;
61 print ("arvados.v1.users.current.full_name = '", $me-&gt;{'full_name'}, "'\n");
62 EOF</code>
63 arvados.v1.users.current.full_name = 'Your Name'
64 </pre>
65 </notextile>
66
67 h3. Examples
68
69 Set up an API client user agent:
70
71 <notextile>
72 <pre><code class="userinput">my $arv = Arvados->new('apiVersion' => 'v1');
73 </code></pre>
74 </notextile>
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>
82
83 Get the UUID of an object that was retrieved using the SDK:
84
85 <notextile>
86 <pre><code class="userinput">my $current_user_uuid = $current_user->{'uuid'}
87 </code></pre>
88 </notextile>
89
90 Retrieve an object by ID:
91
92 <notextile>
93 <pre><code class="userinput">my $some_user = $arv->{'users'}->{'get'}->execute('uuid' => $current_user_uuid);
94 </code></pre>
95 </notextile>
96
97 Create an object:
98
99 <notextile>
100 <pre><code class="userinput">my $test_link = $arv->{'links'}->{'create'}->execute('link' => { 'link_class' => 'test', 'name' => 'test' });
101 </code></pre>
102 </notextile>
103
104 Update an object:
105
106 <notextile>
107 <pre><code class="userinput">my $test_link = $arv->{'links'}->{'update'}->execute(
108         'uuid' => $test_link->{'uuid'},
109         'link' => { 'properties' => { 'foo' => 'bar' } });
110 </code></pre>
111 </notextile>
112
113 Get a list of objects:
114
115 <notextile>
116 <pre><code class="userinput">my $repos = $arv->{'repositories'}->{'list'}->execute;
117 print ("UUID of first repo returned is ", $repos->{'items'}->[0], "\n");
118 </code></pre>
119 </notextile>
120
121 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.