File Coverage

blib/lib/Net/Etcd/User.pm
Criterion Covered Total %
statement 27 40 67.5
branch 0 2 0.0
condition n/a
subroutine 9 12 75.0
pod 3 3 100.0
total 39 57 68.4


line stmt bran cond sub pod time code
1 9     9   54 use utf8;
  9         18  
  9         46  
2             package Net::Etcd::User;
3              
4 9     9   320 use strict;
  9         17  
  9         155  
5 9     9   43 use warnings;
  9         18  
  9         235  
6              
7 9     9   55 use Moo;
  9         17  
  9         43  
8 9     9   2588 use Carp;
  9         18  
  9         627  
9 9     9   3398 use Net::Etcd::User::Role;
  9         23  
  9         312  
10 9     9   59 use Types::Standard qw(Str Int Bool HashRef ArrayRef);
  9         33  
  9         42  
11 9     9   8143 use Data::Dumper;
  9         19  
  9         517  
12              
13             with 'Net::Etcd::Role::Actions';
14              
15 9     9   51 use namespace::clean;
  9         17  
  9         38  
16              
17             =head1 NAME
18              
19             Net::Etcd::User
20              
21             =cut
22              
23             our $VERSION = '0.020';
24              
25             =head1 DESCRIPTION
26              
27             User class
28              
29             =cut
30              
31             =head1 ACCESSORS
32              
33             =head2 endpoint
34              
35             =cut
36              
37             has endpoint => (
38             is => 'rwp',
39             isa => Str,
40             );
41              
42             =head2 name
43              
44             name of user
45              
46             =cut
47              
48             has name => (
49             is => 'ro',
50             isa => Str,
51             required => 1,
52             );
53              
54             =head2 password
55              
56             =cut
57              
58             has password => (
59             is => 'ro',
60             isa => Str,
61             );
62              
63             =head1 PUBLIC METHODS
64              
65             =head2 add
66              
67             $etcd->user({ name =>'foo' password => 'bar' })->add
68              
69             =cut
70              
71             sub add {
72 0     0 1   my $self = shift;
73 0           $self->{endpoint} = '/auth/user/add';
74             confess 'password required for ' . __PACKAGE__ . '->add'
75 0 0         unless $self->{password};
76 0           $self->request;
77 0           return $self;
78             }
79              
80             =head2 delete
81              
82             $etcd->user({ name =>'foo' })->delete
83              
84             =cut
85              
86             sub delete {
87 0     0 1   my $self = shift;
88 0           $self->{endpoint} = '/auth/user/delete';
89 0           $self->request;
90 0           return $self;
91             }
92              
93              
94             =head2 changepw
95              
96             $etcd->user({ name =>'foo' password => 'bar' })->changepw
97              
98             =cut
99              
100             sub changepw {
101 0     0 1   my $self = shift;
102 0           $self->{endpoint} = '/auth/user/changepw';
103 0           $self->request;
104 0           return $self;
105             }
106              
107             1;