Add custom hostname options (#131)
* Add ability to set additional SSL settings * Add ability to specify a custom origin server * Add ability to set wildcard * Fix json parsing error with empty 'ssl' key Co-authored-by: Craig Menning <craig@bubbleup.net>
This commit is contained in:
@@ -30,18 +30,27 @@ class CustomHostnames implements API
|
||||
* @param string $hostname
|
||||
* @param string $sslMethod
|
||||
* @param string $sslType
|
||||
* @param array $sslSettings
|
||||
* @param string $customOriginServer
|
||||
* @param bool $wildcard
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function addHostname(string $zoneID, string $hostname, string $sslMethod = 'http', string $sslType = 'dv'): \stdClass
|
||||
public function addHostname(string $zoneID, string $hostname, string $sslMethod = 'http', string $sslType = 'dv', array $sslSettings = [], string $customOriginServer = '', bool $wildcard = false): \stdClass
|
||||
{
|
||||
$options = [
|
||||
'hostname' => $hostname,
|
||||
'ssl' => [
|
||||
'method' => $sslMethod,
|
||||
'type' => $sslType
|
||||
]
|
||||
'type' => $sslType,
|
||||
'settings' => $sslSettings
|
||||
],
|
||||
'wildcard' => $wildcard,
|
||||
];
|
||||
|
||||
if (!empty($customOriginServer)) {
|
||||
$options['custom_origin_server'] = $customOriginServer;
|
||||
}
|
||||
|
||||
$zone = $this->adapter->post('zones/'.$zoneID.'/custom_hostnames', $options);
|
||||
$this->body = json_decode($zone->getBody());
|
||||
return $this->body->result;
|
||||
@@ -118,7 +127,7 @@ class CustomHostnames implements API
|
||||
* @param string $sslType
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function updateHostname(string $zoneID, string $hostnameID, string $sslMethod = '', string $sslType = ''): \stdClass
|
||||
public function updateHostname(string $zoneID, string $hostnameID, string $sslMethod = '', string $sslType = '', array $sslSettings = [], string $customOriginServer = ''): \stdClass
|
||||
{
|
||||
$query = [];
|
||||
|
||||
@@ -130,9 +139,19 @@ class CustomHostnames implements API
|
||||
$query['type'] = $sslType;
|
||||
}
|
||||
|
||||
$options = [
|
||||
'ssl' => $query
|
||||
];
|
||||
if (!empty($sslSettings)) {
|
||||
$query['settings'] = $sslSettings;
|
||||
}
|
||||
|
||||
if (!empty($query)) {
|
||||
$options = [
|
||||
'ssl' => $query
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($customOriginServer)) {
|
||||
$options['custom_origin_server'] = $customOriginServer;
|
||||
}
|
||||
|
||||
$zone = $this->adapter->patch('zones/'.$zoneID.'/custom_hostnames/'.$hostnameID, $options);
|
||||
$this->body = json_decode($zone->getBody());
|
||||
|
||||
Reference in New Issue
Block a user