diff --git a/README.md b/README.md index f1c800d..c12a925 100644 --- a/README.md +++ b/README.md @@ -370,17 +370,6 @@ queue.clear(); -- -### Add alerts to a queue. This is for Pull Queue only. - -```java -ArrayList alerts = new ArrayList(); -alerts.add(new Alert(Alert.typeProgressive, Alert.directionAscending, 5, "some_q")); -QueueModel info = queue.updateAlerts(alerts); -``` - --- - - ## Push Queues IronMQ push queues allow you to setup a queue that will push to an endpoint, rather than having to poll the endpoint. diff --git a/src/main/java/io/iron/ironmq/Alert.java b/src/main/java/io/iron/ironmq/Alert.java deleted file mode 100644 index 9119a63..0000000 --- a/src/main/java/io/iron/ironmq/Alert.java +++ /dev/null @@ -1,80 +0,0 @@ -package io.iron.ironmq; - -public class Alert { - private String type; - private String direction; - private int trigger; - private Integer snooze; - private String queue; - private String id; - - public static final String typeFixed = "fixed"; - public static final String typeProgressive = "progressive"; - public static final String directionAscending = "asc"; - public static final String directionDescending = "desc"; - - public Alert(String type, String direction, int trigger, int snooze, String queue) { - - this.type = type; - this.direction = direction; - this.trigger = trigger; - this.snooze = snooze; - this.queue = queue; - } - - public Alert(String type, String direction, int trigger, String queue) { - - this.type = type; - this.direction = direction; - this.trigger = trigger; - this.queue = queue; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - public int getTrigger() { - return trigger; - } - - public void setTrigger(int trigger) { - this.trigger = trigger; - } - - public int getSnooze() { - return snooze; - } - - public void setSnooze(int snooze) { - this.snooze = snooze; - } - - public String getQueue() { - return queue; - } - - public void setQueue(String queue) { - this.queue = queue; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } -} diff --git a/src/main/java/io/iron/ironmq/Alerts.java b/src/main/java/io/iron/ironmq/Alerts.java deleted file mode 100644 index 3901408..0000000 --- a/src/main/java/io/iron/ironmq/Alerts.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.iron.ironmq; - -import java.util.ArrayList; - -public class Alerts { - private ArrayList alerts; - - public Alerts(ArrayList alerts) { - this.alerts = alerts; - } - - public Alert getAlert(int i) { - return alerts.get(i); - } - - public ArrayList getAlerts() { - return alerts; - } -} diff --git a/src/main/java/io/iron/ironmq/Queue.java b/src/main/java/io/iron/ironmq/Queue.java index f335d18..4ef2112 100644 --- a/src/main/java/io/iron/ironmq/Queue.java +++ b/src/main/java/io/iron/ironmq/Queue.java @@ -693,7 +693,6 @@ public QueueModel create() throws IOException { * Creates a queue for specified queue client. * If queue exists, it will be updated. * @param subscribersList The subscribers list. - * @param alertsList The alerts list. * @param pushType The push type - multicast or unicast. * @param errorQueue The name of the error queue to use (can be null) * @param retries The retries. @@ -701,10 +700,9 @@ public QueueModel create() throws IOException { * @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK. * @throws java.io.IOException If there is an error accessing the IronMQ server. */ - public QueueModel create(ArrayList subscribersList, ArrayList alertsList, String pushType, String errorQueue, int retries, int retriesDelay) throws IOException { + public QueueModel create(ArrayList subscribersList, String pushType, String errorQueue, int retries, int retriesDelay) throws IOException { QueueModel model = new QueueModel(); model.setPushInfo(new QueuePushModel(subscribersList, retries, retriesDelay, errorQueue)); - model.setAlerts(alertsList); model.setType(pushType); return create(model); } @@ -713,15 +711,14 @@ public QueueModel create(ArrayList subscribersList, ArrayList * Creates a queue for specified queue client. * If queue exists, it will be updated. * @param subscribersList The subscribers list. - * @param alertsList The alerts list. * @param pushType The push type - multicast or unicast. * @param retries The retries. * @param retriesDelay The retries delay. * @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK. * @throws java.io.IOException If there is an error accessing the IronMQ server. */ - public QueueModel create(ArrayList subscribersList, ArrayList alertsList, String pushType, int retries, int retriesDelay) throws IOException { - return create(subscribersList, alertsList, pushType, "", retries, retriesDelay); + public QueueModel create(ArrayList subscribersList, String pushType, int retries, int retriesDelay) throws IOException { + return create(subscribersList, pushType, "", retries, retriesDelay); } /** @@ -744,7 +741,6 @@ public QueueModel create(QueueModel model) throws IOException { /** * Update queue. If there is no queue, an EmptyQueueException is thrown. * @param subscribersList The subscribers list. - * @param alertsList The alerts list. * @param pushType The push type - multicast or unicast. * @param errorQueue The name of the error queue to use (can be null) * @param retries The retries. @@ -752,10 +748,9 @@ public QueueModel create(QueueModel model) throws IOException { * @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK. * @throws java.io.IOException If there is an error accessing the IronMQ server. */ - public QueueModel updateQueue(ArrayList subscribersList, ArrayList alertsList, String pushType, String errorQueue, int retries, int retriesDelay) throws IOException { + public QueueModel updateQueue(ArrayList subscribersList, String pushType, String errorQueue, int retries, int retriesDelay) throws IOException { QueueModel model = new QueueModel(); model.setPushInfo(new QueuePushModel(subscribersList, retries, retriesDelay, errorQueue)); - model.setAlerts(alertsList); model.setType(pushType); return update(model); } @@ -763,15 +758,14 @@ public QueueModel updateQueue(ArrayList subscribersList, ArrayList subscribersList, ArrayList alertsList, String pushType, int retries, int retriesDelay) throws IOException { - return updateQueue(subscribersList, alertsList, pushType, "", retries,retriesDelay); + public QueueModel updateQueue(ArrayList subscribersList, String pushType, int retries, int retriesDelay) throws IOException { + return updateQueue(subscribersList, pushType, "", retries,retriesDelay); } public QueueModel update(QueueModel model) throws IOException { @@ -785,59 +779,23 @@ public QueueModel update(QueueModel model) throws IOException { } /** - * Add alerts to a queue. If there is no queue, an EmptyQueueException is thrown. - * @param alerts The array list of alerts. * @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK. * @throws java.io.IOException If there is an error accessing the IronMQ server. */ - public QueueModel addAlertsToQueue(ArrayList alerts) throws IOException { - return this.updateAlerts(alerts); - } /** - * Replace current queue alerts with a given list of alerts. If there is no queue, an EmptyQueueException is thrown. - * @param alerts The array list of alerts. * @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK. * @throws java.io.IOException If there is an error accessing the IronMQ server. */ - public QueueModel updateAlertsToQueue(ArrayList alerts) throws IOException { - return this.updateAlerts(alerts); - } /** - * Replace current queue alerts with a given list of alerts. If there is no queue, an EmptyQueueException is thrown. - * @param alerts The array list of alerts. * @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK. * @throws java.io.IOException If there is an error accessing the IronMQ server. */ - public QueueModel updateAlerts(ArrayList alerts) throws IOException { - QueueModel payload = new QueueModel(alerts); - return this.update(payload); - } /** - * Delete alerts from a queue. If there is no queue, an EmptyQueueException is thrown. - * @param alert_ids The array list of alert ids. + * @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK. * @throws java.io.IOException If there is an error accessing the IronMQ server. */ - public void deleteAlertsFromQueue(ArrayList alert_ids) throws IOException { - String url = "queues/" + name + "/alerts"; - Alerts alert = new Alerts(alert_ids); - String jsonMessages = gson.toJson(alert); - IronReader reader = client.delete(url, jsonMessages); - reader.close(); - } - - /** - * Delete alert from a queue by alert id. If there is no queue, an EmptyQueueException is thrown. - * @param alert_id The alert id. - * @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK. - * @throws java.io.IOException If there is an error accessing the IronMQ server. - */ - public void deleteAlertFromQueueById(String alert_id) throws IOException { - String url = "queues/" + name + "/alerts/" + alert_id; - IronReader reader = client.delete(url); - reader.close(); - } } diff --git a/src/main/java/io/iron/ironmq/QueueModel.java b/src/main/java/io/iron/ironmq/QueueModel.java index 2af3281..4247807 100644 --- a/src/main/java/io/iron/ironmq/QueueModel.java +++ b/src/main/java/io/iron/ironmq/QueueModel.java @@ -12,22 +12,19 @@ public class QueueModel { private String project_id; private Long total_messages; private QueuePushModel push; - private ArrayList alerts; @SerializedName("message_timeout") private Integer messageTimeout; @SerializedName("message_expiration") private Integer messageExpiration; - public QueueModel(String id, String name, Integer size, Integer total_messages, String project_id, Integer retries, String pushType, Integer retriesDelay, String errorQueue, ArrayList subscribers, ArrayList alerts) { + public QueueModel(String id, String name, Integer size, Integer total_messages, String project_id, Integer retries, String pushType, Integer retriesDelay, String errorQueue, ArrayList subscribers) { this.id = id; this.name = name; this.size = (long)size; this.total_messages = (long)total_messages; this.project_id = project_id; - this.alerts = alerts; } public QueueModel(int messageExpiration, int retries, String pushType, int retries_delay, String error_queue, ArrayList subscribers, ArrayList alerts, int messageTimeout) { this.messageExpiration = messageExpiration; - this.alerts = alerts; this.messageTimeout = messageTimeout; } @@ -36,10 +33,6 @@ public QueueModel(int messageTimeout, int messageExpiration) { this.messageExpiration = messageExpiration; } - public QueueModel(ArrayList alerts) { - this.alerts = alerts; - } - public QueueModel(QueuePushModel push) { this.push = push; } @@ -187,13 +180,9 @@ public void setSubscribers(ArrayList subscribers) { throw new UnsupportedOperationException(); } - public ArrayList getAlerts() { - return alerts; - } + - public void setAlerts(ArrayList alerts) { - this.alerts = alerts; - } + public int getMessageTimeout() { return messageTimeout; diff --git a/src/test/java/io/iron/ironmq/IronMQTest.java b/src/test/java/io/iron/ironmq/IronMQTest.java index 00021a9..b359985 100644 --- a/src/test/java/io/iron/ironmq/IronMQTest.java +++ b/src/test/java/io/iron/ironmq/IronMQTest.java @@ -656,23 +656,7 @@ public void testUpdateQueuePushParameters() throws IOException { Assert.assertEquals(url, info.getPushInfo().getSubscribers().get(0).getUrl()); } - /** - * This test shows how to update alerts of a queue - * Expected that: - * - new alert will be available after update - * @throws IOException - */ - @Test - public void testUpdateQueueAlerts() throws IOException { - queue.create(); - ArrayList alerts = new ArrayList(); - alerts.add(new Alert(Alert.typeProgressive, Alert.directionAscending, 5, "some_q")); - QueueModel info = queue.updateAlerts(alerts); - - Assert.assertEquals(5, info.getAlerts().get(0).getTrigger()); - Assert.assertEquals(Alert.directionAscending, info.getAlerts().get(0).getDirection()); - Assert.assertEquals(Alert.typeProgressive, info.getAlerts().get(0).getType()); - Assert.assertEquals("some_q", info.getAlerts().get(0).getQueue()); + sameQueue.getInfoAboutQueue(); } /** @@ -691,11 +675,11 @@ public void testDeleteQueue() throws IOException, InterruptedException { sameQueue.getInfoAboutQueue(); } - /** * This test shows how to add subscribers to a queue. * @throws IOException */ + @Test public void testAddSubscribers() throws IOException { QueueModel payload = new QueueModel();