Example #1
0
 /**
  * set the security object of a database
  *
  * @link http://wiki.apache.org/couchdb/Security_Features_Overview
  * @param stdClass $security the security object to apply to the database
  * @return stdClass CouchDB server response ( { "ok": true } )
  * @throws InvalidArgumentException|couchException
  */
 public function setSecurity($security)
 {
     if (!is_object($security)) {
         throw new InvalidArgumentException("Security should be an object");
     }
     $dbname = $this->client->getDatabaseName();
     $raw = $this->client->query("PUT", "/" . $dbname . "/_security", array(), json_encode($security));
     $resp = couch::parseRawResponse($raw);
     if ($resp['status_code'] == 200) {
         return $resp['body'];
     }
     throw new couchException($raw);
 }