| 1 | package Consul::API::Health; | ||||||||||
| 2 | 9 | $Consul::API::Health::VERSION = '0.027'; | |||||||||
| 3 | 9 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 9 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 9 | ▶ | use Types::Standard qw(Str); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 9 | requires qw(_version_prefix _api_exec); | |||||||||
| 9 | |||||||||||
| 10 | 9 | has _health_endpoint => ( is => 'lazy', isa => Str ); | |||||||||
| 11 | 0 | ▶ | sub _build__health_endpoint { | ||||||||
|
Subroutine
_build__health_endpoint: not called CC=1 SCAR=6.9
| |||||||||||
| 12 | 0 | shift->_version_prefix . '/health'; | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub health { | ||||||||
|
Subroutine
health: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 16 | 0 | my $self = shift; | |||||||||
| 17 | 0 | ▶ | $self = Consul->new(@_) unless ref $self; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | return bless \$self, "Consul::API::Health::Impl"; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | package | ||||||||||
| 22 | Consul::API::Health::Impl; # hide from PAUSE | ||||||||||
| 23 | |||||||||||
| 24 | 9 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 9 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub node { | ||||||||
|
Subroutine
node: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 29 | 0 | my ($self, $node, %args) = @_; | |||||||||
| 30 | 0 | ▶ | croak 'usage: $health->node($node, [%args])' if grep { !defined } ($node); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | ▶ | $$self->_api_exec($$self->_health_endpoint."/node/".$node, 'GET', %args, sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 32 | 0 | [ map { Consul::API::Health::Check->new(%$_) } @{$_[0]} ] | |||||||||
| 33 | 0 | }); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | sub checks { | ||||||||
|
Subroutine
checks: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 37 | 0 | my ($self, $service, %args) = @_; | |||||||||
| 38 | 0 | ▶ | croak 'usage: $health->checks($service, [%args])' if grep { !defined } ($service); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | ▶ | $$self->_api_exec($$self->_health_endpoint."/checks/".$service, 'GET', %args, sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 40 | 0 | [ map { Consul::API::Health::Check->new(%$_) } @{$_[0]} ] | |||||||||
| 41 | 0 | }); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub service { | ||||||||
|
Subroutine
service: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 45 | 0 | my ($self, $service, %args) = @_; | |||||||||
| 46 | 0 | ▶ | croak 'usage: $health->service($service, [%args])' if grep { !defined } ($service); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | ▶ | $$self->_api_exec($$self->_health_endpoint."/service/".$service, 'GET', %args, sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 48 | 0 | [ map { Consul::API::Health::Service->new(%$_) } @{$_[0]} ] | |||||||||
| 49 | 0 | }); | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub state { | ||||||||
|
Subroutine
state: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 53 | 0 | my ($self, $state, %args) = @_; | |||||||||
| 54 | 0 | ▶ | croak 'usage: $health->state($state, [%args])' if grep { !defined } ($state); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 0 | ▶ | $$self->_api_exec($$self->_health_endpoint."/state/".$state, 'GET', %args, sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 56 | 0 | [ map { Consul::API::Health::Check->new(%$_) } @{$_[0]} ] | |||||||||
| 57 | 0 | }); | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | package Consul::API::Health::Check; | ||||||||||
| 61 | 9 | $Consul::API::Health::Check::VERSION = '0.027'; | |||||||||
| 62 | 9 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 63 | 9 | ▶ | use Types::Standard qw(Str); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 64 | |||||||||||
| 65 | 9 | has node => ( is => 'ro', isa => Str, init_arg => 'Node', required => 1 ); | |||||||||
| 66 | 9 | has id => ( is => 'ro', isa => Str, init_arg => 'CheckID', required => 1 ); | |||||||||
| 67 | 9 | has name => ( is => 'ro', isa => Str, init_arg => 'Name', required => 1 ); | |||||||||
| 68 | 9 | has status => ( is => 'ro', isa => Str, init_arg => 'Status', required => 1 ); | |||||||||
| 69 | 9 | has notes => ( is => 'ro', isa => Str, init_arg => 'Notes', required => 1 ); | |||||||||
| 70 | 9 | has output => ( is => 'ro', isa => Str, init_arg => 'Output', required => 1 ); | |||||||||
| 71 | 9 | has service_id => ( is => 'ro', isa => Str, init_arg => 'ServiceID', required => 1 ); | |||||||||
| 72 | 9 | has service_name => ( is => 'ro', isa => Str, init_arg => 'ServiceName', required => 1 ); | |||||||||
| 73 | |||||||||||
| 74 | package Consul::API::Health::Service; | ||||||||||
| 75 | 9 | $Consul::API::Health::Service::VERSION = '0.027'; | |||||||||
| 76 | 9 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 77 | 9 | ▶ | use Types::Standard qw(ArrayRef); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 78 | 9 | ▶ | use Type::Utils qw(class_type); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | has node => ( is => 'ro', isa => class_type('Consul::API::Catalog::ShortNode'), init_arg => 'Node', required => 1, coerce => sub { Consul::API::Catalog::ShortNode->new($_[0]) } ); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 81 | 0 | ▶ | has service => ( is => 'ro', isa => class_type('Consul::API::Agent::Service'), init_arg => 'Service', required => 1, coerce => sub { Consul::API::Agent::Service->new($_[0]) } ); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 82 | 0 | ▶ | has checks => ( is => 'ro', isa => ArrayRef[class_type('Consul::API::Health::Check')], init_arg => 'Checks', required => 1, coerce => sub { [ map { Consul::API::Health::Check->new($_) } @{$_[0]} ] } ); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||
| 83 | |||||||||||
| 84 | 9 | 1; | |||||||||
| 85 | |||||||||||
| 86 | =pod | ||||||||||
| 87 | |||||||||||
| 88 | =encoding UTF-8 | ||||||||||
| 89 | |||||||||||
| 90 | =head1 NAME | ||||||||||
| 91 | |||||||||||
| 92 | Consul::API::Health - Health check API | ||||||||||
| 93 | |||||||||||
| 94 | =head1 SYNOPSIS | ||||||||||
| 95 | |||||||||||
| 96 | use Consul; | ||||||||||
| 97 | my $health = Consul->health; | ||||||||||
| 98 | |||||||||||
| 99 | =head1 DESCRIPTION | ||||||||||
| 100 | |||||||||||
| 101 | The Health API is used to query health-related information. | ||||||||||
| 102 | |||||||||||
| 103 | This API is fully documented at L<https://www.consul.io/docs/agent/http/health.html>. | ||||||||||
| 104 | |||||||||||
| 105 | =head1 METHODS | ||||||||||
| 106 | |||||||||||
| 107 | =head2 node | ||||||||||
| 108 | |||||||||||
| 109 | =head2 checks | ||||||||||
| 110 | |||||||||||
| 111 | =head2 service | ||||||||||
| 112 | |||||||||||
| 113 | =head2 state | ||||||||||
| 114 | |||||||||||
| 115 | =head1 SEE ALSO | ||||||||||
| 116 | |||||||||||
| 117 | L<Consul> | ||||||||||
| 118 | |||||||||||
| 119 | =cut | ||||||||||