|
@@ -457,21 +457,33 @@ sub deleteProject {
|
|
return $self->_doRequest('index.php?/api/v2/delete_project/'.$proj,'POST');
|
|
return $self->_doRequest('index.php?/api/v2/delete_project/'.$proj,'POST');
|
|
}
|
|
}
|
|
|
|
|
|
-=head2 B<getProjects ()>
|
|
|
|
|
|
+=head2 B<getProjects (filters)>
|
|
|
|
|
|
Get all available projects
|
|
Get all available projects
|
|
|
|
|
|
|
|
+=over 4
|
|
|
|
+
|
|
|
|
+=item HASHREF C<FILTERS> (optional) - HASHREF describing parameters to filter cases by.
|
|
|
|
+
|
|
|
|
+=back
|
|
|
|
+
|
|
Returns array of project definition HASHREFs, false otherwise.
|
|
Returns array of project definition HASHREFs, false otherwise.
|
|
|
|
|
|
$projects = $tl->getProjects;
|
|
$projects = $tl->getProjects;
|
|
|
|
|
|
|
|
+See:
|
|
|
|
+
|
|
|
|
+ L<https://www.gurock.com/testrail/docs/api/reference/projects#getprojects>
|
|
|
|
+
|
|
|
|
+for details as to the allowable filter keys.
|
|
|
|
+
|
|
=cut
|
|
=cut
|
|
|
|
|
|
sub getProjects {
|
|
sub getProjects {
|
|
- state $check = compile(Object);
|
|
|
|
- my ($self) = $check->(@_);
|
|
|
|
-
|
|
|
|
- my $result = $self->_doRequest('index.php?/api/v2/get_projects');
|
|
|
|
|
|
+ state $check = compile(Object,Optional[Maybe[HashRef]]);
|
|
|
|
+ my ($self,$filters) = $check->(@_);
|
|
|
|
+
|
|
|
|
+ my $result = $self->_doRequest('index.php?/api/v2/get_projects' . _convert_filters_to_string($filters) );
|
|
|
|
|
|
#Save state for future use, if needed
|
|
#Save state for future use, if needed
|
|
return -500 if !$result || (reftype($result) || 'undef') ne 'ARRAY';
|
|
return -500 if !$result || (reftype($result) || 'undef') ne 'ARRAY';
|
|
@@ -1110,20 +1122,7 @@ sub getCases {
|
|
my ($self,$project_id,$suite_id,$filters) = $check->(@_);
|
|
my ($self,$project_id,$suite_id,$filters) = $check->(@_);
|
|
|
|
|
|
my $url = "index.php?/api/v2/get_cases/$project_id&suite_id=$suite_id";
|
|
my $url = "index.php?/api/v2/get_cases/$project_id&suite_id=$suite_id";
|
|
-
|
|
|
|
- my @valid_keys = qw{section_id created_after created_before created_by milestone_id priority_id type_id updated_after updated_before updated_by};
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- # Add in filters
|
|
|
|
- foreach my $filter (keys(%$filters)) {
|
|
|
|
- confess("Invalid filter key '$filter' passed") unless grep {$_ eq $filter} @valid_keys;
|
|
|
|
- if (ref $filters->{$filter} eq 'ARRAY') {
|
|
|
|
- confess "$filter cannot be an ARRAYREF" if grep {$_ eq $filter} qw{created_after created_before updated_after updated_before};
|
|
|
|
- $url .= "&$filter=".join(',',@{$filters->{$filter}});
|
|
|
|
- } else {
|
|
|
|
- $url .= "&$filter=".$filters->{$filter} if defined($filters->{$filter});
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ $url .= _convert_filters_to_string($filters);
|
|
|
|
|
|
return $self->_doRequest($url);
|
|
return $self->_doRequest($url);
|
|
}
|
|
}
|
|
@@ -1364,7 +1363,7 @@ sub deleteRun {
|
|
return $self->_doRequest("index.php?/api/v2/delete_run/$run_id",'POST');
|
|
return $self->_doRequest("index.php?/api/v2/delete_run/$run_id",'POST');
|
|
}
|
|
}
|
|
|
|
|
|
-=head2 B<getRuns (project_id)>
|
|
|
|
|
|
+=head2 B<getRuns (project_id,filters)>
|
|
|
|
|
|
Get all runs for specified project.
|
|
Get all runs for specified project.
|
|
To do this, it must make (no. of runs/250) HTTP requests.
|
|
To do this, it must make (no. of runs/250) HTTP requests.
|
|
@@ -1421,7 +1420,7 @@ sub getRuns {
|
|
return $runs;
|
|
return $runs;
|
|
}
|
|
}
|
|
|
|
|
|
-=head2 B<getRunsPaginated (project_id,limit,offset)>
|
|
|
|
|
|
+=head2 B<getRunsPaginated (project_id,limit,offset,filters)>
|
|
|
|
|
|
Get some runs for specified project.
|
|
Get some runs for specified project.
|
|
|
|
|
|
@@ -1433,7 +1432,7 @@ Get some runs for specified project.
|
|
|
|
|
|
=item INTEGER C<OFFSET> - Page of runs to return.
|
|
=item INTEGER C<OFFSET> - Page of runs to return.
|
|
|
|
|
|
-=item HASHREF C<FILTERS> - (optional) other filters to apply to the requests. See getRuns for more information.
|
|
|
|
|
|
+=item HASHREF C<FILTERS> - (optional) other filters to apply to the requests other than limit/offset. See getRuns for more information.
|
|
|
|
|
|
=back
|
|
=back
|
|
|
|
|
|
@@ -1446,15 +1445,12 @@ Returns ARRAYREF of run definition HASHREFs.
|
|
sub getRunsPaginated {
|
|
sub getRunsPaginated {
|
|
state $check = compile(Object, Int, Optional[Maybe[Int]], Optional[Maybe[Int]], Optional[Maybe[HashRef]]);
|
|
state $check = compile(Object, Int, Optional[Maybe[Int]], Optional[Maybe[Int]], Optional[Maybe[HashRef]]);
|
|
my ($self,$project_id,$limit,$offset,$filters) = $check->(@_);
|
|
my ($self,$project_id,$limit,$offset,$filters) = $check->(@_);
|
|
- $filters //= {};
|
|
|
|
|
|
|
|
confess("Limit greater than ".$self->{'global_limit'}) if $limit > $self->{'global_limit'};
|
|
confess("Limit greater than ".$self->{'global_limit'}) if $limit > $self->{'global_limit'};
|
|
my $apiurl = "index.php?/api/v2/get_runs/$project_id";
|
|
my $apiurl = "index.php?/api/v2/get_runs/$project_id";
|
|
$apiurl .= "&offset=$offset" if defined($offset);
|
|
$apiurl .= "&offset=$offset" if defined($offset);
|
|
$apiurl .= "&limit=$limit" if $limit; #You have problems if you want 0 results
|
|
$apiurl .= "&limit=$limit" if $limit; #You have problems if you want 0 results
|
|
- foreach my $key (keys(%$filters)) {
|
|
|
|
- $apiurl .= "&$key=$filters->{$key}";
|
|
|
|
- }
|
|
|
|
|
|
+ $apiurl .= _convert_filters_to_string($filters);
|
|
return $self->_doRequest($apiurl);
|
|
return $self->_doRequest($apiurl);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1596,34 +1592,35 @@ you will need to use getTestResults.
|
|
=cut
|
|
=cut
|
|
|
|
|
|
sub getRunResults {
|
|
sub getRunResults {
|
|
- state $check = compile(Object, Int);
|
|
|
|
- my ($self,$run_id) = $check->(@_);
|
|
|
|
|
|
+ state $check = compile(Object, Int, Optional[Maybe[HashRef]]);
|
|
|
|
+ my ($self,$run_id, $filters) = $check->(@_);
|
|
|
|
|
|
- my $initial_results = $self->getRunResultsPaginated($run_id,$self->{'global_limit'},undef);
|
|
|
|
|
|
+ my $initial_results = $self->getRunResultsPaginated($run_id,$self->{'global_limit'},undef,$filters);
|
|
return $initial_results unless (reftype($initial_results) || 'undef') eq 'ARRAY';
|
|
return $initial_results unless (reftype($initial_results) || 'undef') eq 'ARRAY';
|
|
my $results = [];
|
|
my $results = [];
|
|
push(@$results,@$initial_results);
|
|
push(@$results,@$initial_results);
|
|
my $offset = 1;
|
|
my $offset = 1;
|
|
while (scalar(@$initial_results) == $self->{'global_limit'}) {
|
|
while (scalar(@$initial_results) == $self->{'global_limit'}) {
|
|
- $initial_results = $self->getRunResultsPaginated($run_id,$self->{'global_limit'},($self->{'global_limit'} * $offset));
|
|
|
|
|
|
+ $initial_results = $self->getRunResultsPaginated($run_id,$self->{'global_limit'},($self->{'global_limit'} * $offset),$filters);
|
|
push(@$results,@$initial_results);
|
|
push(@$results,@$initial_results);
|
|
$offset++;
|
|
$offset++;
|
|
}
|
|
}
|
|
return $results;
|
|
return $results;
|
|
}
|
|
}
|
|
|
|
|
|
-=head2 B<getRunResultsPaginated(run_id,limit,offset)>
|
|
|
|
|
|
+=head2 B<getRunResultsPaginated(run_id,limit,offset,filters)>
|
|
|
|
|
|
=cut
|
|
=cut
|
|
|
|
|
|
sub getRunResultsPaginated {
|
|
sub getRunResultsPaginated {
|
|
- state $check = compile(Object, Int, Optional[Maybe[Int]], Optional[Maybe[Int]]);
|
|
|
|
- my ($self,$run_id,$limit,$offset) = $check->(@_);
|
|
|
|
|
|
+ state $check = compile(Object, Int, Optional[Maybe[Int]], Optional[Maybe[Int]], Optional[Maybe[HashRef]]);
|
|
|
|
+ my ($self,$run_id,$limit,$offset,$filters) = $check->(@_);
|
|
|
|
|
|
confess("Limit greater than ".$self->{'global_limit'}) if $limit > $self->{'global_limit'};
|
|
confess("Limit greater than ".$self->{'global_limit'}) if $limit > $self->{'global_limit'};
|
|
my $apiurl = "index.php?/api/v2/get_results_for_run/$run_id";
|
|
my $apiurl = "index.php?/api/v2/get_results_for_run/$run_id";
|
|
$apiurl .= "&offset=$offset" if defined($offset);
|
|
$apiurl .= "&offset=$offset" if defined($offset);
|
|
$apiurl .= "&limit=$limit" if $limit; #You have problems if you want 0 results
|
|
$apiurl .= "&limit=$limit" if $limit; #You have problems if you want 0 results
|
|
|
|
+ $apiurl .= _convert_filters_to_string($filters);
|
|
return $self->_doRequest($apiurl);
|
|
return $self->_doRequest($apiurl);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1847,7 +1844,7 @@ Get some plans for specified project.
|
|
|
|
|
|
=item INTEGER C<OFFSET> - Page of plans to return.
|
|
=item INTEGER C<OFFSET> - Page of plans to return.
|
|
|
|
|
|
-=item HASHREF C<FILTERS> - (optional) other filters to apply to the requests. See getPlans for more information.
|
|
|
|
|
|
+=item HASHREF C<FILTERS> - (optional) other filters to apply to the requests (other than limit/offset). See getPlans for more information.
|
|
|
|
|
|
=back
|
|
=back
|
|
|
|
|
|
@@ -1860,15 +1857,12 @@ Returns ARRAYREF of plan definition HASHREFs.
|
|
sub getPlansPaginated {
|
|
sub getPlansPaginated {
|
|
state $check = compile(Object, Int, Optional[Maybe[Int]], Optional[Maybe[Int]], Optional[Maybe[HashRef]]);
|
|
state $check = compile(Object, Int, Optional[Maybe[Int]], Optional[Maybe[Int]], Optional[Maybe[HashRef]]);
|
|
my ($self,$project_id,$limit,$offset,$filters) = $check->(@_);
|
|
my ($self,$project_id,$limit,$offset,$filters) = $check->(@_);
|
|
- $filters //= {};
|
|
|
|
|
|
|
|
confess("Limit greater than ".$self->{'global_limit'}) if $limit > $self->{'global_limit'};
|
|
confess("Limit greater than ".$self->{'global_limit'}) if $limit > $self->{'global_limit'};
|
|
my $apiurl = "index.php?/api/v2/get_plans/$project_id";
|
|
my $apiurl = "index.php?/api/v2/get_plans/$project_id";
|
|
$apiurl .= "&offset=$offset" if defined($offset);
|
|
$apiurl .= "&offset=$offset" if defined($offset);
|
|
$apiurl .= "&limit=$limit" if $limit; #You have problems if you want 0 results
|
|
$apiurl .= "&limit=$limit" if $limit; #You have problems if you want 0 results
|
|
- foreach my $key (keys(%$filters)) {
|
|
|
|
- $apiurl .= "&$key=$filters->{$key}";
|
|
|
|
- }
|
|
|
|
|
|
+ $apiurl .= _convert_filters_to_string($filters);
|
|
return $self->_doRequest($apiurl);
|
|
return $self->_doRequest($apiurl);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2106,7 +2100,7 @@ sub deleteMilestone {
|
|
return $self->_doRequest("index.php?/api/v2/delete_milestone/$milestone_id",'POST');
|
|
return $self->_doRequest("index.php?/api/v2/delete_milestone/$milestone_id",'POST');
|
|
}
|
|
}
|
|
|
|
|
|
-=head2 B<getMilestones (project_id)>
|
|
|
|
|
|
+=head2 B<getMilestones (project_id,filters)>
|
|
|
|
|
|
Get milestones for some project.
|
|
Get milestones for some project.
|
|
|
|
|
|
@@ -2114,20 +2108,27 @@ Get milestones for some project.
|
|
|
|
|
|
=item INTEGER C<PROJECT ID> - ID of parent project.
|
|
=item INTEGER C<PROJECT ID> - ID of parent project.
|
|
|
|
|
|
|
|
+=item HASHREF C<FILTERS> (optional) - HASHREF describing parameters to filter milestones by.
|
|
|
|
+
|
|
=back
|
|
=back
|
|
|
|
|
|
|
|
+See:
|
|
|
|
+
|
|
|
|
+ L<https://www.gurock.com/testrail/docs/api/reference/milestones#getmilestones>
|
|
|
|
+
|
|
|
|
+for details as to the allowable filter keys.
|
|
|
|
+
|
|
Returns ARRAYREF of milestone definition HASHREFs.
|
|
Returns ARRAYREF of milestone definition HASHREFs.
|
|
|
|
|
|
$tr->getMilestones(8);
|
|
$tr->getMilestones(8);
|
|
|
|
|
|
-
|
|
|
|
=cut
|
|
=cut
|
|
|
|
|
|
sub getMilestones {
|
|
sub getMilestones {
|
|
- state $check = compile(Object, Int);
|
|
|
|
- my ($self,$project_id) = $check->(@_);
|
|
|
|
|
|
+ state $check = compile(Object, Int, Optional[Maybe[HashRef]]);
|
|
|
|
+ my ($self,$project_id, $filters) = $check->(@_);
|
|
|
|
|
|
- return $self->_doRequest("index.php?/api/v2/get_milestones/$project_id");
|
|
|
|
|
|
+ return $self->_doRequest("index.php?/api/v2/get_milestones/$project_id" . _convert_filters_to_string($filters));
|
|
}
|
|
}
|
|
|
|
|
|
=head2 B<getMilestoneByName (project_id,name)>
|
|
=head2 B<getMilestoneByName (project_id,name)>
|
|
@@ -2529,7 +2530,7 @@ sub bulkAddResultsByCase {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-=head2 B<getTestResults(test_id,limit,offset)>
|
|
|
|
|
|
+=head2 B<getTestResults(test_id,limit,offset,filters)>
|
|
|
|
|
|
Get the recorded results for desired test, limiting output to 'limit' entries.
|
|
Get the recorded results for desired test, limiting output to 'limit' entries.
|
|
|
|
|
|
@@ -2541,23 +2542,32 @@ Get the recorded results for desired test, limiting output to 'limit' entries.
|
|
|
|
|
|
=item INTEGER C<OFFSET> (OPTIONAL) - Offset to begin viewing result set at.
|
|
=item INTEGER C<OFFSET> (OPTIONAL) - Offset to begin viewing result set at.
|
|
|
|
|
|
|
|
+=item HASHREF C<FILTERS> (optional) - HASHREF describing parameters to filter test results by (other than limit/offset).
|
|
|
|
+
|
|
=back
|
|
=back
|
|
|
|
|
|
|
|
+See:
|
|
|
|
+
|
|
|
|
+ L<https://www.gurock.com/testrail/docs/api/reference/results#getresults>
|
|
|
|
+
|
|
|
|
+for details as to the allowable filter keys.
|
|
|
|
+
|
|
Returns ARRAYREF of result definition HASHREFs.
|
|
Returns ARRAYREF of result definition HASHREFs.
|
|
|
|
|
|
=cut
|
|
=cut
|
|
|
|
|
|
sub getTestResults {
|
|
sub getTestResults {
|
|
- state $check = compile(Object, Int, Optional[Maybe[Int]], Optional[Maybe[Int]]);
|
|
|
|
- my ($self,$test_id,$limit,$offset) = $check->(@_);
|
|
|
|
|
|
+ state $check = compile(Object, Int, Optional[Maybe[Int]], Optional[Maybe[Int]], Optional[Maybe[HashRef]]);
|
|
|
|
+ my ($self,$test_id,$limit,$offset,$filters) = $check->(@_);
|
|
|
|
|
|
my $url = "index.php?/api/v2/get_results/$test_id";
|
|
my $url = "index.php?/api/v2/get_results/$test_id";
|
|
$url .= "&limit=$limit" if $limit;
|
|
$url .= "&limit=$limit" if $limit;
|
|
$url .= "&offset=$offset" if defined($offset);
|
|
$url .= "&offset=$offset" if defined($offset);
|
|
|
|
+ $url .= _convert_filters_to_string($filters);
|
|
return $self->_doRequest($url);
|
|
return $self->_doRequest($url);
|
|
}
|
|
}
|
|
|
|
|
|
-=head2 B<getResultsForCase(run_id,case_id,limit,offset)>
|
|
|
|
|
|
+=head2 B<getResultsForCase(run_id,case_id,limit,offset,filters)>
|
|
|
|
|
|
Get the recorded results for a test run and case combination., limiting output to 'limit' entries.
|
|
Get the recorded results for a test run and case combination., limiting output to 'limit' entries.
|
|
|
|
|
|
@@ -2571,19 +2581,28 @@ Get the recorded results for a test run and case combination., limiting output t
|
|
|
|
|
|
=item INTEGER C<OFFSET> (OPTIONAL) - Offset to begin viewing result set at.
|
|
=item INTEGER C<OFFSET> (OPTIONAL) - Offset to begin viewing result set at.
|
|
|
|
|
|
|
|
+=item HASHREF C<FILTERS> (optional) - HASHREF describing parameters to filter by (other than limit/offset).
|
|
|
|
+
|
|
=back
|
|
=back
|
|
|
|
|
|
|
|
+See:
|
|
|
|
+
|
|
|
|
+ L<https://www.gurock.com/testrail/docs/api/reference/results#getresultsforcase>
|
|
|
|
+
|
|
|
|
+for details as to the allowable filter keys.
|
|
|
|
+
|
|
Returns ARRAYREF of result definition HASHREFs.
|
|
Returns ARRAYREF of result definition HASHREFs.
|
|
|
|
|
|
=cut
|
|
=cut
|
|
|
|
|
|
sub getResultsForCase {
|
|
sub getResultsForCase {
|
|
- state $check = compile(Object, Int, Int, Optional[Maybe[Int]], Optional[Maybe[Int]]);
|
|
|
|
- my ($self,$run_id,$case_id,$limit,$offset) = $check->(@_);
|
|
|
|
|
|
+ state $check = compile(Object, Int, Int, Optional[Maybe[Int]], Optional[Maybe[Int]], Optional[Maybe[HashRef]]);
|
|
|
|
+ my ($self,$run_id,$case_id,$limit,$offset,$filters) = $check->(@_);
|
|
|
|
|
|
my $url = "index.php?/api/v2/get_results_for_case/$run_id/$case_id";
|
|
my $url = "index.php?/api/v2/get_results_for_case/$run_id/$case_id";
|
|
$url .= "&limit=$limit" if $limit;
|
|
$url .= "&limit=$limit" if $limit;
|
|
$url .= "&offset=$offset" if defined($offset);
|
|
$url .= "&offset=$offset" if defined($offset);
|
|
|
|
+ $url .= _convert_filters_to_string($filters);
|
|
return $self->_doRequest($url);
|
|
return $self->_doRequest($url);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2911,6 +2930,28 @@ sub buildStepResults {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+# Convenience method for building filter string from filters Hashref
|
|
|
|
+sub _convert_filters_to_string {
|
|
|
|
+ state $check = compile(Maybe[HashRef]);
|
|
|
|
+ my ($filters) = $check->(@_);
|
|
|
|
+
|
|
|
|
+ $filters //= {};
|
|
|
|
+
|
|
|
|
+ my @valid_keys = qw{ is_completed limit offset created_after created_before filter refs section_id updated_after updated_before refs_filter defects_filter };
|
|
|
|
+ my @valid_arrayref_keys = qw{ created_by milestone_id priority_id template_id type_id updated_by suite_id status_id };
|
|
|
|
+
|
|
|
|
+ my $filter_string = '';
|
|
|
|
+ foreach my $filter (keys(%$filters)) {
|
|
|
|
+ confess("Invalid filter key '$filter' passed") unless grep {$_ eq $filter} (@valid_keys, @valid_arrayref_keys);
|
|
|
|
+ if (ref $filters->{$filter} eq 'ARRAY') {
|
|
|
|
+ confess "$filter cannot be an ARRAYREF" if grep {$_ eq $filter} @valid_keys;
|
|
|
|
+ $filter_string .= "&$filter=".join(',',@{$filters->{$filter}});
|
|
|
|
+ } else {
|
|
|
|
+ $filter_string .= "&$filter=".$filters->{$filter} if defined($filters->{$filter});
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $filter_string;
|
|
|
|
+}
|
|
|
|
|
|
1;
|
|
1;
|
|
|
|
|