Add Create Virtual Server

This commit is contained in:
Miguel Nogueira 2019-03-19 00:56:12 +00:00
parent cb04da36ee
commit 249c0b8422
6 changed files with 67 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.idea
vendor
/nbproject/private/

View File

@ -0,0 +1,7 @@
include.path=${php.global.include.path}
php.version=PHP_72
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
web.root=.

9
nbproject/project.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>Wrapper</name>
</data>
</configuration>
</project>

View File

@ -109,7 +109,7 @@ class HttpClient implements HttpClientInterface {
private function processResponse() {
$this->responseMessage = json_decode($this->response->getBody()->getContents());
// TODO delete var_dump.
var_dump($this->responseMessage);
// var_dump($this->responseMessage); ("deleted" var dump as per TODO)
if ($this->responseMessage->status == "success") return true;
return false;
}

View File

@ -112,6 +112,42 @@ class VirtualServerManager extends BaseManager implements VirtualServerManagerIn
return $this->httpClient->sendRequest();
}
/**
*
* Creates a Virtual Server (Not an alias).
* Might be missing two params.
* This method is the same as the CreateSubserver, but without the alias arg. Can overload original method.
*
* @param string $domain The new domain
* @param string $password The password
* @param string $description The description
* @param array $options Any other needed options
* @return bool True if success, false otherwise
*/
public function createServer(string $domain, string $password, string $description, array $options = array()): bool {
// sets all necessary params
$this->httpClient->queryStringBuilder()->addParameter("program", "create-domain");
$this->httpClient->queryStringBuilder()->addParameter("domain", $domain);
$this->httpClient->queryStringBuilder()->addParameter("password", $password);
$this->httpClient->queryStringBuilder()->addParameter("desc", $description);
// fetches each element inside the options array, in order to feed them to string builder, that then is used to make the URL
foreach ($options as $key => $value) {
if (is_numeric($key)) {
$this->httpClient->queryStringBuilder()->addParameter($value);
} else {
$this->httpClient->queryStringBuilder()->addParameter($key, $value);
}
}
// web and dir can be specified inside options.
return $this->httpClient->sendRequest();
}
/**
* Retrieving single virtual server.
*

View File

@ -39,6 +39,19 @@ interface VirtualServerManagerInterface {
*/
public function createSubServer(string $domain, string $parentDomain, string $description, array $options = []) : bool;
/**
* Create a new Virtual Server.
*
* @param string $domain The new domain name.
* @param string $password The user's password.
* @param string $description The server's description
* @param array $options Additional options for the server's creation, expressed in an array.
* @return bool True on completion, false on error
*
*/
public function createServer(string $domain, string $password, string $description, array $options = []) : bool;
/**
* Creates Virtual Server alias.
*