blib/lib/Net/Silverpeak/Orchestrator.pm

filter: Statementstmt 13.5% 35 / 259 Branchbran 0.0% 0 / 184 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 12.6% 9 / 71 Podpod 98.1% 53 / 54 totaltotal 16.0% 97 / 606 CC 110 SCAR 25.3
CC
110
Cov
7%
login
30.0
get_appliance_backups
30.0
logout
20.0
CRAP 12.5
↑ Summary
1 package Net::Silverpeak::Orchestrator;
2 3 $Net::Silverpeak::Orchestrator::VERSION = '0.018000';
3 # ABSTRACT: Silverpeak Orchestrator REST API client library
4  
5 3 ▶use 5.024;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Types::Standard qw( Bool Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use HTTP::CookieJar;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use List::Util qw( any );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use URI::Escape::XS qw( uri_escape );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 # use Data::Dumper::Concise;
14  
15 3 ▶no warnings "experimental::signatures";
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17  
18 3 has 'user' => (
19 isa => Str,
20 is => 'rw',
21 predicate => 1,
22 );
23 3 has 'passwd' => (
24 isa => Str,
25 is => 'rw',
26 predicate => 1,
27 );
28 3 has 'api_key' => (
29 isa => Str,
30 is => 'rw',
31 predicate => 1,
32 );
33  
34  
35 has 'is_logged_in' => (
36 isa => Bool,
37 is => 'rwp',
38 0 ▶ default => sub { 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 3 );
40  
41 3 with 'Role::REST::Client';
42  
43 has '+persistent_headers' => (
44 0 ▶ default => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
45 0 my $self = shift;
46 0 my %headers;
47 0 ▶ $headers{'X-Auth-Token'} = $self->api_key
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_api_key 0 0 0
48 if $self->has_api_key;
49 0 return \%headers;
50 },
51 3 );
52  
53 0 ▶around 'do_request' => sub($orig, $self, $method, $uri, $opts) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 # $uri .= '?apiKey=' . $self->api_key
55 # if $self->has_api_key;
56 # warn 'request: ' . Dumper([$method, $uri, $opts]);
57 0 my $response = $orig->($self, $method, $uri, $opts);
58 # warn 'response: ' . Dumper($response);
59 0 return $response;
60 3 };
61  
62 0 ▶sub _build_user_agent ($self) {
Subroutine _build_user_agent: not called CC=3 SCAR=24.8
63 0 require HTTP::Thin;
64  
65 0 my %params = $self->clientattrs->%*;
66 0 ▶ if ($self->has_user && $self->has_passwd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_user and $self->has_passwd) 0 0 0
Condition0%0/3
$self->has_user and $self->has_passwd
!ll&&!rl&&r
000
MC/DC0%0/2
$self->has_user and $self->has_passwd
$self->has_user $self->has_passwd
Truth table0%0/3
A and B
A= $self->has_userB= $self->has_passwd
ABresult
0X0
100
111
67 0 $params{cookie_jar} = HTTP::CookieJar->new;
68 }
69  
70 0 return HTTP::Thin->new(%params);
71 }
72  
73 0 ▶sub _error_handler ($self, $res) {
Subroutine _error_handler: not called CC=3 SCAR=24.8
74 my $error_message = ref $res->data eq 'HASH' && exists $res->data->{error}
75 ? $res->data->{error}
76 0 ▶ : $res->response->decoded_content;
Branch: 1 branch
BranchTrueFalseTotal
ref $res->data eq 'HASH' && exists $res->data->{'error'} ? : 0 0 0
Condition0%0/3
ref $res->data eq "HASH" and exists $res->data->{"error"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $res->data eq "HASH" and exists $res->data->{"error"}
ref $res->data eq "HASH" exists $res->data->{"error"}
Truth table0%0/3
A and B
A= ref $res->data eq "HASH"B= exists $res->data->{"error"}
ABresult
0X0
100
111
77  
78 0 croak('error (' . $res->code . '): ' . $error_message);
79 }
80  
81 0 ▶sub _post_with_params ($self, $endpoint, $params, @rest) {
Subroutine _post_with_params: not called CC=2 SCAR=17.9
82 0 my $uri_params = $self->_urlencode_data($params);
83 0 my $uri = $endpoint;
84 0 ▶ $uri .= $endpoint =~ /\?/
Branch: 1 branch
BranchTrueFalseTotal
$endpoint =~ /\?/u ? : 0 0 0
85 ? '&' . $uri_params
86 : '?' . $uri_params;
87  
88 0 return $self->post($uri, @rest);
89 }
90  
91  
92 0 ▶sub login($self) {
Subroutine login: not called CC=5 SCAR=34.0
Pod documented
93 0 ▶ die "user and password required\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_user and $self->has_passwd 0 0 0
Condition0%0/3
$self->has_user and $self->has_passwd
!ll&&!rl&&r
000
MC/DC0%0/2
$self->has_user and $self->has_passwd
$self->has_user $self->has_passwd
Truth table0%0/3
A and B
A= $self->has_userB= $self->has_passwd
ABresult
0X0
100
111
94 unless $self->has_user && $self->has_passwd;
95  
96 0 my $res = $self->post('/gms/rest/authentication/login', {
97 user => $self->user,
98 password => $self->passwd,
99 });
100  
101 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
102 unless $res->code == 200;
103  
104 0 my @cookies = $self->user_agent->cookie_jar->cookies_for($self->server);
105 0 ▶ if (my ($csrf_cookie) = grep { $_->{name} eq 'orchCsrfToken' } @cookies ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($csrf_cookie) = grep({$_->{"name"} eq "orchCsrfToken";} @cookies)) 0 0 0
106 0 $self->set_persistent_header('X-XSRF-TOKEN' => $csrf_cookie->{value});
107 }
108  
109 0 $self->_set_is_logged_in(1);
110  
111 0 return 1;
112 }
113  
114  
115 0 ▶sub logout($self) {
Subroutine logout: not called CC=4 SCAR=30.0
Pod documented
116 0 ▶ die "user and password required\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_user and $self->has_passwd 0 0 0
Condition0%0/3
$self->has_user and $self->has_passwd
!ll&&!rl&&r
000
MC/DC0%0/2
$self->has_user and $self->has_passwd
$self->has_user $self->has_passwd
Truth table0%0/3
A and B
A= $self->has_userB= $self->has_passwd
ABresult
0X0
100
111
117 unless $self->has_user && $self->has_passwd;
118  
119 0 my $res = $self->get('/gms/rest/authentication/logout');
120 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
121 unless $res->code == 200;
122  
123 0 delete $self->persistent_headers->{'X-XSRF-TOKEN'};
124  
125 0 $self->_set_is_logged_in(0);
126  
127 0 return 1;
128 }
129  
130  
131 0 ▶sub get_version($self) {
Subroutine get_version: not called CC=2 SCAR=17.9
Pod documented
132 0 my $res = $self->get('/gms/rest/gms/versions');
133 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
134 unless $res->code == 200;
135  
136 0 return $res->data->{current};
137 }
138  
139 0 ▶sub _is_version_93 ($self) {
Subroutine _is_version_93: not called CC=4 SCAR=30.0
140 0 state $rv;
141 0 ▶ return $rv
Branch: 1 branch
BranchTrueFalseTotal
if defined $rv 0 0 0
142 if defined $rv;
143 0 my $version = $self->get_version;
144 0 my ($major, $minor) = split(/\./, $version);
145 0 ▶ return ($major == 9 && $minor >= 3) || $major > 9;
Condition0%0/6
$major == 9 && $minor >= 3 || $major > 9
l!l&&r!l&&!r
000
$major == 9 and $minor >= 3
!ll&&!rl&&r
000
MC/DC0%0/3
$major == 9 && $minor >= 3 || $major > 9
$major == 9 $minor >= 3 $major > 9
Truth table0%0/5
A and B || C
A= $major == 9B= $minor >= 3C= $major > 9
ABCresult
11X1
0X11
1011
0X00
1000
146 }
147  
148  
149 0 ▶sub list_templategroups($self) {
Subroutine list_templategroups: not called CC=2 SCAR=17.9
Pod documented
150 0 my $res = $self->get('/gms/rest/template/templateGroups');
151 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
152 unless $res->code == 200;
153 0 return $res->data;
154 }
155  
156  
157 0 ▶sub get_templategroup($self, $name) {
Subroutine get_templategroup: not called CC=4 SCAR=30.0
Pod documented
158 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
159 ? $self->get('/gms/rest/template/templateGroups', { templateGroup => $name })
160 : $self->get('/gms/rest/template/templateGroups/' . uri_escape($name));
161 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
162 unless $res->code == 200;
163 # version 9.3+ returns an array with a single hashref
164 # instead of the hashref
165 0 ▶ return $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
166 ? $res->data->[0]
167 : $res->data;
168 }
169  
170  
171 0 ▶sub create_templategroup($self, $name, $data = {}) {
Subroutine create_templategroup: not called CC=3 SCAR=24.8
Pod documented
172 0 $data->{name} = $name;
173 0 my $res = $self->post('/gms/rest/template/templateCreate',
174 $data);
175 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 204 0 0 0
176 unless $res->code == 204;
177 0 return 1;
178 }
179  
180  
181 0 ▶sub update_templates_of_templategroup($self, $name, $templatenames) {
Subroutine update_templates_of_templategroup: not called CC=4 SCAR=30.0
Pod documented
182 0 ▶ croak('templates names must be passed as an arrayref')
Branch: 1 branch
BranchTrueFalseTotal
unless ref $templatenames eq "ARRAY" 0 0 0
183 unless ref $templatenames eq 'ARRAY';
184  
185 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
186 ? $self->_post_with_params('/gms/rest/template/templateSelection',
187 { templateGroup => $name }, $templatenames)
188 : $self->post('/gms/rest/template/templateSelection/' . uri_escape($name),
189 $templatenames);
190 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
191 unless $res->code == 200;
192 0 return $res->data;
193 }
194  
195  
196 0 ▶sub update_templategroup($self, $name, $data) {
Subroutine update_templategroup: not called CC=3 SCAR=24.8
Pod documented
197 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
198 ? $self->_post_with_params('/gms/rest/template/templateGroups', { templateGroup => $name }, $data)
199 : $self->post('/gms/rest/template/templateGroups/' . uri_escape($name), $data);
200 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
201 unless $res->code == 200;
202 0 return $res->data;
203 }
204  
205  
206 0 ▶sub delete_templategroup($self, $name) {
Subroutine delete_templategroup: not called CC=3 SCAR=24.8
Pod documented
207 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
208 ? $self->delete('/gms/rest/template/templateGroups', { templateGroup => $name })
209 : $self->delete('/gms/rest/template/templateGroups/' . uri_escape($name));
210 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 204 0 0 0
211 unless $res->code == 204;
212 0 return 1;
213 }
214  
215  
216 0 ▶sub has_segmentation_enabled ($self) {
Subroutine has_segmentation_enabled: not called CC=2 SCAR=17.9
Pod documented
217 0 my $res = $self->get('/gms/rest/vrf/config/enable');
218 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
219 unless $res->code == 200;
220 0 return $res->data->{enable};
221 }
222  
223  
224 0 ▶sub get_vrf_zones_map ($self) {
Subroutine get_vrf_zones_map: not called CC=2 SCAR=17.9
Pod documented
225 0 my $res = $self->get("/gms/rest/zones/vrfZonesMap");
226 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
227 unless $res->code == 200;
228 0 return $res->data;
229 }
230  
231  
232 0 ▶sub get_vrf_by_id ($self) {
Subroutine get_vrf_by_id: not called CC=2 SCAR=17.9
Pod documented
233 0 my $res = $self->get("/gms/rest/vrf/config/segments");
234 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
235 unless $res->code == 200;
236 0 return $res->data;
237 }
238  
239  
240 0 ▶sub get_vrf_security_policies_by_ids ($self, $source_vrf_id, $destination_vrf_id) {
Subroutine get_vrf_security_policies_by_ids: not called CC=3 SCAR=24.8
Pod documented
241 0 my $mapname = $source_vrf_id . '_' . $destination_vrf_id;
242 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
243 ? $self->get('/gms/rest/vrf/config/securityPolicies', { map => $mapname })
244 : $self->get('/gms/rest/vrf/config/securityPolicies/' . uri_escape($mapname));
245 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
246 unless $res->code == 200;
247 0 return $res->data;
248 }
249  
250  
251 0 ▶sub update_vrf_security_policies_by_ids ($self, $source_vrf_id, $destination_vrf_id, $data) {
Subroutine update_vrf_security_policies_by_ids: not called CC=3 SCAR=24.8
Pod documented
252 0 my $mapname = $source_vrf_id . '_' . $destination_vrf_id;
253 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
254 ? $self->_post_with_params('/gms/rest/vrf/config/securityPolicies', { map => $mapname }, $data)
255 : $self->post('/gms/rest/vrf/config/securityPolicies/' . uri_escape($mapname), $data);
256 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 204 0 0 0
257 unless $res->code == 204;
258 0 return 1;
259 }
260  
261  
262 0 ▶sub list_appliances($self) {
Subroutine list_appliances: not called CC=2 SCAR=17.9
Pod documented
263 0 my $res = $self->get('/gms/rest/appliance');
264 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
265 unless $res->code == 200;
266 0 return $res->data;
267 }
268  
269  
270 0 ▶sub get_appliance($self, $id) {
Subroutine get_appliance: not called CC=3 SCAR=24.8
Pod documented
271 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
272 ? $self->get('/gms/rest/appliance', { nePk => $id })
273 : $self->get('/gms/rest/appliance/' . uri_escape($id));
274 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
275 unless $res->code == 200;
276 0 return $res->data;
277 }
278  
279  
280 0 ▶sub get_appliance_extrainfo ($self, $id) {
Subroutine get_appliance_extrainfo: not called CC=3 SCAR=24.8
Pod documented
281 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
282 ? $self->get('/gms/rest/appliance/extraInfo', { nePk => $id })
283 : $self->get('/gms/rest/appliance/extraInfo/'. uri_escape($id));
284 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
285 unless $res->code == 200;
286 0 return $res->data;
287 }
288  
289  
290 0 ▶sub get_appliance_rest ($self, $id, $url) {
Subroutine get_appliance_rest: not called CC=3 SCAR=24.8
Pod documented
291 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
292 ? $self->get('/gms/rest/appliance/rest', { nePk => $id, url => $url })
293 : $self->get('/gms/rest/appliance/rest/' . uri_escape($id) . '/' . uri_escape($url));
294 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
295 unless $res->code == 200;
296 0 return $res->data;
297 }
298  
299  
300 0 ▶sub create_or_update_appliance_rest ($self, $id, $url, $data) {
Subroutine create_or_update_appliance_rest: not called CC=3 SCAR=24.8
Pod documented
301 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
302 ? $self->_post_with_params('/gms/rest/appliance/rest', { nePk => $id, url => $url }, $data)
303 : $self->post('/gms/rest/appliance/rest/' . uri_escape($id) . '/' . uri_escape($url), $data);
304 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
305 unless $res->code == 200;
306 0 return $res->data;
307 }
308  
309  
310 0 ▶sub get_ha_groups_by_id ($self) {
Subroutine get_ha_groups_by_id: not called CC=2 SCAR=17.9
Pod documented
311 0 my $res = $self->get("/gms/rest/haGroups");
312 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
313 unless $res->code == 200;
314 0 return $res->data;
315 }
316  
317  
318 0 ▶sub list_groups ($self) {
Subroutine list_groups: not called CC=2 SCAR=17.9
Pod documented
319 0 my $res = $self->get('/gms/rest/gms/group');
320 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
321 unless $res->code == 200;
322 0 return $res->data;
323 }
324  
325  
326 0 ▶sub get_deployment ($self, $id) {
Subroutine get_deployment: not called CC=3 SCAR=24.8
Pod documented
327 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
328 ? $self->get('/gms/rest/deployment', { nePk => $id })
329 : $self->get('/gms/rest/deployment/' . uri_escape($id));
330 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
331 unless $res->code == 200;
332 0 return $res->data;
333 }
334  
335  
336 0 ▶sub get_interface_state ($self, $id) {
Subroutine get_interface_state: not called CC=3 SCAR=24.8
Pod documented
337 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
338 ? $self->get('/gms/rest/interfaceState', { nePk => $id })
339 : $self->get('/gms/rest/interfaceState/'. uri_escape($id));
340 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
341 unless $res->code == 200;
342 0 return $res->data;
343 }
344  
345  
346 0 ▶sub get_interface_labels_by_type ($self) {
Subroutine get_interface_labels_by_type: not called CC=2 SCAR=17.9
Pod documented
347 0 my $res = $self->get("/gms/rest/gms/interfaceLabels");
348 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
349 unless $res->code == 200;
350 0 return $res->data;
351 }
352  
353  
354 0 ▶sub get_appliance_ipsla_configs ($self, $id) {
Subroutine get_appliance_ipsla_configs: not called CC=3 SCAR=24.8
Pod documented
355 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
356 ? $self->get('/gms/rest/ipsla/config/managers', { nePk => $id })
357 : $self->get('/gms/rest/ipsla/config/managers/' . uri_escape($id));
358 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
359 unless $res->code == 200;
360 0 return $res->data;
361 }
362  
363  
364 0 ▶sub get_appliance_ipsla_states ($self, $id) {
Subroutine get_appliance_ipsla_states: not called CC=3 SCAR=24.8
Pod documented
365 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
366 ? $self->get('/gms/rest/ipsla/state/managers', { nePk => $id })
367 : $self->get('/gms/rest/ipsla/state/managers/'. uri_escape($id));
368 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
369 unless $res->code == 200;
370 0 return $res->data;
371 }
372  
373  
374 0 ▶sub get_appliance_bgp_system_config ($self, $id, $params = {}) {
Subroutine get_appliance_bgp_system_config: not called CC=4 SCAR=30.0
Pod documented
375 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
376 ? $self->get('/gms/rest/bgp/config/system', { nePk => $id, $params->%* })
377 : $self->get('/gms/rest/bgp/config/system/' . uri_escape($id), $params);
378 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
379 unless $res->code == 200;
380 0 return $res->data;
381 }
382  
383  
384 0 ▶sub get_appliance_bgp_system_config_allvrfs ($self, $id, $params = {}) {
Subroutine get_appliance_bgp_system_config_allvrfs: not called CC=4 SCAR=30.0
Pod documented
385 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
386 ? $self->get('/gms/rest/bgp/config/allVrfs/system', { nePk => $id, $params->%* })
387 : $self->get('/gms/rest/bgp/config/allVrfs/system/' . uri_escape($id), $params);
388 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
389 unless $res->code == 200;
390 0 return $res->data;
391 }
392  
393  
394 0 ▶sub get_appliance_bgp_neighbors ($self, $id, $params = {}) {
Subroutine get_appliance_bgp_neighbors: not called CC=4 SCAR=30.0
Pod documented
395 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
396 ? $self->get('/gms/rest/bgp/config/allVrfs/neighbor', { nePk => $id, $params->%* })
397 : $self->get('/gms/rest/bgp/config/allVrfs/neighbor/' . uri_escape($id), $params);
398 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
399 unless $res->code == 200;
400 0 return $res->data;
401 }
402  
403  
404 0 ▶sub get_appliance_backups ($self, $id, $params = {}) {
Subroutine get_appliance_backups: not called CC=5 SCAR=34.0
Pod documented
405 $params->{runningConfig} = 'false'
406 0 ▶ unless exists $params->{runningConfig};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params->{"runningConfig"} 0 0 0
407 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
408 ? $self->get('/gms/rest/appliance/backup', { nePk => $id, $params->%* })
409 : $self->get('/gms/rest/appliance/backup/' . uri_escape($id), $params);
410 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
411 unless $res->code == 200;
412 0 return $res->data;
413 }
414  
415  
416 0 ▶sub list_template_applianceassociations($self) {
Subroutine list_template_applianceassociations: not called CC=2 SCAR=17.9
Pod documented
417 0 my $res = $self->get('/gms/rest/template/applianceAssociation');
418 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
419 unless $res->code == 200;
420 0 return $res->data;
421 }
422  
423  
424 0 ▶sub list_applianceids_by_templategroupname($self, $name) {
Subroutine list_applianceids_by_templategroupname: not called CC=3 SCAR=24.8
Pod documented
425 0 my $associations = $self->list_template_applianceassociations;
426 0 my @appliance_ids;
427 0 for my $appliance_id (keys %$associations) {
428 push @appliance_ids, $appliance_id
429 0 ▶ if any { $_ eq $name } $associations->{$appliance_id}->@*;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { $_ eq $name; } , @{$$associations{$appliance_id}}) 0 0 0
430 }
431 0 return \@appliance_ids;
432 }
433  
434  
435 0 ▶sub list_addressgroups($self) {
Subroutine list_addressgroups: not called CC=2 SCAR=17.9
Pod documented
436 0 my $res = $self->get('/gms/rest/ipObjects/addressGroup');
437 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
438 unless $res->code == 200;
439 0 return $res->data;
440 }
441  
442  
443 0 ▶sub list_addressgroup_names($self) {
Subroutine list_addressgroup_names: not called CC=2 SCAR=17.9
Pod documented
444 0 my $res = $self->get('/gms/rest/ipObjects/addressGroupNames');
445 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
446 unless $res->code == 200;
447 0 return $res->data;
448 }
449  
450  
451 0 ▶sub get_addressgroup($self, $name) {
Subroutine get_addressgroup: not called CC=3 SCAR=24.8
Pod documented
452 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
453 ? $self->get('/gms/rest/ipObjects/addressGroup', { name => $name })
454 : $self->get('/gms/rest/ipObjects/addressGroup/' . uri_escape($name));
455 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
456 unless $res->code == 200;
457 0 return $res->data;
458 }
459  
460  
461 0 ▶sub create_or_update_addressgroup($self, $name, $data) {
Subroutine create_or_update_addressgroup: not called CC=2 SCAR=17.9
Pod documented
462 0 $data->{name} = $name;
463 0 $data->{type} = 'AG';
464 0 my $res = $self->post('/gms/rest/ipObjects/addressGroup', $data);
465 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 204 0 0 0
466 unless $res->code == 204;
467 0 return 1;
468 }
469  
470  
471 0 ▶sub update_addressgroup($self, $name, $data) {
Subroutine update_addressgroup: not called CC=2 SCAR=17.9
Pod documented
472 0 $data->{name} = $name;
473 0 $data->{type} = 'AG';
474 0 my $res = $self->put('/gms/rest/ipObjects/addressGroup', $data);
475 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 204 0 0 0
476 unless $res->code == 204;
477 0 return 1;
478 }
479  
480  
481 0 ▶sub delete_addressgroup($self, $name) {
Subroutine delete_addressgroup: not called CC=3 SCAR=24.8
Pod documented
482 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
483 ? $self->delete('/gms/rest/ipObjects/addressGroup', { name => $name })
484 : $self->delete('/gms/rest/ipObjects/addressGroup/' . uri_escape($name));
485 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 204 0 0 0
486 unless $res->code == 204;
487 0 return 1;
488 }
489  
490  
491 0 ▶sub list_servicegroups($self) {
Subroutine list_servicegroups: not called CC=2 SCAR=17.9
Pod documented
492 0 my $res = $self->get('/gms/rest/ipObjects/serviceGroup');
493 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
494 unless $res->code == 200;
495 0 return $res->data;
496 }
497  
498  
499 0 ▶sub list_servicegroup_names($self) {
Subroutine list_servicegroup_names: not called CC=2 SCAR=17.9
Pod documented
500 0 my $res = $self->get('/gms/rest/ipObjects/serviceGroupNames');
501 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
502 unless $res->code == 200;
503 0 return $res->data;
504 }
505  
506  
507 0 ▶sub get_servicegroup($self, $name) {
Subroutine get_servicegroup: not called CC=3 SCAR=24.8
Pod documented
508 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
509 ? $self->get('/gms/rest/ipObjects/serviceGroup', { name => $name })
510 : $self->get('/gms/rest/ipObjects/serviceGroup/' . uri_escape($name));
511 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
512 unless $res->code == 200;
513 0 return $res->data;
514 }
515  
516  
517 0 ▶sub create_or_update_servicegroup($self, $name, $data) {
Subroutine create_or_update_servicegroup: not called CC=2 SCAR=17.9
Pod documented
518 0 $data->{name} = $name;
519 0 $data->{type} = 'SG';
520 0 my $res = $self->post('/gms/rest/ipObjects/serviceGroup', $data);
521 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 204 0 0 0
522 unless $res->code == 204;
523 0 return 1;
524 }
525  
526  
527 0 ▶sub update_servicegroup($self, $name, $data) {
Subroutine update_servicegroup: not called CC=2 SCAR=17.9
Pod documented
528 0 $data->{name} = $name;
529 0 $data->{type} = 'SG';
530 0 my $res = $self->put('/gms/rest/ipObjects/serviceGroup', $data);
531 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 204 0 0 0
532 unless $res->code == 204;
533 0 return 1;
534 }
535  
536  
537 0 ▶sub delete_servicegroup($self, $name) {
Subroutine delete_servicegroup: not called CC=3 SCAR=24.8
Pod documented
538 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
539 ? $self->delete('/gms/rest/ipObjects/serviceGroup', { name => $name })
540 : $self->delete('/gms/rest/ipObjects/serviceGroup/' . uri_escape($name));
541 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 204 0 0 0
542 unless $res->code == 204;
543 0 return 1;
544 }
545  
546  
547 0 ▶sub list_compound_applications($self, $resource_key='userDefined') {
Subroutine list_compound_applications: not called CC=4 SCAR=30.0
Pod documented
548 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
549 ? $self->get('/gms/rest/applicationDefinition',
550 {
551 resourceKey => $resource_key,
552 base => 'compoundClassification',
553 })
554 : $self->get('/gms/rest/applicationDefinition/compoundClassification',
555 { resourceKey => $resource_key });
556 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
557 unless $res->code == 200;
558 0 return $res->data;
559 }
560  
561  
562 0 ▶sub create_or_update_compound_application($self, $id, $data) {
Subroutine create_or_update_compound_application: not called CC=2 SCAR=17.9
Pod documented
563 0 $data->{id} = $id;
564  
565 0 my $res = $self->_post_with_params('/gms/rest/applicationDefinition/compoundClassification', { id => $id }, $data);
566 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
567 unless $res->code == 200;
568 0 return 1;
569 }
570  
571  
572 0 ▶sub delete_compound_application($self, $id) {
Subroutine delete_compound_application: not called CC=3 SCAR=24.8
Pod documented
573 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
574 ? $self->delete('/gms/rest/applicationDefinition/compoundClassification', { id => $id })
575 : $self->delete('/gms/rest/applicationDefinition/compoundClassification/' . uri_escape($id));
576 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
577 unless $res->code == 200;
578 0 return 1;
579 }
580  
581  
582 0 ▶sub list_domain_applications($self, $resource_key='userDefined') {
Subroutine list_domain_applications: not called CC=4 SCAR=30.0
Pod documented
583 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
584 ? $self->get('/gms/rest/applicationDefinition',
585 {
586 resourceKey => $resource_key,
587 base => 'dnsClassification',
588 })
589 : $self->get('/gms/rest/applicationDefinition/dnsClassification',
590 { resourceKey => $resource_key });
591 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
592 unless $res->code == 200;
593 0 return $res->data;
594 }
595  
596  
597 0 ▶sub create_or_update_domain_application($self, $domain, $data) {
Subroutine create_or_update_domain_application: not called CC=2 SCAR=17.9
Pod documented
598 0 $data->{domain} = $domain;
599 0 my $res = $self->post('/gms/rest/applicationDefinition/dnsClassification2/domain', $data);
600 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
601 unless $res->code == 200;
602 0 return 1;
603 }
604  
605  
606 0 ▶sub delete_domain_application($self, $domain) {
Subroutine delete_domain_application: not called CC=3 SCAR=24.8
Pod documented
607 0 ▶ my $res = $self->_is_version_93
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_version_93 ? : 0 0 0
608 ? $self->delete('/gms/rest/applicationDefinition/dnsClassification', { domain => $domain })
609 : $self->delete('/gms/rest/applicationDefinition/dnsClassification/' . uri_escape($domain));
610 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
611 unless $res->code == 200;
612 0 return 1;
613 }
614  
615  
616 0 ▶sub list_application_groups($self, $resource_key='userDefined') {
Subroutine list_application_groups: not called CC=3 SCAR=24.8
Pod documented
617 0 my $res = $self->get('/gms/rest/applicationDefinition/applicationTags',
618 { resourceKey => $resource_key });
619 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
620 unless $res->code == 200;
621 0 return $res->data;
622 }
623  
624  
625 0 ▶sub create_or_update_application_group($self, $name, $data) {
Subroutine create_or_update_application_group: not called CC=2 SCAR=17.9
Pod documented
626 0 my $application_groups = $self->list_application_groups;
627 # set or overwrite existing application group
628 0 $application_groups->{$name} = $data;
629 0 my $res = $self->post('/gms/rest/applicationDefinition/applicationTags',
630 $application_groups);
631 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
632 unless $res->code == 200;
633 0 return 1;
634 }
635  
636  
637 0 ▶sub delete_application_group($self, $name) {
Subroutine delete_application_group: not called CC=3 SCAR=24.8
Pod documented
638 0 my $application_groups = $self->list_application_groups;
639 # set or overwrite existing application group
640 croak("application '$name' doesn't exist")
641 0 ▶ unless exists $application_groups->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $application_groups->{$name} 0 0 0
642 0 delete $application_groups->{$name};
643 0 my $res = $self->post('/gms/rest/applicationDefinition/applicationTags',
644 $application_groups);
645 0 ▶ $self->_error_handler($res)
Branch: 1 branch
BranchTrueFalseTotal
unless $res->code == 200 0 0 0
646 unless $res->code == 200;
647 0 return 1;
648 }
649  
650  
651 0 ▶sub DEMOLISH {
Subroutine DEMOLISH: not called CC=4 SCAR=30.0
Pod undocumented
652 0 my $self = shift;
653  
654 0 ▶ $self->logout
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_user and $self->has_passwd and $self->is_logged_in 0 0 0
Condition0%0/6
$self->has_user and $self->has_passwd and $self->is_logged_in
!ll&&!rl&&r
000
$self->has_user and $self->has_passwd
!ll&&!rl&&r
000
MC/DC0%0/3
$self->has_user and $self->has_passwd and $self->is_logged_in
$self->has_user $self->has_passwd $self->is_logged_in
Truth table0%0/4
A and B and C
A= $self->has_userB= $self->has_passwdC= $self->is_logged_in
ABCresult
0XX0
10X0
1100
1111
655 if $self->has_user
656 && $self->has_passwd
657 && $self->is_logged_in;
658 }
659  
660 3 1;
661  
662 __END__
↑ Summary