{"id":18103157,"url":"https://github.com/ruby-amqp/rabbitmq_http_api_client","last_synced_at":"2025-04-04T17:07:46.151Z","repository":{"id":5772031,"uuid":"6985606","full_name":"ruby-amqp/rabbitmq_http_api_client","owner":"ruby-amqp","description":"RabbitMQ HTTP API client for Ruby","archived":false,"fork":false,"pushed_at":"2024-01-30T18:36:12.000Z","size":294,"stargazers_count":77,"open_issues_count":3,"forks_count":50,"subscribers_count":9,"default_branch":"main","last_synced_at":"2024-04-26T06:04:43.712Z","etag":null,"topics":["api","http","monitoring","rabbitmq","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ruby-amqp.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-12-03T16:36:39.000Z","updated_at":"2024-06-18T16:42:23.906Z","dependencies_parsed_at":"2024-01-29T18:17:16.297Z","dependency_job_id":"a4c74a6b-89c4-461d-a68f-013547f97967","html_url":"https://github.com/ruby-amqp/rabbitmq_http_api_client","commit_stats":{"total_commits":298,"total_committers":30,"mean_commits":9.933333333333334,"dds":"0.49328859060402686","last_synced_commit":"7bbcf15af711381e3205cec20dd897b669ca307f"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-amqp%2Frabbitmq_http_api_client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-amqp%2Frabbitmq_http_api_client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-amqp%2Frabbitmq_http_api_client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-amqp%2Frabbitmq_http_api_client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruby-amqp","download_url":"https://codeload.github.com/ruby-amqp/rabbitmq_http_api_client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217183,"owners_count":20903009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","http","monitoring","rabbitmq","ruby"],"created_at":"2024-10-31T22:10:40.501Z","updated_at":"2025-04-04T17:07:46.129Z","avatar_url":"https://github.com/ruby-amqp.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RabbitMQ HTTP API Client for Ruby\n\nThis gem is a [RabbitMQ HTTP API]() client for Ruby. It supports\n\n * Getting cluster overview information\n * Getting cluster nodes status (# file descriptors used, RAM consumption and so on)\n * Getting information about exchanges, queues, bindings\n * Closing client connections\n * Getting information about vhosts, users, permissions\n * Getting information about enabled plugins, protocols, their ports, etc\n * Managing vhosts, users, permissions\n\nand will support more HTTP API features in the future\n\n * Publishing messages via HTTP\n * Operations on components/extensions\n * Operations on federation policies\n\n## Supported Ruby Versions\n\n * CRuby 2.7 through 3.x\n * JRuby 9K\n\n## Supported RabbitMQ Versions\n\nThis library targets [RabbitMQ release series covered by community support](https://www.rabbitmq.com/release-information).\n\nAll versions require [RabbitMQ Management UI plugin](https://www.rabbitmq.com/docs/management/) to be installed and enabled.\n\n## Installation\n\nAdd this line to your application's Gemfile to\nuse the latest version of this library:\n\n``` ruby\n# Depends on Faraday 2.x\ngem 'rabbitmq_http_api_client', '\u003e= 3.0.0'\n```\n\nIf you **absolutely must** use Faraday 1.x, use the 2.x series:\n\n``` ruby\n# Depends on Faraday 1.x.\n# Consider using 3.0.0 and later versions.\ngem 'rabbitmq_http_api_client', '\u003e= 2.2.0'\n```\n\nAnd then execute:\n\n``` shell\nbundle install\n```\n\nOr install it manually with:\n\n``` shell\ngem install rabbitmq_http_api_client\n```\n\n## Usage\n\nTo require the client:\n\n``` ruby\nrequire \"rabbitmq/http/client\"\n```\n\n### Specifying Endpoint and Credentials\n\nUse `RabbitMQ::HTTP::Client#connect` to specify RabbitMQ HTTP API endpoint (e.g. `http://127.0.0.1:15672`) and credentials:\n\n``` ruby\nrequire \"rabbitmq/http/client\"\n\nendpoint = \"http://127.0.0.1:15672\"\nclient = RabbitMQ::HTTP::Client.new(endpoint, username: \"guest\", password: \"guest\")\n```\n\nAlternatively, credentials can be specified in the endpoint URI:\n\n``` ruby\nrequire \"rabbitmq/http/client\"\n\nclient = RabbitMQ::HTTP::Client.new(\"http://guest:guest@127.0.0.1:15672\")\n```\n\n### Client API Design Overview\n\nAll client methods return arrays or hash-like structures that can be used\nlike JSON, via `Hash#[]` or regular method access:\n\n``` ruby\nr = client.overview\n\nputs r[:rabbitmq_version]\nputs r.erlang_version\n```\n\n### Accessing Management API with HTTPS\n\nAll additional options other than `:username` and `:password` are passed\nto [Faraday::Connection](https://github.com/lostisland/faraday). So, it is possible to use HTTPS\nlike so:\n\n``` ruby\nc = RabbitMQ::HTTP::Client.new(\"https://127.0.0.1:15672/\", username: \"guest\", password: \"guest\", ssl: {\n  client_cer: ...,\n  client_key: ...,\n  ca_file:    ...,\n  ca_path:    ...,\n  cert_store: ...\n})\n```\n\nOr, if you have good reasons to do so, disable peer verification:\n\n``` ruby\nc = RabbitMQ::HTTP::Client.new(\"https://127.0.0.1:15672/\", username: \"guest\", password: \"guest\", ssl: {\n  verify: false\n})\n```\n\n\n### Node and Cluster Status\n\n``` ruby\n# Get cluster information overview\nh     = client.overview\n\n# List cluster nodes with detailed status info for each one of them\nnodes = client.list_nodes\nn     = nodes.first\nputs n.mem_used\nputs n.run_queue\n\n# Get detailed status of a node\nn     = client.node_info(\"rabbit@localhost\")\nputs n.disk_free\nputs n.proc_used\nputs n.fd_total\n\n# Get Management Plugin extension list\nxs    = client.list_extensions\n\n# List all the entities (vhosts, queues, exchanges, bindings, users, etc)\ndefs  = client.list_definitions\n```\n\n### Operations on Connections\n\n``` ruby\n# List all connections to a node\nconns = client.list_connections\nconn  = conns.first\nputs conn.name\nputs conn.client_properties.product\n\n# Get a connection information by name\nconns = client.list_connections\nconn  = client.connection_info(conns.first.name)\nputs conn.name\nputs conn.client_properties.product\n\n# Forcefully close a connection\nconns = client.list_connections\nclient.close_connection(conns.first.name)\n```\n\n### Operations on Channels\n\n``` ruby\n# List all channels\nchanns = client.list_channels\nch     = channs.first\nputs ch.number\nputs ch.prefetch_count\nputs ch.name\n\n\n# Get a channel information by name\nconns = client.list_channels\nconn  = client.channel_info(conns.first.name)\nputs conn.name\n```\n\n### Operations on Exchanges\n\n``` ruby\n# List all exchanges in the cluster\nxs = client.list_exchanges\nx  = xs.first\n\nputs x.type\nputs x.name\nputs x.vhost\nputs x.durable\nputs x.auto_delete\n\n# List all exchanges in a vhost\nxs = client.list_exchanges(\"myapp.production\")\nx  = xs.first\n\nputs x.type\nputs x.name\nputs x.vhost\n\n# Get information about an exchange in a vhost\nx  = client.exchange_info(\"/\", \"log.events\")\n\nputs x.type\nputs x.name\nputs x.vhost\n\n# List all exchanges in a vhost for which an exchange is the source\nclient.list_bindings_by_source(\"/\", \"log.events\")\n\n# List all exchanges in a vhost for which an exchange is the destination\nclient.list_bindings_by_destination(\"/\", \"command.handlers.email\")\n```\n\n### Operations on Queues\n\n``` ruby\n# List all queues in a node\nqs = client.list_queues\nq  = qs.first\n\nputs q.name\nputs q.auto_delete\nputs q.durable\nputs q.backing_queue_status\nputs q.active_consumers\n\n\n# Get information about a queue\nclient.queue_info(\"/\", \"collector1.megacorp.local\")\n\n# Declare a queue\nclient.declare_queue(\"/\", \"collector1.megacorp.local\", :durable =\u003e false, :auto_delete =\u003e true)\n\n# Delete a queue\nclient.delete_queue(\"/\", \"collector1.megacorp.local\")\n\n# List bindings for a queue\nbs = client.list_queue_bindings(\"/\", \"collector1.megacorp.local\")\n\n# Purge a queue\nclient.purge_queue(\"/\", \"collector1.megacorp.local\")\n\n# Fetch messages from a queue\nms = client.get_messages(\"/\", \"collector1.megacorp.local\", :count =\u003e 10, :requeue =\u003e false, :encoding =\u003e \"auto\")\nm  = ms.first\n\nputs m.properties.content_type\nputs m.payload\nputs m.payload_encoding\n```\n\n### Operations on Bindings\n\n``` ruby\n# List all bindings\nbs = client.list_bindings\nb  = bs.first\n\nputs b.destination\nputs b.destination_type\nputs b.source\nputs b.routing_key\nputs b.vhost\n\n# List all bindings in a vhost\nbs = client.list_bindings(\"/\")\n\n# List all bindings between an exchange and a queue\nbs = client.list_bindings_between_queue_and_exchange(\"/\", \"collector1.megacorp.local\", \"log.events\")\n```\n\n### Operations on Vhosts\n\n``` ruby\n# List all vhosts\nvs = client.list_vhosts\nv  = vs.first\n\nputs v.name\nputs v.tracing\n\n# Get information about a vhost\nv  = client.vhost_info(\"/\")\n\nputs v.name\nputs v.tracing\n\n# Create a vhost\nclient.create_vhost(\"myapp.staging\")\n\n# Delete a vhost\nclient.delete_vhost(\"myapp.staging\")\n```\n\n### Managing Users\n\n``` ruby\n# List all users\nus = client.list_users\nu  = us.first\n\nputs u.name\nputs u.password_hash\nputs u.tags\n\n# Get information about a user\nu  = client.user_info(\"guest\")\n\nputs u.name\nputs u.password_hash\nputs u.tags\n\n# Update information about a user\nclient.update_user(\"myapp\", :tags =\u003e \"services,policymaker,management\", :password =\u003e \"t0ps3krEt\")\n\n# Delete a user\nclient.delete_user(\"myapp\")\n```\n\n### Managing Permissions\n\n``` ruby\n# List all permissions\nps = client.list_permissions\n\nputs p.user\nputs p.read\nputs p.write\nputs p.configure\nputs p.vhost\n\n# List all permissions in a vhost\nps = client.list_permissions(\"/\")\n\nputs p.user\nputs p.read\nputs p.write\nputs p.configure\nputs p.vhost\n\n# List permissions of a user\nps = client.user_permissions(\"guest\")\n\n# List permissions of a user in a vhost\nps = client.list_permissions_of(\"/\", \"guest\")\n\n# Update permissions of a user in a vhost\nps = client.update_permissions_of(\"/\", \"guest\", :write =\u003e \".*\", :read =\u003e \".*\", :configure =\u003e \".*\")\n\n# Clear permissions of a user in a vhost\nps = client.clear_permissions_of(\"/\", \"guest\")\n```\n\n## Running Tests\n\nBefore running the test suites, run a script that will set up the local node:\n\n``` shell\nexport RUBY_RABBITMQ_HTTP_API_CLIENT_RABBITMQCTL=\"/path/to/sbin/rabbitmqctl\"\nexport RUBY_RABBITMQ_HTTP_API_CLIENT_RABBITMQ_PLUGINS=\"/path/to/sbin/rabbitmq-plugins\"\n\n./bin/ci/before_build.sh\n```\n\nTo run all specs:\n\n``` shell\nbundle install\nbundle exec rspec -cfd spec\n```\n\nThe test suite assumes that RabbitMQ is running locally with stock settings\nand rabbitmq-management plugin enabled.\n\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new pull request\n\n\n## License \u0026 Copyright\n\nDouble-licensed under the MIT and the Mozilla Public License 2.0 ([same as RabbitMQ](https://github.com/rabbitmq/rabbitmq-server/blob/main/LICENSE)).\n\n(c) Michael S. Klishin, 2012-2024.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby-amqp%2Frabbitmq_http_api_client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruby-amqp%2Frabbitmq_http_api_client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby-amqp%2Frabbitmq_http_api_client/lists"}