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