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 =
"0.2.0"
Class Method Summary collapse
Instance Method Summary collapse
- #aliveness_test(vhost) ⇒ 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_queue(vhost, name, attributes) ⇒ Object
- #delete_queue(vhost, name) ⇒ Object
- #delete_user(name) ⇒ Object
- #delete_vhost(name) ⇒ 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) ⇒ Object
- #list_bindings_between_queue_and_exchange(vhost, queue, exchange) ⇒ Object
- #list_bindings_by_destination(vhost, exchange) ⇒ Object
- #list_bindings_by_source(vhost, exchange) ⇒ Object
- #list_channels ⇒ Object
- #list_connections ⇒ Object
- #list_definitions ⇒ Object
- #list_exchanges(vhost = nil) ⇒ Object
- #list_extensions ⇒ Object
- #list_nodes ⇒ Object
- #list_parameters(component = nil) ⇒ Object
- #list_parameters_of(component, vhost, name = nil) ⇒ Object
- #list_permissions(vhost = nil) ⇒ Object
- #list_permissions_of(vhost, user) ⇒ Object
- #list_policies(vhost = nil) ⇒ Object
- #list_policies_of(vhost, name = nil) ⇒ Object
- #list_queue_bindings(vhost, queue) ⇒ Object
- #list_queues(vhost = nil) ⇒ Object
- #list_users ⇒ Object
- #list_vhosts ⇒ Object
- #node_info(name) ⇒ Object
- #overview ⇒ Object
- #purge_queue(vhost, name) ⇒ 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_user(name, attributes) ⇒ Object (also: #create_user)
- #upload_definitions(defs) ⇒ Object
- #user_info(name) ⇒ Object
- #user_permissions(name) ⇒ Object
- #vhost_info(name) ⇒ Object
- #whoami ⇒ Object
Constructor Details
#initialize(endpoint, options = {}) ⇒ Client
Returns a new instance of Client.
21 22 23 24 25 26 |
# File 'lib/rabbitmq/http/client.rb', line 21 def initialize(endpoint, = {}) @endpoint = endpoint @options = initialize_connection(endpoint, ) end |
Class Method Details
.connect(endpoint, options = {}) ⇒ Object
API
17 18 19 |
# File 'lib/rabbitmq/http/client.rb', line 17 def self.connect(endpoint, = {}) new(endpoint, ) end |
Instance Method Details
#aliveness_test(vhost) ⇒ Object
300 301 302 303 |
# File 'lib/rabbitmq/http/client.rb', line 300 def aliveness_test(vhost) r = @connection.get("/api/aliveness-test/#{uri_encode(vhost)}") r.body["status"] == "ok" end |
#channel_info(name) ⇒ Object
68 69 70 |
# File 'lib/rabbitmq/http/client.rb', line 68 def channel_info(name) decode_resource(@connection.get("/api/channels/#{uri_encode(name)}")) end |
#clear_parameters_of(component, vhost, name) ⇒ Object
294 295 296 |
# File 'lib/rabbitmq/http/client.rb', line 294 def clear_parameters_of(component, vhost, name) decode_resource(@connection.delete("/api/parameters/#{uri_encode(component)}/#{uri_encode(vhost)}/#{uri_encode(name)}")) end |
#clear_permissions_of(vhost, user) ⇒ Object
197 198 199 |
# File 'lib/rabbitmq/http/client.rb', line 197 def (vhost, user) decode_resource(@connection.delete("/api/permissions/#{uri_encode(vhost)}/#{uri_encode(user)}")) end |
#clear_policies_of(vhost, name) ⇒ Object
261 262 263 |
# File 'lib/rabbitmq/http/client.rb', line 261 def clear_policies_of(vhost, name) decode_resource(@connection.delete("/api/policies/#{uri_encode(vhost)}/#{uri_encode(name)}")) end |
#close_connection(name) ⇒ Object
60 61 62 |
# File 'lib/rabbitmq/http/client.rb', line 60 def close_connection(name) decode_resource(@connection.delete("/api/connections/#{uri_encode(name)}")) end |
#connection_info(name) ⇒ Object
56 57 58 |
# File 'lib/rabbitmq/http/client.rb', line 56 def connection_info(name) decode_resource(@connection.get("/api/connections/#{uri_encode(name)}")) end |
#create_vhost(name) ⇒ Object
162 163 164 165 166 167 |
# File 'lib/rabbitmq/http/client.rb', line 162 def create_vhost(name) response = @connection.put("/api/vhosts/#{uri_encode(name)}") do |req| req.headers['Content-Type'] = "application/json" end decode_resource(response) end |
#declare_queue(vhost, name, attributes) ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/rabbitmq/http/client.rb', line 108 def declare_queue(vhost, name, attributes) response = @connection.put("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump(attributes) end decode_resource(response) end |
#delete_queue(vhost, name) ⇒ Object
116 117 118 |
# File 'lib/rabbitmq/http/client.rb', line 116 def delete_queue(vhost, name) decode_resource(@connection.delete("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}")) end |
#delete_user(name) ⇒ Object
220 221 222 |
# File 'lib/rabbitmq/http/client.rb', line 220 def delete_user(name) decode_resource(@connection.delete("/api/users/#{uri_encode(name)}")) end |
#delete_vhost(name) ⇒ Object
169 170 171 |
# File 'lib/rabbitmq/http/client.rb', line 169 def delete_vhost(name) decode_resource(@connection.delete("/api/vhosts/#{uri_encode(name)}")) end |
#exchange_info(vhost, name) ⇒ Object
82 83 84 |
# File 'lib/rabbitmq/http/client.rb', line 82 def exchange_info(vhost, name) decode_resource(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(name)}")) end |
#get_messages(vhost, name, options) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/rabbitmq/http/client.rb', line 128 def (vhost, name, ) response = @connection.post("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}/get") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump() end decode_resource_collection(response) end |
#list_bindings(vhost = nil) ⇒ Object
137 138 139 140 141 142 143 144 145 |
# File 'lib/rabbitmq/http/client.rb', line 137 def list_bindings(vhost = nil) path = if vhost.nil? "/api/bindings" else "/api/bindings/#{uri_encode(vhost)}" end decode_resource_collection(@connection.get(path)) end |
#list_bindings_between_queue_and_exchange(vhost, queue, exchange) ⇒ Object
147 148 149 |
# File 'lib/rabbitmq/http/client.rb', line 147 def list_bindings_between_queue_and_exchange(vhost, queue, exchange) decode_resource_collection(@connection.get("/api/bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}")) end |
#list_bindings_by_destination(vhost, exchange) ⇒ Object
90 91 92 |
# File 'lib/rabbitmq/http/client.rb', line 90 def list_bindings_by_destination(vhost, exchange) decode_resource_collection(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(exchange)}/bindings/destination")) end |
#list_bindings_by_source(vhost, exchange) ⇒ Object
86 87 88 |
# File 'lib/rabbitmq/http/client.rb', line 86 def list_bindings_by_source(vhost, exchange) decode_resource_collection(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(exchange)}/bindings/source")) end |
#list_channels ⇒ Object
64 65 66 |
# File 'lib/rabbitmq/http/client.rb', line 64 def list_channels decode_resource_collection(@connection.get("/api/channels")) end |
#list_connections ⇒ Object
52 53 54 |
# File 'lib/rabbitmq/http/client.rb', line 52 def list_connections decode_resource_collection(@connection.get("/api/connections")) end |
#list_definitions ⇒ Object
44 45 46 |
# File 'lib/rabbitmq/http/client.rb', line 44 def list_definitions decode_resource(@connection.get("/api/definitions")) end |
#list_exchanges(vhost = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/rabbitmq/http/client.rb', line 72 def list_exchanges(vhost = nil) path = if vhost.nil? "/api/exchanges" else "/api/exchanges/#{uri_encode(vhost)}" end decode_resource_collection(@connection.get(path)) end |
#list_extensions ⇒ Object
40 41 42 |
# File 'lib/rabbitmq/http/client.rb', line 40 def list_extensions decode_resource_collection(@connection.get("/api/extensions")) end |
#list_nodes ⇒ Object
32 33 34 |
# File 'lib/rabbitmq/http/client.rb', line 32 def list_nodes decode_resource_collection(@connection.get("/api/nodes")) end |
#list_parameters(component = nil) ⇒ Object
268 269 270 271 272 273 274 275 |
# File 'lib/rabbitmq/http/client.rb', line 268 def list_parameters(component = nil) path = if component "/api/parameters/#{uri_encode(component)}" else "/api/parameters" end decode_resource_collection(@connection.get(path)) end |
#list_parameters_of(component, vhost, name = nil) ⇒ Object
277 278 279 280 281 282 283 284 |
# File 'lib/rabbitmq/http/client.rb', line 277 def list_parameters_of(component, vhost, name = nil) path = if name "/api/parameters/#{uri_encode(component)}/#{uri_encode(vhost)}/#{uri_encode(name)}" else "/api/parameters/#{uri_encode(component)}/#{uri_encode(vhost)}" end decode_resource_collection(@connection.get(path)) end |
#list_permissions(vhost = nil) ⇒ Object
175 176 177 178 179 180 181 182 183 |
# File 'lib/rabbitmq/http/client.rb', line 175 def (vhost = nil) path = if vhost "/api/vhosts/#{uri_encode(vhost)}/permissions" else "/api/permissions" end decode_resource_collection(@connection.get(path)) end |
#list_permissions_of(vhost, user) ⇒ Object
185 186 187 |
# File 'lib/rabbitmq/http/client.rb', line 185 def (vhost, user) decode_resource(@connection.get("/api/permissions/#{uri_encode(vhost)}/#{uri_encode(user)}")) end |
#list_policies(vhost = nil) ⇒ Object
234 235 236 237 238 239 240 241 242 |
# File 'lib/rabbitmq/http/client.rb', line 234 def list_policies(vhost = nil) path = if vhost "/api/policies/#{uri_encode(vhost)}" else "/api/policies" end decode_resource_collection(@connection.get(path)) end |
#list_policies_of(vhost, name = nil) ⇒ Object
244 245 246 247 248 249 250 251 |
# File 'lib/rabbitmq/http/client.rb', line 244 def list_policies_of(vhost, name = nil) path = if name "/api/policies/#{uri_encode(vhost)}/#{uri_encode(name)}" else "/api/policies/#{uri_encode(vhost)}" end decode_resource_collection(@connection.get(path)) end |
#list_queue_bindings(vhost, queue) ⇒ Object
120 121 122 |
# File 'lib/rabbitmq/http/client.rb', line 120 def list_queue_bindings(vhost, queue) decode_resource_collection(@connection.get("/api/queues/#{uri_encode(vhost)}/#{uri_encode(queue)}/bindings")) end |
#list_queues(vhost = nil) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/rabbitmq/http/client.rb', line 94 def list_queues(vhost = nil) path = if vhost.nil? "/api/queues" else "/api/queues/#{uri_encode(vhost)}" end decode_resource_collection(@connection.get(path)) end |
#list_users ⇒ Object
203 204 205 |
# File 'lib/rabbitmq/http/client.rb', line 203 def list_users decode_resource_collection(@connection.get("/api/users")) end |
#list_vhosts ⇒ Object
154 155 156 |
# File 'lib/rabbitmq/http/client.rb', line 154 def list_vhosts decode_resource_collection(@connection.get("/api/vhosts")) end |
#node_info(name) ⇒ Object
36 37 38 |
# File 'lib/rabbitmq/http/client.rb', line 36 def node_info(name) decode_resource(@connection.get("/api/nodes/#{uri_encode(name)}")) end |
#overview ⇒ Object
28 29 30 |
# File 'lib/rabbitmq/http/client.rb', line 28 def overview decode_resource(@connection.get("/api/overview")) end |
#purge_queue(vhost, name) ⇒ Object
124 125 126 |
# File 'lib/rabbitmq/http/client.rb', line 124 def purge_queue(vhost, name) decode_resource(@connection.delete("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}/contents")) end |
#queue_info(vhost, name) ⇒ Object
104 105 106 |
# File 'lib/rabbitmq/http/client.rb', line 104 def queue_info(vhost, name) decode_resource(@connection.get("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}")) end |
#update_parameters_of(component, vhost, name, attributes) ⇒ Object
286 287 288 289 290 291 292 |
# File 'lib/rabbitmq/http/client.rb', line 286 def update_parameters_of(component, vhost, name, attributes) response = @connection.put("/api/parameters/#{uri_encode(component)}/#{uri_encode(vhost)}/#{uri_encode(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
189 190 191 192 193 194 195 |
# File 'lib/rabbitmq/http/client.rb', line 189 def (vhost, user, attributes) response = @connection.put("/api/permissions/#{uri_encode(vhost)}/#{uri_encode(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
253 254 255 256 257 258 259 |
# File 'lib/rabbitmq/http/client.rb', line 253 def update_policies_of(vhost, name, attributes) response = @connection.put("/api/policies/#{uri_encode(vhost)}/#{uri_encode(name)}") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump(attributes) end decode_resource(response) end |
#update_user(name, attributes) ⇒ Object Also known as: create_user
211 212 213 214 215 216 217 |
# File 'lib/rabbitmq/http/client.rb', line 211 def update_user(name, attributes) response = @connection.put("/api/users/#{uri_encode(name)}") do |req| req.headers['Content-Type'] = "application/json" req.body = MultiJson.dump(attributes) end decode_resource(response) end |
#upload_definitions(defs) ⇒ Object
48 49 50 |
# File 'lib/rabbitmq/http/client.rb', line 48 def upload_definitions(defs) raise NotImplementedError.new end |
#user_info(name) ⇒ Object
207 208 209 |
# File 'lib/rabbitmq/http/client.rb', line 207 def user_info(name) decode_resource(@connection.get("/api/users/#{uri_encode(name)}")) end |
#user_permissions(name) ⇒ Object
224 225 226 |
# File 'lib/rabbitmq/http/client.rb', line 224 def (name) decode_resource_collection(@connection.get("/api/users/#{uri_encode(name)}/permissions")) end |
#vhost_info(name) ⇒ Object
158 159 160 |
# File 'lib/rabbitmq/http/client.rb', line 158 def vhost_info(name) decode_resource(@connection.get("/api/vhosts/#{uri_encode(name)}")) end |
#whoami ⇒ Object
228 229 230 |
# File 'lib/rabbitmq/http/client.rb', line 228 def whoami decode_resource(@connection.get("/api/whoami")) end |