| 1 | package Consul::API::Session; | ||||||||||||||||||||||||||||
| 2 | 9 | $Consul::API::Session::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 _session_endpoint => ( is => 'lazy', isa => Str ); | |||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub _build__session_endpoint { | ||||||||||||||||||||||||||
|
Subroutine
_build__session_endpoint: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 12 | 0 | shift->_version_prefix . '/session'; | |||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub session { | ||||||||||||||||||||||||||
|
Subroutine
session: 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::Session::Impl"; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | package | ||||||||||||||||||||||||||||
| 22 | Consul::API::Session::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 create { | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 0 | my ($self, $session, %args) = @_; | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | $$self->_api_exec($$self->_session_endpoint."/create", 'PUT', %args, ($session ? (_content => $session->to_json) : ()), sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 31 | $_[0]->{ID} | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | }); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub destroy { | ||||||||||||||||||||||||||
|
Subroutine
destroy: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 0 | my ($self, $id, %args) = @_; | |||||||||||||||||||||||||||
| 37 | 0 | ▶ | croak 'usage: $session->destroy($id, [%args])' if grep { !defined } ($id); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 0 | $$self->_api_exec($$self->_session_endpoint."/destroy/".$id, 'PUT', %args) | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub info { | ||||||||||||||||||||||||||
|
Subroutine
info: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 0 | my ($self, $id, %args) = @_; | |||||||||||||||||||||||||||
| 43 | 0 | ▶ | croak 'usage: $session->info($id, [%args])' if grep { !defined } ($id); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | $$self->_api_exec($$self->_session_endpoint."/info/".$id, 'GET', %args, | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return undef unless $_[0] && $_[0]->[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[0] and $_[0][0]
MC/DC0%0/2
$_[0] and $_[0][0]
$_[0]
$_[0][0]
Truth table0%0/3
A and B
A= $_[0]B= $_[0][0]
| |||||||||||||||||||||||||||||
| 47 | 0 | Consul::API::Session::Session->new($_[0]->[0]) | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 0 | ); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub node { | ||||||||||||||||||||||||||
|
Subroutine
node: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 0 | my ($self, $node, %args) = @_; | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | croak 'usage: $session->node($id, [%args])' if grep { !defined } ($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | $$self->_api_exec($$self->_session_endpoint."/node/".$node, 'GET', %args, sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 56 | 0 | [ map { Consul::API::Session::Session->new($_) } @{$_[0]} ] | |||||||||||||||||||||||||||
| 57 | 0 | }); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub list { | ||||||||||||||||||||||||||
|
Subroutine
list: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | $$self->_api_exec($$self->_session_endpoint."/list", 'GET', %args, sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 63 | 0 | [ map { Consul::API::Session::Session->new($_) } @{$_[0]} ] | |||||||||||||||||||||||||||
| 64 | 0 | }); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub renew { | ||||||||||||||||||||||||||
|
Subroutine
renew: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | 0 | my ($self, $id, %args) = @_; | |||||||||||||||||||||||||||
| 69 | 0 | ▶ | croak 'usage: $session->renew($id, [%args])' if grep { !defined } ($id); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | $$self->_api_exec($$self->_session_endpoint."/renew/".$id, 'PUT', %args, sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 71 | 0 | Consul::API::Session::Session->new($_[0]->[0]) | |||||||||||||||||||||||||||
| 72 | 0 | }); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | package Consul::API::Session::Session; | ||||||||||||||||||||||||||||
| 76 | 9 | $Consul::API::Session::Session::VERSION = '0.027'; | |||||||||||||||||||||||||||
| 77 | 9 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 78 | 9 | ▶ | use Types::Standard qw(Str Enum ArrayRef Num Int); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 9 | has id => ( is => 'ro', isa => Str, init_arg => 'ID', required => 1 ); | |||||||||||||||||||||||||||
| 81 | 9 | has name => ( is => 'ro', isa => Str, init_arg => 'Name', required => 1 ); | |||||||||||||||||||||||||||
| 82 | 9 | has behavior => ( is => 'ro', isa => Enum[qw(release delete)], init_arg => 'Behavior', required => 1 ); | |||||||||||||||||||||||||||
| 83 | 9 | has ttl => ( is => 'ro', isa => Str, init_arg => 'TTL', required => 1 ); | |||||||||||||||||||||||||||
| 84 | 9 | has node => ( is => 'ro', isa => Str, init_arg => 'Node', required => 1 ); | |||||||||||||||||||||||||||
| 85 | 9 | has checks => ( is => 'ro', isa => ArrayRef[Str], init_arg => 'Checks', ); | |||||||||||||||||||||||||||
| 86 | 9 | has lock_delay => ( is => 'ro', isa => Num, init_arg => 'LockDelay', required => 1 ); | |||||||||||||||||||||||||||
| 87 | 9 | has create_index => ( is => 'ro', isa => Int, init_arg => 'CreateIndex', required => 1 ); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 9 | 1; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =pod | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =head1 NAME | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | Consul::API::Session - Sessions API | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | use Consul; | ||||||||||||||||||||||||||||
| 102 | my $session = Consul->session; | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | The Session API is used to create, destroy, and query sessions. | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | This API is fully documented at L<https://www.consul.io/docs/agent/http/session.html>. | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =head1 METHODS | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =head2 create | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head2 destroy | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =head2 info | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =head2 node | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =head2 list | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =head2 renew | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | L<Consul> | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =cut | ||||||||||||||||||||||||||||