Class: Veterinarian::Client
- Inherits:
-
Object
- Object
- Veterinarian::Client
- Defined in:
- lib/veterinarian/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #aliveness_test(vhost) ⇒ Object
- #channel_info(name) ⇒ Object
- #close_connection(name) ⇒ Object
- #connection_info(name) ⇒ Object
- #declare_queue(vhost, name, attributes) ⇒ Object
- #delete_queue(vhost, name) ⇒ Object
- #exchange_info(vhost, name) ⇒ Object
-
#initialize(endpoint, options = {}) ⇒ Client
constructor
A new instance of Client.
- #list_bindings(vhost = nil) ⇒ 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 ⇒ Object
- #list_policies ⇒ 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
- #upload_definitions(defs) ⇒ Object
- #vhost_info(name) ⇒ Object
Constructor Details
#initialize(endpoint, options = {}) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 |
# File 'lib/veterinarian/client.rb', line 20 def initialize(endpoint, = {}) @endpoint = endpoint @options = initialize_connection(endpoint, ) end |
Class Method Details
.connect(endpoint, options = {}) ⇒ Object
API
16 17 18 |
# File 'lib/veterinarian/client.rb', line 16 def self.connect(endpoint, = {}) new(endpoint, ) end |
Instance Method Details
#aliveness_test(vhost) ⇒ Object
157 158 159 160 |
# File 'lib/veterinarian/client.rb', line 157 def aliveness_test(vhost) r = @connection.get("/api/aliveness-test/#{uri_encode(vhost)}") r.body["status"] == "ok" end |
#channel_info(name) ⇒ Object
67 68 69 |
# File 'lib/veterinarian/client.rb', line 67 def channel_info(name) decode_resource(@connection.get("/api/channels/#{uri_encode(name)}")) end |
#close_connection(name) ⇒ Object
59 60 61 |
# File 'lib/veterinarian/client.rb', line 59 def close_connection(name) decode_resource(@connection.delete("/api/connections/#{uri_encode(name)}")) end |
#connection_info(name) ⇒ Object
55 56 57 |
# File 'lib/veterinarian/client.rb', line 55 def connection_info(name) decode_resource(@connection.get("/api/connections/#{uri_encode(name)}")) end |
#declare_queue(vhost, name, attributes) ⇒ Object
107 108 109 |
# File 'lib/veterinarian/client.rb', line 107 def declare_queue(vhost, name, attributes) raise NotImplementedError.new end |
#delete_queue(vhost, name) ⇒ Object
111 112 113 |
# File 'lib/veterinarian/client.rb', line 111 def delete_queue(vhost, name) raise NotImplementedError.new end |
#exchange_info(vhost, name) ⇒ Object
81 82 83 |
# File 'lib/veterinarian/client.rb', line 81 def exchange_info(vhost, name) decode_resource(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(name)}")) end |
#list_bindings(vhost = nil) ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'lib/veterinarian/client.rb', line 120 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_by_destination(vhost, exchange) ⇒ Object
89 90 91 |
# File 'lib/veterinarian/client.rb', line 89 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
85 86 87 |
# File 'lib/veterinarian/client.rb', line 85 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
63 64 65 |
# File 'lib/veterinarian/client.rb', line 63 def list_channels decode_resource_collection(@connection.get("/api/channels")) end |
#list_connections ⇒ Object
51 52 53 |
# File 'lib/veterinarian/client.rb', line 51 def list_connections decode_resource_collection(@connection.get("/api/connections")) end |
#list_definitions ⇒ Object
43 44 45 |
# File 'lib/veterinarian/client.rb', line 43 def list_definitions decode_resource_collection(@connection.get("/api/definitions")) end |
#list_exchanges(vhost = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/veterinarian/client.rb', line 71 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
39 40 41 |
# File 'lib/veterinarian/client.rb', line 39 def list_extensions decode_resource_collection(@connection.get("/api/extensions")) end |
#list_nodes ⇒ Object
31 32 33 |
# File 'lib/veterinarian/client.rb', line 31 def list_nodes decode_resource_collection(@connection.get("/api/nodes")) end |
#list_parameters ⇒ Object
151 152 153 |
# File 'lib/veterinarian/client.rb', line 151 def list_parameters decode_resource_collection(@connection.get("/api/parameters")) end |
#list_policies ⇒ Object
146 147 148 |
# File 'lib/veterinarian/client.rb', line 146 def list_policies decode_resource_collection(@connection.get("/api/policies")) end |
#list_queues(vhost = nil) ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/veterinarian/client.rb', line 93 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
140 141 142 |
# File 'lib/veterinarian/client.rb', line 140 def list_users decode_resource_collection(@connection.get("/api/users")) end |
#list_vhosts ⇒ Object
130 131 132 |
# File 'lib/veterinarian/client.rb', line 130 def list_vhosts decode_resource_collection(@connection.get("/api/vhosts")) end |
#node_info(name) ⇒ Object
35 36 37 |
# File 'lib/veterinarian/client.rb', line 35 def node_info(name) decode_resource(@connection.get("/api/nodes/#{uri_encode(name)}")) end |
#overview ⇒ Object
27 28 29 |
# File 'lib/veterinarian/client.rb', line 27 def overview decode_resource(@connection.get("/api/overview")) end |
#purge_queue(vhost, name) ⇒ Object
115 116 117 |
# File 'lib/veterinarian/client.rb', line 115 def purge_queue(vhost, name) raise NotImplementedError.new end |
#queue_info(vhost, name) ⇒ Object
103 104 105 |
# File 'lib/veterinarian/client.rb', line 103 def queue_info(vhost, name) decode_resource(@connection.get("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}")) end |
#upload_definitions(defs) ⇒ Object
47 48 49 |
# File 'lib/veterinarian/client.rb', line 47 def upload_definitions(defs) raise NotImplementedError.new end |
#vhost_info(name) ⇒ Object
134 135 136 |
# File 'lib/veterinarian/client.rb', line 134 def vhost_info(name) decode_resource(@connection.get("/api/vhosts/#{uri_encode(name)}")) end |