Admin/User.pm

filter: Statementstmt 100% 44 / 44 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 85.7% 6 / 7 totaltotal 98.4% 62 / 63 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Admin.pm ↑ Summary
1 package Ceph::RadosGW::Admin::User;
2 2 $Ceph::RadosGW::Admin::User::VERSION = '0.4';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 Ceph::RadosGW::Admin::User - A Rados Gateway User
12  
13 =head1 VERSION
14  
15 version 0.4
16  
17 =head1 DESCRIPTION
18  
19 This class provides objects that represent users on a rados gateway object
20 store.
21  
22 =cut
23  
24 2 has user_id => (is => 'ro', required => 1, isa => 'Str');
25 2 has display_name => (is => 'rw', required => 1, isa => 'Str');
26 2 has suspended => (is => 'rw', required => 1, isa => 'Bool');
27 2 has max_buckets => (is => 'rw', required => 1, isa => 'Int');
28 2 has subusers => (is => 'rw', required => 1, isa => 'ArrayRef[Ceph::RadosGW::Admin::User]');
29 2 has keys => (is => 'rw', required => 1, isa => 'ArrayRef[HashRef[Str]]');
30 2 has swift_keys => (is => 'rw', required => 1, isa => 'ArrayRef[Str]');
31 2 has caps => (is => 'rw', required => 1, isa => 'ArrayRef[Str]');
32 2 has _client => (is => 'ro', required => 1, isa => 'Ceph::RadosGW::Admin');
33  
34 2 __PACKAGE__->meta->make_immutable;
35  
36 =head1 METHODS
37  
38 =head2 delete
39  
40 Removes the user from the rados system.
41  
42 Dies on failure.
43  
44 =cut
45  
46 17 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
47 17 my ($self, %args) = @_;
48
49 17 $self->_request(DELETE => 'user', %args);
50
51 17 return 1;
52 }
53  
54 =head2 save
55  
56 Save changes to the user.
57  
58 Dies on failure.
59  
60 =cut
61  
62 1 ▶sub save {
Subroutine save: called CC=1 SCAR=0.0
Pod documented
63 1 my ($self) = @_;
64
65 1 return $self->_request(
66 POST => 'user',
67 display_name => $self->display_name,
68 suspended => $self->suspended,
69 max_buckets => $self->max_buckets,
70 );
71 }
72  
73 =head2 create_key
74  
75 Create an access/secret key pair. Returns the keys as a list of hashrefs.
76  
77 Dies on failure.
78  
79 =cut
80  
81 1 ▶sub create_key {
Subroutine create_key: called CC=1 SCAR=0.0
Pod documented
82 1 my ($self) = @_;
83
84 1 return $self->_request(
85 PUT => 'user',
86 key => '',
87 generate_key => 'True',
88 );
89 }
90  
91 =head2 delete_key
92  
93 Delete a specific access/secret key pair.
94  
95 Dies on failure.
96  
97 =cut
98  
99 1 ▶sub delete_key {
Subroutine delete_key: called CC=1 SCAR=0.0
Pod documented
100 1 my ($self, %args) = @_;
101
102 return $self->_request(
103 DELETE => 'user',
104 key => '',
105 1 access_key => $args{'access_key'},
106 );
107 }
108  
109 =head2 get_usage
110  
111 Get usage information for the user.
112  
113 Dies on failure.
114  
115 =cut
116  
117 1 ▶sub get_usage {
Subroutine get_usage: called CC=1 SCAR=0.0
Pod documented
118 1 my ($self, %args) = @_;
119  
120 1 my %usage = $self->_request(GET => 'usage', %args);
121  
122 1 return %usage;
123 }
124  
125 =head2 get_bucket_info
126  
127 Gets bucket information and statistics for the user.
128  
129 Dies on failure.
130  
131 =cut
132  
133 1 ▶sub get_bucket_info {
Subroutine get_bucket_info: called CC=1 SCAR=0.0
Pod documented
134 1 my ($self) = @_;
135  
136 1 my @info = $self->_request(
137 GET => 'bucket',
138 stats => 'True',
139 );
140  
141 1 return @info;
142 }
143  
144 21 ▶sub _request {
Subroutine _request: called CC=1 SCAR=0.0
145 21 my ($self, @args) = @_;
146
147 21 return $self->_client->_request(
148 @args,
149 uid => $self->user_id,
150 );
151 }
152  
153 1 ▶sub as_hashref {
Subroutine as_hashref: called CC=1 SCAR=0.0
Pod undocumented
154 1 my ($self) = @_;
155
156 return {
157 1 map { $_ => $self->$_ } qw/user_id display_name suspended max_buckets keys caps/
158 };
159 }
160  
161 2 1;
« Admin.pm ↑ Summary