File Coverage

blib/lib/Etcd3/Auth/UserAdd.pm
Criterion Covered Total %
statement 24 35 68.5
branch 0 4 0.0
condition n/a
subroutine 8 10 80.0
pod 1 1 100.0
total 33 50 66.0


line stmt bran cond sub pod time code
1 4     4   14 use utf8;
  4         4  
  4         15  
2             package Etcd3::Auth::UserAdd;
3              
4 4     4   125 use strict;
  4         5  
  4         59  
5 4     4   11 use warnings;
  4         4  
  4         76  
6              
7 4     4   12 use Moo;
  4         3  
  4         12  
8 4     4   688 use Types::Standard qw(Str Int Bool HashRef ArrayRef);
  4         4  
  4         31  
9 4     4   2182 use MIME::Base64;
  4         5  
  4         176  
10 4     4   16 use JSON;
  4         5  
  4         22  
11              
12             with 'Etcd3::Role::Actions';
13              
14 4     4   384 use namespace::clean;
  4         8  
  4         20  
15              
16             =head1 NAME
17              
18             Etcd3::Auth::UserAdd
19              
20             =cut
21              
22             our $VERSION = '0.005';
23              
24             =head1 DESCRIPTION
25              
26             Add user
27              
28             =head2 endpoint
29              
30             =cut
31              
32             has endpoint => (
33             is => 'ro',
34             isa => Str,
35             default => '/auth/user/add'
36             );
37              
38             =head2 name
39              
40             name of user
41              
42             =cut
43              
44             has name => (
45             is => 'ro',
46             isa => Str,
47             required => 1,
48             # coerce => sub { return encode_base64($_[0],'') },
49             );
50              
51             =head2 password
52              
53             =cut
54              
55             has password => (
56             is => 'ro',
57             isa => Str,
58             required => 1,
59             # coerce => sub { return encode_base64($_[0],'') },
60             );
61              
62             =head2 json_args
63              
64             arguments that will be sent to the api
65              
66             =cut
67              
68             has json_args => (
69             is => 'lazy',
70             );
71              
72             sub _build_json_args {
73 0     0     my ($self) = @_;
74 0           my $args;
75 0           for my $key ( keys %{ $self }) {
  0            
76 0 0         unless ( $key =~ /(?:_client|json_args|endpoint)$/ ) {
77 0           $args->{$key} = $self->{$key};
78             }
79             }
80 0           return to_json($args);
81             }
82              
83             =head2 init
84              
85             =cut
86              
87             sub init {
88 0     0 1   my ($self) = @_;
89 0           my $init = $self->json_args;
90 0 0         $init or return;
91 0           return $self;
92             }
93              
94             1;