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

Annotation of /FigKernelPackages/P3WorkspaceClient.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3