Simple client library for the RabbitMQ HTTP API, built on Tesla.
Read the full documentation here.
- Basic information endpoints (listing connections, channels, nodes, and so on)
- Client adapter configuration
- User management endpoints
- Virtual host endpoints
- Queue endpoints
- Exchange endpoints
- Bindings endpoints
- Parameters
- Policies endpoints
- Operator endpoints
- Health check endpoints
This package is available in Hex, and can be installed
by adding ex_rabbitmq_admin
to your list of dependencies in mix.exs
:
def deps do
[
{:ex_rabbitmq_admin, "~> 0.1.0"}
]
end
First step is to set up some basic configuration in your config.exs
file.
# config.exs
config :ex_rabbitmq_admin, ExRabbitMQAdmin,
base_url: "https://rabbitmq.example.com:56721"
Next, you can use the ExRabbitMQAdmin
client from wherever you want.
defmodule RabbitMQControl do
alias ExRabbitMQAdmin
@doc """
Creates a new user on the RabbitMQ cluster.
"""
def create_rabbit_user(username, password) do
{:ok, %Tesla.Env{status: 201}} =
ExRabbitMQAdmin.client()
|> ExRabbitMQAdmin.add_basic_auth_middleware(username: "rabbit-admin", password: "secret-password")
|> ExRabbitMQAdmin.User.put_user(username, password: password, tags: "moderator")
end
# Or maybe you want to list virtual hosts
def virtual_hosts do
{:ok, %Tesla.Env{:status: 200, body: response}} =
ExRabbitMQAdmin.client()
|> ExRabbitMQAdmin.add_basic_auth_middleware(username: "rabbit-admin", password: "secret-password")
|> ExRabbitMQAdmin.Vhost.list_vhosts()
end
end
The RabbitMQ HTTP API documentation is available here.
$ mix coveralls.html