line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::RabbitMQ::Management::API; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Net::RabbitMQ::Management::API::VERSION = '0.01'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Interface to the HTTP Rest API of the RabbitMQ management plugin |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
701193
|
use Moo; |
|
4
|
|
|
|
|
38543
|
|
|
4
|
|
|
|
|
33
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
4809
|
use Carp qw(croak); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
259
|
|
11
|
4
|
|
|
4
|
|
1871
|
use HTTP::Headers; |
|
4
|
|
|
|
|
18739
|
|
|
4
|
|
|
|
|
169
|
|
12
|
4
|
|
|
4
|
|
3654
|
use HTTP::Request; |
|
4
|
|
|
|
|
34124
|
|
|
4
|
|
|
|
|
138
|
|
13
|
4
|
|
|
4
|
|
4571
|
use JSON::Any; |
|
4
|
|
|
|
|
98956
|
|
|
4
|
|
|
|
|
35
|
|
14
|
4
|
|
|
4
|
|
37311
|
use LWP::UserAgent; |
|
4
|
|
|
|
|
101391
|
|
|
4
|
|
|
|
|
159
|
|
15
|
4
|
|
|
4
|
|
3527
|
use Net::RabbitMQ::Management::API::Result; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
144
|
|
16
|
4
|
|
|
4
|
|
40
|
use URI; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
18265
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'ua' => ( |
21
|
|
|
|
|
|
|
builder => '_build_ua', |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
lazy => 1, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'username' => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
default => sub { |
30
|
|
|
|
|
|
|
return 'guest'; |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has 'password' => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
default => sub { |
38
|
|
|
|
|
|
|
return 'guest'; |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has 'url' => ( |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
required => 1, |
46
|
|
|
|
|
|
|
trigger => sub { |
47
|
|
|
|
|
|
|
my ( $self, $uri ) = @_; |
48
|
|
|
|
|
|
|
$self->{url} = URI->new("$uri"); |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has '_json' => ( |
53
|
|
|
|
|
|
|
builder => '_build__json', |
54
|
|
|
|
|
|
|
is => 'ro', |
55
|
|
|
|
|
|
|
lazy => 1, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub request { |
60
|
8
|
|
|
8
|
1
|
5619
|
my ( $self, %args ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
8
|
|
66
|
|
|
66
|
my $method = delete $args{method} || croak 'Missing mandatory key in parameters: method'; |
63
|
7
|
|
66
|
|
|
44
|
my $path = delete $args{path} || croak 'Missing mandatory key in parameters: path'; |
64
|
6
|
|
|
|
|
17
|
my $data = delete $args{data}; |
65
|
|
|
|
|
|
|
|
66
|
6
|
100
|
|
|
|
54
|
croak "Invalid method: $method" unless grep $_ eq $method, qw(DELETE GET PATCH POST PUT); |
67
|
|
|
|
|
|
|
|
68
|
5
|
|
|
|
|
20
|
my $uri = $self->_uri_for($path); |
69
|
5
|
|
|
|
|
20
|
my $request = $self->_request_for( $method, $uri, $data ); |
70
|
5
|
|
|
|
|
132
|
my $response = $self->ua->request($request); |
71
|
|
|
|
|
|
|
|
72
|
5
|
|
|
|
|
4425
|
return Net::RabbitMQ::Management::API::Result->new( response => $response ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _request_for { |
76
|
5
|
|
|
5
|
|
13
|
my ( $self, $method, $uri, $data ) = @_; |
77
|
|
|
|
|
|
|
|
78
|
5
|
|
|
|
|
36
|
my $headers = HTTP::Headers->new; |
79
|
|
|
|
|
|
|
|
80
|
5
|
|
|
|
|
73
|
my $request = HTTP::Request->new( $method, $uri, $headers ); |
81
|
5
|
|
|
|
|
910
|
$request->authorization_basic( $self->username, $self->password ); |
82
|
|
|
|
|
|
|
|
83
|
5
|
100
|
|
|
|
3705
|
if ($data) { |
84
|
1
|
|
|
|
|
9
|
my $json = $self->_json->encode($data); |
85
|
1
|
|
|
|
|
160
|
$request->content($json); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
5
|
|
|
|
|
58
|
$request->header( 'Content-Length' => length $request->content ); |
89
|
5
|
|
|
|
|
339
|
$request->header( 'Content-Type' => 'application/json' ); |
90
|
|
|
|
|
|
|
|
91
|
5
|
|
|
|
|
229
|
return $request; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _uri_for { |
95
|
5
|
|
|
5
|
|
12
|
my ( $self, $path ) = @_; |
96
|
|
|
|
|
|
|
|
97
|
5
|
|
|
|
|
86
|
my $uri = $self->url->clone; |
98
|
|
|
|
|
|
|
|
99
|
5
|
|
|
|
|
213
|
$uri->path( $uri->path . $path ); |
100
|
|
|
|
|
|
|
|
101
|
5
|
|
|
|
|
262
|
return $uri; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _build__json { |
105
|
1
|
|
|
1
|
|
1079
|
my ($self) = @_; |
106
|
1
|
|
|
|
|
12
|
return JSON::Any->new; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _build_ua { |
110
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
111
|
0
|
|
|
|
|
|
return LWP::UserAgent->new; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub get_overview { |
116
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
return $self->request( |
119
|
|
|
|
|
|
|
method => 'GET', |
120
|
|
|
|
|
|
|
path => '/overview', |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub get_nodes { |
126
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return $self->request( |
129
|
|
|
|
|
|
|
method => 'GET', |
130
|
|
|
|
|
|
|
path => '/nodes', |
131
|
|
|
|
|
|
|
); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub get_node { |
136
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
137
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
return $self->request( |
140
|
|
|
|
|
|
|
method => 'GET', |
141
|
|
|
|
|
|
|
path => sprintf( '/nodes/%s/', $args{name} ), |
142
|
|
|
|
|
|
|
); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub get_extensions { |
147
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
return $self->request( |
150
|
|
|
|
|
|
|
method => 'GET', |
151
|
|
|
|
|
|
|
path => '/extensions', |
152
|
|
|
|
|
|
|
); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub get_configuration { |
157
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
158
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
return $self->request( |
160
|
|
|
|
|
|
|
method => 'GET', |
161
|
|
|
|
|
|
|
path => '/all-configuration', |
162
|
|
|
|
|
|
|
); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub update_configuration { |
167
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
168
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: users' unless $args{users}; |
169
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhosts' unless $args{vhosts}; |
170
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: permissions' unless $args{permissions}; |
171
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: queues' unless $args{queues}; |
172
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: exchanges' unless $args{exchanges}; |
173
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: bindings' unless $args{bindings}; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
return $self->request( |
176
|
|
|
|
|
|
|
method => 'POST', |
177
|
|
|
|
|
|
|
path => '/all-configuration', |
178
|
|
|
|
|
|
|
data => \%args, |
179
|
|
|
|
|
|
|
); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub get_connections { |
184
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
return $self->request( |
187
|
|
|
|
|
|
|
method => 'GET', |
188
|
|
|
|
|
|
|
path => '/connections', |
189
|
|
|
|
|
|
|
); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub get_connection { |
194
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
195
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
196
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
return $self->request( |
198
|
|
|
|
|
|
|
method => 'GET', |
199
|
|
|
|
|
|
|
path => sprintf( '/connections/%s', $args{name} ), |
200
|
|
|
|
|
|
|
); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub delete_connection { |
205
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
206
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
207
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
return $self->request( |
209
|
|
|
|
|
|
|
method => 'DELETE', |
210
|
|
|
|
|
|
|
path => sprintf( '/connections/%s', $args{name} ), |
211
|
|
|
|
|
|
|
); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub get_channels { |
216
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
217
|
|
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
return $self->request( |
219
|
|
|
|
|
|
|
method => 'GET', |
220
|
|
|
|
|
|
|
path => '/channels', |
221
|
|
|
|
|
|
|
); |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub get_channel { |
226
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
227
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
228
|
|
|
|
|
|
|
|
229
|
0
|
|
|
|
|
|
return $self->request( |
230
|
|
|
|
|
|
|
method => 'GET', |
231
|
|
|
|
|
|
|
path => sprintf( '/channels/%s', $args{name} ), |
232
|
|
|
|
|
|
|
); |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub get_exchanges { |
237
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
238
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
return $self->request( |
240
|
|
|
|
|
|
|
method => 'GET', |
241
|
|
|
|
|
|
|
path => '/exchanges', |
242
|
|
|
|
|
|
|
); |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub get_exchanges_in_vhost { |
247
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
248
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
249
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
return $self->request( |
251
|
|
|
|
|
|
|
method => 'GET', |
252
|
|
|
|
|
|
|
path => sprintf( '/exchanges/%s', $args{vhost} ), |
253
|
|
|
|
|
|
|
); |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub get_exchange { |
258
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
259
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
260
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
261
|
|
|
|
|
|
|
|
262
|
0
|
|
|
|
|
|
return $self->request( |
263
|
|
|
|
|
|
|
method => 'GET', |
264
|
|
|
|
|
|
|
path => sprintf( '/exchanges/%s/%s', $args{vhost}, $args{name} ), |
265
|
|
|
|
|
|
|
); |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
sub create_exchange { |
270
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
271
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
272
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
273
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: type' unless $args{type}; |
274
|
|
|
|
|
|
|
|
275
|
0
|
|
|
|
|
|
return $self->request( |
276
|
|
|
|
|
|
|
method => 'PUT', |
277
|
|
|
|
|
|
|
path => sprintf( '/exchanges/%s/%s', delete $args{vhost}, delete $args{name} ), |
278
|
|
|
|
|
|
|
data => \%args, |
279
|
|
|
|
|
|
|
); |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
sub delete_exchange { |
284
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
285
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
286
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
287
|
|
|
|
|
|
|
|
288
|
0
|
|
|
|
|
|
return $self->request( |
289
|
|
|
|
|
|
|
method => 'DELETE', |
290
|
|
|
|
|
|
|
path => sprintf( '/exchanges/%s/%s', $args{vhost}, $args{name} ), |
291
|
|
|
|
|
|
|
); |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
sub get_exchange_bindings_by_source { |
296
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
297
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
298
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
299
|
|
|
|
|
|
|
|
300
|
0
|
|
|
|
|
|
return $self->request( |
301
|
|
|
|
|
|
|
method => 'GET', |
302
|
|
|
|
|
|
|
path => sprintf( '/exchanges/%s/%s/bindings/source', $args{vhost}, $args{name} ), |
303
|
|
|
|
|
|
|
); |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub get_exchange_bindings_by_destination { |
308
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
309
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
310
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
311
|
|
|
|
|
|
|
|
312
|
0
|
|
|
|
|
|
return $self->request( |
313
|
|
|
|
|
|
|
method => 'GET', |
314
|
|
|
|
|
|
|
path => sprintf( '/exchanges/%s/%s/bindings/destination', $args{vhost}, $args{name} ), |
315
|
|
|
|
|
|
|
); |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub publish_exchange_message { |
320
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
321
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
322
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
323
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: properties' unless $args{properties}; |
324
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: routing_key' unless $args{routing_key}; |
325
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: payload' unless $args{payload}; |
326
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: payload_encoding' unless $args{payload_encoding}; |
327
|
|
|
|
|
|
|
|
328
|
0
|
|
|
|
|
|
return $self->request( |
329
|
|
|
|
|
|
|
method => 'POST', |
330
|
|
|
|
|
|
|
path => sprintf( '/exchanges/%s/%s/publish', delete $args{vhost}, delete $args{name} ), |
331
|
|
|
|
|
|
|
data => \%args, |
332
|
|
|
|
|
|
|
); |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
sub get_queues { |
337
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
338
|
|
|
|
|
|
|
|
339
|
0
|
|
|
|
|
|
return $self->request( |
340
|
|
|
|
|
|
|
method => 'GET', |
341
|
|
|
|
|
|
|
path => '/queues', |
342
|
|
|
|
|
|
|
); |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
sub get_queues_in_vhost { |
347
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
348
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
349
|
|
|
|
|
|
|
|
350
|
0
|
|
|
|
|
|
return $self->request( |
351
|
|
|
|
|
|
|
method => 'GET', |
352
|
|
|
|
|
|
|
path => sprintf( '/queues/%s', $args{vhost} ), |
353
|
|
|
|
|
|
|
); |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
sub get_queue { |
358
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
359
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
360
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
361
|
|
|
|
|
|
|
|
362
|
0
|
|
|
|
|
|
return $self->request( |
363
|
|
|
|
|
|
|
method => 'GET', |
364
|
|
|
|
|
|
|
path => sprintf( '/queues/%s/%s', $args{vhost}, $args{name} ), |
365
|
|
|
|
|
|
|
); |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
sub create_queue { |
370
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
371
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
372
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
373
|
|
|
|
|
|
|
|
374
|
0
|
|
|
|
|
|
return $self->request( |
375
|
|
|
|
|
|
|
method => 'PUT', |
376
|
|
|
|
|
|
|
path => sprintf( '/queues/%s/%s', delete $args{vhost}, delete $args{name} ), |
377
|
|
|
|
|
|
|
data => \%args, |
378
|
|
|
|
|
|
|
); |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
sub delete_queue { |
383
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
384
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
385
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
386
|
|
|
|
|
|
|
|
387
|
0
|
|
|
|
|
|
return $self->request( |
388
|
|
|
|
|
|
|
method => 'DELETE', |
389
|
|
|
|
|
|
|
path => sprintf( '/queues/%s/%s', $args{vhost}, $args{name} ), |
390
|
|
|
|
|
|
|
); |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
sub get_queue_bindings { |
395
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
396
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
397
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
398
|
|
|
|
|
|
|
|
399
|
0
|
|
|
|
|
|
return $self->request( |
400
|
|
|
|
|
|
|
method => 'GET', |
401
|
|
|
|
|
|
|
path => sprintf( '/queues/%s/%s/bindings', $args{vhost}, $args{name} ), |
402
|
|
|
|
|
|
|
); |
403
|
|
|
|
|
|
|
} |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
sub delete_queue_contents { |
407
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
408
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
409
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
410
|
|
|
|
|
|
|
|
411
|
0
|
|
|
|
|
|
return $self->request( |
412
|
|
|
|
|
|
|
method => 'DELETE', |
413
|
|
|
|
|
|
|
path => sprintf( '/queues/%s/%s/contents', $args{vhost}, $args{name} ), |
414
|
|
|
|
|
|
|
); |
415
|
|
|
|
|
|
|
} |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
sub get_queue_messages { |
419
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
420
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
421
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
422
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: encoding' unless $args{encoding}; |
423
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: count' unless defined $args{count}; |
424
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: requeue' unless defined $args{requeue}; |
425
|
|
|
|
|
|
|
|
426
|
0
|
|
|
|
|
|
return $self->request( |
427
|
|
|
|
|
|
|
method => 'POST', |
428
|
|
|
|
|
|
|
path => sprintf( '/queues/%s/%s/get', delete $args{vhost}, delete $args{name} ), |
429
|
|
|
|
|
|
|
data => \%args, |
430
|
|
|
|
|
|
|
); |
431
|
|
|
|
|
|
|
} |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
sub get_bindings { |
435
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
436
|
|
|
|
|
|
|
|
437
|
0
|
|
|
|
|
|
return $self->request( |
438
|
|
|
|
|
|
|
method => 'GET', |
439
|
|
|
|
|
|
|
path => '/bindings', |
440
|
|
|
|
|
|
|
); |
441
|
|
|
|
|
|
|
} |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
sub get_bindings_in_vhost { |
445
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
446
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
447
|
|
|
|
|
|
|
|
448
|
0
|
|
|
|
|
|
return $self->request( |
449
|
|
|
|
|
|
|
method => 'GET', |
450
|
|
|
|
|
|
|
path => sprintf( '/bindings/%s', $args{vhost} ), |
451
|
|
|
|
|
|
|
); |
452
|
|
|
|
|
|
|
} |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
sub get_bindings_between_exchange_and_queue { |
456
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
457
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
458
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: exchange' unless $args{exchange}; |
459
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: queue' unless $args{queue}; |
460
|
|
|
|
|
|
|
|
461
|
0
|
|
|
|
|
|
return $self->request( |
462
|
|
|
|
|
|
|
method => 'GET', |
463
|
|
|
|
|
|
|
path => sprintf( '/bindings/%s/e/%s/q/%s', $args{vhost}, $args{exchange}, $args{queue} ), |
464
|
|
|
|
|
|
|
); |
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
sub create_bindings_between_exchange_and_queue { |
469
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
470
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
471
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: exchange' unless $args{exchange}; |
472
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: queue' unless $args{queue}; |
473
|
|
|
|
|
|
|
|
474
|
0
|
|
|
|
|
|
return $self->request( |
475
|
|
|
|
|
|
|
method => 'POST', |
476
|
|
|
|
|
|
|
path => sprintf( '/bindings/%s/e/%s/q/%s', delete $args{vhost}, delete $args{exchange}, delete $args{queue} ), |
477
|
|
|
|
|
|
|
data => \%args, |
478
|
|
|
|
|
|
|
); |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
sub get_binding { |
483
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
484
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
485
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: exchange' unless $args{exchange}; |
486
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: queue' unless $args{queue}; |
487
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
488
|
|
|
|
|
|
|
|
489
|
0
|
|
|
|
|
|
return $self->request( |
490
|
|
|
|
|
|
|
method => 'GET', |
491
|
|
|
|
|
|
|
path => sprintf( '/bindings/%s/e/%s/q/%s/%s', $args{vhost}, $args{exchange}, $args{queue}, $args{name} ), |
492
|
|
|
|
|
|
|
); |
493
|
|
|
|
|
|
|
} |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
sub create_binding { |
497
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
498
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
499
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: exchange' unless $args{exchange}; |
500
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: queue' unless $args{queue}; |
501
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
502
|
|
|
|
|
|
|
|
503
|
0
|
|
|
|
|
|
return $self->request( |
504
|
|
|
|
|
|
|
method => 'PUT', |
505
|
|
|
|
|
|
|
path => sprintf( '/bindings/%s/e/%s/q/%s/%s', $args{vhost}, $args{exchange}, $args{queue}, $args{name} ), |
506
|
|
|
|
|
|
|
); |
507
|
|
|
|
|
|
|
} |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
sub delete_binding { |
511
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
512
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
513
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: exchange' unless $args{exchange}; |
514
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: queue' unless $args{queue}; |
515
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
516
|
|
|
|
|
|
|
|
517
|
0
|
|
|
|
|
|
return $self->request( |
518
|
|
|
|
|
|
|
method => 'DELETE', |
519
|
|
|
|
|
|
|
path => sprintf( '/bindings/%s/e/%s/q/%s/%s', $args{vhost}, $args{exchange}, $args{queue}, $args{name} ), |
520
|
|
|
|
|
|
|
); |
521
|
|
|
|
|
|
|
} |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
sub get_vhosts { |
525
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
526
|
|
|
|
|
|
|
|
527
|
0
|
|
|
|
|
|
return $self->request( |
528
|
|
|
|
|
|
|
method => 'GET', |
529
|
|
|
|
|
|
|
path => '/vhosts', |
530
|
|
|
|
|
|
|
); |
531
|
|
|
|
|
|
|
} |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
sub get_vhost { |
535
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
536
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
537
|
|
|
|
|
|
|
|
538
|
0
|
|
|
|
|
|
return $self->request( |
539
|
|
|
|
|
|
|
method => 'GET', |
540
|
|
|
|
|
|
|
path => sprintf( '/vhosts/%s', $args{name} ), |
541
|
|
|
|
|
|
|
); |
542
|
|
|
|
|
|
|
} |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
sub create_vhost { |
546
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
547
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
548
|
|
|
|
|
|
|
|
549
|
0
|
|
|
|
|
|
return $self->request( |
550
|
|
|
|
|
|
|
method => 'PUT', |
551
|
|
|
|
|
|
|
path => sprintf( '/vhosts/%s', $args{name} ), |
552
|
|
|
|
|
|
|
); |
553
|
|
|
|
|
|
|
} |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
sub delete_vhost { |
557
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
558
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
559
|
|
|
|
|
|
|
|
560
|
0
|
|
|
|
|
|
return $self->request( |
561
|
|
|
|
|
|
|
method => 'DELETE', |
562
|
|
|
|
|
|
|
path => sprintf( '/vhosts/%s', $args{name} ), |
563
|
|
|
|
|
|
|
); |
564
|
|
|
|
|
|
|
} |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
sub get_vhost_permissions { |
568
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
569
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
570
|
|
|
|
|
|
|
|
571
|
0
|
|
|
|
|
|
return $self->request( |
572
|
|
|
|
|
|
|
method => 'GET', |
573
|
|
|
|
|
|
|
path => sprintf( '/vhosts/%s/permissions', $args{name} ), |
574
|
|
|
|
|
|
|
); |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
sub get_users { |
579
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
580
|
|
|
|
|
|
|
|
581
|
0
|
|
|
|
|
|
return $self->request( |
582
|
|
|
|
|
|
|
method => 'GET', |
583
|
|
|
|
|
|
|
path => '/users', |
584
|
|
|
|
|
|
|
); |
585
|
|
|
|
|
|
|
} |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
sub get_user { |
589
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
590
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
591
|
|
|
|
|
|
|
|
592
|
0
|
|
|
|
|
|
return $self->request( |
593
|
|
|
|
|
|
|
method => 'GET', |
594
|
|
|
|
|
|
|
path => sprintf( '/users/%s', $args{name} ), |
595
|
|
|
|
|
|
|
); |
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
sub create_user { |
600
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
601
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
602
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: tags' unless $args{tags}; |
603
|
0
|
0
|
0
|
|
|
|
croak 'Missing key in parameters: password or password_hash' unless $args{password} or $args{password_hash}; |
604
|
|
|
|
|
|
|
|
605
|
0
|
|
|
|
|
|
return $self->request( |
606
|
|
|
|
|
|
|
method => 'PUT', |
607
|
|
|
|
|
|
|
path => sprintf( '/users/%s', delete $args{name} ), |
608
|
|
|
|
|
|
|
data => \%args, |
609
|
|
|
|
|
|
|
); |
610
|
|
|
|
|
|
|
} |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
sub delete_user { |
614
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
615
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
616
|
|
|
|
|
|
|
|
617
|
0
|
|
|
|
|
|
return $self->request( |
618
|
|
|
|
|
|
|
method => 'DELETE', |
619
|
|
|
|
|
|
|
path => sprintf( '/users/%s', $args{name} ), |
620
|
|
|
|
|
|
|
); |
621
|
|
|
|
|
|
|
} |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
sub get_user_permissions { |
625
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
626
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
627
|
|
|
|
|
|
|
|
628
|
0
|
|
|
|
|
|
return $self->request( |
629
|
|
|
|
|
|
|
method => 'GET', |
630
|
|
|
|
|
|
|
path => sprintf( '/users/%s/permissions', $args{name} ), |
631
|
|
|
|
|
|
|
); |
632
|
|
|
|
|
|
|
} |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
sub get_user_details { |
636
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
637
|
|
|
|
|
|
|
|
638
|
0
|
|
|
|
|
|
return $self->request( |
639
|
|
|
|
|
|
|
method => 'GET', |
640
|
|
|
|
|
|
|
path => '/whoami', |
641
|
|
|
|
|
|
|
); |
642
|
|
|
|
|
|
|
} |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
sub get_users_permissions { |
646
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
647
|
|
|
|
|
|
|
|
648
|
0
|
|
|
|
|
|
return $self->request( |
649
|
|
|
|
|
|
|
method => 'GET', |
650
|
|
|
|
|
|
|
path => '/permissions', |
651
|
|
|
|
|
|
|
); |
652
|
|
|
|
|
|
|
} |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
sub get_user_vhost_permissions { |
656
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
657
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
658
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
659
|
|
|
|
|
|
|
|
660
|
0
|
|
|
|
|
|
return $self->request( |
661
|
|
|
|
|
|
|
method => 'GET', |
662
|
|
|
|
|
|
|
path => sprintf( '/permissions/%s/%s', $args{vhost}, $args{name} ), |
663
|
|
|
|
|
|
|
); |
664
|
|
|
|
|
|
|
} |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
sub create_user_vhost_permissions { |
668
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
669
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
670
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
671
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: write' unless $args{write}; |
672
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: read' unless $args{read}; |
673
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: configure' unless $args{configure}; |
674
|
|
|
|
|
|
|
|
675
|
0
|
|
|
|
|
|
return $self->request( |
676
|
|
|
|
|
|
|
method => 'PUT', |
677
|
|
|
|
|
|
|
path => sprintf( '/permissions/%s/%s', delete $args{vhost}, delete $args{name} ), |
678
|
|
|
|
|
|
|
data => \%args, |
679
|
|
|
|
|
|
|
); |
680
|
|
|
|
|
|
|
} |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
sub delete_user_vhost_permissions { |
684
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
685
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: name' unless $args{name}; |
686
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
687
|
|
|
|
|
|
|
|
688
|
0
|
|
|
|
|
|
return $self->request( |
689
|
|
|
|
|
|
|
method => 'DELETE', |
690
|
|
|
|
|
|
|
path => sprintf( '/permissions/%s/%s', $args{vhost}, $args{name} ), |
691
|
|
|
|
|
|
|
); |
692
|
|
|
|
|
|
|
} |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
sub vhost_aliveness_test { |
696
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
697
|
0
|
0
|
|
|
|
|
croak 'Missing key in parameters: vhost' unless $args{vhost}; |
698
|
|
|
|
|
|
|
|
699
|
0
|
|
|
|
|
|
return $self->request( |
700
|
|
|
|
|
|
|
method => 'GET', |
701
|
|
|
|
|
|
|
path => sprintf( '/aliveness-test/%s', $args{vhost} ), |
702
|
|
|
|
|
|
|
); |
703
|
|
|
|
|
|
|
} |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
1; |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
__END__ |