line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Consul::API::Session; |
2
|
|
|
|
|
|
|
$Consul::API::Session::VERSION = '0.026'; |
3
|
9
|
|
|
9
|
|
4233
|
use namespace::autoclean; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
46
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
589
|
use Moo::Role; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
45
|
|
6
|
9
|
|
|
9
|
|
2701
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
47
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires qw(_version_prefix _api_exec); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has _session_endpoint => ( is => 'lazy', isa => Str ); |
11
|
|
|
|
|
|
|
sub _build__session_endpoint { |
12
|
0
|
|
|
0
|
|
|
shift->_version_prefix . '/session'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub session { |
16
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
17
|
0
|
0
|
|
|
|
|
$self = Consul->new(@_) unless ref $self; |
18
|
0
|
|
|
|
|
|
return bless \$self, "Consul::API::Session::Impl"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package |
22
|
|
|
|
|
|
|
Consul::API::Session::Impl; # hide from PAUSE |
23
|
|
|
|
|
|
|
|
24
|
9
|
|
|
9
|
|
4568
|
use Moo; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
55
|
|
25
|
|
|
|
|
|
|
|
26
|
9
|
|
|
9
|
|
2630
|
use Carp qw(croak); |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
5278
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub create { |
29
|
0
|
|
|
0
|
0
|
|
my ($self, $session, %args) = @_; |
30
|
|
|
|
|
|
|
$$self->_api_exec($$self->_session_endpoint."/create", 'PUT', %args, ($session ? (_content => $session->to_json) : ()), sub { |
31
|
|
|
|
|
|
|
$_[0]->{ID} |
32
|
0
|
0
|
|
0
|
|
|
}); |
|
0
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub destroy { |
36
|
0
|
|
|
0
|
0
|
|
my ($self, $id, %args) = @_; |
37
|
0
|
0
|
|
|
|
|
croak 'usage: $session->destroy($id, [%args])' if grep { !defined } ($id); |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$$self->_api_exec($$self->_session_endpoint."/destroy/".$id, 'PUT', %args) |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub info { |
42
|
0
|
|
|
0
|
0
|
|
my ($self, $id, %args) = @_; |
43
|
0
|
0
|
|
|
|
|
croak 'usage: $session->info($id, [%args])' if grep { !defined } ($id); |
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$$self->_api_exec($$self->_session_endpoint."/info/".$id, 'GET', %args, |
45
|
|
|
|
|
|
|
sub { |
46
|
0
|
0
|
0
|
0
|
|
|
return undef unless $_[0] && $_[0]->[0]; |
47
|
0
|
|
|
|
|
|
Consul::API::Session::Session->new($_[0]->[0]) |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub node { |
53
|
0
|
|
|
0
|
0
|
|
my ($self, $node, %args) = @_; |
54
|
0
|
0
|
|
|
|
|
croak 'usage: $session->node($id, [%args])' if grep { !defined } ($node); |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$$self->_api_exec($$self->_session_endpoint."/node/".$node, 'GET', %args, sub { |
56
|
0
|
|
|
0
|
|
|
[ map { Consul::API::Session::Session->new($_) } @{$_[0]} ] |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
}); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub list { |
61
|
0
|
|
|
0
|
0
|
|
my ($self, %args) = @_; |
62
|
|
|
|
|
|
|
$$self->_api_exec($$self->_session_endpoint."/list", 'GET', %args, sub { |
63
|
0
|
|
|
0
|
|
|
[ map { Consul::API::Session::Session->new($_) } @{$_[0]} ] |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
}); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub renew { |
68
|
0
|
|
|
0
|
0
|
|
my ($self, $id, %args) = @_; |
69
|
0
|
0
|
|
|
|
|
croak 'usage: $session->renew($id, [%args])' if grep { !defined } ($id); |
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$$self->_api_exec($$self->_session_endpoint."/renew/".$id, 'PUT', %args, sub { |
71
|
0
|
|
|
0
|
|
|
Consul::API::Session::Session->new($_[0]->[0]) |
72
|
0
|
|
|
|
|
|
}); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
package Consul::API::Session::Session; |
76
|
|
|
|
|
|
|
$Consul::API::Session::Session::VERSION = '0.026'; |
77
|
9
|
|
|
9
|
|
57
|
use Moo; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
47
|
|
78
|
9
|
|
|
9
|
|
2655
|
use Types::Standard qw(Str Enum ArrayRef Num Int); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
35
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
has id => ( is => 'ro', isa => Str, init_arg => 'ID', required => 1 ); |
81
|
|
|
|
|
|
|
has name => ( is => 'ro', isa => Str, init_arg => 'Name', required => 1 ); |
82
|
|
|
|
|
|
|
has behavior => ( is => 'ro', isa => Enum[qw(release delete)], init_arg => 'Behavior', required => 1 ); |
83
|
|
|
|
|
|
|
has ttl => ( is => 'ro', isa => Str, init_arg => 'TTL', required => 1 ); |
84
|
|
|
|
|
|
|
has node => ( is => 'ro', isa => Str, init_arg => 'Node', required => 1 ); |
85
|
|
|
|
|
|
|
has checks => ( is => 'ro', isa => ArrayRef[Str], init_arg => 'Checks', required => 1 ); |
86
|
|
|
|
|
|
|
has lock_delay => ( is => 'ro', isa => Num, init_arg => 'LockDelay', required => 1 ); |
87
|
|
|
|
|
|
|
has create_index => ( is => 'ro', isa => Int, init_arg => 'CreateIndex', required => 1 ); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
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. |
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 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |