1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
7 Arvados -- client library for Arvados services
12 $arv = Arvados->new(apiHost => 'arvados.local');
14 my $instances = $arv->{'pipeline_instances'}->{'list'}->execute();
15 print "UUID is ", $instances->{'items'}->[0]->{'uuid'}, "\n";
17 $uuid = 'eiv0u-arx5y-2c5ovx43zw90gvh';
18 $instance = $arv->{'pipeline_instances'}->{'get'}->execute('uuid' => $uuid);
19 print "ETag is ", $instance->{'etag'}, "\n";
21 $instance->{'active'} = 1;
22 $instance->{'name'} = '';
24 print "ETag is ", $instance->{'etag'}, "\n";
30 my $whc = Arvados->new( %OPTIONS );
32 Set up a client and retrieve the schema from the server.
40 Hostname of API discovery service. Default: C<ARVADOS_API_HOST>
41 environment variable, or C<arvados>
43 =item apiProtocolScheme
45 Protocol scheme. Default: C<ARVADOS_API_PROTOCOL_SCHEME> environment
50 Authorization token. Default: C<ARVADOS_API_TOKEN> environment variable
66 use Net::SSL (); # From Crypt-SSLeay
68 $Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL
73 use Arvados::ResourceAccessor;
74 use Arvados::ResourceMethod;
75 use Arvados::ResourceProxy;
76 use Arvados::ResourceProxyList;
80 $Arvados::VERSION = 0.1;
87 bless ($self, $class);
88 return $self->build(@_);
95 $config = load_config_file("$ENV{HOME}/.config/arvados/settings.conf");
97 $self->{'authToken'} ||=
98 $ENV{ARVADOS_API_TOKEN} || $config->{ARVADOS_API_TOKEN};
100 $self->{'apiHost'} ||=
101 $ENV{ARVADOS_API_HOST} || $config->{ARVADOS_API_HOST};
103 $self->{'noVerifyHostname'} ||=
104 $ENV{ARVADOS_API_HOST_INSECURE};
106 $self->{'apiProtocolScheme'} ||=
107 $ENV{ARVADOS_API_PROTOCOL_SCHEME} ||
108 $config->{ARVADOS_API_PROTOCOL_SCHEME};
110 $self->{'ua'} = new Arvados::Request;
112 my $host = $self->{'apiHost'} || 'arvados';
113 my $service = $self->{'apiService'} || 'arvados';
114 my $version = $self->{'apiVersion'} || 'v1';
115 my $scheme = $self->{'apiProtocolScheme'} || 'https';
116 my $uri = "$scheme://$host/discovery/v1/apis/$service/$version/rest";
117 my $r = $self->new_request;
119 $r->set_method("GET");
120 $r->process_request();
122 my ($status_number, $status_phrase) = $r->get_status();
123 $data = $r->get_body() if $status_number == 200;
124 $headers = $r->get_headers();
126 my $doc = $self->{'discoveryDocument'} = JSON::decode_json($data);
127 print STDERR Dumper $doc if $ENV{'DEBUG_ARVADOS_API_DISCOVERY'};
129 while (($k, $v) = each %{$doc->{'resources'}}) {
130 $self->{$k} = Arvados::ResourceAccessor->new($self, $k);
133 croak "No discovery doc at $uri - $status_number $status_phrase";
141 local $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'};
142 if ($self->{'noVerifyHostname'} || ($host =~ /\.local$/)) {
143 $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
145 Arvados::Request->new();
148 sub load_config_file ($)
150 my $config_file = shift;
153 if (open (CONF, $config_file)) {
155 next if /^\s*#/ || /^\s*$/; # skip comments and blank lines
157 my ($key, $val) = split /\s*=\s*/, $_, 2;
158 $config{$key} = $val;