
com.indeed.rabbitmq.admin.RabbitManagementApi Maven / Gradle / Ivy
package com.indeed.rabbitmq.admin;
import com.indeed.rabbitmq.admin.pojo.Bind;
import com.indeed.rabbitmq.admin.pojo.Binding;
import com.indeed.rabbitmq.admin.pojo.Channel;
import com.indeed.rabbitmq.admin.pojo.ClusterName;
import com.indeed.rabbitmq.admin.pojo.Connection;
import com.indeed.rabbitmq.admin.pojo.Consumer;
import com.indeed.rabbitmq.admin.pojo.Exchange;
import com.indeed.rabbitmq.admin.pojo.Extension;
import com.indeed.rabbitmq.admin.pojo.Node;
import com.indeed.rabbitmq.admin.pojo.OperatorPolicy;
import com.indeed.rabbitmq.admin.pojo.Overview;
import com.indeed.rabbitmq.admin.pojo.Parameter;
import com.indeed.rabbitmq.admin.pojo.Permission;
import com.indeed.rabbitmq.admin.pojo.Policy;
import com.indeed.rabbitmq.admin.pojo.Queue;
import com.indeed.rabbitmq.admin.pojo.Shovel;
import com.indeed.rabbitmq.admin.pojo.Status;
import com.indeed.rabbitmq.admin.pojo.User;
import com.indeed.rabbitmq.admin.pojo.VirtualHost;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import java.util.List;
/**
* RabbitMQ server 3.6.1 has a total of 74 APIs, not all of which are
* implemented here. Missing APIs include:
*
* - {@code Definitions getDefinitions()}
* - {@code Definitions getDefinitions(String vhost)}
* - {@code Call
setDefinitions(Definitions definitions)}
* - {@code Call
setDefinitions(String vhost, Definitions definitions)}
* - {@code Call
publishMessage(String vhost, String exchange, Message message)}
* - {@code Call
setAction(String vhost, String queue, Action action}
* - {@code Message getMessage(String vhost, String queue}
*
*
* @author Kevin Sitze ([email protected])
*/
public interface RabbitManagementApi {
/**
* Returns an {@code Overview} of the RabbitMQ service.
* @return an {@link Overview} instance.
*/
@GET("api/overview")
Call getOverview();
/**
* Returns the {@code "ok"} status if the indicated virtual host is alive.
* @param vhost the name of the virtual host.
* @return the {@link Status} of the indicated virtual host.
*/
@GET("api/aliveness-test/{vhost}")
Call getAliveness(@Path("vhost") String vhost);
// Cluster
/**
* Returns the name of the cluster.
* @return the cluster name.
*/
@GET("api/cluster-name")
Call getClusterName();
/**
* Sets the name of the cluster.
* @param name the cluster name.
* @return the HTTP ResponseBody.
*/
@PUT("api/cluster-name")
Call setClusterName(@Body ClusterName name);
// Bindings
/**
* Returns all exchange-to-exchange and exchange-to-queue bindings.
* @return a list of all bindings on the RabbitMQ service.
*/
@GET("api/bindings")
Call> listBindings();
/**
* Returns all exchange-to-exchange and exchange-to-queue bindings in the
* specified virtual host.
* @param vhost the RabbitMQ virtual host.
* @return all bindings in the indicated virtual host.
*/
@GET("api/bindings/{vhost}")
Call> listBindings(@Path("vhost") String vhost);
/**
* Returns all bindings whose source is the indicated exchange.
* @param vhost the RabbitMQ virtual host.
* @param exchange the source exchange.
* @return all bindings whose source is the indicated exchange.
*/
@GET("api/exchanges/{vhost}/{exchange}/bindings/source")
Call> listBindingsFromExchange(@Path("vhost") String vhost, @Path("exchange") String exchange);
/**
* Returns all bindings whose target is the indicated exchange.
*
* @param vhost a RabbitMQ virtual host.
* @param exchange the target exchange.
* @return all bindings whose target is the indicated exchange.
*/
@GET("api/exchanges/{vhost}/{exchange}/bindings/destination")
Call> listBindingsToExchange(@Path("vhost") String vhost, @Path("exchange") String exchange);
/**
* Returns all bindings whose target is the indicated queue.
*
* @param vhost a RabbitMQ virtual host.
* @param queue the target queue.
* @return all bindings whose target is the indicated queue.
*/
@GET("api/queues/{vhost}/{queue}/bindings")
Call> listBindingsToQueue(@Path("vhost") String vhost, @Path("queue") String queue);
/**
* Returns all bindings whose source is the indicated exchange and whose
* target is the indicated queue.
*
* @param vhost a RabbitMQ virtual host.
* @param exchange the source exchange.
* @param queue the target queue.
* @return all bindings from {@code exchange} to {@code queue}.
*/
@GET("api/bindings/{vhost}/e/{exchange}/q/{queue}")
Call> listExchangeToQueueBindings(@Path("vhost") String vhost, @Path("exchange") String exchange, @Path("queue") String queue);
/**
* Create a new exchange-to-queue binding.
*
* @param vhost the virtual host containing the exchange and queue to bind.
* @param exchange the name of the source exchange.
* @param queue the name of the target queue.
* @param bind the binding key and any binding arguments.
* @return an HTTP ResponseBody.
*/
@POST("api/bindings/{vhost}/e/{exchange}/q/{queue}")
Call bindExchangeToQueue(@Path("vhost") String vhost, @Path("exchange") String exchange, @Path("queue") String queue, @Body Bind bind);
/**
* Returns the {@code Binding} metadata for the exchange-to-queue binding
* from {@code exchange} to {@code queue}.
*
* @param vhost a RabbitMQ virtual host.
* @param exchange the name of the source exchange.
* @param queue the name of the target queue.
* @param bindingKey the unique binding key.
* @return the exchange-to-queue binding metadata.
*/
@GET("api/bindings/{vhost}/e/{exchange}/q/{queue}/{props}")
Call getExchangeToQueueBinding(@Path("vhost") String vhost, @Path("exchange") String exchange, @Path("queue") String queue, @Path("props") String bindingKey);
/**
* Destroys the exchange-to-queue binding from {@code exchange} to
* {@code queue} whose binding key is {@code bindingKey}.
*
* @param vhost a RabbitMQ virtual host.
* @param exchange the name of the source exchange.
* @param queue the name of the target queue.
* @param bindingKey the unique binding key.
* @return an HTTP ResponseBody.
*/
@DELETE("api/bindings/{vhost}/e/{exchange}/q/{queue}/{props}")
Call deleteExchangeToQueueBinding(@Path("vhost") String vhost, @Path("exchange") String exchange, @Path("queue") String queue, @Path("props") String bindingKey);
/**
* Returns all bindings whose source is the indicated exchange and whose
* target is the indicated exchange.
*
* @param vhost a RabbitMQ virtual host.
* @param source the source exchange.
* @param destination the target exchange.
* @return all bindings from {@code source} to {@code destination}.
*/
@GET("api/bindings/{vhost}/e/{source}/e/{destination}")
Call> listExchangeToExchangeBindings(@Path("vhost") String vhost, @Path("source") String source, @Path("destination") String destination);
/**
* Create a new exchange-to-exchange binding.
*
* @param vhost a RabbitMQ virtual host.
* @param source the source exchange.
* @param destination the target exchange.
* @param bind the binding key and any binding arguments.
* @return an HTTP ResponseBody.
*/
@POST("api/bindings/{vhost}/e/{source}/e/{destination}")
Call bindExchangeToExchange(@Path("vhost") String vhost, @Path("source") String source, @Path("destination") String destination, @Body Bind bind);
/**
* Returns the exchange-to-exchange binding metadata from {@code source}
* exchange to {@code destination} exchange whose binding key is
* {@code bindingKey}.
*
* @param vhost a RabbitMQ virtual host.
* @param source the source exchange.
* @param destination the target exchange.
* @param bindingKey the unique binding key.
* @return the exchange-to-exchange binding metadata.
*/
@GET("api/bindings/{vhost}/e/{source}/e/{destination}/{props}")
Call getExchangeToExchangeBinding(@Path("vhost") String vhost, @Path("source") String source, @Path("destination") String destination, @Path("props") String bindingKey);
/**
* Destroys the exchange-to-exchange binding from {@code source} to
* {@code destination} whose binding key is {@code bindingKey}.
*
* @param vhost a RabbitMQ virtual host.
* @param source the name of the source exchange.
* @param destination the name of the target exchange.
* @param bindingKey the unique binding key.
* @return an HTTP ResponseBody.
*/
@DELETE("api/bindings/{vhost}/e/{source}/e/{destination}/{props}")
Call deleteExchangeToExchangeBinding(@Path("vhost") String vhost, @Path("source") String source, @Path("destination") String destination, @Path("props") String bindingKey);
// Channels
/**
* Returns a list of all open channels on the RabbitMQ service.
* @return a list of open channels.
*/
@GET("api/channels")
Call> listChannels();
/**
* Returns a list of all open channels in the specified virtual host.
* @param vhost a RabbitMQ virtual host.
* @return a list of open channels in the specified virtual host.
*/
@GET("api/vhosts/{vhost}/channels")
Call> listChannels(@Path("vhost") String vhost);
/**
* Returns a list of all channels on the named connection.
* @param name the name of a RabbitMQ connection.
* @return the list of open channels on the named connection.
*/
@GET("api/connections/{name}/channels")
Call> listConnectionChannels(@Path("name") String name);
/**
* Returns the named channel.
* @param name the name of a channel.
* @return the metadata for the indicated channel.
*/
@GET("api/channels/{name}")
Call getChannel(@Path("name") String name);
// Connections
/**
* Returns a list of all current RabbitMQ client connections.
* @return a list of RabbitMQ client connections.
*/
@GET("api/connections")
Call> listConnections();
/**
* Returns a list of all connections to the specified virtual host.
* @param vhost a RabbitMQ virtual host.
* @return a list of connections to the specified virtual host.
*/
@GET("api/vhosts/{vhost}/connections")
Call> listConnections(@Path("vhost") String vhost);
/**
* Returns the metadata for the named connection.
* @param name the connection name.
* @return the connection metadata.
*/
@GET("api/connections/{name}")
Call getConnection(@Path("name") String name);
/**
* Destroys the named connection.
* @param name a connection name.
* @return an HTTP ResponseBody.
*/
@DELETE("api/connections/{name}")
Call deleteConnection(@Path("name") String name);
// Consumers
/**
* Returns a list of all consumers in the RabbitMQ service.
* @return a list of all consumers in the RabbitMQ service.
*/
@GET("api/consumers")
Call> listConsumers();
/**
* Returns a list of all consumers in the indicated virtual host.
* @param vhost a RabbitMQ virtual host.
* @return a list of all consumers in the virtual host.
*/
@GET("api/consumers/{vhost}")
Call> listConsumers(@Path("vhost") String vhost);
// Server Definitions
// @GET("api/definitions")
// Call getDefinitions();
// @POST("api/definitions")
// Call setDefinitions(@Body Definitions definitions);
// @GET("api/definitions/{vhost}")
// Call getDefinitions(@Path("vhost") String vhost);
// @POST("api/definitions/{vhost}")
// Call setDefinitions(@Path("vhost") String vhost, @Body Definitions definitions);
// Exchanges
/**
* Returns a list of all exchanges on the RabbitMQ service.
* @return a list of all exchanges
*/
@GET("api/exchanges")
Call> listExchanges();
/**
* Returns a list of all exchanges in the indicated virtual host.
* @return a list of all exchanges in the indicated virtual host.
*/
@GET("api/exchanges/{vhost}")
Call> listExchanges(@Path("vhost") String vhost);
/**
* Returns the named exchange in the specified virtual host.
* @param vhost a RabbitMQ virtual host.
* @param name the name of an exchange.
* @return the exchange metadata.
*/
@GET("api/exchanges/{vhost}/{name}")
Call getExchange(@Path("vhost") String vhost, @Path("name") String name);
/**
* Creates a new exchange in the specified virtual host.
* @param vhost a RabbitMQ virtual host.
* @param name the name of the exchange to create.
* @param exchange the exchange metadata.
* @return an HTTP ResponseBody.
*/
@PUT("api/exchanges/{vhost}/{name}")
Call createExchange(@Path("vhost") String vhost, @Path("name") String name, @Body Exchange exchange);
/**
* Deletes an exchange in the specified virtual host.
* @param vhost a RabbitMQ virtual host.
* @param name the name of the exchange to destroy.
* @return an HTTP ResponseBody.
*/
@DELETE("api/exchanges/{vhost}/{name}")
Call deleteExchange(@Path("vhost") String vhost, @Path("name") String name);
// Extensions
/**
* Returns the list of all extensions installed in the RabbitMQ service.
* @return the list of all installed extensions.
*/
@GET("api/extensions")
Call> listExtensions();
// Nodes
/**
* Returns all nodes in the RabbitMQ cluster.
* @return all RabbitMQ cluster nodes.
*/
@GET("api/nodes")
Call> listNodes();
/**
* Returns the metadata for the named RabbitMQ node.
* @param name the name of a RabbitMQ node.
* @return the node metadata.
*/
@GET("api/nodes/{name}")
Call getNode(@Path("name") String name);
// Parameters
/**
* Returns a list of all parameters defined in the RabbitMQ service.
* @return a list of all defined parameters.
*/
@GET("api/parameters")
Call> listParameters();
/**
* Returns a list of all parameters defined on the indicated component.
* @param component the name of a RabbitMQ component.
* @return a list of all parameters defined on the indicated component.
*/
@GET("api/parameters/{component}")
Call> listParameters(@Path("component") String component);
/**
* List all parameters for the indicated component in the specified virtual
* host.
*
* @param vhost a RabbitMQ virtual host.
* @param component the name of a RabbitMQ component.
* @return a list of all parameters defined on the indicated component
* within the specified virtual host.
*/
@GET("api/parameters/{component}/{vhost}")
Call> listParameters(@Path("vhost") String vhost, @Path("component") String component);
/**
* Returns the parameter by name.
*
* @param vhost a RabbitMQ virtual host.
* @param component the name of a RabbitMQ component.
* @param name the parameter name.
* @return the parameter.
*/
@GET("api/parameters/{component}/{vhost}/{name}")
Call getParameter(@Path("vhost") String vhost, @Path("component") String component, @Path("name") String name);
/**
* Create a new parameter for a component in the specified virtual host.
*
* @param vhost a RabbitMQ virtual host.
* @param component the name of a RabbitMQ component.
* @param name the parameter name.
* @param parameter the parameter metadata.
* @return an HTTP ResponseBody.
*/
@PUT("api/parameters/{component}/{vhost}/{name}")
Call createParameter(@Path("vhost") String vhost, @Path("component") String component, @Path("name") String name, @Body Parameter parameter);
/**
* Destroys an existing parameter in the specified virtual host.
*
* @param vhost a RabbitMQ virtual host.
* @param component the name of a RabbitMQ component.
* @param name the name of the parameter to destroy.
* @return an HTTP ResponseBody.
*/
@DELETE("api/parameters/{component}/{vhost}/{name}")
Call deleteParameter(@Path("vhost") String vhost, @Path("component") String component, @Path("name") String name);
// Permissions
/**
* Returns all permissions defined on the RabbitMQ service.
* @return all permissions.
*/
@GET("api/permissions")
Call> listPermissions();
/**
* Returns all permissions defined in the indicated virtual host.
* @param vhost a RabbitMQ virtual host.
* @return the list of permissions found in the indicated virtual host.
*/
@GET("api/vhosts/{vhost}/permissions")
Call> listPermissions(@Path("vhost") String vhost);
/**
* Returns all user authorizations.
* @param user the user name.
* @return all permissions associated with the named user.
*/
@GET("api/users/{user}/permissions")
Call> listUserPermissions(@Path("user") String user);
/**
* Returns all user authorizations.
* @param vhost a RabbitMQ virtual host.
* @param user the user name.
* @return all permissions associated with the named user in {@code vhost}.
*/
@GET("api/permissions/{vhost}/{user}")
Call getPermission(@Path("vhost") String vhost, @Path("user") String user);
/**
* Create a new authorization for a user.
* @param vhost a RabbitMQ virtual host.
* @param user the user name.
* @param permission the permissions allocated to the user.
* @return an HTTP ResponseBody.
*/
@PUT("api/permissions/{vhost}/{user}")
Call createPermission(@Path("vhost") String vhost, @Path("user") String user, @Body Permission permission);
/**
* Destroys an user authorization.
* @param vhost a RabbitMQ virtual host.
* @param user the user name.
* @return an HTTP ResponseBody.
*/
@DELETE("api/permissions/{vhost}/{user}")
Call deletePermission(@Path("vhost") String vhost, @Path("user") String user);
// Policies
/**
* Returns a list of all RabbitMQ policies.
* @return a list of all defined policies.
*/
@GET("api/policies")
Call> listPolicies();
/**
* Returns a list of all policies defined in the specified virtual host.
* @param vhost a RabbitMQ virtual host.
* @return a list of all policies defined.
*/
@GET("api/policies/{vhost}")
Call> listPolicies(@Path("vhost") String vhost);
/**
* Returns a policy by name.
*
* @param vhost a RabbitMQ virtual host.
* @param name the name of the policy to retrieve.
* @return the policy metadata.
*/
@GET("api/policies/{vhost}/{name}")
Call getPolicy(@Path("vhost") String vhost, @Path("name") String name);
/**
* Creates a new policy.
*
* @param vhost a RabbitMQ virtual host.
* @param name the policy name.
* @param policy the policy details
* @return an HTTP ResponseBody.
*/
@PUT("api/policies/{vhost}/{name}")
Call createPolicy(@Path("vhost") String vhost, @Path("name") String name, @Body Policy policy);
/**
* Destroys an existing policy.
*
* @param vhost a RabbitMQ virtual host.
* @param name the policy name.
* @return an HTTP ResponseBody.
*/
@DELETE("api/policies/{vhost}/{name}")
Call deletePolicy(@Path("vhost") String vhost, @Path("name") String name);
// Operator Policies
/**
* Returns a list of all RabbitMQ operator policies.
* @return a list of all defined operator policies.
*/
@GET("api/operator-policies")
Call> listOperatorPolicies();
/**
* Returns a list of all operator policies defined in the specified virtual host.
* @param vhost a RabbitMQ virtual host.
* @return a list of all operator policies defined.
*/
@GET("api/operator-policies/{vhost}")
Call> listOperatorPolicies(@Path("vhost") String vhost);
/**
* Returns a operator policy by name.
*
* @param vhost a RabbitMQ virtual host.
* @param name the name of the operator policy to retrieve.
* @return the operator policy metadata.
*/
@GET("api/operator-policies/{vhost}/{name}")
Call getOperatorPolicy(@Path("vhost") String vhost, @Path("name") String name);
/**
* Creates a new operator policy.
*
* @param vhost a RabbitMQ virtual host.
* @param name the operator policy name.
* @param policy the operator policy details
* @return an HTTP ResponseBody.
*/
@PUT("api/operator-policies/{vhost}/{name}")
@Headers("Content-Type: application/json")
Call createOperatorPolicy(@Path("vhost") String vhost, @Path("name") String name, @Body OperatorPolicy policy);
/**
* Destroys an existing operator policy.
*
* @param vhost a RabbitMQ virtual host.
* @param name the operator policy name.
* @return an HTTP ResponseBody.
*/
@DELETE("api/operator-policies/{vhost}/{name}")
Call deleteOperatorPolicy(@Path("vhost") String vhost, @Path("name") String name);
// Queues
/**
* Returns a list of all queues declared in the RabbitMQ service.
* @return a list of all declared queues.
*/
@GET("api/queues")
Call> listQueues();
/**
* Returns a list of all queues declared in the specified virtual host.
* @param vhost a RabbitMQ virtual host.
* @return a list of all queues declared in the virtual host.
*/
@GET("api/queues/{vhost}")
Call> listQueues(@Path("vhost") String vhost);
/**
* Returns the metadata for the named queue.
*
* @param vhost a RabbitMQ virtual host.
* @param name the queue name.
* @return the queue metadata.
*/
@GET("api/queues/{vhost}/{name}")
Call getQueue(@Path("vhost") String vhost, @Path("name") String name);
/**
* Create a new queue in the specified virtual host.
* @param vhost a RabbitMQ virtual host.
* @param name the queue name.
* @param queue the queue metadata.
* @return an HTTP ResponseBody.
*/
@PUT("api/queues/{vhost}/{name}")
Call createQueue(@Path("vhost") String vhost, @Path("name") String name, @Body Queue queue);
/**
* Destroys a queue in the specified virtual host.
* @param vhost a RabbitMQ virtual host.
* @param name the name of the queue to remove.
* @return an HTTP ResponseBody.
*/
@DELETE("api/queues/{vhost}/{name}")
Call deleteQueue(@Path("vhost") String vhost, @Path("name") String name);
/**
* Destroys all messages in a queue.
* @param vhost a RabbitMQ virtual host.
* @param name the name of the queue to purge.
* @return an HTTP ResponseBody.
*/
@DELETE("api/queues/{vhost}/{name}/contents")
Call purgeQueue(@Path("vhost") String vhost, @Path("name") String name);
// Users
/**
* Returns information on all users on the RabbitMQ service.
* @return a list of RabbitMQ users.
*/
@GET("api/users")
Call> listUsers();
/**
* Returns the user metadata for the named user.
* @param name the user name.
* @return the user metadata.
*/
@GET("api/users/{user}")
Call getUser(@Path("user") String name);
/**
* Define a new user on the current RabbitMQ cluster.
* @param name the user name.
* @param user the user metadata.
* @return an HTTP ResponseBody.
*/
@PUT("api/users/{user}")
Call createUser(@Path("user") String name, @Body User user);
/**
* Deletes the named user from the current RabbitMQ server.
* @param name the user name.
* @return an HTTP ResponseBody.
*/
@DELETE("api/users/{user}")
Call deleteUser(@Path("user") String name);
/**
* Returns the name of the authenticated user.
* @return the authenticated user name.
*/
@GET("api/whoami")
Call whoami();
// Virtual Hosts
/**
* Returns a list of all virtual hosts on the RabbitMQ service.
* @return a list of virtual hosts.
*/
@GET("api/vhosts")
Call> listVirtualHosts();
/**
* Returns metadata on the indicated virtual host.
* @param vhost a virtual host.
* @return details on the virtual host.
*/
@GET("api/vhosts/{vhost}")
Call getVirtualHost(@Path("vhost") String vhost);
/**
* Create a new virtual host.
* @param vhost the virtual host.
* @return an HTTP ResponseBody.
*/
@PUT("api/vhosts/{vhost}")
@Headers("Content-Type: application/json")
Call createVirtualHost(@Path("vhost") String vhost);
/**
* Delete an existing virtual host.
* @param vhost the virtual host to remove.
* @return an HTTP ResponseBody.
*/
@DELETE("api/vhosts/{vhost}")
Call deleteVirtualHost(@Path("vhost") String vhost);
// Shovels
/**
* Returns a list of all shovels defined in the RabbitMQ service.
* @return a list of all defined shovels.
*/
@GET("api/parameters/shovel")
Call> listShovels();
/**
* List all shovels in the specified virtual host.
*
* @param vhost a RabbitMQ virtual host.
* @return a list of all shovels defined on the specified virtual host.
*/
@GET("api/parameters/shovel/{vhost}")
Call> listShovels(@Path("vhost") String vhost);
/**
* Returns a shovel by name.
*
* @param vhost a RabbitMQ virtual host.
* @param name the shovel name.
* @return the shovel.
*/
@GET("api/parameters/shovel/{vhost}/{name}")
Call getShovel(@Path("vhost") String vhost, @Path("name") String name);
/**
* Create a new shovel in the specified virtual host.
*
* @param vhost a RabbitMQ virtual host.
* @param name the shovel name.
* @param shovel the shovel metadata.
* @return an HTTP ResponseBody.
*/
@PUT("api/parameters/shovel/{vhost}/{name}")
Call createShovel(@Path("vhost") String vhost, @Path("name") String name, @Body Shovel shovel);
/**
* Destroys a shovel in the specified virtual host.
*
* @param vhost a RabbitMQ virtual host.
* @param name the name of the shovel to destroy.
* @return an HTTP ResponseBody.
*/
@DELETE("api/parameters/shovel/{vhost}/{name}")
Call deleteShovel(@Path("vhost") String vhost, @Path("name") String name);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy