diff --git a/queues.go b/queues.go index 4a433a2..34985c2 100644 --- a/queues.go +++ b/queues.go @@ -269,6 +269,20 @@ func (c *Client) ListQueuesWithParameters(params url.Values) (rec []QueueInfo, e return rec, nil } +// ListQueuesWithParametersIs lists queues with a list of query string values in the vhost vhost. +func (c *Client) ListQueuesWithParametersIn(vhost string, params url.Values) (rec []QueueInfo, err error) { + req, err := newGETRequestWithParameters(c, "queues/"+url.PathEscape(vhost), params) + if err != nil { + return []QueueInfo{}, err + } + + if err = executeAndParseRequest(c, req, &rec); err != nil { + return []QueueInfo{}, err + } + + return rec, nil +} + // PagedListQueuesWithParameters lists queues with pagination. func (c *Client) PagedListQueuesWithParameters(params url.Values) (rec PagedQueueInfo, err error) { req, err := newGETRequestWithParameters(c, "queues", params) @@ -284,6 +298,21 @@ func (c *Client) PagedListQueuesWithParameters(params url.Values) (rec PagedQueu } +// PagedListQueuesWithParameters lists queues with pagination in the vhost vhost. +func (c *Client) PagedListQueuesWithParametersIn(vhost string, params url.Values) (rec PagedQueueInfo, err error) { + req, err := newGETRequestWithParameters(c, "queues/"+url.PathEscape(vhost), params) + if err != nil { + return PagedQueueInfo{}, err + } + + if err = executeAndParseRequest(c, req, &rec); err != nil { + return PagedQueueInfo{}, err + } + + return rec, nil + +} + // // GET /api/queues/{vhost} // diff --git a/rabbithole_test.go b/rabbithole_test.go index 0ef595b..11684a0 100644 --- a/rabbithole_test.go +++ b/rabbithole_test.go @@ -533,6 +533,45 @@ var _ = Describe("RabbitMQ HTTP API client", func() { }) }) + Context("GET /queues/{vhost} with arguments", func() { + It("returns decoded response", func() { + conn := openConnection("rabbit/hole") + defer conn.Close() + + ch, err := conn.Channel() + Ω(err).Should(BeNil()) + defer ch.Close() + + _, err = ch.QueueDeclare( + "", // name + false, // durable + false, // auto delete + true, // exclusive + false, + nil) + Ω(err).Should(BeNil()) + + // give internal events a moment to be + // handled + awaitEventPropagation() + + params := url.Values{} + params.Add("lengths_age", "1800") + params.Add("lengths_incr", "30") + + qs, err := rmqc.ListQueuesWithParametersIn("rabbit/hole", params) + Ω(err).Should(BeNil()) + + q := qs[0] + Ω(q.Name).ShouldNot(Equal("")) + Ω(q.Node).ShouldNot(BeNil()) + Ω(q.Vhost).Should(Equal("rabbit/hole")) + Ω(q.Durable).ShouldNot(BeNil()) + Ω(q.Status).ShouldNot(BeEmpty()) + Ω(q.MessagesDetails.Samples[0]).ShouldNot(BeNil()) + }) + }) + Context("GET /queues paged with arguments", func() { It("returns decoded response", func() { conn := openConnection("/") @@ -575,6 +614,49 @@ var _ = Describe("RabbitMQ HTTP API client", func() { }) }) + Context("GET /queues/{vhost} paged with arguments", func() { + It("returns decoded response", func() { + conn := openConnection("rabbit/hole") + defer conn.Close() + + ch, err := conn.Channel() + Ω(err).Should(BeNil()) + defer ch.Close() + + _, err = ch.QueueDeclare( + "", // name + false, // durable + false, // auto delete + true, // exclusive + false, + nil) + Ω(err).Should(BeNil()) + + // give internal events a moment to be + // handled + awaitEventPropagation() + + params := url.Values{} + params.Add("page", "1") + + qs, err := rmqc.PagedListQueuesWithParameters(params) + Ω(err).Should(BeNil()) + + q := qs.Items[0] + Ω(q.Name).ShouldNot(Equal("")) + Ω(q.Node).ShouldNot(BeNil()) + Ω(q.Durable).ShouldNot(BeNil()) + Ω(q.Status).ShouldNot(BeEmpty()) + Ω(qs.Page).Should(Equal(1)) + Ω(qs.PageCount).Should(Equal(1)) + Ω(qs.ItemCount).ShouldNot(BeNil()) + Ω(qs.PageSize).Should(Equal(100)) + Ω(qs.TotalCount).ShouldNot(BeNil()) + Ω(qs.FilteredCount).ShouldNot(BeNil()) + Ω(q.Vhost).Should(Equal("rabbit/hole")) + }) + }) + Context("GET /queues/{vhost}", func() { It("returns decoded response", func() { conn := openConnection("rabbit/hole")