| 1 | package WWW::DNSMadeEasy::Monitor; | ||||||||||
| 2 | 8 | our $VERSION = '0.100'; | |||||||||
| 3 | 8 | our $AUTHORITY = 'cpan:GETTY'; | |||||||||
| 4 | # ABSTRACT: DNS Failover and System Monitoring configuration | ||||||||||
| 5 | |||||||||||
| 6 | 8 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 8 | ▶ | use String::CamelSnakeKebab qw/lower_camel_case/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 8 | ▶ | use feature qw/say/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 8 | has dme => (is => 'ro', required => 1, handles => ['request']); | |||||||||
| 12 | 8 | has record => (is => 'ro', required => 1, handles => {path => 'monitor_path'}); | |||||||||
| 13 | 8 | has as_hashref => (is => 'rw', builder => 1, lazy => 1, clearer => 1); | |||||||||
| 14 | 8 | has response => (is => 'rw'); | |||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | sub _build_as_hashref { shift->response->as_hashref } | ||||||||
|
Subroutine
_build_as_hashref: not called CC=1 SCAR=6.9
| |||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub auto_failover { shift->as_hashref->{autoFailover} } | ||||||||
|
Subroutine
auto_failover: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 19 | 0 | ▶ | sub contact_list_id { shift->as_hashref->{contactListId} } | ||||||||
|
Subroutine
contact_list_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 20 | 0 | ▶ | sub failover { shift->as_hashref->{failover} } | ||||||||
|
Subroutine
failover: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 21 | 0 | ▶ | sub http_file { shift->as_hashref->{httpFile} } | ||||||||
|
Subroutine
http_file: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 22 | 0 | ▶ | sub http_fqdn { shift->as_hashref->{httpFqdn} } | ||||||||
|
Subroutine
http_fqdn: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 23 | 0 | ▶ | sub http_query_string { shift->as_hashref->{httpQueryString} } | ||||||||
|
Subroutine
http_query_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 24 | 0 | ▶ | sub ip1 { shift->as_hashref->{ip1} } | ||||||||
|
Subroutine
ip1: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 25 | 0 | ▶ | sub ip1_failed { shift->as_hashref->{ip1Failed} } | ||||||||
|
Subroutine
ip1_failed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 26 | 0 | ▶ | sub ip2 { shift->as_hashref->{ip2} } | ||||||||
|
Subroutine
ip2: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 27 | 0 | ▶ | sub ip2_failed { shift->as_hashref->{ip2Failed} } | ||||||||
|
Subroutine
ip2_failed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | 0 | ▶ | sub ip3 { shift->as_hashref->{ip3} } | ||||||||
|
Subroutine
ip3: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | 0 | ▶ | sub ip3_failed { shift->as_hashref->{ip3Failed} } | ||||||||
|
Subroutine
ip3_failed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 0 | ▶ | sub ip4 { shift->as_hashref->{ip4} } | ||||||||
|
Subroutine
ip4: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 31 | 0 | ▶ | sub ip4_failed { shift->as_hashref->{ip4Failed} } | ||||||||
|
Subroutine
ip4_failed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 32 | 0 | ▶ | sub ip5 { shift->as_hashref->{ip5} } | ||||||||
|
Subroutine
ip5: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 33 | 0 | ▶ | sub ip5_failed { shift->as_hashref->{ip5Failed} } | ||||||||
|
Subroutine
ip5_failed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 34 | 0 | ▶ | sub max_emails { shift->as_hashref->{maxEmails} } | ||||||||
|
Subroutine
max_emails: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 35 | 0 | ▶ | sub monitor { shift->as_hashref->{monitor} } | ||||||||
|
Subroutine
monitor: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 36 | 0 | ▶ | sub port { shift->as_hashref->{port} } | ||||||||
|
Subroutine
port: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 37 | 0 | ▶ | sub protocol_id { shift->as_hashref->{protocolId} } | ||||||||
|
Subroutine
protocol_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 38 | 0 | ▶ | sub record_id { shift->as_hashref->{recordId} } | ||||||||
|
Subroutine
record_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 39 | 0 | ▶ | sub sensitivity { shift->as_hashref->{sensitivity} } | ||||||||
|
Subroutine
sensitivity: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | 0 | ▶ | sub source { shift->as_hashref->{source} } | ||||||||
|
Subroutine
source: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 41 | 0 | ▶ | sub source_id { shift->as_hashref->{sourceId} } | ||||||||
|
Subroutine
source_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | 0 | ▶ | sub system_description { shift->as_hashref->{systemDescription} } | ||||||||
|
Subroutine
system_description: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub ips { | ||||||||
|
Subroutine
ips: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 45 | 0 | my ($self) = @_; | |||||||||
| 46 | 0 | my @ips; | |||||||||
| 47 | 0 | ▶ | push @ips, $self->ip1 if $self->ip1; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 0 | ▶ | push @ips, $self->ip2 if $self->ip2; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | ▶ | push @ips, $self->ip3 if $self->ip3; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | ▶ | push @ips, $self->ip4 if $self->ip4; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 0 | ▶ | push @ips, $self->ip5 if $self->ip5; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | return @ips; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 8 | my %PROTOCOL = ( | |||||||||
| 56 | 1 => 'TCP', | ||||||||||
| 57 | 2 => 'UDP', | ||||||||||
| 58 | 3 => 'HTTP', | ||||||||||
| 59 | 4 => 'DNS', | ||||||||||
| 60 | 5 => 'SMTP', | ||||||||||
| 61 | 6 => 'HTTPS', | ||||||||||
| 62 | ); | ||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub protocol { $PROTOCOL{shift->protocol_id} } | ||||||||
|
Subroutine
protocol: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub create { shift->update(@_) } | ||||||||
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | sub disable { | ||||||||
|
Subroutine
disable: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 69 | 0 | my ($self) = @_; | |||||||||
| 70 | 0 | $self->update( | |||||||||
| 71 | port => $self->port, | ||||||||||
| 72 | failover => 'false', | ||||||||||
| 73 | monitor => 'false', | ||||||||||
| 74 | sensitivity => $self->sensitivity, | ||||||||||
| 75 | ); | ||||||||||
| 76 | |||||||||||
| 77 | 0 | my $res = $self->request(GET => $self->path); | |||||||||
| 78 | 0 | $self->response($res); | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 0 | ▶ | sub update { | ||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 82 | 0 | my ($self, %data) = @_; | |||||||||
| 83 | |||||||||||
| 84 | 0 | my %req; | |||||||||
| 85 | 0 | for my $old (keys %data) { | |||||||||
| 86 | 0 | my $new = lower_camel_case($old); | |||||||||
| 87 | 0 | $req{$new} = $data{$old}; | |||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | 0 | $self->clear_as_hashref; | |||||||||
| 91 | 0 | my $res = $self->request(PUT => $self->path, \%req); | |||||||||
| 92 | 0 | $self->response($res); | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | |||||||||||
| 96 | 8 | 1; | |||||||||
| 97 | |||||||||||
| 98 | __END__ | ||||||||||