File Coverage

blib/lib/WFA/Workflow.pm
Criterion Covered Total %
statement 15 34 44.1
branch n/a
condition n/a
subroutine 5 12 41.6
pod 6 7 85.7
total 26 53 49.0


line stmt bran cond sub pod time code
1             package WFA::Workflow;
2              
3 4     4   76 use 5.008;
  4         12  
  4         141  
4 4     4   18 use strict;
  4         10  
  4         118  
5 4     4   17 use warnings;
  4         9  
  4         102  
6 4     4   42 use Moo;
  4         6  
  4         27  
7              
8 4     4   2485 use WFA::Job;
  4         9  
  4         1237  
9              
10             with 'WFA::Role::Response';
11              
12             =head1 NAME
13              
14             WFA::Workflow - A workflow object, representing a single WFA workflow
15              
16             =cut
17              
18             sub BUILDARGS {
19 0     0 0   my ($class, %args) = @_;
20              
21 0           my $response = $args{response}->{workflow};
22 0           delete $args{response};
23              
24             return {
25 0           %args,
26             response => $response,
27             };
28             };
29              
30             =head1 METHODS
31              
32             =head2 my $workflow_name = $workflow->name()
33              
34             Get the name of the workflow.
35              
36             =cut
37              
38             sub name {
39 0     0 1   my ($self) = @_;
40 0           return $self->response()->{name};
41             }
42              
43             =head2 my $workflow_version = $workflow->version()
44              
45             Get the version of the workflow in the form C<$major.$minor.$revision>.
46              
47             =cut
48              
49             sub version {
50 0     0 1   my ($self) = @_;
51 0           my %version_hash = %{ $self->response()->{version} };
  0            
52 0           return join('.', @version_hash{qw/major minor revision/});
53             }
54              
55             =head2 my $workflow_description = $workflow->description()
56              
57             Get the description of the workflow.
58              
59             =cut
60              
61             sub description {
62 0     0 1   my ($self) = @_;
63 0           return $self->response()->{description};
64             }
65              
66             =head2 my $workflow_uuid = $workflow->uuid()
67              
68             Get the uuid of the workflow. This unique identifier is assigned server-side and is often used in the URLs of the REST C<api>.
69              
70             =cut
71              
72             sub uuid {
73 0     0 1   my ($self) = @_;
74 0           return $self->response()->{uuid};
75             }
76              
77             =head2 my %workflow_parameters = $workflow->parameters()
78              
79             Get the parameters accepted by this workflow during execution. Example:
80              
81             (
82             Parameter1 => {
83             type => 'String',
84             description => 'Some parameter',
85             mandatory => 'true',
86             },
87             Parameter2 => {
88             type => 'String',
89             description => 'Some parameter',
90             mandatory => 'false',
91             },
92             )
93              
94             =cut
95              
96             sub parameters {
97 0     0 1   my ($self) = @_;
98 0           return %{ $self->response()->{userInputList}->{userInput} };
  0            
99             }
100              
101             =head2 my $job = $workflow->execute(%parameters)
102              
103             Execute the workflow with the given parameters. This returns a C<WFA::Job> object which can be used to poll the job status.
104              
105             =over
106              
107             =item I<%parameters>
108              
109             Parameters for the job. Example:
110              
111             (
112             Parameter1 => 'value1',
113             Parameter2 => 'value2',
114             )
115              
116             =back
117              
118             =cut
119              
120             sub execute {
121 0     0 1   my ($self, %parameters) = @_;
122              
123 0           return WFA::Job->new(
124             client => $self->client(),
125             response => $self->client()->submit_wfa_request(
126             $self->url_for_action('execute'),
127             $self->client()->construct_xml_request_parameters(%parameters),
128             ),
129             );
130             }
131              
132             1;