Class: RabbitMQ::HTTP::Client
- Inherits:
-
Object
- Object
- RabbitMQ::HTTP::Client
- Defined in:
- lib/rabbitmq/http/client.rb,
lib/rabbitmq/http/client/version.rb
Constant Summary collapse
- VERSION =
"3.0.0"
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#endpoint ⇒ Object
readonly
API.
-
#health ⇒ Object
readonly
API.
-
#request_helper ⇒ Object
readonly
Returns the value of attribute request_helper.
-
#response_helper ⇒ Object
readonly
Returns the value of attribute response_helper.
Class Method Summary collapse
Instance Method Summary collapse
- #bind_exchange(vhost, destination_exchange, source_exchange, routing_key, arguments = []) ⇒ Object
- #bind_queue(vhost, queue, exchange, routing_key, arguments = []) ⇒ Object
- #channel_info(name) ⇒ Object
- #clear_parameters_of(component, vhost, name) ⇒ Object
- #clear_permissions_of(vhost, user) ⇒ Object
- #clear_policies_of(vhost, name) ⇒ Object
- #close_connection(name) ⇒ Object
- #connection_info(name) ⇒ Object
- #create_vhost(name) ⇒ Object
- #declare_exchange(vhost, name, attributes = {}) ⇒ Object
- #declare_queue(vhost, name, attributes) ⇒ Object
- #delete_exchange(vhost, name, if_unused = false) ⇒ Object
- #delete_exchange_binding(vhost, destination_exchange, source_exchange, properties_key) ⇒ Object
- #delete_queue(vhost, name, if_unused = false, if_empty = false) ⇒ Object
- #delete_queue_binding(vhost, queue, exchange, properties_key) ⇒ Object
- #delete_topic_permissions_of(vhost, user) ⇒ Object
- #delete_user(name) ⇒ Object
- #delete_vhost(name) ⇒ Object
-
#enabled_protocols ⇒ Array<String>
Returns a list of messaging protocols supported by the node (or cluster).
- #exchange_binding_info(vhost, destination_exchange, source_exchange, properties_key) ⇒ Object
- #exchange_info(vhost, name) ⇒ Object
- #get_messages(vhost, name, options) ⇒ Object
-
#initialize(endpoint, options = {}) ⇒ Client
constructor
A new instance of Client.
- #list_bindings(vhost = nil, query = {}) ⇒ Object
- #list_bindings_between_exchanges(vhost, destination_exchange, source_exchange, query = {}) ⇒ Object
- #list_bindings_between_queue_and_exchange(vhost, queue, exchange, query = {}) ⇒ Object
- #list_bindings_by_destination(vhost, exchange, query = {}) ⇒ Object
- #list_bindings_by_source(vhost, exchange, query = {}) ⇒ Object
- #list_channels(query = {}) ⇒ Object
- #list_connections(query = {}) ⇒ Object
- #list_definitions ⇒ Object
- #list_exchanges(vhost = nil, query = {}) ⇒ Object
- #list_extensions(query = {}) ⇒ Object
- #list_nodes(query = {}) ⇒ Object
- #list_parameters(component = nil, query = {}) ⇒ Object
- #list_parameters_of(component, vhost, name = nil, query = {}) ⇒ Object
- #list_permissions(vhost = nil, query = {}) ⇒ Object
- #list_permissions_of(vhost, user) ⇒ Object
- #list_policies(vhost = nil, query = {}) ⇒ Object
- #list_policies_of(vhost, name = nil, query = {}) ⇒ Object
- #list_queue_bindings(vhost, queue, query = {}) ⇒ Object
- #list_queues(vhost = nil, query = {}) ⇒ Object
- #list_topic_permissions(vhost = nil, query = {}) ⇒ Object
- #list_topic_permissions_of(vhost, user) ⇒ Object
- #list_users(query = {}) ⇒ Object
- #list_vhosts(query = {}) ⇒ Object
- #node_info(name) ⇒ Object
- #overview ⇒ Object
-
#protocol_ports ⇒ Hash<String, Integer>
Returns a hash of protocol => port.
- #purge_queue(vhost, name) ⇒ Object
- #queue_binding_info(vhost, queue, exchange, properties_key) ⇒ Object
- #queue_info(vhost, name) ⇒ Object
- #update_parameters_of(component, vhost, name, attributes) ⇒ Object
- #update_permissions_of(vhost, user, attributes) ⇒ Object
- #update_policies_of(vhost, name, attributes) ⇒ Object
- #update_topic_permissions_of(vhost, user, attributes) ⇒ Object
- #update_user(name, attributes) ⇒ Object (also: #create_user)
- #upload_definitions(defs) ⇒ Object
- #user_info(name) ⇒ Object
- #user_permissions(name, query = {}) ⇒ Object
- #vhost_info(name) ⇒ Object
- #whoami ⇒ Object
Constructor Details
#initialize(endpoint, options = {}) ⇒ Client
Returns a new instance of Client.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rabbitmq/http/client.rb', line 27 def initialize(endpoint, = {}) @endpoint = endpoint @options = @request_helper = RequestHelper.new() @response_helper = ResponseHelper.new(self) @health = HealthChecks.new(self) initialize_connection(endpoint, ) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
21 22 23 |
# File 'lib/rabbitmq/http/client.rb', line 21 def connection @connection end |
#endpoint ⇒ Object (readonly)
API
20 21 22 |
# File 'lib/rabbitmq/http/client.rb', line 20 def endpoint @endpoint end |
#health ⇒ Object (readonly)
API
20 21 22 |
# File 'lib/rabbitmq/http/client.rb', line 20 def health @health end |
#request_helper ⇒ Object (readonly)
Returns the value of attribute request_helper.
21 22 23 |
# File 'lib/rabbitmq/http/client.rb', line 21 def request_helper @request_helper end |
#response_helper ⇒ Object (readonly)
Returns the value of attribute response_helper.
21 22 23 |
# File 'lib/rabbitmq/http/client.rb', line 21 def response_helper @response_helper end |
Class Method Details
.connect(endpoint, options = {}) ⇒ Object
23 24 25 |
# File 'lib/rabbitmq/http/client.rb', line 23 def self.connect(endpoint, = {}) new(endpoint, ) end |
Instance Method Details
#bind_exchange(vhost, destination_exchange, source_exchange, routing_key, arguments = []) ⇒ Object
245 246 247 248 249 250 251 |
# File 'lib/rabbitmq/http/client.rb', line 245 def bind_exchange(vhost, destination_exchange, source_exchange, routing_key, arguments = []) resp = @connection.post("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(source_exchange)}/e/#{encode_uri_path_segment(destination_exchange)}") do |req| req.headers['Content-Type'] = 'application/json' req.body = MultiJson.dump({:routing_key => routing_key, :arguments => arguments}) end resp.headers['location'] end |
#bind_queue(vhost, queue, exchange, routing_key, arguments = []) ⇒ Object
223 224 225 226 227 228 229 |
# File 'lib/rabbitmq/http/client.rb', line 223 def bind_queue(vhost, queue, exchange, routing_key, arguments = []) resp = @connection.post("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(exchange)}/q/#{encode_uri_path_segment(queue)}") do |req| req.headers['Content-Type'] = 'application/json' req.body = MultiJson.dump({:routing_key => routing_key, :arguments => arguments}) end resp.headers['location'] end |
#channel_info(name) ⇒ Object
110 111 112 |
# File 'lib/rabbitmq/http/client.rb', line 110 def channel_info(name) decode_resource(@connection.get("channels/#{encode_uri_path_segment(name)}")) end |
#clear_parameters_of(component, vhost, name) ⇒ Object
438 439 440 |
# File 'lib/rabbitmq/http/client.rb', line 438 def clear_parameters_of(component, vhost, name) decode_resource(@connection.delete("parameters/#{encode_uri_path_segment(component)}/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}")) end |
#clear_permissions_of(vhost, user) ⇒ Object
302 303 304 |
# File 'lib/rabbitmq/http/client.rb', line 302 def (vhost, user) decode_resource(@connection.delete("permissions/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(user)}")) end |
#clear_policies_of(vhost, name) ⇒ Object
405 406 407 |
# File 'lib/rabbitmq/http/client.rb', line 405 def clear_policies_of(vhost, name) decode_resource(@connection.delete("policies/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}")) end |
#close_connection(name) ⇒ Object
102 103 104 |
# File 'lib/rabbitmq/http/client.rb', line 102 def close_connection(name) decode_resource(@connection.delete("connections/#{encode_uri_path_segment(name)}")) end |
#connection_info(name) ⇒ Object
98 99 100 |
# File 'lib/rabbitmq/http/client.rb', line 98 def connection_info(name) decode_resource(@connection.get("connections/#{encode_uri_path_segment(name)}")) end |
#create_vhost(name) ⇒ Object
267 268 269 270 271 272 |
# File 'lib/rabbitmq/http/client.rb', line 267 def create_vhost(name) response = @connection.put("vhosts/#{encode_uri_path_segment(name)}") do |req| req.headers['Content-Type'] = "application/json" end decode_resource(response) end |
#declare_exchange(vhost, name, attributes = {}) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/rabbitmq/http/client.rb', line 124 def declare_exchange(vhost, name, attributes = {}) opts = { type: "direct", auto_delete: false, durable: true, arguments: {} }.merge(attributes) response = @connection.put("exchanges/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req| req.headers['Content-Type'] = 'application/json' req.body = MultiJson.dump(opts) end decode_resource(response) end |
#declare_queue(vhost, name, attributes) ⇒ Object
172 173 174 175 176 177 178 |
# File 'lib/rabbitmq/http/client.rb', line 172 def declare_queue(vhost, name, attributes) response = @connection.put("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump(attributes) end decode_resource(response) end |
#delete_exchange(vhost, name, if_unused = false) ⇒ Object
139 140 141 142 143 144 |
# File 'lib/rabbitmq/http/client.rb', line 139 def delete_exchange(vhost, name, if_unused = false) response = @connection.delete("exchanges/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req| req.params["if-unused"] = true if if_unused end decode_resource(response) end |
#delete_exchange_binding(vhost, destination_exchange, source_exchange, properties_key) ⇒ Object
253 254 255 256 |
# File 'lib/rabbitmq/http/client.rb', line 253 def delete_exchange_binding(vhost, destination_exchange, source_exchange, properties_key) resp = @connection.delete("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(source_exchange)}/e/#{encode_uri_path_segment(destination_exchange)}/#{encode_uri_path_segment(properties_key)}") resp.success? end |
#delete_queue(vhost, name, if_unused = false, if_empty = false) ⇒ Object
180 181 182 183 184 185 186 |
# File 'lib/rabbitmq/http/client.rb', line 180 def delete_queue(vhost, name, if_unused = false, if_empty = false) response = @connection.delete("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req| req.params["if-unused"] = true if if_unused req.params["if-empty"] = true if if_empty end decode_resource(response) end |
#delete_queue_binding(vhost, queue, exchange, properties_key) ⇒ Object
231 232 233 234 |
# File 'lib/rabbitmq/http/client.rb', line 231 def delete_queue_binding(vhost, queue, exchange, properties_key) resp = @connection.delete("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(exchange)}/q/#{encode_uri_path_segment(queue)}/#{encode_uri_path_segment(properties_key)}") resp.success? end |
#delete_topic_permissions_of(vhost, user) ⇒ Object
330 331 332 |
# File 'lib/rabbitmq/http/client.rb', line 330 def (vhost, user) decode_resource(@connection.delete("topic-permissions/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(user)}")) end |
#delete_user(name) ⇒ Object
364 365 366 |
# File 'lib/rabbitmq/http/client.rb', line 364 def delete_user(name) decode_resource(@connection.delete("users/#{encode_uri_path_segment(name)}")) end |
#delete_vhost(name) ⇒ Object
274 275 276 |
# File 'lib/rabbitmq/http/client.rb', line 274 def delete_vhost(name) decode_resource(@connection.delete("vhosts/#{encode_uri_path_segment(name)}")) end |
#enabled_protocols ⇒ Array<String>
Returns a list of messaging protocols supported by the node (or cluster).
Common values are:
-
amqp
-
amqp/ssl
-
mqtt
-
stomp
The exact value depends on RabbitMQ configuration and enabled plugins.
56 57 58 59 60 |
# File 'lib/rabbitmq/http/client.rb', line 56 def enabled_protocols self.overview.listeners. map { |lnr| lnr.protocol }. uniq end |
#exchange_binding_info(vhost, destination_exchange, source_exchange, properties_key) ⇒ Object
240 241 242 |
# File 'lib/rabbitmq/http/client.rb', line 240 def exchange_binding_info(vhost, destination_exchange, source_exchange, properties_key) decode_resource(@connection.get("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(source_exchange)}/e/#{encode_uri_path_segment(destination_exchange)}/#{encode_uri_path_segment(properties_key)}")) end |
#exchange_info(vhost, name) ⇒ Object
146 147 148 |
# File 'lib/rabbitmq/http/client.rb', line 146 def exchange_info(vhost, name) decode_resource(@connection.get("exchanges/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}")) end |
#get_messages(vhost, name, options) ⇒ Object
197 198 199 200 201 202 203 |
# File 'lib/rabbitmq/http/client.rb', line 197 def (vhost, name, ) response = @connection.post("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}/get") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump() end decode_resource_collection(response) end |
#list_bindings(vhost = nil, query = {}) ⇒ Object
205 206 207 208 209 210 211 212 213 |
# File 'lib/rabbitmq/http/client.rb', line 205 def list_bindings(vhost = nil, query = {}) path = if vhost.nil? "bindings" else "bindings/#{encode_uri_path_segment(vhost)}" end decode_resource_collection(@connection.get(path, query)) end |
#list_bindings_between_exchanges(vhost, destination_exchange, source_exchange, query = {}) ⇒ Object
236 237 238 |
# File 'lib/rabbitmq/http/client.rb', line 236 def list_bindings_between_exchanges(vhost, destination_exchange, source_exchange, query = {}) decode_resource_collection(@connection.get("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(source_exchange)}/e/#{encode_uri_path_segment(destination_exchange)}", query)) end |
#list_bindings_between_queue_and_exchange(vhost, queue, exchange, query = {}) ⇒ Object
215 216 217 |
# File 'lib/rabbitmq/http/client.rb', line 215 def list_bindings_between_queue_and_exchange(vhost, queue, exchange, query = {}) decode_resource_collection(@connection.get("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(exchange)}/q/#{encode_uri_path_segment(queue)}", query)) end |
#list_bindings_by_destination(vhost, exchange, query = {}) ⇒ Object
154 155 156 |
# File 'lib/rabbitmq/http/client.rb', line 154 def list_bindings_by_destination(vhost, exchange, query = {}) decode_resource_collection(@connection.get("exchanges/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(exchange)}/bindings/destination", query)) end |
#list_bindings_by_source(vhost, exchange, query = {}) ⇒ Object
150 151 152 |
# File 'lib/rabbitmq/http/client.rb', line 150 def list_bindings_by_source(vhost, exchange, query = {}) decode_resource_collection(@connection.get("exchanges/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(exchange)}/bindings/source", query)) end |
#list_channels(query = {}) ⇒ Object
106 107 108 |
# File 'lib/rabbitmq/http/client.rb', line 106 def list_channels(query = {}) decode_resource_collection(@connection.get("channels", query)) end |
#list_connections(query = {}) ⇒ Object
94 95 96 |
# File 'lib/rabbitmq/http/client.rb', line 94 def list_connections(query = {}) decode_resource_collection(@connection.get("connections", query)) end |
#list_definitions ⇒ Object
82 83 84 |
# File 'lib/rabbitmq/http/client.rb', line 82 def list_definitions decode_resource(@connection.get("definitions")) end |
#list_exchanges(vhost = nil, query = {}) ⇒ Object
114 115 116 117 118 119 120 121 122 |
# File 'lib/rabbitmq/http/client.rb', line 114 def list_exchanges(vhost = nil, query = {}) path = if vhost.nil? "exchanges" else "exchanges/#{encode_uri_path_segment(vhost)}" end decode_resource_collection(@connection.get(path, query)) end |
#list_extensions(query = {}) ⇒ Object
78 79 80 |
# File 'lib/rabbitmq/http/client.rb', line 78 def list_extensions(query = {}) decode_resource_collection(@connection.get("extensions", query)) end |
#list_nodes(query = {}) ⇒ Object
70 71 72 |
# File 'lib/rabbitmq/http/client.rb', line 70 def list_nodes(query = {}) decode_resource_collection(@connection.get("nodes", query)) end |
#list_parameters(component = nil, query = {}) ⇒ Object
412 413 414 415 416 417 418 419 |
# File 'lib/rabbitmq/http/client.rb', line 412 def list_parameters(component = nil, query = {}) path = if component "parameters/#{encode_uri_path_segment(component)}" else "parameters" end decode_resource_collection(@connection.get(path, query)) end |
#list_parameters_of(component, vhost, name = nil, query = {}) ⇒ Object
421 422 423 424 425 426 427 428 |
# File 'lib/rabbitmq/http/client.rb', line 421 def list_parameters_of(component, vhost, name = nil, query = {}) path = if name "parameters/#{encode_uri_path_segment(component)}/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}" else "parameters/#{encode_uri_path_segment(component)}/#{encode_uri_path_segment(vhost)}" end decode_resource_collection(@connection.get(path, query)) end |
#list_permissions(vhost = nil, query = {}) ⇒ Object
280 281 282 283 284 285 286 287 288 |
# File 'lib/rabbitmq/http/client.rb', line 280 def (vhost = nil, query = {}) path = if vhost "vhosts/#{encode_uri_path_segment(vhost)}/permissions" else "permissions" end decode_resource_collection(@connection.get(path, query)) end |
#list_permissions_of(vhost, user) ⇒ Object
290 291 292 |
# File 'lib/rabbitmq/http/client.rb', line 290 def (vhost, user) decode_resource(@connection.get("permissions/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(user)}")) end |
#list_policies(vhost = nil, query = {}) ⇒ Object
378 379 380 381 382 383 384 385 386 |
# File 'lib/rabbitmq/http/client.rb', line 378 def list_policies(vhost = nil, query = {}) path = if vhost "policies/#{encode_uri_path_segment(vhost)}" else "policies" end decode_resource_collection(@connection.get(path, query)) end |
#list_policies_of(vhost, name = nil, query = {}) ⇒ Object
388 389 390 391 392 393 394 395 |
# File 'lib/rabbitmq/http/client.rb', line 388 def list_policies_of(vhost, name = nil, query = {}) path = if name "policies/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}" else "policies/#{encode_uri_path_segment(vhost)}" end decode_resource_collection(@connection.get(path, query)) end |
#list_queue_bindings(vhost, queue, query = {}) ⇒ Object
188 189 190 |
# File 'lib/rabbitmq/http/client.rb', line 188 def list_queue_bindings(vhost, queue, query = {}) decode_resource_collection(@connection.get("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(queue)}/bindings", query)) end |
#list_queues(vhost = nil, query = {}) ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/rabbitmq/http/client.rb', line 158 def list_queues(vhost = nil, query = {}) path = if vhost.nil? "queues" else "queues/#{encode_uri_path_segment(vhost)}" end decode_resource_collection(@connection.get(path, query)) end |
#list_topic_permissions(vhost = nil, query = {}) ⇒ Object
306 307 308 309 310 311 312 313 314 |
# File 'lib/rabbitmq/http/client.rb', line 306 def (vhost = nil, query = {}) path = if vhost "vhosts/#{encode_uri_path_segment(vhost)}/topic-permissions" else "topic-permissions" end decode_resource_collection(@connection.get(path, query)) end |
#list_topic_permissions_of(vhost, user) ⇒ Object
316 317 318 319 |
# File 'lib/rabbitmq/http/client.rb', line 316 def (vhost, user) path = "topic-permissions/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(user)}" decode_resource_collection(@connection.get(path)) end |
#list_users(query = {}) ⇒ Object
334 335 336 337 338 339 340 341 342 |
# File 'lib/rabbitmq/http/client.rb', line 334 def list_users(query = {}) results = decode_resource_collection(@connection.get("users", query)) # HTTP API will return tags as an array starting with RabbitMQ 3.9 results.map do |u| u. = u..split(",") if u..is_a?(String) u end end |
#list_vhosts(query = {}) ⇒ Object
259 260 261 |
# File 'lib/rabbitmq/http/client.rb', line 259 def list_vhosts(query = {}) decode_resource_collection(@connection.get("vhosts", query)) end |
#node_info(name) ⇒ Object
74 75 76 |
# File 'lib/rabbitmq/http/client.rb', line 74 def node_info(name) decode_resource(@connection.get("nodes/#{encode_uri_path_segment(name)}")) end |
#overview ⇒ Object
38 39 40 |
# File 'lib/rabbitmq/http/client.rb', line 38 def overview decode_resource(@connection.get("overview")) end |
#protocol_ports ⇒ Hash<String, Integer>
Returns a hash of protocol => port.
65 66 67 68 |
# File 'lib/rabbitmq/http/client.rb', line 65 def protocol_ports (self.overview.listeners || []). reduce(Hash.new) { |acc, lnr| acc[lnr.protocol] = lnr.port; acc } end |
#purge_queue(vhost, name) ⇒ Object
192 193 194 195 |
# File 'lib/rabbitmq/http/client.rb', line 192 def purge_queue(vhost, name) @connection.delete("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}/contents") Hashie::Mash.new end |
#queue_binding_info(vhost, queue, exchange, properties_key) ⇒ Object
219 220 221 |
# File 'lib/rabbitmq/http/client.rb', line 219 def queue_binding_info(vhost, queue, exchange, properties_key) decode_resource(@connection.get("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(exchange)}/q/#{encode_uri_path_segment(queue)}/#{encode_uri_path_segment(properties_key)}")) end |
#queue_info(vhost, name) ⇒ Object
168 169 170 |
# File 'lib/rabbitmq/http/client.rb', line 168 def queue_info(vhost, name) decode_resource(@connection.get("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}")) end |
#update_parameters_of(component, vhost, name, attributes) ⇒ Object
430 431 432 433 434 435 436 |
# File 'lib/rabbitmq/http/client.rb', line 430 def update_parameters_of(component, vhost, name, attributes) response = @connection.put("parameters/#{encode_uri_path_segment(component)}/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump(attributes) end decode_resource(response) end |
#update_permissions_of(vhost, user, attributes) ⇒ Object
294 295 296 297 298 299 300 |
# File 'lib/rabbitmq/http/client.rb', line 294 def (vhost, user, attributes) response = @connection.put("permissions/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(user)}") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump(attributes) end decode_resource(response) end |
#update_policies_of(vhost, name, attributes) ⇒ Object
397 398 399 400 401 402 403 |
# File 'lib/rabbitmq/http/client.rb', line 397 def update_policies_of(vhost, name, attributes) response = @connection.put("policies/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump(attributes) end decode_resource(response) end |
#update_topic_permissions_of(vhost, user, attributes) ⇒ Object
321 322 323 324 325 326 327 328 |
# File 'lib/rabbitmq/http/client.rb', line 321 def (vhost, user, attributes) response = @connection.put("topic-permissions/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(user)}") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump(attributes) end nil end |
#update_user(name, attributes) ⇒ Object Also known as: create_user
353 354 355 356 357 358 359 360 361 |
# File 'lib/rabbitmq/http/client.rb', line 353 def update_user(name, attributes) attributes[:tags] ||= "" response = @connection.put("users/#{encode_uri_path_segment(name)}") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump(attributes) end decode_resource(response) end |
#upload_definitions(defs) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/rabbitmq/http/client.rb', line 86 def upload_definitions(defs) response = @connection.post("definitions") do |req| req.headers['Content-Type'] = "application/json" req.body = defs end response.success? end |
#user_info(name) ⇒ Object
344 345 346 347 348 349 350 351 |
# File 'lib/rabbitmq/http/client.rb', line 344 def user_info(name) result = decode_resource(@connection.get("users/#{encode_uri_path_segment(name)}")) # HTTP API will return tags as an array starting with RabbitMQ 3.9 result. = result..split(",") if result..is_a?(String) result end |
#user_permissions(name, query = {}) ⇒ Object
368 369 370 |
# File 'lib/rabbitmq/http/client.rb', line 368 def (name, query = {}) decode_resource_collection(@connection.get("users/#{encode_uri_path_segment(name)}/permissions", query)) end |
#vhost_info(name) ⇒ Object
263 264 265 |
# File 'lib/rabbitmq/http/client.rb', line 263 def vhost_info(name) decode_resource(@connection.get("vhosts/#{encode_uri_path_segment(name)}")) end |
#whoami ⇒ Object
372 373 374 |
# File 'lib/rabbitmq/http/client.rb', line 372 def whoami decode_resource(@connection.get("whoami")) end |