public bool DeleteMessage(Queue queue, Message message)
 {
     return DeleteMessage(queue.Name, message.ID);
 }
 public bool DeleteMessage(Queue queue, string messageId)
 {
     return DeleteMessage(queue.Name, messageId);
 }
 public MessageList PopMessages(Queue queue, int maxMessages = 1)
 {
     return PopMessages(queue.Name, maxMessages);
 }
 public bool DeleteQueue(Queue queue, bool forceDeletion = false)
 {
     return DeleteQueue(queue.Name, forceDeletion);
 }
 public Message PublishToQueue(Queue queue, Message message)
 {
     return PublishToQueue(queue.Name, message);
 }
 public Message PopMessage(Queue queue)
 {
     return PopMessage(queue.Name);
 }
        private Queue CreateOrUpdateQueue(Queue queue, bool create = true)
        {
            MessagingRequest request = new MessagingRequest("queues/{queueName}", Method.PUT);
            request.AddUrlSegment("queueName", queue.Name);
            request.HttpStatusSuccessCodes.Add(200);
            request.HttpStatusExceptionMap.Add(400, typeof(BadRequestException));

            if (create) {
                request.HttpStatusSuccessCodes.Add(201);
            }
            else {
                request.HttpStatusSuccessCodes.Add(200);
            }

            object postObj = new {
                name = queue.Name,
                expiration = queue.Expiration,
                visibility_interval = queue.VisibilityInterval,
                tags = queue.Tags
            };

            if (DebugRequests) {
                Console.WriteLine("-> " + request.JsonSerializer.Serialize(postObj));
            }

            request.AddBody(postObj);

            QueueResponse response = client.Execute<QueueResponse>(request);

            queue.Name = response.name;
            queue.Expiration = response.expiration;
            queue.VisibilityInterval = response.visibility_interval;
            queue.Tags = new TagList(response.tags);

            return queue;
        }
 public MessageList PublishToQueue(Queue queue, MessageList messages)
 {
     return PublishToQueue(queue.Name, messages);
 }
 public Queue UpdateQueue(Queue queue)
 {
     return CreateOrUpdateQueue(queue, false);
 }
 public Queue CreateQueue(Queue queue)
 {
     return CreateOrUpdateQueue(queue, true);
 }
        public Queue CreateQueue(string name, int expiration, int visibilityInterval, TagList tags)
        {
            Queue newQueue = new Queue(name);
            newQueue.Expiration = expiration;
            newQueue.VisibilityInterval = visibilityInterval;
            newQueue.Tags = tags;

            return CreateQueue(newQueue);
        }
        public Queue GetQueue(string name)
        {
            MessagingRequest request = new MessagingRequest("queues/{queueName}", Method.GET);
            request.AddUrlSegment("queueName", name);
            request.HttpStatusSuccessCodes.Add(200);
            request.HttpStatusExceptionMap.Add(404, typeof(QueueNotFoundException));

            QueueResponse response = client.Execute<QueueResponse>(request);

            Queue tmpQueue = new Queue();
            tmpQueue.Name = response.name;
            tmpQueue.Expiration = response.expiration;
            tmpQueue.VisibilityInterval = response.visibility_interval;
            tmpQueue.Tags = new TagList(response.tags);

            return tmpQueue;
        }
        public QueueList GetQueueList(IEnumerable<string> tagList)
        {
            QueueList queueList = new QueueList();
            MessagingRequest request = new MessagingRequest("queues");
            request.HttpStatusSuccessCodes.Add(200);

            if (tagList != null) {
                request.AddParameter("tags", new TagList(tagList).ToString(","));
            }

            EntityListResponse<QueueResponse> queueListResponse =
                client.Execute<EntityListResponse<QueueResponse>>(request);

            foreach (QueueResponse tmpQueue in queueListResponse.items) {
                Queue queue = new Queue(tmpQueue.name);
                queue.Expiration = tmpQueue.expiration;
                queue.VisibilityInterval = tmpQueue.visibility_interval;
                queue.Tags = new TagList(tmpQueue.tags);

                queueList.Add(queue);
            }

            return queueList;
        }