Class: RabbitMQManager

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbitmq_manager.rb,
lib/rabbitmq_manager/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ RabbitMQManager

Returns a new instance of RabbitMQManager.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rabbitmq_manager.rb', line 7

def initialize(url)
  headers = { 
    'accept' => 'application/json',
    'Content-Type' => 'application/json'
  }
  @conn = Faraday.new(:url => url, :headers => headers) do |builder|
    builder.use Faraday::Response::RaiseError
    builder.use FaradayMiddleware::EncodeJson
    builder.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
    builder.adapter Faraday.default_adapter
  end
end

Instance Method Details

#node(name) ⇒ Object



28
29
30
# File 'lib/rabbitmq_manager.rb', line 28

def node(name)
  @conn.get("/api/nodes/#{URI.escape name}").body
end

#nodesObject



24
25
26
# File 'lib/rabbitmq_manager.rb', line 24

def nodes
  @conn.get('/api/nodes').body
end

#overviewObject



20
21
22
# File 'lib/rabbitmq_manager.rb', line 20

def overview
  @conn.get('/api/overview').body
end

#user(name) ⇒ Object



52
53
54
# File 'lib/rabbitmq_manager.rb', line 52

def user(name)
  @conn.get("/api/users/#{URI.escape name}").body
end

#user_create(name, password, tags = '') ⇒ Object



56
57
58
59
60
61
# File 'lib/rabbitmq_manager.rb', line 56

def user_create(name, password, tags = '')
  @conn.put("/api/users/#{URI.escape name}", {
    :password => password, 
    :tags => tags 
  }).body
end

#user_delete(name) ⇒ Object



63
64
65
# File 'lib/rabbitmq_manager.rb', line 63

def user_delete(name)
  @conn.delete("/api/users/#{URI.escape name}").body
end

#user_permissions(name) ⇒ Object



75
76
77
# File 'lib/rabbitmq_manager.rb', line 75

def user_permissions(name)
  @conn.get("/api/users/#{URI.escape name}/permissions").body
end

#user_set_permissions(name, vhost, configure, write, read) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/rabbitmq_manager.rb', line 67

def user_set_permissions(name, vhost, configure, write, read)
  @conn.put("/api/permissions/#{URI.escape vhost}/#{URI.escape name}", {
    :configure => configure,
    :write => write, 
    :read => read
  }).body
end

#usersObject



48
49
50
# File 'lib/rabbitmq_manager.rb', line 48

def users
  @conn.get('/api/users').body
end

#vhost(name) ⇒ Object



36
37
38
# File 'lib/rabbitmq_manager.rb', line 36

def vhost(name)
  @conn.get("/api/vhosts/#{URI.escape name}").body
end

#vhost_create(name) ⇒ Object



40
41
42
# File 'lib/rabbitmq_manager.rb', line 40

def vhost_create(name)
  @conn.put("/api/vhosts/#{URI.escape name}").body
end

#vhost_delete(name) ⇒ Object



44
45
46
# File 'lib/rabbitmq_manager.rb', line 44

def vhost_delete(name)
  @conn.delete("/api/vhosts/#{URI.escape name}").body
end

#vhostsObject



32
33
34
# File 'lib/rabbitmq_manager.rb', line 32

def vhosts
  @conn.get('/api/vhosts').body
end