| 1 | package WebService::TeamCity; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Cpanel::JSON::XS; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Data::Visitor::Callback; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use HTTP::Request; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use String::CamelSnakeKebab qw( lower_snake_case ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use Type::Utils qw( class_type ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use Types::Standard qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | ArrayRef | ||||||||||||||||||||||||||||
| 19 | Bool | ||||||||||||||||||||||||||||
| 20 | Dict | ||||||||||||||||||||||||||||
| 21 | InstanceOf | ||||||||||||||||||||||||||||
| 22 | Int | ||||||||||||||||||||||||||||
| 23 | Optional | ||||||||||||||||||||||||||||
| 24 | Str | ||||||||||||||||||||||||||||
| 25 | 4 | ); | |||||||||||||||||||||||||||
| 26 | 4 | ▶ | use URI::FromHash qw( uri_object ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use URI::QueryParam; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use URI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 4 | ▶ | use WebService::TeamCity::Entity::Build; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 4 | ▶ | use WebService::TeamCity::Entity::BuildType; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 4 | ▶ | use WebService::TeamCity::Iterator; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 4 | ▶ | use WebService::TeamCity::LocatorSpec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 4 | ▶ | use WebService::TeamCity::Entity::Project; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 4 | ▶ | use WebService::TeamCity::Types qw( BuildStatus DateTimeObject JSONBool ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 4 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 4 | has scheme => ( | |||||||||||||||||||||||||||
| 39 | is => 'ro', | ||||||||||||||||||||||||||||
| 40 | isa => Str, | ||||||||||||||||||||||||||||
| 41 | default => 'http', | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 4 | has host => ( | |||||||||||||||||||||||||||
| 45 | is => 'ro', | ||||||||||||||||||||||||||||
| 46 | isa => Str, | ||||||||||||||||||||||||||||
| 47 | required => 1, | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 4 | has port => ( | |||||||||||||||||||||||||||
| 51 | is => 'ro', | ||||||||||||||||||||||||||||
| 52 | isa => Int, | ||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 4 | has user => ( | |||||||||||||||||||||||||||
| 56 | is => 'ro', | ||||||||||||||||||||||||||||
| 57 | isa => Str, | ||||||||||||||||||||||||||||
| 58 | required => 1, | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 4 | has password => ( | |||||||||||||||||||||||||||
| 62 | is => 'ro', | ||||||||||||||||||||||||||||
| 63 | isa => Str, | ||||||||||||||||||||||||||||
| 64 | required => 1, | ||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | has ua => ( | ||||||||||||||||||||||||||||
| 68 | is => 'ro', | ||||||||||||||||||||||||||||
| 69 | isa => InstanceOf ['LWP::UserAgent'], | ||||||||||||||||||||||||||||
| 70 | lazy => 1, | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | default => sub { LWP::UserAgent->new }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 72 | 4 | ); | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | has _json => ( | ||||||||||||||||||||||||||||
| 75 | is => 'ro', | ||||||||||||||||||||||||||||
| 76 | isa => InstanceOf ['Cpanel::JSON::XS'], | ||||||||||||||||||||||||||||
| 77 | lazy => 1, | ||||||||||||||||||||||||||||
| 78 | 4 | ▶ | default => sub { Cpanel::JSON::XS->new }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 79 | 4 | ); | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 4 | with 'WebService::TeamCity::Inflator'; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 2 | ▶ | sub projects { | ||||||||||||||||||||||||||
|
Subroutine
projects: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 84 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 2 | my $uri = $self->uri_for('projects'); | |||||||||||||||||||||||||||
| 87 | 2 | my $projects = $self->decoded_json_for( uri => $uri ); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 2 | return $self->_inflate_array( $projects->{project}, 'Project' ); | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 1 | ▶ | sub build_types { | ||||||||||||||||||||||||||
|
Subroutine
build_types: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 93 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 1 | my $uri = $self->uri_for('buildTypes'); | |||||||||||||||||||||||||||
| 96 | 1 | my $types = $self->decoded_json_for( uri => $uri ); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 1 | return $self->_inflate_array( $types->{build_type}, 'BuildType' ); | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||
| 102 | 4 | my $check; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 6 | ▶ | sub builds { | ||||||||||||||||||||||||||
|
Subroutine
builds: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 105 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 6 | ▶ | $check ||= $self->_build_locator_spec->validator( | ||||||||||||||||||||||||||
|
Condition66%2/3
$check ||= $self->_build_locator_spec->validator("include_paging_args", 1)
MC/DC0%0/2
$check ||= $self->_build_locator_spec->validator("include_paging_args", 1)
$check
$self->_build_locator_spec->validator("include_paging_args", 1)
Truth table66%2/3
A ||= B
A= $checkB= $self->_build_locator_spec->validator("include_paging_args", 1)
| |||||||||||||||||||||||||||||
| 108 | include_paging_args => 1 ); | ||||||||||||||||||||||||||||
| 109 | 6 | my ($args) = $check->(@_); | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 6 | my %query; | |||||||||||||||||||||||||||
| 112 | 6 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | my $locator | ||||||||||||||||||||||||||||
| 114 | = $self->_build_locator_spec->locator_string_for_args( | ||||||||||||||||||||||||||||
| 115 | search_args => $args, | ||||||||||||||||||||||||||||
| 116 | include_paging_args => 1, | ||||||||||||||||||||||||||||
| 117 | ) | ||||||||||||||||||||||||||||
| 118 | ) { | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 5 | $query{locator} = $locator; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 6 | my $uri = $self->uri_for( 'builds', \%query ); | |||||||||||||||||||||||||||
| 124 | 6 | return $self->_iterator_for( | |||||||||||||||||||||||||||
| 125 | $uri, | ||||||||||||||||||||||||||||
| 126 | 'build', | ||||||||||||||||||||||||||||
| 127 | 'Build', | ||||||||||||||||||||||||||||
| 128 | ); | ||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||
| 133 | 4 | my $build_locator_spec; | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 8 | ▶ | sub _build_locator_spec { | ||||||||||||||||||||||||||
|
Subroutine
_build_locator_spec: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 136 | 8 | ▶ | return $build_locator_spec ||= do { | ||||||||||||||||||||||||||
|
Condition33%1/3
$build_locator_spec ||= do {
my $self = shift();
my $project_spec = $self->_project_locator_spec;
my(%base) = ("affected_project", $project_spec, "agent_name", &Str(), "branch", &Str(), "build_type", $self->_build_type_locator_spec, "canceled", &Bool() | &JSONBool(), "failed_to_start", &Bool() | &JSONBool(), "id", &Str(), "lookup_limit", &Int(), "number", &Int(), "personal", &Bool() | &JSONBool(), "pinned", &Bool() | &JSONBool(), "project", $project_spec, "running", &Bool() | &JSONBool(), "since_date", &DateTimeObject(), "status", &BuildStatus(), "tags", &ArrayRef([&Str()]));
my $base_spec = "WebService::TeamCity::LocatorSpec"->new("name", "build base", "type_spec", \%base);
return "WebService::TeamCity::LocatorSpec"->new("name", "build", "type_spec", {%base, "since_build", $base_spec})
}
MC/DC0%0/2
$build_locator_spec ||= do {
my $self = shift();
my $project_spec = $self->_project_locator_spec;
my(%base) = ("affected_project", $project_spec, "agent_name", &Str(), "branch", &Str(), "build_type", $self->_build_type_locator_spec, "canceled", &Bool() | &JSONBool(), "failed_to_start", &Bool() | &JSONBool(), "id", &Str(), "lookup_limit", &Int(), "number", &Int(), "personal", &Bool() | &JSONBool(), "pinned", &Bool() | &JSONBool(), "project", $project_spec, "running", &Bool() | &JSONBool(), "since_date", &DateTimeObject(), "status", &BuildStatus(), "tags", &ArrayRef([&Str()]));
my $base_spec = "WebService::TeamCity::LocatorSpec"->new("name", "build base", "type_spec", \%base);
return "WebService::TeamCity::LocatorSpec"->new("name", "build", "type_spec", {%base, "since_build", $base_spec})
}
$build_locator_spec
do {
my $self = shift();
my $project_spec = $self->_project_locator_spec;
my(%base) = ("affected_project", $project_spec, "agent_name", &Str(), "branch", &Str(), "build_type", $self->_build_type_locator_spec, "canceled", &Bool() | &JSONBool(), "failed_to_start", &Bool() | &JSONBool(), "id", &Str(), "lookup_limit", &Int(), "number", &Int(), "personal", &Bool() | &JSONBool(), "pinned", &Bool() | &JSONBool(), "project", $project_spec, "running", &Bool() | &JSONBool(), "since_date", &DateTimeObject(), "status", &BuildStatus(), "tags", &ArrayRef([&Str()]));
my $base_spec = "WebService::TeamCity::LocatorSpec"->new("name", "build base", "type_spec", \%base);
return "WebService::TeamCity::LocatorSpec"->new("name", "build", "type_spec", {%base, "since_build", $base_spec})
}
Truth table33%1/3
A ||= B
A= $build_locator_specB= do {
my $self = shift();
my $project_spec = $self->_project_locator_spec;
my(%base) = ("affected_project", $project_spec, "agent_name", &Str(), "branch", &Str(), "build_type", $self->_build_type_locator_spec, "canceled", &Bool() | &JSONBool(), "failed_to_start", &Bool() | &JSONBool(), "id", &Str(), "lookup_limit", &Int(), "number", &Int(), "personal", &Bool() | &JSONBool(), "pinned", &Bool() | &JSONBool(), "project", $project_spec, "running", &Bool() | &JSONBool(), "since_date", &DateTimeObject(), "status", &BuildStatus(), "tags", &ArrayRef([&Str()]));
my $base_spec = "WebService::TeamCity::LocatorSpec"->new("name", "build base", "type_spec", \%base);
return "WebService::TeamCity::LocatorSpec"->new("name", "build", "type_spec", {%base, "since_build", $base_spec})
}
| |||||||||||||||||||||||||||||
| 137 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 8 | my $project_spec = $self->_project_locator_spec; | |||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 8 | my %base = ( | |||||||||||||||||||||||||||
| 142 | affected_project => $project_spec, | ||||||||||||||||||||||||||||
| 143 | agent_name => Str, | ||||||||||||||||||||||||||||
| 144 | branch => Str, | ||||||||||||||||||||||||||||
| 145 | build_type => $self->_build_type_locator_spec, | ||||||||||||||||||||||||||||
| 146 | canceled => Bool | JSONBool, | ||||||||||||||||||||||||||||
| 147 | failed_to_start => Bool | JSONBool, | ||||||||||||||||||||||||||||
| 148 | id => Str, | ||||||||||||||||||||||||||||
| 149 | lookup_limit => Int, | ||||||||||||||||||||||||||||
| 150 | number => Int, | ||||||||||||||||||||||||||||
| 151 | personal => Bool | JSONBool, | ||||||||||||||||||||||||||||
| 152 | pinned => Bool | JSONBool, | ||||||||||||||||||||||||||||
| 153 | project => $project_spec, | ||||||||||||||||||||||||||||
| 154 | running => Bool | JSONBool, | ||||||||||||||||||||||||||||
| 155 | since_date => DateTimeObject, | ||||||||||||||||||||||||||||
| 156 | status => BuildStatus, | ||||||||||||||||||||||||||||
| 157 | tags => ArrayRef [Str], | ||||||||||||||||||||||||||||
| 158 | ); | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | # We're not going to allow arbitrarily nested since_build build | ||||||||||||||||||||||||||||
| 161 | # specs. | ||||||||||||||||||||||||||||
| 162 | 8 | my $base_spec = WebService::TeamCity::LocatorSpec->new( | |||||||||||||||||||||||||||
| 163 | name => 'build base', | ||||||||||||||||||||||||||||
| 164 | type_spec => \%base, | ||||||||||||||||||||||||||||
| 165 | ); | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 8 | return WebService::TeamCity::LocatorSpec->new( | |||||||||||||||||||||||||||
| 168 | name => 'build', | ||||||||||||||||||||||||||||
| 169 | type_spec => { | ||||||||||||||||||||||||||||
| 170 | %base, | ||||||||||||||||||||||||||||
| 171 | since_build => $base_spec, | ||||||||||||||||||||||||||||
| 172 | }, | ||||||||||||||||||||||||||||
| 173 | ); | ||||||||||||||||||||||||||||
| 174 | }; | ||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||
| 179 | 4 | my $build_type_locator_spec; | |||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 8 | ▶ | sub _build_type_locator_spec { | ||||||||||||||||||||||||||
|
Subroutine
_build_type_locator_spec: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 182 | 8 | ▶ | return $build_type_locator_spec ||= do { | ||||||||||||||||||||||||||
|
Condition33%1/3
$build_type_locator_spec ||= do {
my $self = shift();
my $project_spec = $self->_project_locator_spec;
my(%base) = ("affected_project", $project_spec, "id", &Str(), "name", &Str(), "paused", &Bool() | &JSONBool(), "project", $project_spec, "template_flag", &Bool() | &JSONBool());
my $base_spec = "WebService::TeamCity::LocatorSpec"->new("name", "build type base", "type_spec", \%base);
return "WebService::TeamCity::LocatorSpec"->new("name", "build type", "type_spec", {%base, "template", $base_spec})
}
MC/DC0%0/2
$build_type_locator_spec ||= do {
my $self = shift();
my $project_spec = $self->_project_locator_spec;
my(%base) = ("affected_project", $project_spec, "id", &Str(), "name", &Str(), "paused", &Bool() | &JSONBool(), "project", $project_spec, "template_flag", &Bool() | &JSONBool());
my $base_spec = "WebService::TeamCity::LocatorSpec"->new("name", "build type base", "type_spec", \%base);
return "WebService::TeamCity::LocatorSpec"->new("name", "build type", "type_spec", {%base, "template", $base_spec})
}
$build_type_locator_spec
do {
my $self = shift();
my $project_spec = $self->_project_locator_spec;
my(%base) = ("affected_project", $project_spec, "id", &Str(), "name", &Str(), "paused", &Bool() | &JSONBool(), "project", $project_spec, "template_flag", &Bool() | &JSONBool());
my $base_spec = "WebService::TeamCity::LocatorSpec"->new("name", "build type base", "type_spec", \%base);
return "WebService::TeamCity::LocatorSpec"->new("name", "build type", "type_spec", {%base, "template", $base_spec})
}
Truth table33%1/3
A ||= B
A= $build_type_locator_specB= do {
my $self = shift();
my $project_spec = $self->_project_locator_spec;
my(%base) = ("affected_project", $project_spec, "id", &Str(), "name", &Str(), "paused", &Bool() | &JSONBool(), "project", $project_spec, "template_flag", &Bool() | &JSONBool());
my $base_spec = "WebService::TeamCity::LocatorSpec"->new("name", "build type base", "type_spec", \%base);
return "WebService::TeamCity::LocatorSpec"->new("name", "build type", "type_spec", {%base, "template", $base_spec})
}
| |||||||||||||||||||||||||||||
| 183 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 8 | my $project_spec = $self->_project_locator_spec; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 8 | my %base = ( | |||||||||||||||||||||||||||
| 188 | affected_project => $project_spec, | ||||||||||||||||||||||||||||
| 189 | id => Str, | ||||||||||||||||||||||||||||
| 190 | name => Str, | ||||||||||||||||||||||||||||
| 191 | paused => Bool | JSONBool, | ||||||||||||||||||||||||||||
| 192 | project => $project_spec, | ||||||||||||||||||||||||||||
| 193 | template_flag => Bool | JSONBool, | ||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | # We're not going to allow arbitrarily nested template build | ||||||||||||||||||||||||||||
| 197 | # specs. | ||||||||||||||||||||||||||||
| 198 | 8 | my $base_spec = WebService::TeamCity::LocatorSpec->new( | |||||||||||||||||||||||||||
| 199 | name => 'build type base', | ||||||||||||||||||||||||||||
| 200 | type_spec => \%base, | ||||||||||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 8 | return WebService::TeamCity::LocatorSpec->new( | |||||||||||||||||||||||||||
| 204 | name => 'build type', | ||||||||||||||||||||||||||||
| 205 | type_spec => { | ||||||||||||||||||||||||||||
| 206 | %base, | ||||||||||||||||||||||||||||
| 207 | template => $base_spec, | ||||||||||||||||||||||||||||
| 208 | }, | ||||||||||||||||||||||||||||
| 209 | ); | ||||||||||||||||||||||||||||
| 210 | }; | ||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||
| 215 | 4 | my $project_locator_spec; | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 16 | ▶ | sub _project_locator_spec { | ||||||||||||||||||||||||||
|
Subroutine
_project_locator_spec: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 218 | 16 | ▶ | return $project_locator_spec | ||||||||||||||||||||||||||
|
Condition66%2/3
$project_locator_spec ||= "WebService::TeamCity::LocatorSpec"->new("name", "project", "type_spec", {"id", &Str(), "name", &Str()})
MC/DC0%0/2
$project_locator_spec ||= "WebService::TeamCity::LocatorSpec"->new("name", "project", "type_spec", {"id", &Str(), "name", &Str()})
$project_locator_spec
"WebService::TeamCity::LocatorSpec"->new("name", "project", "type_spec", {"id", &Str(), "name", &Str()})
Truth table66%2/3
A ||= B
A= $project_locator_specB= "WebService::TeamCity::LocatorSpec"->new("name", "project", "type_spec", {"id", &Str(), "name", &Str()})
| |||||||||||||||||||||||||||||
| 219 | ||= WebService::TeamCity::LocatorSpec->new( | ||||||||||||||||||||||||||||
| 220 | name => 'project', | ||||||||||||||||||||||||||||
| 221 | type_spec => { | ||||||||||||||||||||||||||||
| 222 | id => Str, | ||||||||||||||||||||||||||||
| 223 | name => Str, | ||||||||||||||||||||||||||||
| 224 | }, | ||||||||||||||||||||||||||||
| 225 | ); | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 866 | ▶ | sub client { $_[0] } | ||||||||||||||||||||||||||
|
Subroutine
client: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 22 | ▶ | sub decoded_json_for { | ||||||||||||||||||||||||||
|
Subroutine
decoded_json_for: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 232 | 22 | my $self = shift; | |||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 22 | my ( $response, $request ) = $self->make_request(@_); | |||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 22 | ▶ | my $json = try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | # HTTP::Message will handle Content-Encoding (gzip, etc) for us. It | ||||||||||||||||||||||||||||
| 239 | # will not actually decode to UTF-8 for application/json responses. | ||||||||||||||||||||||||||||
| 240 | 22 | $self->_json->decode( $response->decoded_content ); | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | 0 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 243 | 0 | die 'Invalid JSON in response: ' | |||||||||||||||||||||||||||
| 244 | . $response->decoded_content | ||||||||||||||||||||||||||||
| 245 | . "\nFor the request:\n\n" | ||||||||||||||||||||||||||||
| 246 | . $request->as_string; | ||||||||||||||||||||||||||||
| 247 | 22 | }; | |||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 22 | return $self->_decamelize_keys($json); | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 23 | ▶ | sub make_request { | ||||||||||||||||||||||||||
|
Subroutine
make_request: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||
| 253 | 23 | my $self = shift; | |||||||||||||||||||||||||||
| 254 | 23 | my %args = @_; | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 23 | ▶ | my $method = $args{method} // 'GET'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{"method"} // "GET"
MC/DC0%0/1
$args{"method"} // "GET"
$args{"method"}
Truth table50%1/2
A
A= $args{"method"}
| |||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | my $request = HTTP::Request->new( | ||||||||||||||||||||||||||||
| 259 | $method => $args{uri}, | ||||||||||||||||||||||||||||
| 260 | 23 | [ Accept => 'application/json' ], | |||||||||||||||||||||||||||
| 261 | ); | ||||||||||||||||||||||||||||
| 262 | 23 | $request->authorization_basic( $self->user, $self->password ); | |||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 23 | ▶ | my $response = $self->ua->request( $request, $args{file} // () ); | ||||||||||||||||||||||||||
|
Condition66%2/3
$args{"file"} // ()
MC/DC0%0/2
$args{"file"} // ()
$args{"file"}
()
Truth table66%2/3
A // B
A= $args{"file"}B= ()
| |||||||||||||||||||||||||||||
| 265 | 23 | ▶ | unless ( $response->is_success ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | 0 | die '[' | |||||||||||||||||||||||||||
| 267 | . scalar(localtime) | ||||||||||||||||||||||||||||
| 268 | . '] Error response:' . "\n\n" | ||||||||||||||||||||||||||||
| 269 | . $response->as_string | ||||||||||||||||||||||||||||
| 270 | . "\nFor the request:\n\n" | ||||||||||||||||||||||||||||
| 271 | . $request->as_string; | ||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 23 | return ( $response, $request ); | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 10 | ▶ | sub uri_for { | ||||||||||||||||||||||||||
|
Subroutine
uri_for: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 278 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 279 | 10 | ▶ | my $path = shift // die 'No path given'; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() // die("No path given")
MC/DC0%0/1
shift() // die("No path given")
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 280 | 10 | my $query = shift; | |||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 10 | ▶ | $path = '/httpAuth/app/rest/' . $path | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | unless $path =~ m{^/}; | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 10 | my $uri = $self->base_uri; | |||||||||||||||||||||||||||
| 286 | 10 | $uri->path($path); | |||||||||||||||||||||||||||
| 287 | 10 | ▶ | $uri->query_form_hash($query) if $query && %{$query}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$query and %{$query;}
MC/DC100%2/2
$query and %{$query;}
$query
%{$query;}
Truth table100%3/3
A and B
A= $queryB= %{$query;}
| |||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 10 | return $uri->canonical; | |||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 23 | ▶ | sub base_uri { | ||||||||||||||||||||||||||
|
Subroutine
base_uri: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 293 | 23 | my $self = shift; | |||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 23 | ▶ | return uri_object( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | scheme => $self->scheme, | ||||||||||||||||||||||||||||
| 297 | host => $self->host, | ||||||||||||||||||||||||||||
| 298 | ( $self->port ? ( port => $self->port ) : () ), | ||||||||||||||||||||||||||||
| 299 | ); | ||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 23 | ▶ | sub _decamelize_keys { | ||||||||||||||||||||||||||
|
Subroutine
_decamelize_keys: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 303 | 23 | my $self = shift; | |||||||||||||||||||||||||||
| 304 | 23 | my $json = shift; | |||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | return Data::Visitor::Callback->new( | ||||||||||||||||||||||||||||
| 307 | 1438 | ▶ | hash => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 308 | 1438 | shift; | |||||||||||||||||||||||||||
| 309 | 1438 | my $node = shift; | |||||||||||||||||||||||||||
| 310 | 1438 | for my $k ( keys %{$node} ) { | |||||||||||||||||||||||||||
| 311 | 8845 | $node->{ lower_snake_case($k) } = delete $node->{$k}; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | 1438 | return $node; | |||||||||||||||||||||||||||
| 314 | }, | ||||||||||||||||||||||||||||
| 315 | 23 | )->visit($json); | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 4 | 1; | |||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | # ABSTRACT: Client for the TeamCity REST API | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | __END__ | ||||||||||||||||||||||||||||