apiUrl = rtrim($apiUrl, '/'); $this->apiKey = $apiKey; } /** * Initially deploy the development site for the customer * * @param username: The username under which the domain is deployed * @param domain: The Domain to migrate * @param adminName: The Super-Admin User of the CRM System (usually the e-mail of the customer * @param adminPassword: A self randomly generated password * * @return a json with ['status' => $httpCode,'response' => ['success' => 'Text']]; * or a json with ['status' => $httpCode,'response' => ['error' => 'Error-Description']]; * * Attention: The given parameters username, adminName and adminPassword must be * stored locally for the Single Sign on from whcms plugin * */ public function deployDev($username, $domain, $adminName, $adminPassword) { $url = "$this->apiUrl/deploydev/$username/$domain"; $data = [ 'admin_name' => $adminName, 'admin_password' => $adminPassword ]; return $this->sendRequest('POST', $url, $data); } /** * Migrate dev site to prod site * * @param username: The username under which the domain is deployed * @param domain: The Domain to migrate * @param adminName: The Super-Admin User of the CRM System (usually the e-mail of the customer * @param adminPassword: A self randomly generated password * * @return a json with ['status' => $httpCode,'response' => ['success' => 'Text']]; * or a json with ['status' => $httpCode,'response' => ['error' => 'Error-Description']]; * * Attention: The given parameters adminName and adminPassword must be stored locally for the * Single Sign on from whcms plugin */ public function migrateprod($username, $domain, $adminName, $adminPassword) { $url = "$this->apiUrl/migrateprod/$username/$domain"; $data = [ 'admin_name' => $adminName, 'admin_password' => $adminPassword ]; return $this->sendRequest('POST', $url, $data); } /** * Disables the prod webpage * * @param username: The username under which the domain is deployed * @param domain: The Domain to migrate * * @return a json with ['status' => $httpCode,'response' => ['success' => 'Text']]; * or a json with ['status' => $httpCode,'response' => ['error' => 'Error-Description']]; */ public function disableprod($domain,$userName) { $url = "$this->apiUrl/disableprod/$username/$domain"; return $this->sendRequest('GET', $url); } /** * Enables the prod webpage * * @param username: The username under which the domain is deployed * @param domain: The Domain to migrate * * @return a json with ['status' => $httpCode,'response' => ['isenabled' => 'YES']]; * or a json with ['status' => $httpCode,'response' => ['isenabled' => 'NO']]; */ public function enableprod($domain,$userName) { $url = "$this->apiUrl/enableprod/$username/$domain"; return $this->sendRequest('GET', $url); } /** * Disables the prod webpage * * @param username: The username under which the domain is deployed * @param domain: The Domain to migrate * * @return a json with ['status' => $httpCode,'response' => ['success' => 'Text']]; * or a json with ['status' => $httpCode,'response' => ['error' => 'Error-Description']]; */ public function isprodenabled($domain,$userName) { $url = "$this->apiUrl/isprodenabled/$username/$domain"; return $this->sendRequest('GET', $url); } /** * Disables the prod webpage * * @param username: The username under which the domain is deployed * @param domain: The Domain to migrate * * @return a json with ['status' => $httpCode,'response' => ['ssl_expiry' => 'Datum des Ablaufs des Zertifikats', 'ssl_remaining' => 'Anzahl der Tage bis zum Ablauf des Zertifikats']]; */ public function getSSLDays($domain,$userName) { $url = "$this->apiUrl/getssldays/$username/$domain"; return $this->sendRequest('GET', $url); } /** * Lists the Prod Backups for the prod webpage * * @param username: The username under which the domain is deployed * @param domain: The Domain to migrate * * @return a json with ['status' => $httpCode,'response' => [ * 'backups' => [ * ['backup_date' => 'ISO Backup Datum', * 'swiss_date' => 'Datum im Schweizer Format', * 'size_mb' => 'Grösse in Megabyte', * 'filename' => 'Dateiname des tar.gz's' * ] * ]; * */ public function listbackups($domain,$userName) { $url = "$this->apiUrl/listbackups/$username/$domain"; return $this->sendRequest('GET', $url); } /** * Restores a Backup with the given ISO Date * * @param username: The username under which the domain is deployed * @param domain: The Domain to migrate * @param backupDate: The ISO-Date of the backup (backup_date from listBackups) to restore * * @return a json with ['status' => $httpCode,'response' => ['success' => 'Text']]; * or a json with ['status' => $httpCode,'response' => ['error' => 'Error-Description']]; */ public function restorebackup($domain,$userName,$backupDate) { $url = "$this->apiUrl/restorebackup/$username/$domain"; $data = [ 'backup_date' => $backupDate ]; return $this->sendRequest('POST', $url, $data); } private function sendRequest($method, $url, $data = []) { $ch = curl_init(); $options = [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "X-Api-Key: $this->apiKey", "Content-Type: application/json" ], CURLOPT_CUSTOMREQUEST => $method, CURLOPT_SSL_VERIFYPEER => false, // Deaktiviert die Überprüfung des SSL-Zertifikats CURLOPT_SSL_VERIFYHOST => false // Akzeptiert alle Hostnamen ]; if ($method === 'POST' && !empty($data)) { $options[CURLOPT_POSTFIELDS] = json_encode($data); } curl_setopt_array($ch, $options); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return [ 'status' => $httpCode, 'response' => json_decode($response, true) ]; } } // Beispielnutzung mit HTTPS $apiClient = new ApiClient('https://vm-dc-builderhost-01.thurdata.local', 'your-secure-password'); $response = $apiClient->getSSLDays('exampleuser','example.com'); print_r($response);