/** * Get all buckets * * @return array() of Bucket objects */ public function buckets() { $url = Utils::buildRestPath($this); $response = Utils::httpRequest('GET', $url . '?buckets=true'); $response_obj = json_decode($response[1]); $buckets = array(); foreach ($response_obj->buckets as $name) { $buckets[] = $this->bucket($name); } return $buckets; }
/** * Retrieve a sibling by sibling number. * * @param integer $i - Sibling number. * @param integer $r - R-Value. Wait until this many partitions * have responded before returning to client. * @return Object. */ public function getSibling($i, $r = null) { # Use defaults if not specified. $r = $this->bucket->getR($r); # Run the request... $vtag = $this->siblings[$i]; $params = array('r' => $r, 'vtag' => $vtag); $url = Utils::buildRestPath($this->client, $this->bucket, $this->key, null, $params); $response = Utils::httpRequest('GET', $url); # Respond with a new object... $obj = new Object($this->client, $this->bucket, $this->key); $obj->jsonize = $this->jsonize; $obj->populate($response, array(200)); return $obj; }
/** * Check if a given key exists in a bucket * * @author Edgar Veiga <*****@*****.**> * @param string $key - The key to check * @return bool */ public function hasKey($key) { $url = Utils::buildRestPath($this->client, $this, $key); $response = Utils::httpRequest('HEAD', $url); if ($response == null) { throw new Exception("Error checking if key exists."); } $status = $response[0]['http_code']; if ($status === 200) { return true; } return false; }