blib/lib/Net/BaruwaAPI.pm

filter: Statementstmt 89.1% 262 / 294 Branchbran 62.5% 20 / 32 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 96.3% 78 / 81 Podpod 98.5% 68 / 69 totaltotal 87.3% 428 / 490 CC 20 SCAR 24.9
CC
20
Cov
84%
_call
110.0
__ANON__
2.0
__ANON__
2.0
CRAP 12.1
↑ Summary
1 # -*- coding: utf-8 -*-
2 # vim: ai ts=4 sts=4 et sw=4
3 # Net::BaruwaAPI Perl bindings for the Baruwa REST API
4 # Copyright (C) 2015-2019 Andrew Colin Kissa <andrew@topdog.za.net>
5 #
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
8 # You can obtain one at http://mozilla.org/MPL/2.0/.
9 package Net::BaruwaAPI;
10  
11 # use utf8;
12 17 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 17 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 17 ▶use HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 17 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 17 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 17 ▶use Type::Params qw/compile/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 17 ▶use Types::Standard qw(Str InstanceOf Object Int Bool Dict Num ArrayRef Optional);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 17 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 17 our $VERSION = '0.06';
22 17 our $AUTHORITY = 'cpan:DATOPDOG';
23  
24 17 my $api_path = '/api/v1';
25  
26 17 has 'api_url' => (is => 'ro', isa => Str, predicate => 'has_api_url', required => 1);
27  
28 17 has 'api_token' => (is => 'ro', isa => Str, predicate => 'has_api_token', required => 1);
29  
30 has 'ua' => (
31 isa => InstanceOf['LWP::UserAgent'],
32 is => 'ro',
33 lazy => 1,
34 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 0 LWP::UserAgent->new(
36 agent => "BaruwaAPI-Perl",
37 cookie_jar => {},
38 keep_alive => 4,
39 timeout => 60,
40 );
41 },
42 17 );
43  
44 has 'json' => (
45 is => 'ro',
46 isa => Object,
47 lazy => 1,
48 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 0 return JSON::MaybeXS->new( utf8 => 1 );
50 }
51 17 );
52  
53 0 ▶sub _call {
Subroutine _call: not called CC=10 SCAR=47.0
54 0 my ($self) = @_;
55 0 my $request_method = shift @_;
56 0 my $url = shift @_;
57 0 my $data = shift @_;
58  
59 0 my $ua = $self->ua;
60 0 $ua->default_header('Authorization', "Bearer " . $self->api_token);
61 0 $url = $self->api_url . $url;
62  
63 0 my $req = HTTP::Request->new( $request_method, $url );
64 0 $req->accept_decodable;
65  
66 0 ▶ if ($data) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data) 0 0 0
67 0 $req->content($data);
68 }
69 0 $req->header( 'Content-Length' => length $req->content );
70  
71 0 my $res = $ua->request($req);
72  
73 0 ▶ if ($res->header('Content-Type') and $res->header('Content-Type') =~ 'application/json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->header('Content-Type') and $res->header('Content-Type') =~ m[application/json]) { } 0 0 0
Condition0%0/3
$res->header("Content-Type") and $res->header("Content-Type") =~ m[application/json]
!ll&&!rl&&r
000
MC/DC0%0/2
$res->header("Content-Type") and $res->header("Content-Type") =~ m[application/json]
$res->header("Content-Type") $res->header("Content-Type") =~ m[application/json]
Truth table0%0/3
A and B
A= $res->header("Content-Type")B= $res->header("Content-Type") =~ m[application/json]
ABresult
0X0
100
111
74 0 my $json = $res->decoded_content;
75 0 $data = eval { $self->json->decode($json) };
76 0 ▶ unless ($data) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($data) 0 0 0
77 0 ▶ die unless $res->is_error;
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_error 0 0 0
78 0 $data = { code => $res->code, message => $res->message };
79 }
80 } else {
81 0 $data = { code => $res->code, message => $res->message };
82 }
83  
84 0 ▶ if (not $res->is_success and ref $data eq 'HASH' and exists $data->{message}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $res->is_success and ref $data eq "HASH" and exists $data->{"message"}) 0 0 0
Condition0%0/6
not $res->is_success and ref $data eq "HASH" and exists $data->{"message"}
!ll&&!rl&&r
000
not $res->is_success and ref $data eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
not $res->is_success and ref $data eq "HASH" and exists $data->{"message"}
not $res->is_success ref $data eq "HASH" exists $data->{"message"}
Truth table0%0/4
not(A) and B and C
A= not $res->is_successB= ref $data eq "HASH"C= exists $data->{"message"}
ABCresult
0XX0
10X0
1100
1111
85 0 my $message = $data->{message};
86  
87 0 ▶ if (exists $data->{errors}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"errors"}) 0 0 0
88 0 $message .= ': '.join(' - ', map { $_->{message} } grep { exists $_->{message} } @{ $data->{errors} });
89 }
90 0 croak $message;
91 }
92 0 return $data;
93 }
94  
95  
96 2 ▶sub get_users {
Subroutine get_users: called CC=2 SCAR=6.9
Pod documented
97 2 state $check = compile(Object, Optional[Int]);
98 2 my ($self, $page) = $check->(@_);
99 2 my $path = "$api_path/users";
100 2 ▶ $path = "$api_path/users?page=$page" unless @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 1 1 2
101 2 return $self->_call('GET', $path);
102 }
103  
104 1 ▶sub get_user {
Subroutine get_user: called CC=1 SCAR=0.0
Pod documented
105 1 state $check = compile(Object, Int);
106 1 my ($self, $userid) = $check->(@_);
107 1 return $self->_call('GET', "$api_path/users/$userid");
108 }
109  
110 1 ▶sub create_user {
Subroutine create_user: called CC=1 SCAR=0.0
Pod documented
111 1 state $check = compile(Object,
112 Dict[
113 username => Str,
114 firstname => Str,
115 lastname => Str,
116 password1 => Str,
117 password2 => Str,
118 email => Str,
119 timezone => Str,
120 account_type => Int,
121 domains => Int,
122 active => Bool,
123 send_report => Bool,
124 spam_checks => Bool,
125 low_score => Num,
126 high_score => Num,
127 block_macros => Bool,
128 ]);
129 1 my ($self, $data) = $check->(@_);
130 1 return $self->_call('POST', "$api_path/users", $data);
131 }
132  
133 1 ▶sub update_user {
Subroutine update_user: called CC=1 SCAR=0.0
Pod documented
134 1 state $check = compile(Object,
135 Dict[
136 username => Str,
137 firstname => Str,
138 lastname => Str,
139 email => Str,
140 timezone => Str,
141 domains => Int,
142 active => Bool,
143 send_report => Bool,
144 spam_checks => Bool,
145 low_score => Num,
146 high_score => Num,
147 block_macros => Bool,
148 ]);
149 1 my ($self, $data) = $check->(@_);
150 1 return $self->_call('PUT', "$api_path/users", $data);
151 }
152  
153 1 ▶sub delete_user {
Subroutine delete_user: called CC=1 SCAR=0.0
Pod documented
154 1 state $check = compile(Object,
155 Dict[
156 username => Str,
157 firstname => Str,
158 lastname => Str,
159 email => Str,
160 timezone => Str,
161 domains => Int,
162 active => Bool,
163 send_report => Bool,
164 spam_checks => Bool,
165 low_score => Num,
166 high_score => Num,
167 block_macros => Bool,
168 ]);
169 1 my ($self, $data) = $check->(@_);
170 # my ($self, $data) = @_;
171 1 return $self->_call('DELETE', "$api_path/users", $data);
172 }
173  
174 1 ▶sub set_user_passwd {
Subroutine set_user_passwd: called CC=1 SCAR=0.0
Pod documented
175 1 state $check = compile(Object, Int,
176 Dict[
177 password1 => Str,
178 password2 => Str,
179 ]);
180 1 my ($self, $userid, $data) = $check->(@_);
181 1 return $self->_call('POST', "$api_path/users/chpw/$userid");
182 }
183  
184 1 ▶sub get_aliases {
Subroutine get_aliases: called CC=1 SCAR=0.0
Pod documented
185 1 state $check = compile(Object, Int);
186 1 my ($self, $addressid) = $check->(@_);
187 1 return $self->_call('GET', "$api_path/aliasaddresses/$addressid");
188 }
189  
190 1 ▶sub create_alias {
Subroutine create_alias: called CC=1 SCAR=0.0
Pod documented
191 1 state $check = compile(Object, Int,
192 Dict[
193 address => Str,
194 enabled => Bool,
195 ]);
196 1 my ($self, $userid, $data) = $check->(@_);
197 1 return $self->_call('POST', "$api_path/aliasaddresses/$userid", $data);
198 }
199  
200 1 ▶sub update_alias {
Subroutine update_alias: called CC=1 SCAR=0.0
Pod documented
201 1 state $check = compile(Object, Int,
202 Dict[
203 address => Str,
204 enabled => Bool,
205 ]);
206 1 my ($self, $addressid, $data) = $check->(@_);
207 1 return $self->_call('PUT', "$api_path/aliasaddresses/$addressid", $data);
208 }
209  
210 1 ▶sub delete_alias {
Subroutine delete_alias: called CC=1 SCAR=0.0
Pod documented
211 1 state $check = compile(Object, Int,
212 Dict[
213 address => Str,
214 enabled => Bool,
215 ]);
216 1 my ($self, $addressid, $data) = $check->(@_);
217 1 return $self->_call('DELETE', "$api_path/aliasaddresses/$addressid", $data);
218 }
219  
220 2 ▶sub get_domains {
Subroutine get_domains: called CC=2 SCAR=6.9
Pod documented
221 2 state $check = compile(Object, Optional[Int]);
222 2 my ($self, $page) = $check->(@_);
223 2 my $path = "$api_path/domains";
224 2 ▶ $path = "$api_path/domains?page=$page" unless @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 1 1 2
225 2 return $self->_call('GET', $path);
226 }
227  
228 1 ▶sub get_domain {
Subroutine get_domain: called CC=1 SCAR=0.0
Pod documented
229 1 state $check = compile(Object, Int);
230 1 my ($self, $domainid) = $check->(@_);
231 1 return $self->_call('GET', "$api_path/domains/$domainid");
232 }
233  
234 1 ▶sub get_domain_by_name {
Subroutine get_domain_by_name: called CC=1 SCAR=0.0
Pod undocumented
235 1 state $check = compile(Object, Str);
236 1 my ($self, $domain_name) = $check->(@_);
237 1 return $self->_call('GET', "$api_path/domains/byname/$domain_name");
238 }
239  
240 1 ▶sub create_domain {
Subroutine create_domain: called CC=1 SCAR=0.0
Pod documented
241 1 state $check = compile(Object,
242 Dict[
243 name => Str,
244 site_url => Str,
245 status => Bool,
246 accept_inbound => Bool,
247 discard_mail => Bool,
248 smtp_callout => Bool,
249 ldap_callout => Bool,
250 virus_checks => Bool,
251 virus_checks_at_smtp => Bool,
252 block_macros => Bool,
253 spam_checks => Bool,
254 spam_actions => Num,
255 highspam_actions => Num,
256 virus_actions => Num,
257 low_score => Num,
258 high_score => Num,
259 message_size => Str,
260 delivery_mode => Num,
261 language => Str,
262 timezone => Str,
263 report_every => Num,
264 organizations => Num
265 ]);
266 1 my ($self, $data) = $check->(@_);
267 1 return $self->_call('POST', "$api_path/domains", $data);
268 }
269  
270 1 ▶sub update_domain {
Subroutine update_domain: called CC=1 SCAR=0.0
Pod documented
271 1 state $check = compile(Object, Int,
272 Dict[
273 name => Str,
274 site_url => Str,
275 status => Bool,
276 accept_inbound => Bool,
277 discard_mail => Bool,
278 smtp_callout => Bool,
279 ldap_callout => Bool,
280 virus_checks => Bool,
281 virus_checks_at_smtp => Bool,
282 block_macros => Bool,
283 spam_checks => Bool,
284 spam_actions => Num,
285 highspam_actions => Num,
286 virus_actions => Num,
287 low_score => Num,
288 high_score => Num,
289 message_size => Str,
290 delivery_mode => Num,
291 language => Str,
292 timezone => Str,
293 report_every => Num,
294 organizations => Num
295 ]);
296 1 my ($self, $domainid, $data) = $check->(@_);
297 1 return $self->_call('PUT', "$api_path/domains/$domainid", $data);
298 }
299  
300 1 ▶sub delete_domain {
Subroutine delete_domain: called CC=1 SCAR=0.0
Pod documented
301 1 state $check = compile(Object, Int);
302 1 my ($self, $domainid) = $check->(@_);
303 1 return $self->_call('DELETE', "$api_path/domains/$domainid");
304 }
305  
306 2 ▶sub get_domainaliases {
Subroutine get_domainaliases: called CC=2 SCAR=6.9
Pod documented
307 2 state $check = compile(Object, Int, Optional[Int]);
308 2 my ($self, $domainid, $page) = $check->(@_);
309 2 my $path = "$api_path/domainaliases/$domainid";
310 2 ▶ $path = "$api_path/domainaliases/$domainid?page=$page" unless @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 1 1 2
311 2 return $self->_call('GET', $path);
312 }
313  
314 1 ▶sub get_domainalias {
Subroutine get_domainalias: called CC=1 SCAR=0.0
Pod documented
315 1 state $check = compile(Object, Int, Int);
316 1 my ($self, $domainid, $aliasid) = $check->(@_);
317 1 return $self->_call('GET', "$api_path/domainaliases/$domainid/$aliasid");
318 }
319  
320 1 ▶sub create_domainalias {
Subroutine create_domainalias: called CC=1 SCAR=0.0
Pod documented
321 1 state $check = compile(Object, Int,
322 Dict[
323 name => Str,
324 status => Bool,
325 accept_inbound => Bool,
326 domain => Int
327 ]);
328 1 my ($self, $domainid, $data) = $check->(@_);
329 1 return $self->_call('POST', "$api_path/domainaliases/$domainid", $data);
330 }
331  
332 1 ▶sub update_domainalias {
Subroutine update_domainalias: called CC=1 SCAR=0.0
Pod documented
333 1 state $check = compile(Object, Int, Int,
334 Dict[
335 name => Str,
336 status => Bool,
337 accept_inbound => Bool,
338 domain => Int
339 ]);
340 1 my ($self, $domainid, $aliasid, $data) = $check->(@_);
341 1 return $self->_call('PUT', "$api_path/domainaliases/$domainid/$aliasid", $data);
342 }
343  
344 1 ▶sub delete_domainalias {
Subroutine delete_domainalias: called CC=1 SCAR=0.0
Pod documented
345 1 state $check = compile(Object, Int, Int,
346 Dict[
347 name => Str,
348 status => Bool,
349 accept_inbound => Bool,
350 domain => Int
351 ]);
352 1 my ($self, $domainid, $aliasid, $data) = $check->(@_);
353 1 return $self->_call('DELETE', "$api_path/domainaliases/$domainid/$aliasid", $data);
354 }
355  
356 2 ▶sub get_deliveryservers {
Subroutine get_deliveryservers: called CC=2 SCAR=6.9
Pod documented
357 2 state $check = compile(Object, Int, Optional[Int]);
358 2 my ($self, $domainid, $page) = $check->(@_);
359 2 my $path = "$api_path/deliveryservers/$domainid";
360 2 ▶ $path = "$api_path/deliveryservers/$domainid?page=$page" unless @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 1 1 2
361 2 return $self->_call('GET', $path);
362 }
363  
364 1 ▶sub get_deliveryserver {
Subroutine get_deliveryserver: called CC=1 SCAR=0.0
Pod documented
365 1 state $check = compile(Object, Int, Int);
366 1 my ($self, $domainid, $serverid) = $check->(@_);
367 1 return $self->_call('GET', "$api_path/deliveryservers/$domainid/$serverid");
368 }
369  
370 1 ▶sub create_deliveryserver {
Subroutine create_deliveryserver: called CC=1 SCAR=0.0
Pod documented
371 1 state $check = compile(Object, Int,
372 Dict[
373 address => Str,
374 protocol => Int,
375 port => Int,
376 require_tls => Bool,
377 verification_only => Bool,
378 enabled => Bool
379 ]);
380 1 my ($self, $domainid, $data) = $check->(@_);
381 1 return $self->_call('POST', "$api_path/deliveryservers/$domainid", $data);
382 }
383  
384 1 ▶sub update_deliveryserver {
Subroutine update_deliveryserver: called CC=1 SCAR=0.0
Pod documented
385 1 state $check = compile(Object, Int, Int,
386 Dict[
387 address => Str,
388 protocol => Int,
389 port => Int,
390 require_tls => Bool,
391 verification_only => Bool,
392 enabled => Bool
393 ]);
394 1 my ($self, $domainid, $serverid, $data) = $check->(@_);
395 1 return $self->_call('PUT', "$api_path/deliveryservers/$domainid/$serverid", $data);
396 }
397  
398 1 ▶sub delete_deliveryserver {
Subroutine delete_deliveryserver: called CC=1 SCAR=0.0
Pod documented
399 1 state $check = compile(Object, Int, Int,
400 Dict[
401 address => Str,
402 protocol => Int,
403 port => Int,
404 require_tls => Bool,
405 verification_only => Bool,
406 enabled => Bool
407 ]);
408 1 my ($self, $domainid, $serverid, $data) = $check->(@_);
409 1 return $self->_call('DELETE', "$api_path/deliveryservers/$domainid/$serverid", $data);
410 }
411  
412 2 ▶sub get_user_deliveryservers {
Subroutine get_user_deliveryservers: called CC=2 SCAR=6.9
Pod documented
413 2 state $check = compile(Object, Int, Optional[Int]);
414 2 my ($self, $domainid, $page) = $check->(@_);
415 2 my $path = "$api_path/userdeliveryservers/$domainid";
416 2 ▶ $path = "$api_path/userdeliveryservers/$domainid?page=$page" unless @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 1 1 2
417 2 return $self->_call('GET', $path);
418 }
419  
420 1 ▶sub get_user_deliveryserver {
Subroutine get_user_deliveryserver: called CC=1 SCAR=0.0
Pod documented
421 1 state $check = compile(Object, Int, Int);
422 1 my ($self, $domainid, $serverid) = $check->(@_);
423 1 return $self->_call('GET', "$api_path/userdeliveryservers/$domainid/$serverid");
424 }
425  
426 1 ▶sub create_user_deliveryserver {
Subroutine create_user_deliveryserver: called CC=1 SCAR=0.0
Pod documented
427 1 state $check = compile(Object, Int,
428 Dict[
429 address => Str,
430 protocol => Int,
431 port => Int,
432 require_tls => Bool,
433 verification_only => Bool,
434 enabled => Bool
435 ]);
436 1 my ($self, $domainid, $data) = $check->(@_);
437 1 return $self->_call('POST', "$api_path/userdeliveryservers/$domainid", $data);
438 }
439  
440 1 ▶sub update_user_deliveryserver {
Subroutine update_user_deliveryserver: called CC=1 SCAR=0.0
Pod documented
441 1 state $check = compile(Object, Int, Int,
442 Dict[
443 address => Str,
444 protocol => Int,
445 port => Int,
446 require_tls => Bool,
447 verification_only => Bool,
448 enabled => Bool
449 ]);
450 1 my ($self, $domainid, $serverid, $data) = $check->(@_);
451 1 return $self->_call('PUT', "$api_path/userdeliveryservers/$domainid/$serverid", $data);
452 }
453  
454 1 ▶sub delete_user_deliveryserver {
Subroutine delete_user_deliveryserver: called CC=1 SCAR=0.0
Pod documented
455 1 state $check = compile(Object, Int, Int,
456 Dict[
457 address => Str,
458 protocol => Int,
459 port => Int,
460 require_tls => Bool,
461 verification_only => Bool,
462 enabled => Bool
463 ]);
464 1 my ($self, $domainid, $serverid, $data) = $check->(@_);
465 1 return $self->_call('DELETE', "$api_path/userdeliveryservers/$domainid/$serverid", $data);
466 }
467  
468 2 ▶sub get_domain_smarthosts {
Subroutine get_domain_smarthosts: called CC=2 SCAR=6.9
Pod documented
469 2 state $check = compile(Object, Int, Optional[Int]);
470 2 my ($self, $domainid, $page) = $check->(@_);
471 2 my $path = "$api_path/domains/smarthosts/$domainid";
472 2 ▶ $path = "$api_path/domains/smarthosts/$domainid?page=$page" unless @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 1 1 2
473 2 return $self->_call('GET', $path);
474 }
475  
476 2 ▶sub get_domain_smarthost {
Subroutine get_domain_smarthost: called CC=1 SCAR=0.0
Pod documented
477 2 state $check = compile(Object, Int, Int);
478 2 my ($self, $domainid, $serverid) = $check->(@_);
479 2 return $self->_call('GET', "$api_path/domains/smarthosts/$domainid/$serverid");
480 }
481  
482 1 ▶sub create_domain_smarthost {
Subroutine create_domain_smarthost: called CC=1 SCAR=0.0
Pod documented
483 1 state $check = compile(Object, Int,
484 Dict[
485 address => Str,
486 username => Str,
487 password => Str,
488 port => Int,
489 require_tls => Bool,
490 enabled => Bool,
491 description => Str,
492 ]);
493 1 my ($self, $domainid, $data) = $check->(@_);
494 1 return $self->_call('POST', "$api_path/domains/smarthosts/$domainid", $data);
495 }
496  
497 1 ▶sub update_domain_smarthost {
Subroutine update_domain_smarthost: called CC=1 SCAR=0.0
Pod documented
498 1 state $check = compile(Object, Int, Int,
499 Dict[
500 address => Str,
501 username => Str,
502 password => Str,
503 port => Int,
504 require_tls => Bool,
505 enabled => Bool,
506 description => Str,
507 ]);
508 1 my ($self, $domainid, $serverid, $data) = $check->(@_);
509 1 return $self->_call('PUT', "$api_path/domains/smarthosts/$domainid/$serverid", $data);
510 }
511  
512 1 ▶sub delete_domain_smarthost {
Subroutine delete_domain_smarthost: called CC=1 SCAR=0.0
Pod documented
513 1 state $check = compile(Object, Int, Int,
514 Dict[
515 address => Str,
516 username => Str,
517 password => Str,
518 port => Int,
519 require_tls => Bool,
520 enabled => Bool,
521 description => Str,
522 ]);
523 1 my ($self, $domainid, $serverid, $data) = $check->(@_);
524 1 return $self->_call('DELETE', "$api_path/domains/smarthosts/$domainid/$serverid", $data);
525 }
526  
527 2 ▶sub get_org_smarthosts {
Subroutine get_org_smarthosts: called CC=2 SCAR=6.9
Pod documented
528 2 state $check = compile(Object, Int, Optional[Int]);
529 2 my ($self, $orgid, $page) = $check->(@_);
530 2 my $path = "$api_path/organizations/smarthosts/$orgid";
531 2 ▶ $path = "$api_path/organizations/smarthosts/$orgid?page=$page" unless @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 1 1 2
532 2 return $self->_call('GET', $path);
533 }
534  
535 2 ▶sub get_org_smarthost {
Subroutine get_org_smarthost: called CC=1 SCAR=0.0
Pod documented
536 2 state $check = compile(Object, Int, Int);
537 2 my ($self, $orgid, $serverid) = $check->(@_);
538 2 return $self->_call('GET', "$api_path/organizations/smarthosts/$orgid/$serverid");
539 }
540  
541 1 ▶sub create_org_smarthost {
Subroutine create_org_smarthost: called CC=1 SCAR=0.0
Pod documented
542 1 state $check = compile(Object, Int,
543 Dict[
544 address => Str,
545 username => Str,
546 password => Str,
547 port => Int,
548 require_tls => Bool,
549 enabled => Bool,
550 description => Str,
551 ]);
552 1 my ($self, $orgid, $data) = $check->(@_);
553 1 return $self->_call('POST', "$api_path/organizations/smarthosts/$orgid", $data);
554 }
555  
556 1 ▶sub update_org_smarthost {
Subroutine update_org_smarthost: called CC=1 SCAR=0.0
Pod documented
557 1 state $check = compile(Object, Int, Int,
558 Dict[
559 address => Str,
560 username => Str,
561 password => Str,
562 port => Int,
563 require_tls => Bool,
564 enabled => Bool,
565 description => Str,
566 ]);
567 1 my ($self, $orgid, $serverid, $data) = $check->(@_);
568 1 return $self->_call('PUT', "$api_path/organizations/smarthosts/$orgid/$serverid", $data);
569 }
570  
571 1 ▶sub delete_org_smarthost {
Subroutine delete_org_smarthost: called CC=1 SCAR=0.0
Pod documented
572 1 state $check = compile(Object, Int, Int,
573 Dict[
574 address => Str,
575 username => Str,
576 password => Str,
577 port => Int,
578 require_tls => Bool,
579 enabled => Bool,
580 description => Str,
581 ]);
582 1 my ($self, $orgid, $serverid, $data) = $check->(@_);
583 1 return $self->_call('DELETE', "$api_path/organizations/smarthosts/$orgid/$serverid", $data);
584 }
585  
586 2 ▶sub get_fallbackservers {
Subroutine get_fallbackservers: called CC=2 SCAR=6.9
Pod documented
587 2 state $check = compile(Object, Int, Optional[Int]);
588 2 my ($self, $orgid, $page) = $check->(@_);
589 2 my $path = "$api_path/fallbackservers/list/$orgid";
590 2 ▶ $path = "$api_path/fallbackservers/list/$orgid?page=$page" unless @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 1 1 2
591 2 return $self->_call('GET', $path);
592 }
593  
594 1 ▶sub get_fallbackserver {
Subroutine get_fallbackserver: called CC=1 SCAR=0.0
Pod documented
595 1 state $check = compile(Object, Int);
596 1 my ($self, $serverid) = $check->(@_);
597 1 return $self->_call('GET', "$api_path/fallbackservers/$serverid");
598 }
599  
600 1 ▶sub create_fallbackserver {
Subroutine create_fallbackserver: called CC=1 SCAR=0.0
Pod documented
601 1 state $check = compile(Object, Int,
602 Dict[
603 address => Str,
604 protocol => Int,
605 port => Int,
606 require_tls => Bool,
607 verification_only => Bool,
608 enabled => Bool
609 ]);
610 1 my ($self, $orgid, $data) = $check->(@_);
611 1 return $self->_call('POST', "$api_path/fallbackservers/$orgid", $data);
612 }
613  
614 1 ▶sub update_fallbackserver {
Subroutine update_fallbackserver: called CC=1 SCAR=0.0
Pod documented
615 1 state $check = compile(Object, Int,
616 Dict[
617 address => Str,
618 protocol => Int,
619 port => Int,
620 require_tls => Bool,
621 verification_only => Bool,
622 enabled => Bool
623 ]);
624 1 my ($self, $serverid, $data) = $check->(@_);
625 1 return $self->_call('PUT', "$api_path/fallbackservers/$serverid", $data);
626 }
627  
628 1 ▶sub delete_fallbackserver {
Subroutine delete_fallbackserver: called CC=1 SCAR=0.0
Pod documented
629 1 state $check = compile(Object, Int,
630 Dict[
631 address => Str,
632 protocol => Int,
633 port => Int,
634 require_tls => Bool,
635 verification_only => Bool,
636 enabled => Bool
637 ]);
638 1 my ($self, $serverid, $data) = $check->(@_);
639 1 return $self->_call('DELETE', "$api_path/fallbackservers/$serverid", $data);
640 }
641  
642 2 ▶sub get_authservers {
Subroutine get_authservers: called CC=2 SCAR=6.9
Pod documented
643 2 state $check = compile(Object, Int, Optional[Int]);
644 2 my ($self, $domainid, $page) = $check->(@_);
645 2 my $path = "$api_path/authservers/$domainid";
646 2 ▶ $path = "$api_path/authservers/$domainid?page=$page" unless @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 1 1 2
647 2 return $self->_call('GET', $path);
648 }
649  
650 1 ▶sub get_authserver {
Subroutine get_authserver: called CC=1 SCAR=0.0
Pod documented
651 1 state $check = compile(Object, Int, Int);
652 1 my ($self, $domainid, $serverid) = $check->(@_);
653 1 return $self->_call('GET', "$api_path/authservers/$domainid/$serverid");
654 }
655  
656 1 ▶sub create_authserver {
Subroutine create_authserver: called CC=1 SCAR=0.0
Pod documented
657 1 state $check = compile(Object, Int,
658 Dict[
659 address => Str,
660 protocol => Int,
661 port => Int,
662 enabled => Bool,
663 split_address => Bool,
664 user_map_template => Str
665 ]);
666 1 my ($self, $domainid, $data) = $check->(@_);
667 1 return $self->_call('POST', "$api_path/authservers/$domainid", $data);
668 }
669  
670 1 ▶sub update_authserver {
Subroutine update_authserver: called CC=1 SCAR=0.0
Pod documented
671 1 state $check = compile(Object, Int, Int,
672 Dict[
673 address => Str,
674 protocol => Int,
675 port => Int,
676 enabled => Bool,
677 split_address => Bool,
678 user_map_template => Str
679 ]);
680 1 my ($self, $domainid, $serverid, $data) = $check->(@_);
681 1 return $self->_call('PUT', "$api_path/authservers/$domainid/$serverid", $data);
682 }
683  
684 1 ▶sub delete_authserver {
Subroutine delete_authserver: called CC=1 SCAR=0.0
Pod documented
685 1 state $check = compile(Object, Int, Int,
686 Dict[
687 address => Str,
688 protocol => Int,
689 port => Int,
690 enabled => Bool,
691 split_address => Bool,
692 user_map_template => Str
693 ]);
694 1 my ($self, $domainid, $serverid, $data) = $check->(@_);
695 1 return $self->_call('DELETE', "$api_path/authservers/$domainid/$serverid", $data);
696 }
697  
698 1 ▶sub get_ldapsettings {
Subroutine get_ldapsettings: called CC=1 SCAR=0.0
Pod documented
699 1 state $check = compile(Object, Int, Int, Int);
700 1 my ($self, $domainid, $serverid, $settingsid) = $check->(@_);
701 1 return $self->_call('GET', "$api_path/ldapsettings/$domainid/$serverid/$settingsid");
702 }
703  
704 1 ▶sub create_ldapsettings {
Subroutine create_ldapsettings: called CC=1 SCAR=0.0
Pod documented
705 1 state $check = compile(Object, Int, Int,
706 Dict[
707 basedn => Str,
708 nameattribute => Str,
709 emailattribute => Str,
710 binddn => Str,
711 bindpw => Str,
712 usetls => Bool,
713 usesearch => Bool,
714 searchfilter => Str,
715 search_scope => Str,
716 emailsearchfilter => Str,
717 emailsearch_scope => Str
718 ]);
719 1 my ($self, $domainid, $serverid, $data) = $check->(@_);
720 1 return $self->_call('POST', "$api_path/ldapsettings/$domainid/$serverid", $data);
721 }
722  
723 1 ▶sub update_ldapsettings {
Subroutine update_ldapsettings: called CC=1 SCAR=0.0
Pod documented
724 1 state $check = compile(Object, Int, Int, Int,
725 Dict[
726 basedn => Str,
727 nameattribute => Str,
728 emailattribute => Str,
729 binddn => Str,
730 bindpw => Str,
731 usetls => Bool,
732 usesearch => Bool,
733 searchfilter => Str,
734 search_scope => Str,
735 emailsearchfilter => Str,
736 emailsearch_scope => Str
737 ]);
738 1 my ($self, $domainid, $serverid, $settingsid, $data) = $check->(@_);
739 1 return $self->_call('PUT', "$api_path/ldapsettings/$domainid/$serverid/$settingsid", $data);
740 }
741  
742 1 ▶sub delete_ldapsettings {
Subroutine delete_ldapsettings: called CC=1 SCAR=0.0
Pod documented
743 1 state $check = compile(Object, Int, Int, Int,
744 Dict[
745 basedn => Str,
746 nameattribute => Str,
747 emailattribute => Str,
748 binddn => Str,
749 bindpw => Str,
750 usetls => Bool,
751 usesearch => Bool,
752 searchfilter => Str,
753 search_scope => Str,
754 emailsearchfilter => Str,
755 emailsearch_scope => Str
756 ]);
757 1 my ($self, $domainid, $serverid, $settingsid, $data) = $check->(@_);
758 1 return $self->_call('DELETE', "$api_path/ldapsettings/$domainid/$serverid/$settingsid", $data);
759 }
760  
761 1 ▶sub get_radiussettings {
Subroutine get_radiussettings: called CC=1 SCAR=0.0
Pod documented
762 1 state $check = compile(Object, Int, Int, Int);
763 1 my ($self, $domainid, $serverid, $settingsid) = $check->(@_);
764 1 return $self->_call('GET', "$api_path/radiussettings/$domainid/$serverid/$settingsid");
765 }
766  
767 1 ▶sub create_radiussettings {
Subroutine create_radiussettings: called CC=1 SCAR=0.0
Pod documented
768 1 state $check = compile(Object, Int, Int,
769 Dict[
770 secret => Str,
771 timeout => Int
772 ]);
773 1 my ($self, $domainid, $serverid, $data) = $check->(@_);
774 1 return $self->_call('POST', "$api_path/radiussettings/$domainid/$serverid", $data);
775 }
776  
777 1 ▶sub update_radiussettings {
Subroutine update_radiussettings: called CC=1 SCAR=0.0
Pod documented
778 1 state $check = compile(Object, Int, Int, Int,
779 Dict[
780 secret => Str,
781 timeout => Int
782 ]);
783 1 my ($self, $domainid, $serverid, $settingsid, $data) = $check->(@_);
784 1 return $self->_call('PUT', "$api_path/radiussettings/$domainid/$serverid/$settingsid", $data);
785 }
786  
787 1 ▶sub delete_radiussettings {
Subroutine delete_radiussettings: called CC=1 SCAR=0.0
Pod documented
788 1 state $check = compile(Object, Int, Int, Int,
789 Dict[
790 secret => Str,
791 timeout => Int
792 ]);
793 1 my ($self, $domainid, $serverid, $settingsid, $data) = $check->(@_);
794 1 return $self->_call('DELETE', "$api_path/radiussettings/$domainid/$serverid/$settingsid", $data);
795 }
796  
797 2 ▶sub get_organizations {
Subroutine get_organizations: called CC=2 SCAR=6.9
Pod documented
798 2 state $check = compile(Object, Optional[Int]);
799 2 my ($self, $page) = $check->(@_);
800 2 my $path = "$api_path/organizations";
801 2 ▶ $path = "$api_path/organizations?page=$page" unless @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 1 1 2
802 2 return $self->_call('GET', $path);
803 }
804  
805 1 ▶sub get_organization {
Subroutine get_organization: called CC=1 SCAR=0.0
Pod documented
806 1 state $check = compile(Object, Int);
807 1 my ($self, $orgid) = $check->(@_);
808 1 return $self->_call('GET', "$api_path/organizations/$orgid");
809 }
810  
811 1 ▶sub create_organization {
Subroutine create_organization: called CC=1 SCAR=0.0
Pod documented
812 1 state $check = compile(Object,
813 Dict[
814 name => Str,
815 domains => ArrayRef,
816 admins => ArrayRef
817 ]);
818 1 my ($self, $data) = $check->(@_);
819 1 return $self->_call('POST', "$api_path/organizations", $data);
820 }
821  
822 1 ▶sub update_organization {
Subroutine update_organization: called CC=1 SCAR=0.0
Pod documented
823 1 state $check = compile(Object, Int,
824 Dict[
825 name => Str,
826 domains => ArrayRef,
827 admins => ArrayRef
828 ]);
829 1 my ($self, $orgid, $data) = $check->(@_);
830 1 return $self->_call('PUT', "$api_path/organizations/$orgid", $data);
831 }
832  
833 1 ▶sub delete_organization {
Subroutine delete_organization: called CC=1 SCAR=0.0
Pod documented
834 1 state $check = compile(Object, Int);
835 1 my ($self, $orgid) = $check->(@_);
836 1 return $self->_call('DELETE', "$api_path/organizations/$orgid");
837 }
838  
839 1 ▶sub get_relay {
Subroutine get_relay: called CC=1 SCAR=0.0
Pod documented
840 1 state $check = compile(Object, Int);
841 1 my ($self, $relayid) = $check->(@_);
842 1 return $self->_call('GET', "$api_path/relays/$relayid");
843 }
844  
845 1 ▶sub create_relay {
Subroutine create_relay: called CC=1 SCAR=0.0
Pod documented
846 1 state $check = compile(Object, Int,
847 Dict[
848 address => Str,
849 username => Str,
850 enabled => Bool,
851 require_tls => Bool,
852 password1 => Str,
853 password2 => Str,
854 description => Str,
855 low_score => Num,
856 high_score => Num,
857 spam_actions => Int,
858 highspam_actions => Int,
859 block_macros => Bool,
860 ratelimit => Int
861 ]);
862 1 my ($self, $orgid, $data) = $check->(@_);
863 1 return $self->_call('POST', "$api_path/relays/$orgid", $data);
864 }
865  
866 1 ▶sub update_relay {
Subroutine update_relay: called CC=1 SCAR=0.0
Pod documented
867 1 state $check = compile(Object, Int,
868 Dict[
869 address => Str,
870 username => Str,
871 enabled => Bool,
872 require_tls => Bool,
873 password1 => Str,
874 password2 => Str,
875 description => Str,
876 low_score => Num,
877 high_score => Num,
878 spam_actions => Int,
879 highspam_actions => Int,
880 block_macros => Bool,
881 ratelimit => Int
882 ]);
883 1 my ($self, $relayid, $data) = $check->(@_);
884 1 return $self->_call('PUT', "$api_path/relays/$relayid", $data);
885 }
886  
887 1 ▶sub delete_relay {
Subroutine delete_relay: called CC=1 SCAR=0.0
Pod documented
888 1 state $check = compile(Object, Int,
889 Dict[
890 address => Str,
891 username => Str,
892 enabled => Bool,
893 require_tls => Bool,
894 password1 => Str,
895 password2 => Str,
896 description => Str,
897 low_score => Num,
898 high_score => Num,
899 spam_actions => Int,
900 highspam_actions => Int,
901 block_macros => Bool,
902 ratelimit => Int
903 ]);
904 1 my ($self, $relayid, $data) = $check->(@_);
905 1 return $self->_call('DELETE', "$api_path/relays/$relayid", $data);
906 }
907  
908 1 ▶sub get_status {
Subroutine get_status: called CC=1 SCAR=0.0
Pod documented
909 1 state $check = compile(Object);
910 1 my ($self) = $check->(@_);
911 1 return $self->_call('GET', "$api_path/status");
912 }
913  
914 17 ▶no Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
915  
916 17 1;
917  
918 __END__
↑ Summary