public function probeQueue(Queue $queue)
 {
     try {
         if ($queue->toJson() !== $this->client->getQueue($queue->vhost, $queue->name)->toJson()) {
             return self::PROBE_MISCONFIGURED;
         } else {
             return self::PROBE_OK;
         }
     } catch (EntityNotFoundException $e) {
         return self::PROBE_ABSENT;
     }
 }
 public function addQueue(Queue $queue)
 {
     if (!$queue->vhost) {
         throw new InvalidArgumentException('Queue requires a vhost');
     }
     if (!$queue->name) {
         throw new InvalidArgumentException('Queue requires a name');
     }
     $uri = sprintf('/api/queues/%s/%s', urlencode($queue->vhost), urlencode($queue->name));
     try {
         $this->client->put($uri, array('Content-type' => 'application/json'), $queue->toJson())->send();
     } catch (RequestException $e) {
         if ($data = json_decode($e->getResponse()->getBody(true), true)) {
             if (isset($data['reason']) && strpos($data['reason'], '406 PRECONDITION_FAILED') === 0) {
                 throw new PreconditionFailedException('Queue already exists with different properties', $e->getCode(), $e);
             }
         }
         throw new RuntimeException('Unable to put the queue', $e->getCode(), $e);
     }
     return $this->getQueue($queue->vhost, $queue->name, $queue);
 }
 public function addQueue(Queue $queue)
 {
     if (!$queue->vhost) {
         throw new InvalidArgumentException('Queue requires a vhost');
     }
     if (!$queue->name) {
         throw new InvalidArgumentException('Queue requires a name');
     }
     return $this->executeRequest('PUT', sprintf('/api/queues/%s/%s', urlencode($queue->vhost), urlencode($queue->name)), $queue->toJson())->then(Curry::bind(array($this, 'getQueue'), $queue->vhost, $queue->name, $queue));
 }