Consul/API/ACL.pm

filter: Statementstmt 58.2% 46 / 79 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 47.8% 11 / 23 Podpod 0.0% 0 / 7 totaltotal 45.2% 57 / 126 CC 9 SCAR 15.3
CC
9
Cov
48%
create
12.0
update
12.0
acl
6.0
CRAP 4.6
« Consul/API/Agent.pm ↑ Summary Consul/API/Session.pm »
1 package Consul::API::ACL;
2 9 $Consul::API::ACL::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 _acl_endpoint => ( is => 'lazy', isa => Str );
11 0 ▶sub _build__acl_endpoint {
Subroutine _build__acl_endpoint: not called CC=1 SCAR=6.9
12 0 shift->_version_prefix . '/acl';
13 }
14  
15 0 ▶sub acl {
Subroutine acl: 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
BranchTrueFalseTotal
unless ref $self 0 0 0
18 0 return bless \$self, "Consul::API::ACL::Impl";
19 }
20  
21 package
22 Consul::API::ACL::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 9 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
28 9 ▶use Consul::ACL;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 0 ▶sub create {
Subroutine create: not called CC=3 SCAR=24.8
Pod undocumented
31 0 my ($self, $acl, %args) = @_;
32 0 ▶ $acl ||= {};
Condition0%0/2
$acl ||= {}
l!l
00
MC/DC0%0/1
$acl ||= {}
$acl
Truth table0%0/2
A
A= $acl
Aresult
11
00
33 0 ▶ $acl = Consul::ACL->new($acl) if !blessed $acl;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($acl) 0 0 0
34 0 ▶ $$self->_api_exec($$self->_acl_endpoint."/create", 'PUT', %args, _content => $acl->to_json(), sub{
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 0 Consul::API::ACL::Success->new($_[0])
36 0 });
37 }
38  
39 0 ▶sub update {
Subroutine update: not called CC=3 SCAR=24.8
Pod undocumented
40 0 my ($self, $acl, %args) = @_;
41 0 ▶ croak 'usage: $acl->update($acl, [%args])' if grep { !defined } ($acl);
Branch: 1 branch
BranchTrueFalseTotal
if grep {not defined $_;} $acl 0 0 0
42 0 ▶ $acl = Consul::ACL->new($acl) if !blessed $acl;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($acl) 0 0 0
43 0 $$self->_api_exec($$self->_acl_endpoint."/update", 'PUT', %args, _content => $acl->to_json());
44 }
45  
46 0 ▶sub destroy {
Subroutine destroy: not called CC=2 SCAR=17.9
Pod undocumented
47 0 my ($self, $id, %args) = @_;
48 0 ▶ croak 'usage: $acl->destroy($id, [%args])' if grep { !defined } ($id);
Branch: 1 branch
BranchTrueFalseTotal
if grep {not defined $_;} $id 0 0 0
49 0 $$self->_api_exec($$self->_acl_endpoint."/destroy/$id", 'PUT', %args);
50 }
51  
52 0 ▶sub info {
Subroutine info: not called CC=2 SCAR=17.9
Pod undocumented
53 0 my ($self, $id, %args) = @_;
54 0 ▶ croak 'usage: $acl->info($id, [%args])' if grep { !defined } ($id);
Branch: 1 branch
BranchTrueFalseTotal
if grep {not defined $_;} $id 0 0 0
55 0 ▶ $$self->_api_exec($$self->_acl_endpoint."/info/$id", 'GET', %args, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 0 Consul::API::ACL::Info->new($_[0]->[0])
57 0 });
58 }
59  
60 0 ▶sub clone {
Subroutine clone: not called CC=2 SCAR=17.9
Pod undocumented
61 0 my ($self, $id, %args) = @_;
62 0 ▶ croak 'usage: $acl->clone($id, [%args])' if grep { !defined } ($id);
Branch: 1 branch
BranchTrueFalseTotal
if grep {not defined $_;} $id 0 0 0
63 0 ▶ $$self->_api_exec($$self->_acl_endpoint."/clone/$id", 'PUT', %args, sub{
Subroutine __ANON__: not called CC=1 SCAR=6.9
64 0 Consul::API::ACL::Success->new($_[0])
65 0 });
66 }
67  
68 0 ▶sub list {
Subroutine list: not called CC=1 SCAR=6.9
Pod undocumented
69 0 my ($self, %args) = @_;
70 0 ▶ $$self->_api_exec($$self->_acl_endpoint."/list", 'GET', %args, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
71 0 [ map { Consul::API::ACL::Info->new($_) } @{$_[0]} ]
72 0 });
73 }
74  
75 package Consul::API::ACL::Info;
76 9 $Consul::API::ACL::Info::VERSION = '0.027';
77 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 9 ▶use Types::Standard qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
79  
80 9 has create_index => ( is => 'ro', isa => Str, init_arg => 'CreateIndex', required => 1 );
81 9 has modify_index => ( is => 'ro', isa => Str, init_arg => 'ModifyIndex', required => 1 );
82 9 has id => ( is => 'ro', isa => Str, init_arg => 'ID', required => 1 );
83 9 has name => ( is => 'ro', isa => Str, init_arg => 'Name', required => 1 );
84 9 has type => ( is => 'ro', isa => Str, init_arg => 'Type', required => 1 );
85 9 has rules => ( is => 'ro', isa => Str, init_arg => 'Rules', required => 1 );
86  
87 package Consul::API::ACL::Success;
88 9 $Consul::API::ACL::Success::VERSION = '0.027';
89 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 9 ▶use Types::Standard qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
91  
92 9 has id => ( is => 'ro', isa => Str, init_arg => 'ID', required => 1 );
93  
94 9 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<https://www.consul.io/docs/agent/http/acl.html>.
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<Consul>
132  
133 =cut
« Consul/API/Agent.pm ↑ Summary Consul/API/Session.pm »