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

Annotation of /FigKernelPackages/P3WorkspaceClient.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3