3 Arvados -- client library for Arvados services
8 $arv = Arvados->new(apiHost => 'arvados.local');
10 my $instances = $arv->{'pipeline_instances'}->{'list'}->execute();
11 print "UUID is ", $instances->{'items'}->[0]->{'uuid'}, "\n";
13 $uuid = 'eiv0u-arx5y-2c5ovx43zw90gvh';
14 $instance = $arv->{'pipeline_instances'}->{'get'}->execute('uuid' => $uuid);
15 print "ETag is ", $instance->{'etag'}, "\n";
17 $instance->{'active'} = 1;
18 $instance->{'name'} = '';
20 print "ETag is ", $instance->{'etag'}, "\n";
26 my $whc = Arvados->new( %OPTIONS );
28 Set up a client and retrieve the schema from the server.
36 Hostname of API discovery service. Default: C<ARVADOS_API_HOST>
37 environment variable, or C<arvados>
39 =item apiProtocolScheme
41 Protocol scheme. Default: C<ARVADOS_API_PROTOCOL_SCHEME> environment
46 Authorization token. Default: C<ARVADOS_API_TOKEN> environment variable
62 use Net::SSL (); # From Crypt-SSLeay
64 $Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL
69 use Arvados::ResourceAccessor;
70 use Arvados::ResourceMethod;
71 use Arvados::ResourceProxy;
72 use Arvados::ResourceProxyList;
76 $Arvados::VERSION = 0.1;
83 bless ($self, $class);
84 return $self->build(@_);
91 $config = load_config_file("$ENV{HOME}/.config/arvados/settings.conf");
93 $self->{'authToken'} ||=
94 $ENV{ARVADOS_API_TOKEN} || $config->{ARVADOS_API_TOKEN};
96 $self->{'apiHost'} ||=
97 $ENV{ARVADOS_API_HOST} || $config->{ARVADOS_API_HOST};
99 $self->{'noVerifyHostname'} ||=
100 $ENV{ARVADOS_API_HOST_INSECURE};
102 $self->{'apiProtocolScheme'} ||=
103 $ENV{ARVADOS_API_PROTOCOL_SCHEME} ||
104 $config->{ARVADOS_API_PROTOCOL_SCHEME};
106 $self->{'ua'} = new Arvados::Request;
108 my $host = $self->{'apiHost'} || 'arvados';
109 my $service = $self->{'apiService'} || 'arvados';
110 my $version = $self->{'apiVersion'} || 'v1';
111 my $scheme = $self->{'apiProtocolScheme'} || 'https';
112 my $uri = "$scheme://$host/discovery/v1/apis/$service/$version/rest";
113 my $r = $self->new_request;
115 $r->set_method("GET");
116 $r->process_request();
118 my ($status_number, $status_phrase) = $r->get_status();
119 $data = $r->get_body() if $status_number == 200;
120 $headers = $r->get_headers();
122 my $doc = $self->{'discoveryDocument'} = JSON::decode_json($data);
123 print STDERR Dumper $doc if $ENV{'DEBUG_ARVADOS_API_DISCOVERY'};
125 while (($k, $v) = each %{$doc->{'resources'}}) {
126 $self->{$k} = Arvados::ResourceAccessor->new($self, $k);
129 croak "No discovery doc at $uri - $status_number $status_phrase";
137 local $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'};
138 if ($self{'noVerifyHostname'} || ($host =~ /\.local$/)) {
139 $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
141 Arvados::Request->new();
144 sub load_config_file ($)
146 my $config_file = shift;
149 if (open (CONF, $config_file)) {
151 next if /^\s*#/ || /^\s*$/; # skip comments and blank lines
153 my ($key, $val) = split /\s*=\s*/, $_, 2;
154 $config{$key} = $val;