public function createAdmin($login, $password, $roles = array())
	{
		$login = urlencode($login);
		$data = (string) $password;
		if (strlen($login) < 1) {
			throw new InvalidArgumentException("Login can't be empty");
		}
		if (strlen($data) < 1) {
			throw new InvalidArgumentException("Password can't be empty");
		}
		$url = '/_node/' . urlencode($this->node) . '/_config/admins/' . urlencode($login);
		try {
			$raw = $this->client->query(
					"PUT", $url, array(), json_encode($data)
			);
		} catch (Exception $e) {
			throw $e;
		}
		$resp = Couch::parseRawResponse($raw);
		if ($resp['status_code'] != 200) {
			throw new CouchException($raw);
		}

		$dsn = $this->client->dsn_part();
		$dsn["user"] = $login;
		$dsn["pass"] = $password;
		$client = new CouchClient($this->build_url($dsn), $this->usersdb, $this->client->options());
		$user = new stdClass();
		$user->name = $login;
		$user->type = "user";
		$user->roles = $roles;
		$user->_id = "org.couchdb.user:" . $login;
		return $client->storeDoc($user);
	}
public function createAdmin($login, $password, $roles = array())
	{
		$login = urlencode($login);
		$data = (string) $password;
		if (strlen($login) < 1) {
			throw new InvalidArgumentException("Login can't be empty");
		}
		if (strlen($data) < 1) {
			throw new InvalidArgumentException("Password can't be empty");
		}
		$url = '/_node/' . urlencode($this->node) . '/_config/admins/' . urlencode($login);
		try {
			$raw = $this->client->query(
					"PUT", $url, array(), json_encode($data)
			);
		} catch (Exception $e) {
			throw $e;
		}
		$resp = Couch::parseRawResponse($raw);
		if ($resp['status_code'] != 200) {
			throw new CouchException($raw);
		}

		$dsn = $this->client->dsn_part();
		$dsn["user"] = $login;
		$dsn["pass"] = $password;
		$client = new CouchClient($this->build_url($dsn), $this->usersdb, $this->client->options());
		$user = new stdClass();
		$user->name = $login;
		$user->type = "user";
		$user->roles = $roles;
		$user->_id = "org.couchdb.user:" . $login;
		return $client->storeDoc($user);
	}
public function createAdmin ( $ login , $ password , $ roles = array ( ) ) { $ login = urlencode ( $ login ) ; $ data = ( string ) $ password ; if ( strlen ( $ login ) < 1 ) { throw new InvalidArgumentException ( "Login can't be empty" ) ; } if ( strlen ( $ data ) < 1 ) { throw new InvalidArgumentException ( "Password can't be empty" ) ; } $ url = '/_node/' . urlencode ( $ this -> node ) . '/_config/admins/' . urlencode ( $ login ) ; try { $ raw = $ this -> client -> query ( "PUT" , $ url , array ( ) , json_encode ( $ data ) ) ; } catch ( Exception $ e ) { throw $ e ; } $ resp = Couch :: parseRawResponse ( $ raw ) ; if ( $ resp [ 'status_code' ] != 200 ) { throw new CouchException ( $ raw ) ; } $ dsn = $ this -> client -> dsn_part ( ) ; $ dsn [ "user" ] = $ login ; $ dsn [ "pass" ] = $ password ; $ client = new CouchClient ( $ this -> build_url ( $ dsn ) , $ this -> usersdb , $ this -> client -> options ( ) ) ; $ user = new stdClass ( ) ; $ user -> name = $ login ; $ user -> type = "user" ; $ user -> roles = $ roles ; $ user -> _id = "org.couchdb.user:" . $ login ; return $ client -> storeDoc ( $ user ) ; }
Creates a new CouchDB server administrator

@param string $login administrator login
@param string $password administrator password
@param array $roles add additionnal roles to the new admin
@return stdClass CouchDB server response
@throws InvalidArgumentException|Exception|CouchException
Creates a new CouchDB server administrator