Skip to content

intility/ex_rabbitmq_admin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elixir CI License: MIT Hex version badge Hexdocs badge

ExRabbitMQAdmin

Simple client library for the RabbitMQ HTTP API, built on Tesla.

Read the full documentation here.

Supported functionality

  • 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

Installation

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

Example usage

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

Contribution

The RabbitMQ HTTP API documentation is available here.

Running the test suite

$ mix coveralls.html

About

Tesla based client for RabbitMQ HTTP API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages