[Bio] / FigKernelPackages / P3WorkspaceClient.pm Repository:
ViewVC logotype

Annotation of /FigKernelPackages/P3WorkspaceClient.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (view) (download) (as text)

1 : olson 1.4 package P3WorkspaceClient;
2 : parrello 1.3
3 : olson 1.4 # This is a SAS Component
4 : olson 1.1
5 : olson 1.5 use P3DataAPI;
6 : olson 1.1 use POSIX;
7 : parrello 1.3 no warnings 'redefine';
8 : olson 1.1 use strict;
9 :     use Data::Dumper;
10 : parrello 1.3 use JSON::RPC::Legacy::Client;
11 : olson 1.1 use URI;
12 :     my $get_time = sub { time, 0 };
13 :     eval {
14 :     require Time::HiRes;
15 :     $get_time = sub { Time::HiRes::gettimeofday() };
16 :     };
17 :    
18 :     # Client version should match Impl version
19 :     # This is a Semantic Version number,
20 :     # http://semver.org
21 :     our $VERSION = "0.1.0";
22 :    
23 :     =head1 NAME
24 :    
25 :     Bio::P3::Workspace::WorkspaceClient
26 :    
27 :     =head1 DESCRIPTION
28 :    
29 :    
30 :    
31 :    
32 :    
33 :     =cut
34 :    
35 :     sub new
36 :     {
37 :     my($class, $url, @args) = @_;
38 : parrello 1.3
39 : olson 1.1 if (!defined($url))
40 :     {
41 : parrello 1.3 $url = 'http://p3.theseed.org/services/Workspace';
42 : olson 1.1 }
43 :    
44 :     my $self = {
45 : parrello 1.3 client => Bio::P3::Workspace::WorkspaceClient::RpcClient->new,
46 :     url => $url,
47 :     headers => [],
48 : olson 1.5 api => P3DataAPI->new(),
49 : olson 1.1 };
50 :    
51 :     chomp($self->{hostname} = `hostname`);
52 :     $self->{hostname} ||= 'unknown-host';
53 :    
54 :     #
55 :     # Set up for propagating KBRPC_TAG and KBRPC_METADATA environment variables through
56 :     # to invoked services. If these values are not set, we create a new tag
57 :     # and a metadata field with basic information about the invoking script.
58 :     #
59 :     if ($ENV{KBRPC_TAG})
60 :     {
61 : parrello 1.3 $self->{kbrpc_tag} = $ENV{KBRPC_TAG};
62 : olson 1.1 }
63 :     else
64 :     {
65 : parrello 1.3 my ($t, $us) = &$get_time();
66 :     $us = sprintf("%06d", $us);
67 :     my $ts = strftime("%Y-%m-%dT%H:%M:%S.${us}Z", gmtime $t);
68 :     $self->{kbrpc_tag} = "C:$0:$self->{hostname}:$$:$ts";
69 : olson 1.1 }
70 :     push(@{$self->{headers}}, 'Kbrpc-Tag', $self->{kbrpc_tag});
71 :    
72 :     if ($ENV{KBRPC_METADATA})
73 :     {
74 : parrello 1.3 $self->{kbrpc_metadata} = $ENV{KBRPC_METADATA};
75 :     push(@{$self->{headers}}, 'Kbrpc-Metadata', $self->{kbrpc_metadata});
76 : olson 1.1 }
77 :    
78 :     if ($ENV{KBRPC_ERROR_DEST})
79 :     {
80 : parrello 1.3 $self->{kbrpc_error_dest} = $ENV{KBRPC_ERROR_DEST};
81 :     push(@{$self->{headers}}, 'Kbrpc-Errordest', $self->{kbrpc_error_dest});
82 : olson 1.1 }
83 :    
84 :     #
85 :     # This module requires authentication.
86 :     #
87 :     # We create an auth token, passing through the arguments that we were (hopefully) given.
88 :    
89 :     {
90 : parrello 1.3 #
91 :     # We will find our token either in ~/.kbase_config or ~/.patric_token. Prefer .patric_token.
92 :     #
93 :    
94 :     my %args = @args;
95 :     my $token;
96 :     my $fh;
97 :     if ($args{token})
98 :     {
99 :     $token = $args{token};
100 :     }
101 :     elsif ($ENV{KB_AUTH_TOKEN})
102 :     {
103 :     $token = $ENV{KB_AUTH_TOKEN};
104 :     }
105 : olson 1.5 elsif ($self->{api}->{token})
106 :     {
107 :     $token = $self->{api}->{token};
108 :     }
109 : parrello 1.3 elsif (open($fh, "<", "$ENV{HOME}/.patric_token"))
110 :     {
111 :     $token = <$fh>;
112 :     chomp $token;
113 :     }
114 :     elsif (open($fh, "<", "$ENV{HOME}/.kbase_config"))
115 :     {
116 :     OUTER:
117 :     while (<$fh>)
118 :     {
119 :     if (/\[authentication\]/)
120 :     {
121 :     while (<$fh>)
122 :     {
123 :     if (/^token=(.*)/)
124 :     {
125 :     $token = $1;
126 :     last OUTER;
127 :     }
128 :     }
129 :     }
130 :     }
131 :     }
132 :    
133 :     $self->{token} = $token;
134 :     $self->{client}->{token} = $token;
135 : olson 1.1 }
136 :    
137 : parrello 1.3 my $ua = $self->{client}->ua;
138 :     my $timeout = $ENV{CDMI_TIMEOUT} || (30 * 60);
139 : olson 1.1 $ua->timeout($timeout);
140 :     bless $self, $class;
141 :     # $self->_validate_version();
142 :     return $self;
143 :     }
144 :    
145 :    
146 :    
147 :    
148 :     =head2 create
149 :    
150 :     $output = $obj->create($input)
151 :    
152 :     =over 4
153 :    
154 :     =item Parameter and return types
155 :    
156 :     =begin html
157 :    
158 :     <pre>
159 :     $input is a create_params
160 :     $output is a reference to a list where each element is an ObjectMeta
161 :     create_params is a reference to a hash where the following keys are defined:
162 : parrello 1.3 objects has a value which is a reference to a list where each element is a reference to a list containing 5 items:
163 :     0: a FullObjectPath
164 :     1: an ObjectType
165 :     2: a UserMetadata
166 :     3: an ObjectData
167 :     4: (creation_time) a Timestamp
168 :    
169 :     permission has a value which is a WorkspacePerm
170 :     createUploadNodes has a value which is a bool
171 :     downloadLinks has a value which is a bool
172 :     overwrite has a value which is a bool
173 :     adminmode has a value which is a bool
174 :     setowner has a value which is a string
175 : olson 1.1 FullObjectPath is a string
176 :     ObjectType is a string
177 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
178 :     ObjectData is a string
179 :     Timestamp is a string
180 :     WorkspacePerm is a string
181 :     bool is an int
182 :     ObjectMeta is a reference to a list containing 12 items:
183 : parrello 1.3 0: an ObjectName
184 :     1: an ObjectType
185 :     2: a FullObjectPath
186 :     3: (creation_time) a Timestamp
187 :     4: an ObjectID
188 :     5: (object_owner) a Username
189 :     6: an ObjectSize
190 :     7: a UserMetadata
191 :     8: an AutoMetadata
192 :     9: (user_permission) a WorkspacePerm
193 :     10: (global_permission) a WorkspacePerm
194 :     11: (shockurl) a string
195 : olson 1.1 ObjectName is a string
196 :     ObjectID is a string
197 :     Username is a string
198 :     ObjectSize is an int
199 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
200 :    
201 :     </pre>
202 :    
203 :     =end html
204 :    
205 :     =begin text
206 :    
207 :     $input is a create_params
208 :     $output is a reference to a list where each element is an ObjectMeta
209 :     create_params is a reference to a hash where the following keys are defined:
210 : parrello 1.3 objects has a value which is a reference to a list where each element is a reference to a list containing 5 items:
211 :     0: a FullObjectPath
212 :     1: an ObjectType
213 :     2: a UserMetadata
214 :     3: an ObjectData
215 :     4: (creation_time) a Timestamp
216 :    
217 :     permission has a value which is a WorkspacePerm
218 :     createUploadNodes has a value which is a bool
219 :     downloadLinks has a value which is a bool
220 :     overwrite has a value which is a bool
221 :     adminmode has a value which is a bool
222 :     setowner has a value which is a string
223 : olson 1.1 FullObjectPath is a string
224 :     ObjectType is a string
225 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
226 :     ObjectData is a string
227 :     Timestamp is a string
228 :     WorkspacePerm is a string
229 :     bool is an int
230 :     ObjectMeta is a reference to a list containing 12 items:
231 : parrello 1.3 0: an ObjectName
232 :     1: an ObjectType
233 :     2: a FullObjectPath
234 :     3: (creation_time) a Timestamp
235 :     4: an ObjectID
236 :     5: (object_owner) a Username
237 :     6: an ObjectSize
238 :     7: a UserMetadata
239 :     8: an AutoMetadata
240 :     9: (user_permission) a WorkspacePerm
241 :     10: (global_permission) a WorkspacePerm
242 :     11: (shockurl) a string
243 : olson 1.1 ObjectName is a string
244 :     ObjectID is a string
245 :     Username is a string
246 :     ObjectSize is an int
247 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
248 :    
249 :    
250 :     =end text
251 :    
252 :     =item Description
253 :    
254 :    
255 :    
256 :     =back
257 :    
258 :     =cut
259 :    
260 :     sub create
261 :     {
262 :     my($self, @args) = @_;
263 :    
264 :     # Authentication: required
265 :    
266 :     if ((my $n = @args) != 1)
267 :     {
268 : parrello 1.3 die("Invalid argument count for function create (received $n, expecting 1)");
269 : olson 1.1 }
270 :     {
271 : parrello 1.3 my($input) = @args;
272 : olson 1.1
273 : parrello 1.3 my @_bad_arguments;
274 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
275 :     if (@_bad_arguments) {
276 : parrello 1.3 my $msg = "Invalid arguments passed to create:\n" . join("", map { "\t$_\n" } @_bad_arguments);
277 :     die($msg);
278 :     }
279 : olson 1.1 }
280 :    
281 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
282 : parrello 1.3 method => "Workspace.create",
283 :     params => \@args,
284 : olson 1.1 });
285 :     if ($result) {
286 : parrello 1.3 if ($result->is_error) {
287 :     die($result->error_message);
288 :     } else {
289 :     return wantarray ? @{$result->result} : $result->result->[0];
290 :     }
291 : olson 1.1 } else {
292 :     die("Error invoking method create");
293 :     }
294 :     }
295 :    
296 :    
297 :    
298 :     =head2 update_metadata
299 :    
300 :     $output = $obj->update_metadata($input)
301 :    
302 :     =over 4
303 :    
304 :     =item Parameter and return types
305 :    
306 :     =begin html
307 :    
308 :     <pre>
309 :     $input is an update_metadata_params
310 :     $output is a reference to a list where each element is an ObjectMeta
311 :     update_metadata_params is a reference to a hash where the following keys are defined:
312 : parrello 1.3 objects has a value which is a reference to a list where each element is a reference to a list containing 4 items:
313 :     0: a FullObjectPath
314 :     1: a UserMetadata
315 :     2: an ObjectType
316 :     3: (creation_time) a Timestamp
317 : olson 1.1
318 : parrello 1.3 autometadata has a value which is a bool
319 :     adminmode has a value which is a bool
320 : olson 1.1 FullObjectPath is a string
321 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
322 :     ObjectType is a string
323 :     Timestamp is a string
324 :     bool is an int
325 :     ObjectMeta is a reference to a list containing 12 items:
326 : parrello 1.3 0: an ObjectName
327 :     1: an ObjectType
328 :     2: a FullObjectPath
329 :     3: (creation_time) a Timestamp
330 :     4: an ObjectID
331 :     5: (object_owner) a Username
332 :     6: an ObjectSize
333 :     7: a UserMetadata
334 :     8: an AutoMetadata
335 :     9: (user_permission) a WorkspacePerm
336 :     10: (global_permission) a WorkspacePerm
337 :     11: (shockurl) a string
338 : olson 1.1 ObjectName is a string
339 :     ObjectID is a string
340 :     Username is a string
341 :     ObjectSize is an int
342 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
343 :     WorkspacePerm is a string
344 :    
345 :     </pre>
346 :    
347 :     =end html
348 :    
349 :     =begin text
350 :    
351 :     $input is an update_metadata_params
352 :     $output is a reference to a list where each element is an ObjectMeta
353 :     update_metadata_params is a reference to a hash where the following keys are defined:
354 : parrello 1.3 objects has a value which is a reference to a list where each element is a reference to a list containing 4 items:
355 :     0: a FullObjectPath
356 :     1: a UserMetadata
357 :     2: an ObjectType
358 :     3: (creation_time) a Timestamp
359 : olson 1.1
360 : parrello 1.3 autometadata has a value which is a bool
361 :     adminmode has a value which is a bool
362 : olson 1.1 FullObjectPath is a string
363 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
364 :     ObjectType is a string
365 :     Timestamp is a string
366 :     bool is an int
367 :     ObjectMeta is a reference to a list containing 12 items:
368 : parrello 1.3 0: an ObjectName
369 :     1: an ObjectType
370 :     2: a FullObjectPath
371 :     3: (creation_time) a Timestamp
372 :     4: an ObjectID
373 :     5: (object_owner) a Username
374 :     6: an ObjectSize
375 :     7: a UserMetadata
376 :     8: an AutoMetadata
377 :     9: (user_permission) a WorkspacePerm
378 :     10: (global_permission) a WorkspacePerm
379 :     11: (shockurl) a string
380 : olson 1.1 ObjectName is a string
381 :     ObjectID is a string
382 :     Username is a string
383 :     ObjectSize is an int
384 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
385 :     WorkspacePerm is a string
386 :    
387 :    
388 :     =end text
389 :    
390 :     =item Description
391 :    
392 :    
393 :    
394 :     =back
395 :    
396 :     =cut
397 :    
398 :     sub update_metadata
399 :     {
400 :     my($self, @args) = @_;
401 :    
402 :     # Authentication: required
403 :    
404 :     if ((my $n = @args) != 1)
405 :     {
406 : parrello 1.3 die("Invalid argument count for function update_metadata (received $n, expecting 1)");
407 : olson 1.1 }
408 :     {
409 : parrello 1.3 my($input) = @args;
410 : olson 1.1
411 : parrello 1.3 my @_bad_arguments;
412 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
413 :     if (@_bad_arguments) {
414 : parrello 1.3 my $msg = "Invalid arguments passed to update_metadata:\n" . join("", map { "\t$_\n" } @_bad_arguments);
415 :     die($msg);
416 :     }
417 : olson 1.1 }
418 :    
419 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
420 : parrello 1.3 method => "Workspace.update_metadata",
421 :     params => \@args,
422 : olson 1.1 });
423 :     if ($result) {
424 : parrello 1.3 if ($result->is_error) {
425 :     die($result->error_message);
426 :     } else {
427 :     return wantarray ? @{$result->result} : $result->result->[0];
428 :     }
429 : olson 1.1 } else {
430 :     die("Error invoking method update_metadata");
431 :     }
432 :     }
433 :    
434 :    
435 :    
436 :     =head2 get
437 :    
438 :     $output = $obj->get($input)
439 :    
440 :     =over 4
441 :    
442 :     =item Parameter and return types
443 :    
444 :     =begin html
445 :    
446 :     <pre>
447 :     $input is a get_params
448 :     $output is a reference to a list where each element is a reference to a list containing 2 items:
449 : parrello 1.3 0: an ObjectMeta
450 :     1: an ObjectData
451 : olson 1.1 get_params is a reference to a hash where the following keys are defined:
452 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
453 :     metadata_only has a value which is a bool
454 :     adminmode has a value which is a bool
455 : olson 1.1 FullObjectPath is a string
456 :     bool is an int
457 :     ObjectMeta is a reference to a list containing 12 items:
458 : parrello 1.3 0: an ObjectName
459 :     1: an ObjectType
460 :     2: a FullObjectPath
461 :     3: (creation_time) a Timestamp
462 :     4: an ObjectID
463 :     5: (object_owner) a Username
464 :     6: an ObjectSize
465 :     7: a UserMetadata
466 :     8: an AutoMetadata
467 :     9: (user_permission) a WorkspacePerm
468 :     10: (global_permission) a WorkspacePerm
469 :     11: (shockurl) a string
470 : olson 1.1 ObjectName is a string
471 :     ObjectType is a string
472 :     Timestamp is a string
473 :     ObjectID is a string
474 :     Username is a string
475 :     ObjectSize is an int
476 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
477 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
478 :     WorkspacePerm is a string
479 :     ObjectData is a string
480 :    
481 :     </pre>
482 :    
483 :     =end html
484 :    
485 :     =begin text
486 :    
487 :     $input is a get_params
488 :     $output is a reference to a list where each element is a reference to a list containing 2 items:
489 : parrello 1.3 0: an ObjectMeta
490 :     1: an ObjectData
491 : olson 1.1 get_params is a reference to a hash where the following keys are defined:
492 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
493 :     metadata_only has a value which is a bool
494 :     adminmode has a value which is a bool
495 : olson 1.1 FullObjectPath is a string
496 :     bool is an int
497 :     ObjectMeta is a reference to a list containing 12 items:
498 : parrello 1.3 0: an ObjectName
499 :     1: an ObjectType
500 :     2: a FullObjectPath
501 :     3: (creation_time) a Timestamp
502 :     4: an ObjectID
503 :     5: (object_owner) a Username
504 :     6: an ObjectSize
505 :     7: a UserMetadata
506 :     8: an AutoMetadata
507 :     9: (user_permission) a WorkspacePerm
508 :     10: (global_permission) a WorkspacePerm
509 :     11: (shockurl) a string
510 : olson 1.1 ObjectName is a string
511 :     ObjectType is a string
512 :     Timestamp is a string
513 :     ObjectID is a string
514 :     Username is a string
515 :     ObjectSize is an int
516 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
517 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
518 :     WorkspacePerm is a string
519 :     ObjectData is a string
520 :    
521 :    
522 :     =end text
523 :    
524 :     =item Description
525 :    
526 :    
527 :    
528 :     =back
529 :    
530 :     =cut
531 :    
532 :     sub get
533 :     {
534 :     my($self, @args) = @_;
535 :    
536 :     # Authentication: optional
537 :    
538 :     if ((my $n = @args) != 1)
539 :     {
540 : parrello 1.3 die("Invalid argument count for function get (received $n, expecting 1)");
541 : olson 1.1 }
542 :     {
543 : parrello 1.3 my($input) = @args;
544 : olson 1.1
545 : parrello 1.3 my @_bad_arguments;
546 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
547 :     if (@_bad_arguments) {
548 : parrello 1.3 my $msg = "Invalid arguments passed to get:\n" . join("", map { "\t$_\n" } @_bad_arguments);
549 :     die($msg);
550 :     }
551 : olson 1.1 }
552 :    
553 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
554 : parrello 1.3 method => "Workspace.get",
555 :     params => \@args,
556 : olson 1.1 });
557 :     if ($result) {
558 : parrello 1.3 if ($result->is_error) {
559 :     die($result->error_message);
560 :     } else {
561 :     return wantarray ? @{$result->result} : $result->result->[0];
562 :     }
563 : olson 1.1 } else {
564 :     die("Error invoking method get");
565 :     }
566 :     }
567 :    
568 :    
569 :    
570 :     =head2 update_auto_meta
571 :    
572 :     $output = $obj->update_auto_meta($input)
573 :    
574 :     =over 4
575 :    
576 :     =item Parameter and return types
577 :    
578 :     =begin html
579 :    
580 :     <pre>
581 :     $input is an update_auto_meta_params
582 :     $output is a reference to a list where each element is an ObjectMeta
583 :     update_auto_meta_params is a reference to a hash where the following keys are defined:
584 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
585 :     adminmode has a value which is a bool
586 : olson 1.1 FullObjectPath is a string
587 :     bool is an int
588 :     ObjectMeta is a reference to a list containing 12 items:
589 : parrello 1.3 0: an ObjectName
590 :     1: an ObjectType
591 :     2: a FullObjectPath
592 :     3: (creation_time) a Timestamp
593 :     4: an ObjectID
594 :     5: (object_owner) a Username
595 :     6: an ObjectSize
596 :     7: a UserMetadata
597 :     8: an AutoMetadata
598 :     9: (user_permission) a WorkspacePerm
599 :     10: (global_permission) a WorkspacePerm
600 :     11: (shockurl) a string
601 : olson 1.1 ObjectName is a string
602 :     ObjectType is a string
603 :     Timestamp is a string
604 :     ObjectID is a string
605 :     Username is a string
606 :     ObjectSize is an int
607 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
608 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
609 :     WorkspacePerm is a string
610 :    
611 :     </pre>
612 :    
613 :     =end html
614 :    
615 :     =begin text
616 :    
617 :     $input is an update_auto_meta_params
618 :     $output is a reference to a list where each element is an ObjectMeta
619 :     update_auto_meta_params is a reference to a hash where the following keys are defined:
620 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
621 :     adminmode has a value which is a bool
622 : olson 1.1 FullObjectPath is a string
623 :     bool is an int
624 :     ObjectMeta is a reference to a list containing 12 items:
625 : parrello 1.3 0: an ObjectName
626 :     1: an ObjectType
627 :     2: a FullObjectPath
628 :     3: (creation_time) a Timestamp
629 :     4: an ObjectID
630 :     5: (object_owner) a Username
631 :     6: an ObjectSize
632 :     7: a UserMetadata
633 :     8: an AutoMetadata
634 :     9: (user_permission) a WorkspacePerm
635 :     10: (global_permission) a WorkspacePerm
636 :     11: (shockurl) a string
637 : olson 1.1 ObjectName is a string
638 :     ObjectType is a string
639 :     Timestamp is a string
640 :     ObjectID is a string
641 :     Username is a string
642 :     ObjectSize is an int
643 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
644 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
645 :     WorkspacePerm is a string
646 :    
647 :    
648 :     =end text
649 :    
650 :     =item Description
651 :    
652 :    
653 :    
654 :     =back
655 :    
656 :     =cut
657 :    
658 :     sub update_auto_meta
659 :     {
660 :     my($self, @args) = @_;
661 :    
662 :     # Authentication: required
663 :    
664 :     if ((my $n = @args) != 1)
665 :     {
666 : parrello 1.3 die("Invalid argument count for function update_auto_meta (received $n, expecting 1)");
667 : olson 1.1 }
668 :     {
669 : parrello 1.3 my($input) = @args;
670 : olson 1.1
671 : parrello 1.3 my @_bad_arguments;
672 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
673 :     if (@_bad_arguments) {
674 : parrello 1.3 my $msg = "Invalid arguments passed to update_auto_meta:\n" . join("", map { "\t$_\n" } @_bad_arguments);
675 :     die($msg);
676 :     }
677 : olson 1.1 }
678 :    
679 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
680 : parrello 1.3 method => "Workspace.update_auto_meta",
681 :     params => \@args,
682 : olson 1.1 });
683 :     if ($result) {
684 : parrello 1.3 if ($result->is_error) {
685 :     die($result->error_message);
686 :     } else {
687 :     return wantarray ? @{$result->result} : $result->result->[0];
688 :     }
689 : olson 1.1 } else {
690 :     die("Error invoking method update_auto_meta");
691 :     }
692 :     }
693 :    
694 :    
695 :    
696 :     =head2 get_download_url
697 :    
698 :     $urls = $obj->get_download_url($input)
699 :    
700 :     =over 4
701 :    
702 :     =item Parameter and return types
703 :    
704 :     =begin html
705 :    
706 :     <pre>
707 :     $input is a get_download_url_params
708 :     $urls is a reference to a list where each element is a string
709 :     get_download_url_params is a reference to a hash where the following keys are defined:
710 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
711 : olson 1.1 FullObjectPath is a string
712 :    
713 :     </pre>
714 :    
715 :     =end html
716 :    
717 :     =begin text
718 :    
719 :     $input is a get_download_url_params
720 :     $urls is a reference to a list where each element is a string
721 :     get_download_url_params is a reference to a hash where the following keys are defined:
722 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
723 : olson 1.1 FullObjectPath is a string
724 :    
725 :    
726 :     =end text
727 :    
728 :     =item Description
729 :    
730 :    
731 :    
732 :     =back
733 :    
734 :     =cut
735 :    
736 :     sub get_download_url
737 :     {
738 :     my($self, @args) = @_;
739 :    
740 :     # Authentication: optional
741 :    
742 :     if ((my $n = @args) != 1)
743 :     {
744 : parrello 1.3 die("Invalid argument count for function get_download_url (received $n, expecting 1)");
745 : olson 1.1 }
746 :     {
747 : parrello 1.3 my($input) = @args;
748 : olson 1.1
749 : parrello 1.3 my @_bad_arguments;
750 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
751 :     if (@_bad_arguments) {
752 : parrello 1.3 my $msg = "Invalid arguments passed to get_download_url:\n" . join("", map { "\t$_\n" } @_bad_arguments);
753 :     die($msg);
754 :     }
755 : olson 1.1 }
756 :    
757 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
758 : parrello 1.3 method => "Workspace.get_download_url",
759 :     params => \@args,
760 : olson 1.1 });
761 :     if ($result) {
762 : parrello 1.3 if ($result->is_error) {
763 :     die($result->error_message);
764 :     } else {
765 :     return wantarray ? @{$result->result} : $result->result->[0];
766 :     }
767 : olson 1.1 } else {
768 :     die("Error invoking method get_download_url");
769 :     }
770 :     }
771 :    
772 :    
773 :    
774 :     =head2 get_archive_url
775 :    
776 :     $url = $obj->get_archive_url($input)
777 :    
778 :     =over 4
779 :    
780 :     =item Parameter and return types
781 :    
782 :     =begin html
783 :    
784 :     <pre>
785 :     $input is a get_archive_url_params
786 :     $url is a string
787 :     get_archive_url_params is a reference to a hash where the following keys are defined:
788 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
789 :     recursive has a value which is a bool
790 :     archive_name has a value which is a string
791 :     archive_type has a value which is a string
792 : olson 1.1 FullObjectPath is a string
793 :     bool is an int
794 :    
795 :     </pre>
796 :    
797 :     =end html
798 :    
799 :     =begin text
800 :    
801 :     $input is a get_archive_url_params
802 :     $url is a string
803 :     get_archive_url_params is a reference to a hash where the following keys are defined:
804 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
805 :     recursive has a value which is a bool
806 :     archive_name has a value which is a string
807 :     archive_type has a value which is a string
808 : olson 1.1 FullObjectPath is a string
809 :     bool is an int
810 :    
811 :    
812 :     =end text
813 :    
814 :     =item Description
815 :    
816 :    
817 :    
818 :     =back
819 :    
820 :     =cut
821 :    
822 :     sub get_archive_url
823 :     {
824 :     my($self, @args) = @_;
825 :    
826 :     # Authentication: optional
827 :    
828 :     if ((my $n = @args) != 1)
829 :     {
830 : parrello 1.3 die("Invalid argument count for function get_archive_url (received $n, expecting 1)");
831 : olson 1.1 }
832 :     {
833 : parrello 1.3 my($input) = @args;
834 : olson 1.1
835 : parrello 1.3 my @_bad_arguments;
836 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
837 :     if (@_bad_arguments) {
838 : parrello 1.3 my $msg = "Invalid arguments passed to get_archive_url:\n" . join("", map { "\t$_\n" } @_bad_arguments);
839 :     die($msg);
840 :     }
841 : olson 1.1 }
842 :    
843 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
844 : parrello 1.3 method => "Workspace.get_archive_url",
845 :     params => \@args,
846 : olson 1.1 });
847 :     if ($result) {
848 : parrello 1.3 if ($result->is_error) {
849 :     die($result->error_message);
850 :     } else {
851 :     return wantarray ? @{$result->result} : $result->result->[0];
852 :     }
853 : olson 1.1 } else {
854 :     die("Error invoking method get_archive_url");
855 :     }
856 :     }
857 :    
858 :    
859 :    
860 :     =head2 ls
861 :    
862 :     $output = $obj->ls($input)
863 :    
864 :     =over 4
865 :    
866 :     =item Parameter and return types
867 :    
868 :     =begin html
869 :    
870 :     <pre>
871 :     $input is a list_params
872 :     $output is a reference to a hash where the key is a FullObjectPath and the value is a reference to a list where each element is an ObjectMeta
873 :     list_params is a reference to a hash where the following keys are defined:
874 : parrello 1.3 paths has a value which is a reference to a list where each element is a FullObjectPath
875 :     excludeDirectories has a value which is a bool
876 :     excludeObjects has a value which is a bool
877 :     recursive has a value which is a bool
878 :     fullHierachicalOutput has a value which is a bool
879 :     query has a value which is a reference to a hash where the key is a string and the value is a reference to a list where each element is a string
880 :     adminmode has a value which is a bool
881 : olson 1.1 FullObjectPath is a string
882 :     bool is an int
883 :     ObjectMeta is a reference to a list containing 12 items:
884 : parrello 1.3 0: an ObjectName
885 :     1: an ObjectType
886 :     2: a FullObjectPath
887 :     3: (creation_time) a Timestamp
888 :     4: an ObjectID
889 :     5: (object_owner) a Username
890 :     6: an ObjectSize
891 :     7: a UserMetadata
892 :     8: an AutoMetadata
893 :     9: (user_permission) a WorkspacePerm
894 :     10: (global_permission) a WorkspacePerm
895 :     11: (shockurl) a string
896 : olson 1.1 ObjectName is a string
897 :     ObjectType is a string
898 :     Timestamp is a string
899 :     ObjectID is a string
900 :     Username is a string
901 :     ObjectSize is an int
902 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
903 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
904 :     WorkspacePerm is a string
905 :    
906 :     </pre>
907 :    
908 :     =end html
909 :    
910 :     =begin text
911 :    
912 :     $input is a list_params
913 :     $output is a reference to a hash where the key is a FullObjectPath and the value is a reference to a list where each element is an ObjectMeta
914 :     list_params is a reference to a hash where the following keys are defined:
915 : parrello 1.3 paths has a value which is a reference to a list where each element is a FullObjectPath
916 :     excludeDirectories has a value which is a bool
917 :     excludeObjects has a value which is a bool
918 :     recursive has a value which is a bool
919 :     fullHierachicalOutput has a value which is a bool
920 :     query has a value which is a reference to a hash where the key is a string and the value is a reference to a list where each element is a string
921 :     adminmode has a value which is a bool
922 : olson 1.1 FullObjectPath is a string
923 :     bool is an int
924 :     ObjectMeta is a reference to a list containing 12 items:
925 : parrello 1.3 0: an ObjectName
926 :     1: an ObjectType
927 :     2: a FullObjectPath
928 :     3: (creation_time) a Timestamp
929 :     4: an ObjectID
930 :     5: (object_owner) a Username
931 :     6: an ObjectSize
932 :     7: a UserMetadata
933 :     8: an AutoMetadata
934 :     9: (user_permission) a WorkspacePerm
935 :     10: (global_permission) a WorkspacePerm
936 :     11: (shockurl) a string
937 : olson 1.1 ObjectName is a string
938 :     ObjectType is a string
939 :     Timestamp is a string
940 :     ObjectID is a string
941 :     Username is a string
942 :     ObjectSize is an int
943 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
944 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
945 :     WorkspacePerm is a string
946 :    
947 :    
948 :     =end text
949 :    
950 :     =item Description
951 :    
952 :    
953 :    
954 :     =back
955 :    
956 :     =cut
957 :    
958 :     sub ls
959 :     {
960 :     my($self, @args) = @_;
961 :    
962 :     # Authentication: optional
963 :    
964 :     if ((my $n = @args) != 1)
965 :     {
966 : parrello 1.3 die("Invalid argument count for function ls (received $n, expecting 1)");
967 : olson 1.1 }
968 :     {
969 : parrello 1.3 my($input) = @args;
970 : olson 1.1
971 : parrello 1.3 my @_bad_arguments;
972 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
973 :     if (@_bad_arguments) {
974 : parrello 1.3 my $msg = "Invalid arguments passed to ls:\n" . join("", map { "\t$_\n" } @_bad_arguments);
975 :     die($msg);
976 :     }
977 : olson 1.1 }
978 :    
979 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
980 : parrello 1.3 method => "Workspace.ls",
981 :     params => \@args,
982 : olson 1.1 });
983 :     if ($result) {
984 : parrello 1.3 if ($result->is_error) {
985 :     die($result->error_message);
986 :     } else {
987 :     return wantarray ? @{$result->result} : $result->result->[0];
988 :     }
989 : olson 1.1 } else {
990 :     die("Error invoking method ls");
991 :     }
992 :     }
993 :    
994 :    
995 :    
996 :     =head2 copy
997 :    
998 :     $output = $obj->copy($input)
999 :    
1000 :     =over 4
1001 :    
1002 :     =item Parameter and return types
1003 :    
1004 :     =begin html
1005 :    
1006 :     <pre>
1007 :     $input is a copy_params
1008 :     $output is a reference to a list where each element is an ObjectMeta
1009 :     copy_params is a reference to a hash where the following keys are defined:
1010 : parrello 1.3 objects has a value which is a reference to a list where each element is a reference to a list containing 2 items:
1011 :     0: (source) a FullObjectPath
1012 :     1: (destination) a FullObjectPath
1013 :    
1014 :     overwrite has a value which is a bool
1015 :     recursive has a value which is a bool
1016 :     move has a value which is a bool
1017 :     adminmode has a value which is a bool
1018 : olson 1.1 FullObjectPath is a string
1019 :     bool is an int
1020 :     ObjectMeta is a reference to a list containing 12 items:
1021 : parrello 1.3 0: an ObjectName
1022 :     1: an ObjectType
1023 :     2: a FullObjectPath
1024 :     3: (creation_time) a Timestamp
1025 :     4: an ObjectID
1026 :     5: (object_owner) a Username
1027 :     6: an ObjectSize
1028 :     7: a UserMetadata
1029 :     8: an AutoMetadata
1030 :     9: (user_permission) a WorkspacePerm
1031 :     10: (global_permission) a WorkspacePerm
1032 :     11: (shockurl) a string
1033 : olson 1.1 ObjectName is a string
1034 :     ObjectType is a string
1035 :     Timestamp is a string
1036 :     ObjectID is a string
1037 :     Username is a string
1038 :     ObjectSize is an int
1039 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
1040 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
1041 :     WorkspacePerm is a string
1042 :    
1043 :     </pre>
1044 :    
1045 :     =end html
1046 :    
1047 :     =begin text
1048 :    
1049 :     $input is a copy_params
1050 :     $output is a reference to a list where each element is an ObjectMeta
1051 :     copy_params is a reference to a hash where the following keys are defined:
1052 : parrello 1.3 objects has a value which is a reference to a list where each element is a reference to a list containing 2 items:
1053 :     0: (source) a FullObjectPath
1054 :     1: (destination) a FullObjectPath
1055 :    
1056 :     overwrite has a value which is a bool
1057 :     recursive has a value which is a bool
1058 :     move has a value which is a bool
1059 :     adminmode has a value which is a bool
1060 : olson 1.1 FullObjectPath is a string
1061 :     bool is an int
1062 :     ObjectMeta is a reference to a list containing 12 items:
1063 : parrello 1.3 0: an ObjectName
1064 :     1: an ObjectType
1065 :     2: a FullObjectPath
1066 :     3: (creation_time) a Timestamp
1067 :     4: an ObjectID
1068 :     5: (object_owner) a Username
1069 :     6: an ObjectSize
1070 :     7: a UserMetadata
1071 :     8: an AutoMetadata
1072 :     9: (user_permission) a WorkspacePerm
1073 :     10: (global_permission) a WorkspacePerm
1074 :     11: (shockurl) a string
1075 : olson 1.1 ObjectName is a string
1076 :     ObjectType is a string
1077 :     Timestamp is a string
1078 :     ObjectID is a string
1079 :     Username is a string
1080 :     ObjectSize is an int
1081 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
1082 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
1083 :     WorkspacePerm is a string
1084 :    
1085 :    
1086 :     =end text
1087 :    
1088 :     =item Description
1089 :    
1090 :    
1091 :    
1092 :     =back
1093 :    
1094 :     =cut
1095 :    
1096 :     sub copy
1097 :     {
1098 :     my($self, @args) = @_;
1099 :    
1100 :     # Authentication: required
1101 :    
1102 :     if ((my $n = @args) != 1)
1103 :     {
1104 : parrello 1.3 die("Invalid argument count for function copy (received $n, expecting 1)");
1105 : olson 1.1 }
1106 :     {
1107 : parrello 1.3 my($input) = @args;
1108 : olson 1.1
1109 : parrello 1.3 my @_bad_arguments;
1110 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
1111 :     if (@_bad_arguments) {
1112 : parrello 1.3 my $msg = "Invalid arguments passed to copy:\n" . join("", map { "\t$_\n" } @_bad_arguments);
1113 :     die($msg);
1114 :     }
1115 : olson 1.1 }
1116 :    
1117 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
1118 : parrello 1.3 method => "Workspace.copy",
1119 :     params => \@args,
1120 : olson 1.1 });
1121 :     if ($result) {
1122 : parrello 1.3 if ($result->is_error) {
1123 :     die($result->error_message);
1124 :     } else {
1125 :     return wantarray ? @{$result->result} : $result->result->[0];
1126 :     }
1127 : olson 1.1 } else {
1128 :     die("Error invoking method copy");
1129 :     }
1130 :     }
1131 :    
1132 :    
1133 :    
1134 :     =head2 delete
1135 :    
1136 :     $output = $obj->delete($input)
1137 :    
1138 :     =over 4
1139 :    
1140 :     =item Parameter and return types
1141 :    
1142 :     =begin html
1143 :    
1144 :     <pre>
1145 :     $input is a delete_params
1146 :     $output is a reference to a list where each element is an ObjectMeta
1147 :     delete_params is a reference to a hash where the following keys are defined:
1148 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
1149 :     deleteDirectories has a value which is a bool
1150 :     force has a value which is a bool
1151 :     adminmode has a value which is a bool
1152 : olson 1.1 FullObjectPath is a string
1153 :     bool is an int
1154 :     ObjectMeta is a reference to a list containing 12 items:
1155 : parrello 1.3 0: an ObjectName
1156 :     1: an ObjectType
1157 :     2: a FullObjectPath
1158 :     3: (creation_time) a Timestamp
1159 :     4: an ObjectID
1160 :     5: (object_owner) a Username
1161 :     6: an ObjectSize
1162 :     7: a UserMetadata
1163 :     8: an AutoMetadata
1164 :     9: (user_permission) a WorkspacePerm
1165 :     10: (global_permission) a WorkspacePerm
1166 :     11: (shockurl) a string
1167 : olson 1.1 ObjectName is a string
1168 :     ObjectType is a string
1169 :     Timestamp is a string
1170 :     ObjectID is a string
1171 :     Username is a string
1172 :     ObjectSize is an int
1173 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
1174 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
1175 :     WorkspacePerm is a string
1176 :    
1177 :     </pre>
1178 :    
1179 :     =end html
1180 :    
1181 :     =begin text
1182 :    
1183 :     $input is a delete_params
1184 :     $output is a reference to a list where each element is an ObjectMeta
1185 :     delete_params is a reference to a hash where the following keys are defined:
1186 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
1187 :     deleteDirectories has a value which is a bool
1188 :     force has a value which is a bool
1189 :     adminmode has a value which is a bool
1190 : olson 1.1 FullObjectPath is a string
1191 :     bool is an int
1192 :     ObjectMeta is a reference to a list containing 12 items:
1193 : parrello 1.3 0: an ObjectName
1194 :     1: an ObjectType
1195 :     2: a FullObjectPath
1196 :     3: (creation_time) a Timestamp
1197 :     4: an ObjectID
1198 :     5: (object_owner) a Username
1199 :     6: an ObjectSize
1200 :     7: a UserMetadata
1201 :     8: an AutoMetadata
1202 :     9: (user_permission) a WorkspacePerm
1203 :     10: (global_permission) a WorkspacePerm
1204 :     11: (shockurl) a string
1205 : olson 1.1 ObjectName is a string
1206 :     ObjectType is a string
1207 :     Timestamp is a string
1208 :     ObjectID is a string
1209 :     Username is a string
1210 :     ObjectSize is an int
1211 :     UserMetadata is a reference to a hash where the key is a string and the value is a string
1212 :     AutoMetadata is a reference to a hash where the key is a string and the value is a string
1213 :     WorkspacePerm is a string
1214 :    
1215 :    
1216 :     =end text
1217 :    
1218 :     =item Description
1219 :    
1220 :    
1221 :    
1222 :     =back
1223 :    
1224 :     =cut
1225 :    
1226 :     sub delete
1227 :     {
1228 :     my($self, @args) = @_;
1229 :    
1230 :     # Authentication: required
1231 :    
1232 :     if ((my $n = @args) != 1)
1233 :     {
1234 : parrello 1.3 die("Invalid argument count for function delete (received $n, expecting 1)");
1235 : olson 1.1 }
1236 :     {
1237 : parrello 1.3 my($input) = @args;
1238 : olson 1.1
1239 : parrello 1.3 my @_bad_arguments;
1240 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
1241 :     if (@_bad_arguments) {
1242 : parrello 1.3 my $msg = "Invalid arguments passed to delete:\n" . join("", map { "\t$_\n" } @_bad_arguments);
1243 :     die($msg);
1244 :     }
1245 : olson 1.1 }
1246 :    
1247 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
1248 : parrello 1.3 method => "Workspace.delete",
1249 :     params => \@args,
1250 : olson 1.1 });
1251 :     if ($result) {
1252 : parrello 1.3 if ($result->is_error) {
1253 :     die($result->error_message);
1254 :     } else {
1255 :     return wantarray ? @{$result->result} : $result->result->[0];
1256 :     }
1257 : olson 1.1 } else {
1258 :     die("Error invoking method delete");
1259 :     }
1260 :     }
1261 :    
1262 :    
1263 :    
1264 :     =head2 set_permissions
1265 :    
1266 :     $output = $obj->set_permissions($input)
1267 :    
1268 :     =over 4
1269 :    
1270 :     =item Parameter and return types
1271 :    
1272 :     =begin html
1273 :    
1274 :     <pre>
1275 :     $input is a set_permissions_params
1276 :     $output is a reference to a list where each element is a reference to a list containing 2 items:
1277 : parrello 1.3 0: a Username
1278 :     1: a WorkspacePerm
1279 : olson 1.1 set_permissions_params is a reference to a hash where the following keys are defined:
1280 : parrello 1.3 path has a value which is a FullObjectPath
1281 :     permissions has a value which is a reference to a list where each element is a reference to a list containing 2 items:
1282 :     0: a Username
1283 :     1: a WorkspacePerm
1284 : olson 1.1
1285 : parrello 1.3 new_global_permission has a value which is a WorkspacePerm
1286 :     adminmode has a value which is a bool
1287 : olson 1.1 FullObjectPath is a string
1288 :     Username is a string
1289 :     WorkspacePerm is a string
1290 :     bool is an int
1291 :    
1292 :     </pre>
1293 :    
1294 :     =end html
1295 :    
1296 :     =begin text
1297 :    
1298 :     $input is a set_permissions_params
1299 :     $output is a reference to a list where each element is a reference to a list containing 2 items:
1300 : parrello 1.3 0: a Username
1301 :     1: a WorkspacePerm
1302 : olson 1.1 set_permissions_params is a reference to a hash where the following keys are defined:
1303 : parrello 1.3 path has a value which is a FullObjectPath
1304 :     permissions has a value which is a reference to a list where each element is a reference to a list containing 2 items:
1305 :     0: a Username
1306 :     1: a WorkspacePerm
1307 : olson 1.1
1308 : parrello 1.3 new_global_permission has a value which is a WorkspacePerm
1309 :     adminmode has a value which is a bool
1310 : olson 1.1 FullObjectPath is a string
1311 :     Username is a string
1312 :     WorkspacePerm is a string
1313 :     bool is an int
1314 :    
1315 :    
1316 :     =end text
1317 :    
1318 :     =item Description
1319 :    
1320 :    
1321 :    
1322 :     =back
1323 :    
1324 :     =cut
1325 :    
1326 :     sub set_permissions
1327 :     {
1328 :     my($self, @args) = @_;
1329 :    
1330 :     # Authentication: required
1331 :    
1332 :     if ((my $n = @args) != 1)
1333 :     {
1334 : parrello 1.3 die("Invalid argument count for function set_permissions (received $n, expecting 1)");
1335 : olson 1.1 }
1336 :     {
1337 : parrello 1.3 my($input) = @args;
1338 : olson 1.1
1339 : parrello 1.3 my @_bad_arguments;
1340 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
1341 :     if (@_bad_arguments) {
1342 : parrello 1.3 my $msg = "Invalid arguments passed to set_permissions:\n" . join("", map { "\t$_\n" } @_bad_arguments);
1343 :     die($msg);
1344 :     }
1345 : olson 1.1 }
1346 :    
1347 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
1348 : parrello 1.3 method => "Workspace.set_permissions",
1349 :     params => \@args,
1350 : olson 1.1 });
1351 :     if ($result) {
1352 : parrello 1.3 if ($result->is_error) {
1353 :     die($result->error_message);
1354 :     } else {
1355 :     return wantarray ? @{$result->result} : $result->result->[0];
1356 :     }
1357 : olson 1.1 } else {
1358 :     die("Error invoking method set_permissions");
1359 :     }
1360 :     }
1361 :    
1362 :    
1363 :    
1364 :     =head2 list_permissions
1365 :    
1366 :     $output = $obj->list_permissions($input)
1367 :    
1368 :     =over 4
1369 :    
1370 :     =item Parameter and return types
1371 :    
1372 :     =begin html
1373 :    
1374 :     <pre>
1375 :     $input is a list_permissions_params
1376 :     $output is a reference to a hash where the key is a string and the value is a reference to a list where each element is a reference to a list containing 2 items:
1377 : parrello 1.3 0: a Username
1378 :     1: a WorkspacePerm
1379 : olson 1.1 list_permissions_params is a reference to a hash where the following keys are defined:
1380 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
1381 :     adminmode has a value which is a bool
1382 : olson 1.1 FullObjectPath is a string
1383 :     bool is an int
1384 :     Username is a string
1385 :     WorkspacePerm is a string
1386 :    
1387 :     </pre>
1388 :    
1389 :     =end html
1390 :    
1391 :     =begin text
1392 :    
1393 :     $input is a list_permissions_params
1394 :     $output is a reference to a hash where the key is a string and the value is a reference to a list where each element is a reference to a list containing 2 items:
1395 : parrello 1.3 0: a Username
1396 :     1: a WorkspacePerm
1397 : olson 1.1 list_permissions_params is a reference to a hash where the following keys are defined:
1398 : parrello 1.3 objects has a value which is a reference to a list where each element is a FullObjectPath
1399 :     adminmode has a value which is a bool
1400 : olson 1.1 FullObjectPath is a string
1401 :     bool is an int
1402 :     Username is a string
1403 :     WorkspacePerm is a string
1404 :    
1405 :    
1406 :     =end text
1407 :    
1408 :     =item Description
1409 :    
1410 :    
1411 :    
1412 :     =back
1413 :    
1414 :     =cut
1415 :    
1416 :     sub list_permissions
1417 :     {
1418 :     my($self, @args) = @_;
1419 :    
1420 :     # Authentication: optional
1421 :    
1422 :     if ((my $n = @args) != 1)
1423 :     {
1424 : parrello 1.3 die("Invalid argument count for function list_permissions (received $n, expecting 1)");
1425 : olson 1.1 }
1426 :     {
1427 : parrello 1.3 my($input) = @args;
1428 : olson 1.1
1429 : parrello 1.3 my @_bad_arguments;
1430 : olson 1.1 (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
1431 :     if (@_bad_arguments) {
1432 : parrello 1.3 my $msg = "Invalid arguments passed to list_permissions:\n" . join("", map { "\t$_\n" } @_bad_arguments);
1433 :     die($msg);
1434 :     }
1435 : olson 1.1 }
1436 :    
1437 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
1438 : parrello 1.3 method => "Workspace.list_permissions",
1439 :     params => \@args,
1440 : olson 1.1 });
1441 :     if ($result) {
1442 : parrello 1.3 if ($result->is_error) {
1443 :     die($result->error_message);
1444 :     } else {
1445 :     return wantarray ? @{$result->result} : $result->result->[0];
1446 :     }
1447 : olson 1.1 } else {
1448 :     die("Error invoking method list_permissions");
1449 :     }
1450 :     }
1451 :    
1452 :    
1453 :    
1454 :     sub version {
1455 :     my ($self) = @_;
1456 :     my $result = $self->{client}->call($self->{url}, $self->{headers}, {
1457 :     method => "Workspace.version",
1458 :     params => [],
1459 :     });
1460 :     if ($result) {
1461 :     if ($result->is_error) {
1462 :     die($result->error_message);
1463 :     } else {
1464 :     return wantarray ? @{$result->result} : $result->result->[0];
1465 :     }
1466 :     } else {
1467 :     die("Error invoking method list_permissions");
1468 :     }
1469 :     }
1470 :    
1471 :     sub _validate_version {
1472 :     my ($self) = @_;
1473 :     my $svr_version = $self->version();
1474 :     my $client_version = $VERSION;
1475 :     my ($cMajor, $cMinor) = split(/\./, $client_version);
1476 :     my ($sMajor, $sMinor) = split(/\./, $svr_version);
1477 :     if ($sMajor != $cMajor) {
1478 :     die("Major version numbers differ.");
1479 :     }
1480 :     if ($sMinor < $cMinor) {
1481 :     die("Client minor version greater than Server minor version.");
1482 :     }
1483 :     if ($sMinor > $cMinor) {
1484 :     warn "New client version available for Bio::P3::Workspace::WorkspaceClient\n";
1485 :     }
1486 :     if ($sMajor == 0) {
1487 :     warn "Bio::P3::Workspace::WorkspaceClient version is $svr_version. API subject to change.\n";
1488 :     }
1489 :     }
1490 :    
1491 :     =head1 TYPES
1492 :    
1493 :    
1494 :    
1495 :     =head2 WorkspacePerm
1496 :    
1497 :     =over 4
1498 :    
1499 :    
1500 :    
1501 :     =item Description
1502 :    
1503 :     User permission in worksace (e.g. w - write, r - read, a - admin, n - none)
1504 :    
1505 :    
1506 :     =item Definition
1507 :    
1508 :     =begin html
1509 :    
1510 :     <pre>
1511 :     a string
1512 :     </pre>
1513 :    
1514 :     =end html
1515 :    
1516 :     =begin text
1517 :    
1518 :     a string
1519 :    
1520 :     =end text
1521 :    
1522 :     =back
1523 :    
1524 :    
1525 :    
1526 :     =head2 Username
1527 :    
1528 :     =over 4
1529 :    
1530 :    
1531 :    
1532 :     =item Description
1533 :    
1534 :     Login name for user
1535 :    
1536 :    
1537 :     =item Definition
1538 :    
1539 :     =begin html
1540 :    
1541 :     <pre>
1542 :     a string
1543 :     </pre>
1544 :    
1545 :     =end html
1546 :    
1547 :     =begin text
1548 :    
1549 :     a string
1550 :    
1551 :     =end text
1552 :    
1553 :     =back
1554 :    
1555 :    
1556 :    
1557 :     =head2 bool
1558 :    
1559 :     =over 4
1560 :    
1561 :    
1562 :    
1563 :     =item Definition
1564 :    
1565 :     =begin html
1566 :    
1567 :     <pre>
1568 :     an int
1569 :     </pre>
1570 :    
1571 :     =end html
1572 :    
1573 :     =begin text
1574 :    
1575 :     an int
1576 :    
1577 :     =end text
1578 :    
1579 :     =back
1580 :    
1581 :    
1582 :    
1583 :     =head2 Timestamp
1584 :    
1585 :     =over 4
1586 :    
1587 :    
1588 :    
1589 :     =item Description
1590 :    
1591 :     Indication of a system time
1592 :    
1593 :    
1594 :     =item Definition
1595 :    
1596 :     =begin html
1597 :    
1598 :     <pre>
1599 :     a string
1600 :     </pre>
1601 :    
1602 :     =end html
1603 :    
1604 :     =begin text
1605 :    
1606 :     a string
1607 :    
1608 :     =end text
1609 :    
1610 :     =back
1611 :    
1612 :    
1613 :    
1614 :     =head2 ObjectName
1615 :    
1616 :     =over 4
1617 :    
1618 :    
1619 :    
1620 :     =item Description
1621 :    
1622 :     Name assigned to an object saved to a workspace
1623 :    
1624 :    
1625 :     =item Definition
1626 :    
1627 :     =begin html
1628 :    
1629 :     <pre>
1630 :     a string
1631 :     </pre>
1632 :    
1633 :     =end html
1634 :    
1635 :     =begin text
1636 :    
1637 :     a string
1638 :    
1639 :     =end text
1640 :    
1641 :     =back
1642 :    
1643 :    
1644 :    
1645 :     =head2 ObjectID
1646 :    
1647 :     =over 4
1648 :    
1649 :    
1650 :    
1651 :     =item Description
1652 :    
1653 :     Unique UUID assigned to every object in a workspace on save - IDs never reused
1654 :    
1655 :    
1656 :     =item Definition
1657 :    
1658 :     =begin html
1659 :    
1660 :     <pre>
1661 :     a string
1662 :     </pre>
1663 :    
1664 :     =end html
1665 :    
1666 :     =begin text
1667 :    
1668 :     a string
1669 :    
1670 :     =end text
1671 :    
1672 :     =back
1673 :    
1674 :    
1675 :    
1676 :     =head2 ObjectType
1677 :    
1678 :     =over 4
1679 :    
1680 :    
1681 :    
1682 :     =item Description
1683 :    
1684 :     Specified type of an object (e.g. Genome)
1685 :    
1686 :    
1687 :     =item Definition
1688 :    
1689 :     =begin html
1690 :    
1691 :     <pre>
1692 :     a string
1693 :     </pre>
1694 :    
1695 :     =end html
1696 :    
1697 :     =begin text
1698 :    
1699 :     a string
1700 :    
1701 :     =end text
1702 :    
1703 :     =back
1704 :    
1705 :    
1706 :    
1707 :     =head2 ObjectSize
1708 :    
1709 :     =over 4
1710 :    
1711 :    
1712 :    
1713 :     =item Description
1714 :    
1715 :     Size of the object
1716 :    
1717 :    
1718 :     =item Definition
1719 :    
1720 :     =begin html
1721 :    
1722 :     <pre>
1723 :     an int
1724 :     </pre>
1725 :    
1726 :     =end html
1727 :    
1728 :     =begin text
1729 :    
1730 :     an int
1731 :    
1732 :     =end text
1733 :    
1734 :     =back
1735 :    
1736 :    
1737 :    
1738 :     =head2 ObjectData
1739 :    
1740 :     =over 4
1741 :    
1742 :    
1743 :    
1744 :     =item Description
1745 :    
1746 :     Generic type containing object data
1747 :    
1748 :    
1749 :     =item Definition
1750 :    
1751 :     =begin html
1752 :    
1753 :     <pre>
1754 :     a string
1755 :     </pre>
1756 :    
1757 :     =end html
1758 :    
1759 :     =begin text
1760 :    
1761 :     a string
1762 :    
1763 :     =end text
1764 :    
1765 :     =back
1766 :    
1767 :    
1768 :    
1769 :     =head2 FullObjectPath
1770 :    
1771 :     =over 4
1772 :    
1773 :    
1774 :    
1775 :     =item Description
1776 :    
1777 :     Path to any object in workspace database
1778 :    
1779 :    
1780 :     =item Definition
1781 :    
1782 :     =begin html
1783 :    
1784 :     <pre>
1785 :     a string
1786 :     </pre>
1787 :    
1788 :     =end html
1789 :    
1790 :     =begin text
1791 :    
1792 :     a string
1793 :    
1794 :     =end text
1795 :    
1796 :     =back
1797 :    
1798 :    
1799 :    
1800 :     =head2 UserMetadata
1801 :    
1802 :     =over 4
1803 :    
1804 :    
1805 :    
1806 :     =item Description
1807 :    
1808 :     This is a key value hash of user-specified metadata
1809 :    
1810 :    
1811 :     =item Definition
1812 :    
1813 :     =begin html
1814 :    
1815 :     <pre>
1816 :     a reference to a hash where the key is a string and the value is a string
1817 :     </pre>
1818 :    
1819 :     =end html
1820 :    
1821 :     =begin text
1822 :    
1823 :     a reference to a hash where the key is a string and the value is a string
1824 :    
1825 :     =end text
1826 :    
1827 :     =back
1828 :    
1829 :    
1830 :    
1831 :     =head2 AutoMetadata
1832 :    
1833 :     =over 4
1834 :    
1835 :    
1836 :    
1837 :     =item Description
1838 :    
1839 :     This is a key value hash of automated metadata populated based on object type
1840 :    
1841 :    
1842 :     =item Definition
1843 :    
1844 :     =begin html
1845 :    
1846 :     <pre>
1847 :     a reference to a hash where the key is a string and the value is a string
1848 :     </pre>
1849 :    
1850 :     =end html
1851 :    
1852 :     =begin text
1853 :    
1854 :     a reference to a hash where the key is a string and the value is a string
1855 :    
1856 :     =end text
1857 :    
1858 :     =back
1859 :    
1860 :    
1861 :    
1862 :     =head2 ObjectMeta
1863 :    
1864 :     =over 4
1865 :    
1866 :    
1867 :    
1868 :     =item Description
1869 :    
1870 : parrello 1.3 ObjectMeta: tuple containing information about an object in the workspace
1871 : olson 1.1
1872 :     ObjectName - name selected for object in workspace
1873 :     ObjectType - type of the object in the workspace
1874 :     FullObjectPath - full path to object in workspace, including object name
1875 :     Timestamp creation_time - time when the object was created
1876 :     ObjectID - a globally unique UUID assigned to every object that will never change even if the object is moved
1877 :     Username object_owner - name of object owner
1878 :     ObjectSize - size of the object in bytes or if object is directory, the number of objects in directory
1879 :     UserMetadata - arbitrary user metadata associated with object
1880 :     AutoMetadata - automatically populated metadata generated from object data in automated way
1881 :     WorkspacePerm user_permission - permissions for the authenticated user of this workspace.
1882 :     WorkspacePerm global_permission - whether this workspace is globally readable.
1883 :     string shockurl - shockurl included if object is a reference to a shock node
1884 :    
1885 :    
1886 :     =item Definition
1887 :    
1888 :     =begin html
1889 :    
1890 :     <pre>
1891 :     a reference to a list containing 12 items:
1892 :     0: an ObjectName
1893 :     1: an ObjectType
1894 :     2: a FullObjectPath
1895 :     3: (creation_time) a Timestamp
1896 :     4: an ObjectID
1897 :     5: (object_owner) a Username
1898 :     6: an ObjectSize
1899 :     7: a UserMetadata
1900 :     8: an AutoMetadata
1901 :     9: (user_permission) a WorkspacePerm
1902 :     10: (global_permission) a WorkspacePerm
1903 :     11: (shockurl) a string
1904 :    
1905 :     </pre>
1906 :    
1907 :     =end html
1908 :    
1909 :     =begin text
1910 :    
1911 :     a reference to a list containing 12 items:
1912 :     0: an ObjectName
1913 :     1: an ObjectType
1914 :     2: a FullObjectPath
1915 :     3: (creation_time) a Timestamp
1916 :     4: an ObjectID
1917 :     5: (object_owner) a Username
1918 :     6: an ObjectSize
1919 :     7: a UserMetadata
1920 :     8: an AutoMetadata
1921 :     9: (user_permission) a WorkspacePerm
1922 :     10: (global_permission) a WorkspacePerm
1923 :     11: (shockurl) a string
1924 :    
1925 :    
1926 :     =end text
1927 :    
1928 :     =back
1929 :    
1930 :    
1931 :    
1932 :     =head2 create_params
1933 :    
1934 :     =over 4
1935 :    
1936 :    
1937 :    
1938 :     =item Description
1939 :    
1940 :     ********* DATA LOAD FUNCTIONS *******************
1941 :    
1942 :    
1943 :     =item Definition
1944 :    
1945 :     =begin html
1946 :    
1947 :     <pre>
1948 :     a reference to a hash where the following keys are defined:
1949 :     objects has a value which is a reference to a list where each element is a reference to a list containing 5 items:
1950 :     0: a FullObjectPath
1951 :     1: an ObjectType
1952 :     2: a UserMetadata
1953 :     3: an ObjectData
1954 :     4: (creation_time) a Timestamp
1955 :    
1956 :     permission has a value which is a WorkspacePerm
1957 :     createUploadNodes has a value which is a bool
1958 :     downloadLinks has a value which is a bool
1959 :     overwrite has a value which is a bool
1960 :     adminmode has a value which is a bool
1961 :     setowner has a value which is a string
1962 :    
1963 :     </pre>
1964 :    
1965 :     =end html
1966 :    
1967 :     =begin text
1968 :    
1969 :     a reference to a hash where the following keys are defined:
1970 :     objects has a value which is a reference to a list where each element is a reference to a list containing 5 items:
1971 :     0: a FullObjectPath
1972 :     1: an ObjectType
1973 :     2: a UserMetadata
1974 :     3: an ObjectData
1975 :     4: (creation_time) a Timestamp
1976 :    
1977 :     permission has a value which is a WorkspacePerm
1978 :     createUploadNodes has a value which is a bool
1979 :     downloadLinks has a value which is a bool
1980 :     overwrite has a value which is a bool
1981 :     adminmode has a value which is a bool
1982 :     setowner has a value which is a string
1983 :    
1984 :    
1985 :     =end text
1986 :    
1987 :     =back
1988 :    
1989 :    
1990 :    
1991 :     =head2 update_metadata_params
1992 :    
1993 :     =over 4
1994 :    
1995 :    
1996 :    
1997 :     =item Description
1998 :    
1999 :     "update_metadata" command
2000 : parrello 1.3 Description:
2001 : olson 1.1 This function permits the alteration of metadata associated with an object
2002 :    
2003 :     Parameters:
2004 :     list<tuple<FullObjectPath,UserMetadata>> objects - list of object paths and new metadatas
2005 :     bool autometadata - this flag can only be used by the workspace itself
2006 :     bool adminmode - run this command as an admin, meaning you can set permissions on anything anywhere
2007 :    
2008 :    
2009 :     =item Definition
2010 :    
2011 :     =begin html
2012 :    
2013 :     <pre>
2014 :     a reference to a hash where the following keys are defined:
2015 :     objects has a value which is a reference to a list where each element is a reference to a list containing 4 items:
2016 :     0: a FullObjectPath
2017 :     1: a UserMetadata
2018 :     2: an ObjectType
2019 :     3: (creation_time) a Timestamp
2020 :    
2021 :     autometadata has a value which is a bool
2022 :     adminmode has a value which is a bool
2023 :    
2024 :     </pre>
2025 :    
2026 :     =end html
2027 :    
2028 :     =begin text
2029 :    
2030 :     a reference to a hash where the following keys are defined:
2031 :     objects has a value which is a reference to a list where each element is a reference to a list containing 4 items:
2032 :     0: a FullObjectPath
2033 :     1: a UserMetadata
2034 :     2: an ObjectType
2035 :     3: (creation_time) a Timestamp
2036 :    
2037 :     autometadata has a value which is a bool
2038 :     adminmode has a value which is a bool
2039 :    
2040 :    
2041 :     =end text
2042 :    
2043 :     =back
2044 :    
2045 :    
2046 :    
2047 :     =head2 get_params
2048 :    
2049 :     =over 4
2050 :    
2051 :    
2052 :    
2053 :     =item Description
2054 :    
2055 :     ********* DATA RETRIEVAL FUNCTIONS *******************
2056 :    
2057 :    
2058 :     =item Definition
2059 :    
2060 :     =begin html
2061 :    
2062 :     <pre>
2063 :     a reference to a hash where the following keys are defined:
2064 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2065 :     metadata_only has a value which is a bool
2066 :     adminmode has a value which is a bool
2067 :    
2068 :     </pre>
2069 :    
2070 :     =end html
2071 :    
2072 :     =begin text
2073 :    
2074 :     a reference to a hash where the following keys are defined:
2075 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2076 :     metadata_only has a value which is a bool
2077 :     adminmode has a value which is a bool
2078 :    
2079 :    
2080 :     =end text
2081 :    
2082 :     =back
2083 :    
2084 :    
2085 :    
2086 :     =head2 update_auto_meta_params
2087 :    
2088 :     =over 4
2089 :    
2090 :    
2091 :    
2092 :     =item Description
2093 :    
2094 :     "update_shock_meta" command
2095 :     Description:
2096 :     Call this function to trigger an immediate update of workspace metadata for an object,
2097 :     which should typically take place once the upload of a file into shock has completed
2098 :    
2099 :     Parameters:
2100 :     list<FullObjectPath> objects - list of full paths to objects for which shock nodes should be updated
2101 :    
2102 :    
2103 :     =item Definition
2104 :    
2105 :     =begin html
2106 :    
2107 :     <pre>
2108 :     a reference to a hash where the following keys are defined:
2109 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2110 :     adminmode has a value which is a bool
2111 :    
2112 :     </pre>
2113 :    
2114 :     =end html
2115 :    
2116 :     =begin text
2117 :    
2118 :     a reference to a hash where the following keys are defined:
2119 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2120 :     adminmode has a value which is a bool
2121 :    
2122 :    
2123 :     =end text
2124 :    
2125 :     =back
2126 :    
2127 :    
2128 :    
2129 :     =head2 get_download_url_params
2130 :    
2131 :     =over 4
2132 :    
2133 :    
2134 :    
2135 :     =item Description
2136 :    
2137 :     "get_download_url" command
2138 :     Description:
2139 :     This function returns a URL from which an object may be downloaded
2140 :     without any other authentication required. The download URL will only be
2141 : parrello 1.3 valid for a limited amount of time.
2142 : olson 1.1
2143 :     Parameters:
2144 :     list<FullObjectPath> objects - list of full paths to objects for which URLs are to be constructed
2145 :    
2146 :    
2147 :     =item Definition
2148 :    
2149 :     =begin html
2150 :    
2151 :     <pre>
2152 :     a reference to a hash where the following keys are defined:
2153 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2154 :    
2155 :     </pre>
2156 :    
2157 :     =end html
2158 :    
2159 :     =begin text
2160 :    
2161 :     a reference to a hash where the following keys are defined:
2162 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2163 :    
2164 :    
2165 :     =end text
2166 :    
2167 :     =back
2168 :    
2169 :    
2170 :    
2171 :     =head2 get_archive_url_params
2172 :    
2173 :     =over 4
2174 :    
2175 :    
2176 :    
2177 :     =item Description
2178 :    
2179 :     "get_archive_url" command
2180 :     Description:
2181 : parrello 1.3 This function returns a URL from which an archive of the given
2182 : olson 1.1 objects may be downloaded. The download URL will only be valid for a limited
2183 :     amount of time.
2184 :    
2185 :     Parameters:
2186 :     list<FullObjectPath> objects - list of full paths to objects to be archived
2187 :     bool recursive - if true, recurse into folders
2188 :     string archive_name - name to be given to the archive file
2189 :     string archive_type - type of archive, one of "zip", "tar.gz", "tar.bz2"
2190 :    
2191 :    
2192 :     =item Definition
2193 :    
2194 :     =begin html
2195 :    
2196 :     <pre>
2197 :     a reference to a hash where the following keys are defined:
2198 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2199 :     recursive has a value which is a bool
2200 :     archive_name has a value which is a string
2201 :     archive_type has a value which is a string
2202 :    
2203 :     </pre>
2204 :    
2205 :     =end html
2206 :    
2207 :     =begin text
2208 :    
2209 :     a reference to a hash where the following keys are defined:
2210 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2211 :     recursive has a value which is a bool
2212 :     archive_name has a value which is a string
2213 :     archive_type has a value which is a string
2214 :    
2215 :    
2216 :     =end text
2217 :    
2218 :     =back
2219 :    
2220 :    
2221 :    
2222 :     =head2 list_params
2223 :    
2224 :     =over 4
2225 :    
2226 :    
2227 :    
2228 :     =item Description
2229 :    
2230 :     "list" command
2231 : parrello 1.3 Description:
2232 : olson 1.1 This function retrieves a list of all objects and directories below the specified paths with optional ability to filter by search
2233 :    
2234 :     Parameters:
2235 :     list<FullObjectPath> paths - list of full paths for which subobjects should be listed
2236 :     bool excludeDirectories - don't return directories with output (optional; default = "0")
2237 :     bool excludeObjects - don't return objects with output (optional; default = "0")
2238 :     bool recursive - recursively list contents of all subdirectories; will not work above top level directory (optional; default "0")
2239 :     bool fullHierachicalOutput - return a hash of all directories with contents of each; only useful with "recursive" (optional; default = "0")
2240 :     mapping<string,string> query - filter output object lists by specified key/value query (optional; default = {})
2241 :     bool adminmode - run this command as an admin, meaning you can see anything anywhere
2242 :    
2243 :    
2244 :     =item Definition
2245 :    
2246 :     =begin html
2247 :    
2248 :     <pre>
2249 :     a reference to a hash where the following keys are defined:
2250 :     paths has a value which is a reference to a list where each element is a FullObjectPath
2251 :     excludeDirectories has a value which is a bool
2252 :     excludeObjects has a value which is a bool
2253 :     recursive has a value which is a bool
2254 :     fullHierachicalOutput has a value which is a bool
2255 :     query has a value which is a reference to a hash where the key is a string and the value is a reference to a list where each element is a string
2256 :     adminmode has a value which is a bool
2257 :    
2258 :     </pre>
2259 :    
2260 :     =end html
2261 :    
2262 :     =begin text
2263 :    
2264 :     a reference to a hash where the following keys are defined:
2265 :     paths has a value which is a reference to a list where each element is a FullObjectPath
2266 :     excludeDirectories has a value which is a bool
2267 :     excludeObjects has a value which is a bool
2268 :     recursive has a value which is a bool
2269 :     fullHierachicalOutput has a value which is a bool
2270 :     query has a value which is a reference to a hash where the key is a string and the value is a reference to a list where each element is a string
2271 :     adminmode has a value which is a bool
2272 :    
2273 :    
2274 :     =end text
2275 :    
2276 :     =back
2277 :    
2278 :    
2279 :    
2280 :     =head2 copy_params
2281 :    
2282 :     =over 4
2283 :    
2284 :    
2285 :    
2286 :     =item Description
2287 :    
2288 :     ********* REORGANIZATION FUNCTIONS ******************
2289 :    
2290 :    
2291 :     =item Definition
2292 :    
2293 :     =begin html
2294 :    
2295 :     <pre>
2296 :     a reference to a hash where the following keys are defined:
2297 :     objects has a value which is a reference to a list where each element is a reference to a list containing 2 items:
2298 :     0: (source) a FullObjectPath
2299 :     1: (destination) a FullObjectPath
2300 :    
2301 :     overwrite has a value which is a bool
2302 :     recursive has a value which is a bool
2303 :     move has a value which is a bool
2304 :     adminmode has a value which is a bool
2305 :    
2306 :     </pre>
2307 :    
2308 :     =end html
2309 :    
2310 :     =begin text
2311 :    
2312 :     a reference to a hash where the following keys are defined:
2313 :     objects has a value which is a reference to a list where each element is a reference to a list containing 2 items:
2314 :     0: (source) a FullObjectPath
2315 :     1: (destination) a FullObjectPath
2316 :    
2317 :     overwrite has a value which is a bool
2318 :     recursive has a value which is a bool
2319 :     move has a value which is a bool
2320 :     adminmode has a value which is a bool
2321 :    
2322 :    
2323 :     =end text
2324 :    
2325 :     =back
2326 :    
2327 :    
2328 :    
2329 :     =head2 delete_params
2330 :    
2331 :     =over 4
2332 :    
2333 :    
2334 :    
2335 :     =item Description
2336 :    
2337 :     ********* DELETION FUNCTIONS ******************
2338 :    
2339 :    
2340 :     =item Definition
2341 :    
2342 :     =begin html
2343 :    
2344 :     <pre>
2345 :     a reference to a hash where the following keys are defined:
2346 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2347 :     deleteDirectories has a value which is a bool
2348 :     force has a value which is a bool
2349 :     adminmode has a value which is a bool
2350 :    
2351 :     </pre>
2352 :    
2353 :     =end html
2354 :    
2355 :     =begin text
2356 :    
2357 :     a reference to a hash where the following keys are defined:
2358 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2359 :     deleteDirectories has a value which is a bool
2360 :     force has a value which is a bool
2361 :     adminmode has a value which is a bool
2362 :    
2363 :    
2364 :     =end text
2365 :    
2366 :     =back
2367 :    
2368 :    
2369 :    
2370 :     =head2 set_permissions_params
2371 :    
2372 :     =over 4
2373 :    
2374 :    
2375 :    
2376 :     =item Description
2377 :    
2378 :     ********* FUNCTIONS RELATED TO SHARING *******************
2379 :    
2380 :    
2381 :     =item Definition
2382 :    
2383 :     =begin html
2384 :    
2385 :     <pre>
2386 :     a reference to a hash where the following keys are defined:
2387 :     path has a value which is a FullObjectPath
2388 :     permissions has a value which is a reference to a list where each element is a reference to a list containing 2 items:
2389 :     0: a Username
2390 :     1: a WorkspacePerm
2391 :    
2392 :     new_global_permission has a value which is a WorkspacePerm
2393 :     adminmode has a value which is a bool
2394 :    
2395 :     </pre>
2396 :    
2397 :     =end html
2398 :    
2399 :     =begin text
2400 :    
2401 :     a reference to a hash where the following keys are defined:
2402 :     path has a value which is a FullObjectPath
2403 :     permissions has a value which is a reference to a list where each element is a reference to a list containing 2 items:
2404 :     0: a Username
2405 :     1: a WorkspacePerm
2406 :    
2407 :     new_global_permission has a value which is a WorkspacePerm
2408 :     adminmode has a value which is a bool
2409 :    
2410 :    
2411 :     =end text
2412 :    
2413 :     =back
2414 :    
2415 :    
2416 :    
2417 :     =head2 list_permissions_params
2418 :    
2419 :     =over 4
2420 :    
2421 :    
2422 :    
2423 :     =item Description
2424 :    
2425 :     "list_permissions" command
2426 : parrello 1.3 Description:
2427 : olson 1.1 This function lists permissions for the specified objects
2428 :    
2429 :     Parameters:
2430 :     list<FullObjectPath> objects - path to objects for which permissions are to be listed
2431 :     bool adminmode - run this command as an admin, meaning you can list permissions on anything anywhere
2432 :    
2433 :    
2434 :     =item Definition
2435 :    
2436 :     =begin html
2437 :    
2438 :     <pre>
2439 :     a reference to a hash where the following keys are defined:
2440 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2441 :     adminmode has a value which is a bool
2442 :    
2443 :     </pre>
2444 :    
2445 :     =end html
2446 :    
2447 :     =begin text
2448 :    
2449 :     a reference to a hash where the following keys are defined:
2450 :     objects has a value which is a reference to a list where each element is a FullObjectPath
2451 :     adminmode has a value which is a bool
2452 :    
2453 :    
2454 :     =end text
2455 :    
2456 :     =back
2457 :    
2458 :    
2459 :    
2460 :     =cut
2461 :    
2462 :     package Bio::P3::Workspace::WorkspaceClient::RpcClient;
2463 : parrello 1.3 use base 'JSON::RPC::Legacy::Client';
2464 : olson 1.1 use POSIX;
2465 :     use strict;
2466 :    
2467 :     #
2468 :     # Override JSON::RPC::Client::call because it doesn't handle error returns properly.
2469 :     #
2470 :    
2471 :     sub call {
2472 :     my ($self, $uri, $headers, $obj) = @_;
2473 :     my $result;
2474 :    
2475 :    
2476 :     {
2477 : parrello 1.3 if ($uri =~ /\?/) {
2478 :     $result = $self->_get($uri);
2479 :     }
2480 :     else {
2481 :     Carp::croak "not hashref." unless (ref $obj eq 'HASH');
2482 :     $result = $self->_post($uri, $headers, $obj);
2483 :     }
2484 : olson 1.1
2485 :     }
2486 :    
2487 :     my $service = $obj->{method} =~ /^system\./ if ( $obj );
2488 :    
2489 :     $self->status_line($result->status_line);
2490 :    
2491 :     if ($result->is_success) {
2492 :    
2493 :     return unless($result->content); # notification?
2494 :    
2495 :     if ($service) {
2496 : parrello 1.3 return JSON::RPC::Legacy::ServiceObject->new($result, $self->json);
2497 : olson 1.1 }
2498 :    
2499 : parrello 1.3 return JSON::RPC::Legacy::ReturnObject->new($result, $self->json);
2500 : olson 1.1 }
2501 :     elsif ($result->content_type eq 'application/json')
2502 :     {
2503 : parrello 1.3 return JSON::RPC::Legacy::ReturnObject->new($result, $self->json);
2504 : olson 1.1 }
2505 :     else {
2506 :     return;
2507 :     }
2508 :     }
2509 :    
2510 :    
2511 :     sub _post {
2512 :     my ($self, $uri, $headers, $obj) = @_;
2513 :     my $json = $self->json;
2514 :    
2515 :     $obj->{version} ||= $self->{version} || '1.1';
2516 :    
2517 :     if ($obj->{version} eq '1.0') {
2518 :     delete $obj->{version};
2519 :     if (exists $obj->{id}) {
2520 :     $self->id($obj->{id}) if ($obj->{id}); # if undef, it is notification.
2521 :     }
2522 :     else {
2523 : parrello 1.3 $obj->{id} = $self->id || ($self->id('JSON::RPC::Legacy::Client'));
2524 : olson 1.1 }
2525 :     }
2526 :     else {
2527 :     # $obj->{id} = $self->id if (defined $self->id);
2528 : parrello 1.3 # Assign a random number to the id if one hasn't been set
2529 :     $obj->{id} = (defined $self->id) ? $self->id : substr(rand(),2);
2530 : olson 1.1 }
2531 :    
2532 :     my $content = $json->encode($obj);
2533 :    
2534 :     $self->ua->post(
2535 :     $uri,
2536 :     Content_Type => $self->{content_type},
2537 :     Content => $content,
2538 :     Accept => 'application/json',
2539 : parrello 1.3 @$headers,
2540 :     ($self->{token} ? (Authorization => $self->{token}) : ()),
2541 : olson 1.1 );
2542 :     }
2543 :    
2544 :    
2545 :    
2546 :     1;
2547 :    
2548 :    
2549 :    
2550 :     package P3WorkspaceClientExt;
2551 :    
2552 :     use Data::Dumper;
2553 :     use strict;
2554 :     use base 'P3WorkspaceClient';
2555 :     use LWP::UserAgent;
2556 :     use File::Slurp;
2557 :    
2558 :     #
2559 :     # This depends on having a valid token
2560 :     #
2561 :     sub home_workspace
2562 :     {
2563 :     my($self) = @_;
2564 :    
2565 :     if ($self->{token} =~ /(^|\|)un=([^|]+)/)
2566 :     {
2567 : parrello 1.3 my $un = $2;
2568 :     return "/$un/home";
2569 : olson 1.1 }
2570 :     }
2571 :    
2572 :     sub copy_files_to_handles
2573 :     {
2574 :     my($self, $use_shock, $token, $file_handle_pairs) = @_;
2575 :    
2576 :     my $ua;
2577 :     if ($use_shock)
2578 :     {
2579 : parrello 1.3 $ua = LWP::UserAgent->new();
2580 :     $token = $token->token if ref($token);
2581 : olson 1.1 }
2582 :    
2583 :     my %fhmap = map { @$_ } @$file_handle_pairs;
2584 :     my $res = $self->get({ objects => [ map { $_->[0] } @$file_handle_pairs] });
2585 :    
2586 :     # print Dumper(\%fhmap, $file_handle_pairs, $res);
2587 :     for my $i (0 .. $#$res)
2588 :     {
2589 : parrello 1.3 my $ent = $res->[$i];
2590 :     my($meta, $data) = @$ent;
2591 :    
2592 :     if (!defined($meta->[0]))
2593 :     {
2594 :     my $f = $file_handle_pairs->[$i]->[0];
2595 :     die "Workspace object not found for $f\n";
2596 :     }
2597 :    
2598 :     bless $meta, 'Bio::P3::Workspace::ObjectMeta';
2599 :     my $fh = $fhmap{$meta->full_path};
2600 : olson 1.1
2601 : parrello 1.3 if ($use_shock && $meta->shock_url)
2602 :     {
2603 :     my $cb = sub {
2604 :     my($data) = @_;
2605 :     print $fh $data;
2606 :     };
2607 :    
2608 :     my $res = $ua->get($meta->shock_url. "?download",
2609 :     Authorization => "OAuth " . $token,
2610 :     ':content_cb' => $cb);
2611 :     if (!$res->is_success)
2612 :     {
2613 :     warn "Error retrieving " . $meta->shock_url . ": " . $res->content . "\n";
2614 :     }
2615 :     }
2616 :     else
2617 :     {
2618 :     print $fh $data;
2619 :     }
2620 : olson 1.1 }
2621 :     }
2622 :    
2623 :    
2624 :     sub save_data_to_file
2625 :     {
2626 :     my($self, $data, $metadata, $path, $type, $overwrite, $use_shock, $token) = @_;
2627 :    
2628 :     $type ||= 'unspecified';
2629 :    
2630 :     if ($use_shock)
2631 :     {
2632 : parrello 1.3 local $HTTP::Request::Common::DYNAMIC_FILE_UPLOAD = 1;
2633 : olson 1.1
2634 : parrello 1.3 $token = $token->token if ref($token);
2635 :     my $ua = LWP::UserAgent->new();
2636 : olson 1.1
2637 : parrello 1.3 my $res = $self->create({ objects => [[$path, $type, $metadata ]],
2638 :     overwrite => ($overwrite ? 1 : 0),
2639 :     createUploadNodes => 1 });
2640 :     if (!ref($res) || @$res == 0)
2641 :     {
2642 :     die "Create failed";
2643 :     }
2644 :     $res = $res->[0];
2645 :     my $shock_url = $res->[11];
2646 :     $shock_url or die "Workspace did not return shock url. Return object: " . Dumper($res);
2647 :    
2648 :     my $req = HTTP::Request::Common::POST($shock_url,
2649 :     Authorization => "OAuth " . $token,
2650 :     Content_Type => 'multipart/form-data',
2651 :     Content => [upload => [undef, 'file', Content => $data]]);
2652 :     $req->method('PUT');
2653 :     my $sres = $ua->request($req);
2654 :     if (!$sres->is_success)
2655 :     {
2656 :     die "Failure writing to shock at $shock_url: " . $sres->code . " " . $sres->content;
2657 :     }
2658 :     print STDERR Dumper($sres->content);
2659 : olson 1.1 }
2660 :     else
2661 :     {
2662 : parrello 1.3 my $res = $self->create({ objects => [[$path, $type, $metadata, $data ]],
2663 :     overwrite => ($overwrite ? 1 : 0) });
2664 :     print STDERR Dumper($res);
2665 : olson 1.1 }
2666 :     }
2667 :    
2668 :     sub save_file_to_file
2669 :     {
2670 :     my($self, $local_file, $metadata, $path, $type, $overwrite, $use_shock, $token) = @_;
2671 :    
2672 :     $type ||= 'unspecified';
2673 :    
2674 :     if ($use_shock)
2675 :     {
2676 : parrello 1.3 local $HTTP::Request::Common::DYNAMIC_FILE_UPLOAD = 1;
2677 : olson 1.1
2678 : parrello 1.3 $token = $token->token if ref($token);
2679 :     my $ua = LWP::UserAgent->new();
2680 :    
2681 :     my $res = $self->create({ objects => [[$path, $type, $metadata ]],
2682 :     overwrite => ($overwrite ? 1 : 0),
2683 :     createUploadNodes => 1 });
2684 :     if (!ref($res) || @$res == 0)
2685 :     {
2686 :     die "Create failed";
2687 :     }
2688 :     $res = $res->[0];
2689 :     my $shock_url = $res->[11];
2690 : olson 1.1
2691 : parrello 1.3 my $req = HTTP::Request::Common::POST($shock_url,
2692 :     Authorization => "OAuth " . $token,
2693 :     Content_Type => 'multipart/form-data',
2694 :     Content => [upload => [$local_file]]);
2695 :     $req->method('PUT');
2696 :     my $sres = $ua->request($req);
2697 :     print STDERR Dumper($sres->content);
2698 : olson 1.1 }
2699 :     else
2700 :     {
2701 : parrello 1.3 my $res = $self->create({ objects => [[$path, $type, $metadata, scalar read_file($local_file) ]],
2702 :     overwrite => ($overwrite ? 1 : 0) });
2703 :     print STDERR Dumper($res);
2704 : olson 1.1 }
2705 :     }
2706 :    
2707 :    
2708 :    
2709 :    
2710 :     package Bio::P3::Workspace::ObjectMeta;
2711 :     sub name { return $_[0]->[0] };
2712 :     sub type { return $_[0]->[1] };
2713 :     sub path { return $_[0]->[2] };
2714 :     sub full_path { return join("", @{$_[0]}[2,0]); }
2715 :     sub creation_time { return $_[0]->[3] };
2716 :     sub id { return $_[0]->[4] };
2717 :     sub owner { return $_[0]->[5] };
2718 :     sub size { return $_[0]->[6] };
2719 :     sub user_metadata { return $_[0]->[7] };
2720 :     sub auto_metadata { return $_[0]->[8] };
2721 :     sub user_permission { return $_[0]->[9] };
2722 :     sub global_permission { return $_[0]->[10] };
2723 :     sub shock_url { return $_[0]->[11] };
2724 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3