line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Consul::API::ACL; |
2
|
|
|
|
|
|
|
$Consul::API::ACL::VERSION = '0.025'; |
3
|
9
|
|
|
9
|
|
5575
|
use namespace::autoclean; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
78
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
1255
|
use Moo::Role; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
72
|
|
6
|
9
|
|
|
9
|
|
3747
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
263
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires qw(_version_prefix _api_exec); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has _acl_endpoint => ( is => 'lazy', isa => Str ); |
11
|
|
|
|
|
|
|
sub _build__acl_endpoint { |
12
|
0
|
|
|
0
|
|
|
shift->_version_prefix . '/acl'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub acl { |
16
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
17
|
0
|
0
|
|
|
|
|
$self = Consul->new(@_) unless ref $self; |
18
|
0
|
|
|
|
|
|
return bless \$self, "Consul::API::ACL::Impl"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package |
22
|
|
|
|
|
|
|
Consul::API::ACL::Impl; # hide from PAUSE |
23
|
|
|
|
|
|
|
|
24
|
9
|
|
|
9
|
|
6504
|
use Moo; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
59
|
|
25
|
|
|
|
|
|
|
|
26
|
9
|
|
|
9
|
|
3726
|
use Carp qw(croak); |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
560
|
|
27
|
9
|
|
|
9
|
|
88
|
use Scalar::Util qw( blessed ); |
|
9
|
|
|
|
|
39
|
|
|
9
|
|
|
|
|
516
|
|
28
|
9
|
|
|
9
|
|
3894
|
use Consul::ACL; |
|
9
|
|
|
|
|
40
|
|
|
9
|
|
|
|
|
5912
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub create { |
31
|
0
|
|
|
0
|
0
|
|
my ($self, $acl, %args) = @_; |
32
|
0
|
|
0
|
|
|
|
$acl ||= {}; |
33
|
0
|
0
|
|
|
|
|
$acl = Consul::ACL->new($acl) if !blessed $acl; |
34
|
|
|
|
|
|
|
$$self->_api_exec($$self->_acl_endpoint."/create", 'PUT', %args, _content => $acl->to_json(), sub{ |
35
|
0
|
|
|
0
|
|
|
Consul::API::ACL::Success->new($_[0]) |
36
|
0
|
|
|
|
|
|
}); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub update { |
40
|
0
|
|
|
0
|
0
|
|
my ($self, $acl, %args) = @_; |
41
|
0
|
0
|
|
|
|
|
croak 'usage: $acl->update($acl, [%args])' if grep { !defined } ($acl); |
|
0
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
$acl = Consul::ACL->new($acl) if !blessed $acl; |
43
|
0
|
|
|
|
|
|
$$self->_api_exec($$self->_acl_endpoint."/update", 'PUT', %args, _content => $acl->to_json()); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub destroy { |
47
|
0
|
|
|
0
|
0
|
|
my ($self, $id, %args) = @_; |
48
|
0
|
0
|
|
|
|
|
croak 'usage: $acl->destroy($id, [%args])' if grep { !defined } ($id); |
|
0
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$$self->_api_exec($$self->_acl_endpoint."/destroy/$id", 'PUT', %args); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub info { |
53
|
0
|
|
|
0
|
0
|
|
my ($self, $id, %args) = @_; |
54
|
0
|
0
|
|
|
|
|
croak 'usage: $acl->info($id, [%args])' if grep { !defined } ($id); |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$$self->_api_exec($$self->_acl_endpoint."/info/$id", 'GET', %args, sub { |
56
|
0
|
|
|
0
|
|
|
Consul::API::ACL::Info->new($_[0]->[0]) |
57
|
0
|
|
|
|
|
|
}); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub clone { |
61
|
0
|
|
|
0
|
0
|
|
my ($self, $id, %args) = @_; |
62
|
0
|
0
|
|
|
|
|
croak 'usage: $acl->clone($id, [%args])' if grep { !defined } ($id); |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$$self->_api_exec($$self->_acl_endpoint."/clone/$id", 'PUT', %args, sub{ |
64
|
0
|
|
|
0
|
|
|
Consul::API::ACL::Success->new($_[0]) |
65
|
0
|
|
|
|
|
|
}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub list { |
69
|
0
|
|
|
0
|
0
|
|
my ($self, %args) = @_; |
70
|
|
|
|
|
|
|
$$self->_api_exec($$self->_acl_endpoint."/list", 'GET', %args, sub { |
71
|
0
|
|
|
0
|
|
|
[ map { Consul::API::ACL::Info->new($_) } @{$_[0]} ] |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
}); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
package Consul::API::ACL::Info; |
76
|
|
|
|
|
|
|
$Consul::API::ACL::Info::VERSION = '0.025'; |
77
|
9
|
|
|
9
|
|
78
|
use Moo; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
52
|
|
78
|
9
|
|
|
9
|
|
3532
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
51
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
has create_index => ( is => 'ro', isa => Str, init_arg => 'CreateIndex', required => 1 ); |
81
|
|
|
|
|
|
|
has modify_index => ( is => 'ro', isa => Str, init_arg => 'ModifyIndex', required => 1 ); |
82
|
|
|
|
|
|
|
has id => ( is => 'ro', isa => Str, init_arg => 'ID', required => 1 ); |
83
|
|
|
|
|
|
|
has name => ( is => 'ro', isa => Str, init_arg => 'Name', required => 1 ); |
84
|
|
|
|
|
|
|
has type => ( is => 'ro', isa => Str, init_arg => 'Type', required => 1 ); |
85
|
|
|
|
|
|
|
has rules => ( is => 'ro', isa => Str, init_arg => 'Rules', required => 1 ); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
package Consul::API::ACL::Success; |
88
|
|
|
|
|
|
|
$Consul::API::ACL::Success::VERSION = '0.025'; |
89
|
9
|
|
|
9
|
|
5987
|
use Moo; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
57
|
|
90
|
9
|
|
|
9
|
|
3047
|
use Types::Standard qw(Str); |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
62
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
has id => ( is => 'ro', isa => Str, init_arg => 'ID', required => 1 ); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=pod |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=encoding UTF-8 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 NAME |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Consul::API::ACL - Access control API |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SYNOPSIS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
use Consul; |
107
|
|
|
|
|
|
|
my $acl = Consul->acl; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 DESCRIPTION |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The ACL API is used to create, update, destroy, and query ACL tokens. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This API is fully documented at L. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 METHODS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 create |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 update |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 destroy |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 info |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 clone |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 list |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 SEE ALSO |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |