public function create($client = null)
    {
        if ($this->exists()) {
            $this->logger->debug(
                'A REST API named "' . $this->name . '" already exists'
            );
            return $this;
        }
        $this->client = $client ?: $this->client;
        $params = array();
        $headers = array('Content-type' => 'application/json');
        $body = '
            {
                "rest-api": {
                    "name": "' . $this->name . '",
                    "database": "' . $this->db . '",
                    "modules-database": "' . $this->db . '-modules",
                    "port": "' . $this->port . '",
                    "forests-per-host": 1,
                    "error-format": "json"
                }
            }
        ';
        $request = new RESTRequest('POST', 'rest-apis', $params, $body, $headers);
        $this->logger->debug(
            "Setting up REST API: " . $this->name .
            ' (' . $this->db . ') port ' . $this->port
        );
        $this->client->send($request); // Set up REST API
        return $this;
    }
public function create($client = null)
    {
        if ($this->exists()) {
            $this->logger->debug(
                'A REST API named "' . $this->name . '" already exists'
            );
            return $this;
        }
        $this->client = $client ?: $this->client;
        $params = array();
        $headers = array('Content-type' => 'application/json');
        $body = '
            {
                "rest-api": {
                    "name": "' . $this->name . '",
                    "database": "' . $this->db . '",
                    "modules-database": "' . $this->db . '-modules",
                    "port": "' . $this->port . '",
                    "forests-per-host": 1,
                    "error-format": "json"
                }
            }
        ';
        $request = new RESTRequest('POST', 'rest-apis', $params, $body, $headers);
        $this->logger->debug(
            "Setting up REST API: " . $this->name .
            ' (' . $this->db . ') port ' . $this->port
        );
        $this->client->send($request); // Set up REST API
        return $this;
    }
public function create ( $ client = null ) { if ( $ this -> exists ( ) ) { $ this -> logger -> debug ( 'A REST API named "' . $ this -> name . '" already exists' ) ; return $ this ; } $ this -> client = $ client ? : $ this -> client ; $ params = array ( ) ; $ headers = array ( 'Content-type' => 'application/json' ) ; $ body = '
            {
                "rest-api": {
                    "name": "' . $ this -> name . '",
                    "database": "' . $ this -> db . '",
                    "modules-database": "' . $ this -> db . '-modules",
                    "port": "' . $ this -> port . '",
                    "forests-per-host": 1,
                    "error-format": "json"
                }
            }
        ' ; $ request = new RESTRequest ( 'POST' , 'rest-apis' , $ params , $ body , $ headers ) ; $ this -> logger -> debug ( "Setting up REST API: " . $ this -> name . ' (' . $ this -> db . ') port ' . $ this -> port ) ; $ this -> client -> send ( $ request ) ; // Set up REST API return $ this ; }
Create a REST API via a post to the MarkLogic rest-apis endpoint.
It will not create an API if there already exists one with the
same name.

@param RESTClient client Optional custom REST client object.
Create a REST API via a post to the MarkLogic rest - apis endpoint . It will not create an API if there already exists one with the same name .