diff --git a/queues.go b/queues.go index aaf0886..b3376d4 100644 --- a/queues.go +++ b/queues.go @@ -97,6 +97,16 @@ type QueueInfo struct { BackingQueueStatus BackingQueueStatus `json:"backing_queue_status"` } +type PagedQueueInfo struct { + Page int `json:"page"` + PageCount int `json:"page_count"` + PageSize int `json:"page_size"` + FilteredCount int `json:"filtered_count"` + ItemCount int `json:"item_count"` + TotalCount int `json:"total_count"` + Items []QueueInfo `json:"items"` +} + type DetailedQueueInfo QueueInfo // @@ -193,6 +203,20 @@ func (c *Client) ListQueuesWithParameters(params url.Values) (rec []QueueInfo, e return rec, nil } +func (c *Client) PagedListQueuesWithParameters(params url.Values) (rec PagedQueueInfo, err error) { + req, err := newGETRequestWithParameters(c, "queues", 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 4fb98b2..7b8f862 100644 --- a/rabbithole_test.go +++ b/rabbithole_test.go @@ -566,6 +566,48 @@ var _ = Describe("Rabbithole", func() { }) }) + Context("GET /queues paged with arguments", func() { + It("returns decoded response", func() { + conn := openConnection("/") + 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(BeNil()) + Ω(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()) + }) + }) + Context("GET /queues/{vhost}", func() { It("returns decoded response", func() { conn := openConnection("rabbit/hole")