Beispiel #1
0
 /**
  * POST /db/_replicate
  *
  * @param string $source
  * @param string $target
  * @param bool|null $cancel
  * @param bool|null $continuous
  * @param string|null $filter
  * @param array|null $ids
  * @param string|null $proxy
  * @return array
  * @throws HTTPException
  */
 public function replicate($source, $target, $cancel = null, $continuous = null, $filter = null, array $ids = null, $proxy = null)
 {
     $params = array('target' => $target, 'source' => $source);
     if ($cancel !== null) {
         $params['cancel'] = (bool) $cancel;
     }
     if ($continuous !== null) {
         $params['continuous'] = (bool) $continuous;
     }
     if ($filter !== null) {
         $params['filter'] = $filter;
     }
     if ($ids !== null) {
         $params['doc_ids'] = $ids;
     }
     if ($proxy !== null) {
         $params['proxy'] = $proxy;
     }
     $path = '/_replicate';
     $response = $this->httpClient->request('POST', $path, json_encode($params));
     if ($response->status >= 400) {
         throw HTTPException::fromResponse($path, $response);
     }
     return $response->body;
 }
Beispiel #2
0
 /**
  * Commit any recent changes to the specified database to disk.
  *
  * @return array
  * @throws HTTPException
  */
 public function ensureFullCommit()
 {
     $path = '/' . $this->databaseName . '/_ensure_full_commit';
     $response = $this->httpClient->request('POST', $path);
     if ($response->status != 201) {
         throw HTTPException::fromResponse($path, $response);
     }
     return $response->body;
 }
 /**
  * Get revision difference.
  *
  * @param  array $data
  * @return array
  * @throws HTTPException
  */
 public function getRevisionDifference($data)
 {
     $path = '/' . $this->databaseName . '/_revs_diff';
     $response = $this->httpClient->request('POST', $path, json_encode($data));
     if ($response->status != 200) {
         throw HTTPException::fromResponse($path, $response);
     }
     return $response->body;
 }
Beispiel #4
0
 /**
  * Create non existing view
  *
  * @return void
  * @throws \Doctrine\CouchDB\JsonDecodeException
  * @throws \Exception
  */
 public function createDesignDocument()
 {
     if (!$this->doc) {
         throw new \Exception("No DesignDocument Class is connected to this view query, cannot create the design document with its corresponding view automatically!");
     }
     $data = $this->doc->getData();
     if ($data === null) {
         throw \Doctrine\CouchDB\JsonDecodeException::fromLastJsonError();
     }
     $data['_id'] = '_design/' . $this->designDocumentName;
     $response = $this->client->request("PUT", sprintf("/%s/_design/%s", $this->databaseName, $this->designDocumentName), json_encode($data));
 }
Beispiel #5
0
 /**
  * Lazy Load Data from CouchDB if necessary
  *
  * @return void
  */
 private function lazyLoad()
 {
     if ($this->stub) {
         $response = $this->httpClient->request('GET', $this->path, null, true);
         // raw request
         if ($response->status != 200) {
             throw HTTPException::fromResponse($this->path, $response);
         }
         $this->stub = false;
         $this->binaryData = $response->body;
         $this->data = \base64_encode($this->binaryData);
     }
 }