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

Annotation of /FigKernelPackages/P3WorkspaceClient.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3