From f79f0bdba350cbe523badf593efdf15cfe63f579 Mon Sep 17 00:00:00 2001 From: Sem Schilder Date: Mon, 6 May 2019 10:33:13 +0200 Subject: [PATCH] Add version 5.13 --- CHANGELOG | 115 +++ Transip/ApiSettings.php | 43 ++ Transip/AvailabilityZone.php | 34 + Transip/ColocationService.php | 305 ++++++++ Transip/Cronjob.php | 102 +++ Transip/DataCenterVisitor.php | 42 ++ Transip/Db.php | 49 ++ Transip/DnsEntry.php | 70 ++ Transip/DnsSecEntry.php | 86 +++ Transip/DnsService.php | 247 ++++++ Transip/Domain.php | 105 +++ Transip/DomainAction.php | 35 + Transip/DomainBranding.php | 62 ++ Transip/DomainCheckResult.php | 45 ++ Transip/DomainService.php | 528 +++++++++++++ Transip/Forward.php | 101 +++ Transip/ForwardService.php | 240 ++++++ Transip/Haip.php | 140 ++++ Transip/HaipService.php | 539 ++++++++++++++ Transip/MailBox.php | 80 ++ Transip/MailForward.php | 39 + Transip/Nameserver.php | 50 ++ Transip/OperatingSystem.php | 41 + Transip/PrivateNetwork.php | 20 + Transip/Product.php | 41 + Transip/PropositionService.php | 194 +++++ Transip/Snapshot.php | 41 + Transip/SubDomain.php | 30 + Transip/Tld.php | 70 ++ Transip/Vps.php | 125 ++++ Transip/VpsBackup.php | 48 ++ Transip/VpsService.php | 702 ++++++++++++++++++ Transip/WebHost.php | 60 ++ Transip/WebhostingPackage.php | 41 + Transip/WebhostingService.php | 474 ++++++++++++ Transip/WhoisContact.php | 403 ++++++++++ .../ColocationService-createIpAddress.php | 23 + .../ColocationService-deleteIpAddress.php | 22 + .../ColocationService-getColoOverview.php | 54 ++ examples/ColocationService-requestAccess.php | 114 +++ .../ColocationService-requestRemoteHands.php | 96 +++ examples/ColocationService-setReverseDns.php | 22 + examples/DnsService-getDnsSecEntries.php | 23 + examples/DnsService-setDnsEntries.php | 30 + examples/DnsService-setDnsSecEntries.php | 49 ++ .../DomainService-batchCheckAvailability.php | 82 ++ examples/DomainService-batchGetInfo.php | 138 ++++ examples/DomainService-cancel.php | 57 ++ examples/DomainService-checkAvailability.php | 75 ++ examples/DomainService-domainActions.php | 67 ++ examples/DomainService-getAllTldInfos.php | 30 + examples/DomainService-getAuthCode.php | 62 ++ examples/DomainService-getDomainNames.php | 32 + examples/DomainService-getInfo.php | 130 ++++ examples/DomainService-getWhois.php | 51 ++ examples/DomainService-register-dns.php | 37 + .../DomainService-register-nameserver.php | 43 ++ examples/DomainService-register-whois.php | 59 ++ examples/DomainService-register.php | 24 + examples/DomainService-setContacts.php | 255 +++++++ examples/DomainService-setLock.php | 85 +++ examples/DomainService-setNameservers.php | 33 + examples/DomainService-setOwner.php | 185 +++++ examples/DomainService-transfer.php | 57 ++ examples/ForwardService-order.php | 30 + examples/HaipService-addCertificateToHaip.php | 20 + .../HaipService-addHaipPortConfiguration.php | 24 + examples/HaipService-addPortConfiguration.php | 23 + examples/HaipService-cancelHaip.php | 23 + examples/HaipService-changeHaipVps.php | 20 + .../HaipService-deleteCertificateFromHaip.php | 21 + ...aipService-deleteHaipPortConfiguration.php | 24 + .../HaipService-deletePortConfiguration.php | 22 + ...Service-getAvailableCertificatesByHaip.php | 22 + .../HaipService-getCertificatesByHaip.php | 22 + examples/HaipService-getHaip.php | 22 + .../HaipService-getHaipPortConfigurations.php | 24 + examples/HaipService-getHaips.php | 22 + .../HaipService-getPortConfigurations.php | 22 + examples/HaipService-getPtrForHaip.php | 22 + examples/HaipService-getStatusReport.php | 20 + examples/HaipService-setBalancingMode.php | 31 + ...aipService-setDefaultPortConfiguration.php | 21 + examples/HaipService-setHaipDescription.php | 22 + examples/HaipService-setHaipVpses.php | 20 + examples/HaipService-setHttpHealthCheck.php | 20 + examples/HaipService-setIpSetup.php | 31 + examples/HaipService-setPtrForHaip.php | 21 + examples/HaipService-setTcpHealthCheck.php | 20 + ...e-startHaipLetsEncryptCertificateIssue.php | 21 + ...aipService-updateHaipPortConfiguration.php | 26 + .../HaipService-updatePortConfiguration.php | 24 + ...ropositionService-getPropositionStatus.php | 21 + examples/VpsService-addIpv6ToVps.php | 21 + .../VpsService-addVpsToPrivateNetwork.php | 21 + examples/VpsService-cancelAddon.php | 22 + examples/VpsService-cancelPrivateNetwork.php | 22 + examples/VpsService-cancelVps.php | 22 + examples/VpsService-cloneVps.php | 24 + examples/VpsService-createSnapshot.php | 21 + examples/VpsService-getActiveAddonsForVps.php | 22 + examples/VpsService-getAllIps.php | 22 + examples/VpsService-getAllPrivateNetworks.php | 22 + examples/VpsService-getAvailabilityZones.php | 22 + examples/VpsService-getAvailableAddons.php | 22 + .../VpsService-getAvailableAddonsForVps.php | 22 + examples/VpsService-getAvailableProducts.php | 22 + examples/VpsService-getAvailableUpgrades.php | 22 + .../VpsService-getCancellableAddonsForVps.php | 22 + examples/VpsService-getIpsForVps.php | 25 + examples/VpsService-getOperatingSystems.php | 22 + ...VpsService-getPooledTrafficInformation.php | 33 + .../VpsService-getPrivateNetworksByVps.php | 22 + examples/VpsService-getSnapshotsByVps.php | 22 + ...VpsService-getTrafficInformationForVps.php | 33 + examples/VpsService-getVps.php | 22 + examples/VpsService-getVpsBackupsByVps.php | 22 + examples/VpsService-getVpses.php | 22 + examples/VpsService-handoverVps.php | 23 + .../VpsService-installOperatingSystem.php | 22 + ...rvice-installOperatingSystemUnattended.php | 53 ++ examples/VpsService-orderAddon.php | 23 + examples/VpsService-orderPrivateNetwork.php | 20 + examples/VpsService-orderVps.php | 25 + examples/VpsService-removeSnapshot.php | 24 + ...VpsService-removeVpsFromPrivateNetwork.php | 24 + examples/VpsService-reset.php | 24 + examples/VpsService-revertSnapshot.php | 24 + .../VpsService-revertSnapshotToOtherVps.php | 24 + examples/VpsService-revertVpsBackup.php | 24 + examples/VpsService-setCustomerLock.php | 26 + examples/VpsService-start.php | 24 + examples/VpsService-stop.php | 24 + examples/VpsService-updatePtrRecord.php | 24 + examples/VpsService-upgradeVps.php | 23 + examples/WebhostingService-createMailBox.php | 28 + examples/WebhostingService-getInfo.php | 178 +++++ ...ostingService-getWebhostingDomainNames.php | 31 + .../WebhostingService-order_and_upgrade.php | 37 + 139 files changed, 9222 insertions(+) create mode 100644 CHANGELOG create mode 100644 Transip/ApiSettings.php create mode 100644 Transip/AvailabilityZone.php create mode 100644 Transip/ColocationService.php create mode 100644 Transip/Cronjob.php create mode 100644 Transip/DataCenterVisitor.php create mode 100644 Transip/Db.php create mode 100644 Transip/DnsEntry.php create mode 100644 Transip/DnsSecEntry.php create mode 100644 Transip/DnsService.php create mode 100644 Transip/Domain.php create mode 100644 Transip/DomainAction.php create mode 100644 Transip/DomainBranding.php create mode 100644 Transip/DomainCheckResult.php create mode 100644 Transip/DomainService.php create mode 100644 Transip/Forward.php create mode 100644 Transip/ForwardService.php create mode 100644 Transip/Haip.php create mode 100644 Transip/HaipService.php create mode 100644 Transip/MailBox.php create mode 100644 Transip/MailForward.php create mode 100644 Transip/Nameserver.php create mode 100644 Transip/OperatingSystem.php create mode 100644 Transip/PrivateNetwork.php create mode 100644 Transip/Product.php create mode 100644 Transip/PropositionService.php create mode 100644 Transip/Snapshot.php create mode 100644 Transip/SubDomain.php create mode 100644 Transip/Tld.php create mode 100644 Transip/Vps.php create mode 100644 Transip/VpsBackup.php create mode 100644 Transip/VpsService.php create mode 100644 Transip/WebHost.php create mode 100644 Transip/WebhostingPackage.php create mode 100644 Transip/WebhostingService.php create mode 100644 Transip/WhoisContact.php create mode 100644 examples/ColocationService-createIpAddress.php create mode 100644 examples/ColocationService-deleteIpAddress.php create mode 100644 examples/ColocationService-getColoOverview.php create mode 100644 examples/ColocationService-requestAccess.php create mode 100644 examples/ColocationService-requestRemoteHands.php create mode 100644 examples/ColocationService-setReverseDns.php create mode 100644 examples/DnsService-getDnsSecEntries.php create mode 100644 examples/DnsService-setDnsEntries.php create mode 100644 examples/DnsService-setDnsSecEntries.php create mode 100644 examples/DomainService-batchCheckAvailability.php create mode 100644 examples/DomainService-batchGetInfo.php create mode 100644 examples/DomainService-cancel.php create mode 100644 examples/DomainService-checkAvailability.php create mode 100644 examples/DomainService-domainActions.php create mode 100644 examples/DomainService-getAllTldInfos.php create mode 100644 examples/DomainService-getAuthCode.php create mode 100644 examples/DomainService-getDomainNames.php create mode 100644 examples/DomainService-getInfo.php create mode 100644 examples/DomainService-getWhois.php create mode 100644 examples/DomainService-register-dns.php create mode 100644 examples/DomainService-register-nameserver.php create mode 100644 examples/DomainService-register-whois.php create mode 100644 examples/DomainService-register.php create mode 100644 examples/DomainService-setContacts.php create mode 100644 examples/DomainService-setLock.php create mode 100644 examples/DomainService-setNameservers.php create mode 100644 examples/DomainService-setOwner.php create mode 100644 examples/DomainService-transfer.php create mode 100644 examples/ForwardService-order.php create mode 100644 examples/HaipService-addCertificateToHaip.php create mode 100644 examples/HaipService-addHaipPortConfiguration.php create mode 100644 examples/HaipService-addPortConfiguration.php create mode 100644 examples/HaipService-cancelHaip.php create mode 100644 examples/HaipService-changeHaipVps.php create mode 100644 examples/HaipService-deleteCertificateFromHaip.php create mode 100644 examples/HaipService-deleteHaipPortConfiguration.php create mode 100644 examples/HaipService-deletePortConfiguration.php create mode 100644 examples/HaipService-getAvailableCertificatesByHaip.php create mode 100644 examples/HaipService-getCertificatesByHaip.php create mode 100644 examples/HaipService-getHaip.php create mode 100644 examples/HaipService-getHaipPortConfigurations.php create mode 100644 examples/HaipService-getHaips.php create mode 100644 examples/HaipService-getPortConfigurations.php create mode 100644 examples/HaipService-getPtrForHaip.php create mode 100644 examples/HaipService-getStatusReport.php create mode 100644 examples/HaipService-setBalancingMode.php create mode 100644 examples/HaipService-setDefaultPortConfiguration.php create mode 100644 examples/HaipService-setHaipDescription.php create mode 100644 examples/HaipService-setHaipVpses.php create mode 100644 examples/HaipService-setHttpHealthCheck.php create mode 100644 examples/HaipService-setIpSetup.php create mode 100644 examples/HaipService-setPtrForHaip.php create mode 100644 examples/HaipService-setTcpHealthCheck.php create mode 100644 examples/HaipService-startHaipLetsEncryptCertificateIssue.php create mode 100644 examples/HaipService-updateHaipPortConfiguration.php create mode 100644 examples/HaipService-updatePortConfiguration.php create mode 100644 examples/PropositionService-getPropositionStatus.php create mode 100644 examples/VpsService-addIpv6ToVps.php create mode 100644 examples/VpsService-addVpsToPrivateNetwork.php create mode 100644 examples/VpsService-cancelAddon.php create mode 100644 examples/VpsService-cancelPrivateNetwork.php create mode 100644 examples/VpsService-cancelVps.php create mode 100644 examples/VpsService-cloneVps.php create mode 100644 examples/VpsService-createSnapshot.php create mode 100644 examples/VpsService-getActiveAddonsForVps.php create mode 100644 examples/VpsService-getAllIps.php create mode 100644 examples/VpsService-getAllPrivateNetworks.php create mode 100644 examples/VpsService-getAvailabilityZones.php create mode 100644 examples/VpsService-getAvailableAddons.php create mode 100644 examples/VpsService-getAvailableAddonsForVps.php create mode 100644 examples/VpsService-getAvailableProducts.php create mode 100644 examples/VpsService-getAvailableUpgrades.php create mode 100644 examples/VpsService-getCancellableAddonsForVps.php create mode 100644 examples/VpsService-getIpsForVps.php create mode 100644 examples/VpsService-getOperatingSystems.php create mode 100644 examples/VpsService-getPooledTrafficInformation.php create mode 100644 examples/VpsService-getPrivateNetworksByVps.php create mode 100644 examples/VpsService-getSnapshotsByVps.php create mode 100644 examples/VpsService-getTrafficInformationForVps.php create mode 100644 examples/VpsService-getVps.php create mode 100644 examples/VpsService-getVpsBackupsByVps.php create mode 100644 examples/VpsService-getVpses.php create mode 100644 examples/VpsService-handoverVps.php create mode 100644 examples/VpsService-installOperatingSystem.php create mode 100644 examples/VpsService-installOperatingSystemUnattended.php create mode 100644 examples/VpsService-orderAddon.php create mode 100644 examples/VpsService-orderPrivateNetwork.php create mode 100644 examples/VpsService-orderVps.php create mode 100644 examples/VpsService-removeSnapshot.php create mode 100644 examples/VpsService-removeVpsFromPrivateNetwork.php create mode 100644 examples/VpsService-reset.php create mode 100644 examples/VpsService-revertSnapshot.php create mode 100644 examples/VpsService-revertSnapshotToOtherVps.php create mode 100644 examples/VpsService-revertVpsBackup.php create mode 100644 examples/VpsService-setCustomerLock.php create mode 100644 examples/VpsService-start.php create mode 100644 examples/VpsService-stop.php create mode 100644 examples/VpsService-updatePtrRecord.php create mode 100644 examples/VpsService-upgradeVps.php create mode 100644 examples/WebhostingService-createMailBox.php create mode 100644 examples/WebhostingService-getInfo.php create mode 100644 examples/WebhostingService-getWebhostingDomainNames.php create mode 100644 examples/WebhostingService-order_and_upgrade.php diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..a9ad921 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,115 @@ +TRANSIP API V5.9 + +NEW + - Added a function to request the authcode of a domain at the dnsBE or EURid registries + +TRANSIP API V5.8 + +NEW + - Added Pooled Traffic for VPS + +TRANSIP API V5.7 + +NEW + - Added AvailabilityZones + +TRANSIP API V5.6 + +NEW + - Added custom target ports for HA-IP + Use different source and destination ports for a HA-IP configuration. + - Added option to configure SSL between HA-IP and VPS + For each configuration specify whether the connection between HA-IP and the VPS is secured. + - Added HA-IP Pro support + Attach multiple VPSes to a HA-IP, and modify load balancing settings. + +TRANSIP API V5.5 + +NEW + - Added HA-IP Certificates + HTTPS Offloading on our proxy's + - Add LetsEncrypt certificate to HA-IP + Let transip handle your Lets Encrypt certificate and renewals automatically + - Change proxy modes: HTTP, HTTPS, TCP, PROXY + Use HTTPS modus for SSL offloading. HTTP/HTTPS mode will also set the X-Forwarded-For Header. + +TRANSIP API V5.4 + +NEW + - Added HaipService + With which you can list your Haips and change the coupled Vps to your Haip + +TRANSIP API V5.3 + +NEW + - Added VpsService::installOperatingSystemUnattended + Start a installation with a custom preseed/kickstart provided via the api (base64_encoded) + +TRANSIP API V5.2 + +NEW + - Added VpsService::cloneVps + The ability to clone a VPS to a new VPS + + - Added VpsService::revertSnapshotToOtherVps + Revert a snapshot from any vps to any vps + + - Added VpsService::revertVpsBackup + Revert a automated VPS backup + + +TRANSIP API V5.1 + +NEW + - Added VpsService::getTrafficInformationForVps + This method provides more information about your traffic usage + + - Added VpsService::handoverVps + With this method you will be able to start the push handover process to another TransIP Account + + - Added VpsService::setCustomerLock + Enable or disable the customerlock via the Api + +DEPRECATED: + - VpsService::getAmountOfTrafficUsed (still works for now) + + +TRANSIP API V5.0 + +NEW + - Added Support for VPS + + +TRANSIP API V4.2.1 + +NEW + - The RSA part of the private key is no longer required for newly generated keys + + +TRANSIP API V4.1 + +NEW + - Single distribution for all TransIP countries: added Transip_ApiSettings::$endpoint to determine which endpoint to target when making API requests + + +TRANSIP API V4.0 + +NEW: + - Improved security by using SSL based signatures for API requests. + + +TRANSIP API V3.0 + +NEW: + - check up to 20 domains within one call: Transip_DomainService::batchCheckAvailability() + - get information (price, renewal period, possible actions) about all TLDs offered with Transip_DomainService::getAllTldInfos() and Transip_DomainService::getTldInfo() + - get the current running action a domain is doing and/or retry/cancel with getCurrentDomainAction(), retryCurrentDomainActionWithNewData(), retryTransferWithDifferentAuthCode(), cancelDomainAction() + - The domain object now holds information registrationDate, renewalDate, authCode and isLocked status + - Get all Colocation items with ColocationService::getColoNames() + - Manage IP/Network info with getIpRanges(), createIpAddress(), and more + - Manage, order and modify Forwards with the ForwardService + - Manage, order and modify Webhosting with the WebhostingService + +DEPRECATED: + - Transip_DomainService::getAuthCode(). Returned in Transip_DomainService::getInfo() now. + - Transip_DomainService::getIsLocked(). Returned in Transip_DomainService::getInfo() now. diff --git a/Transip/ApiSettings.php b/Transip/ApiSettings.php new file mode 100644 index 0000000..9a98a06 --- /dev/null +++ b/Transip/ApiSettings.php @@ -0,0 +1,43 @@ + diff --git a/Transip/ColocationService.php b/Transip/ColocationService.php new file mode 100644 index 0000000..3801ffc --- /dev/null +++ b/Transip/ColocationService.php @@ -0,0 +1,305 @@ +' . implode("

\n

", $errors) . '

'); + + $classMap = array( + 'DataCenterVisitor' => 'Transip_DataCenterVisitor', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('

Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('

Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const TRACK_ENDPOINT_NAME = 'Colocation'; + + /** + * Requests access to the data-center + * + * @param string $when the datetime of the wanted datacenter access, in YYYY-MM-DD hh:mm:ss format + * @param int $duration the expected duration of the visit, in minutes + * @param string[] $visitors the names of the visitors for this data-center visit, must be at least 1 and at most 20 + * @param string $phoneNumber if an SMS with access codes needs to be sent, set the phonenumber of the receiving phone here; + * @return Transip_DataCenterVisitor[] An array of Visitor objects holding information (such as reservation and access number) about + * @throws ApiException + */ + public static function requestAccess($when, $duration, $visitors, $phoneNumber) + { + return self::_getSoapClient(array_merge(array($when, $duration, $visitors, $phoneNumber), array('__method' => 'requestAccess')))->requestAccess($when, $duration, $visitors, $phoneNumber); + } + + /** + * Request remote hands to the data-center + * + * @param string $coloName The name of the colocation + * @param string $contactName The contact name + * @param string $phoneNumber Phone number to contact + * @param int $expectedDuration Expected duration of the job in minutes + * @param string $instructions What to do + * @throws ApiException + */ + public static function requestRemoteHands($coloName, $contactName, $phoneNumber, $expectedDuration, $instructions) + { + return self::_getSoapClient(array_merge(array($coloName, $contactName, $phoneNumber, $expectedDuration, $instructions), array('__method' => 'requestRemoteHands')))->requestRemoteHands($coloName, $contactName, $phoneNumber, $expectedDuration, $instructions); + } + + /** + * Get coloNames for customer + * + * @return string[] Array with colo names + */ + public static function getColoNames() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getColoNames')))->getColoNames(); + } + + /** + * Get IpAddresses that are active and assigned to a Colo. + * Both ipv4 and ipv6 addresses are returned: ipv4 adresses in dot notation, + * ipv6 addresses in ipv6 presentation. + * + * @param string $coloName The name of the colo to get the ipaddresses for for + * @return string[] Array with assigned IPv4 and IPv6 addresses for the colo + */ + public static function getIpAddresses($coloName) + { + return self::_getSoapClient(array_merge(array($coloName), array('__method' => 'getIpAddresses')))->getIpAddresses($coloName); + } + + /** + * Get ipranges that are assigned to a Colo. Both ipv4 and ipv6 ranges are + * returned, in CIDR notation. + * + * @param string $coloName The name of the colo to get the ranges for + * @see http://en.wikipedia.org/wiki/CIDR_notation + * @return string[] Array of ipranges in CIDR format assigned to this colo. + */ + public static function getIpRanges($coloName) + { + return self::_getSoapClient(array_merge(array($coloName), array('__method' => 'getIpRanges')))->getIpRanges($coloName); + } + + /** + * Adds a new IpAddress, either an ipv6 or an ipv4 address. + * The service will validate the address, ensure the user is entitled + * to the address and will add the address to the correct Colo and range. + * + * @param string $ipAddress The IpAddress to create, can be either ipv4 or ipv6. + * @param string $reverseDns The RDNS name for this IpAddress + * @throws ApiException + */ + public static function createIpAddress($ipAddress, $reverseDns) + { + return self::_getSoapClient(array_merge(array($ipAddress, $reverseDns), array('__method' => 'createIpAddress')))->createIpAddress($ipAddress, $reverseDns); + } + + /** + * Deletes an IpAddress currently in use this account. + * IpAddress can be either ipv4 or ipv6. The service will validate + * if the user has rights to remove the address and will remove it completely, + * together with any RDNS or monitoring assigned to the address. + * + * @param string $ipAddress the IpAddress to delete, can be either ipv4 or ipv6. + */ + public static function deleteIpAddress($ipAddress) + { + return self::_getSoapClient(array_merge(array($ipAddress), array('__method' => 'deleteIpAddress')))->deleteIpAddress($ipAddress); + } + + /** + * Get the Reverse DNS for an IpAddress assigned to the user + * Throws an Exception when the Address does not exist or is not + * owned by the user. + * + * @param string $ipAddress the IpAddress, either ipv4 or ipv6 + * @return string rdns + */ + public static function getReverseDns($ipAddress) + { + return self::_getSoapClient(array_merge(array($ipAddress), array('__method' => 'getReverseDns')))->getReverseDns($ipAddress); + } + + /** + * Set the RDNS name for an ipAddress. + * Throws an Exception when the Address does not exist or is not + * owned by the user. + * + * @param string $ipAddress The IpAddress to set the reverse dns for, can be either ipv4 or ipv6. + * @param string $reverseDns The new reverse DNS, must be a valid RDNS value. + */ + public static function setReverseDns($ipAddress, $reverseDns) + { + return self::_getSoapClient(array_merge(array($ipAddress, $reverseDns), array('__method' => 'setReverseDns')))->setReverseDns($ipAddress, $reverseDns); + } +} + +?> diff --git a/Transip/Cronjob.php b/Transip/Cronjob.php new file mode 100644 index 0000000..a93c0a1 --- /dev/null +++ b/Transip/Cronjob.php @@ -0,0 +1,102 @@ +name = $name; + $this->url = $url; + $this->email = $email; + $this->minuteTrigger = $minuteTrigger; + $this->hourTrigger = $hourTrigger; + $this->dayTrigger = $dayTrigger; + $this->monthTrigger = $monthTrigger; + $this->weekdayTrigger = $weekdayTrigger; + } +} + +?> diff --git a/Transip/DataCenterVisitor.php b/Transip/DataCenterVisitor.php new file mode 100644 index 0000000..38ddae0 --- /dev/null +++ b/Transip/DataCenterVisitor.php @@ -0,0 +1,42 @@ + diff --git a/Transip/Db.php b/Transip/Db.php new file mode 100644 index 0000000..6b9a8ce --- /dev/null +++ b/Transip/Db.php @@ -0,0 +1,49 @@ +name = $name; + $this->username = $username; + $this->maxDiskUsage = $maxDiskUsage; + } +} + +?> diff --git a/Transip/DnsEntry.php b/Transip/DnsEntry.php new file mode 100644 index 0000000..89dd520 --- /dev/null +++ b/Transip/DnsEntry.php @@ -0,0 +1,70 @@ +name = $name; + $this->expire = $expire; + $this->type = $type; + $this->content = $content; + } +} + +?> diff --git a/Transip/DnsSecEntry.php b/Transip/DnsSecEntry.php new file mode 100644 index 0000000..e9c0ef7 --- /dev/null +++ b/Transip/DnsSecEntry.php @@ -0,0 +1,86 @@ + 3, + 1 => 5, + 2 => 6, + 3 => 7, + 4 => 8, + 5 => 10, + 6 => 12, + 7 => 13, + 8 => 14, + 9 => 15, + 10 => 16, +); + const ALL_FLAGS = array ( + 0 => 0, + 1 => 256, + 2 => 257, +); + + /** + * + * + * @var int $keyTag + */ + public $keyTag; + + /** + * For all supported flags see Transip_DnsSecEntry::ALL_FLAGS + * + * @var int $flags + */ + public $flags; + + /** + * For all supported algorithms see Transip_DnsSecEntry::ALL_ALGORITHMS + * + * @var int $algorithm + */ + public $algorithm; + + /** + * + * + * @var string $publicKey + */ + public $publicKey; + + /** + * DnsSecEntry constructor. + * + */ + public function __construct($keyTag, $flags, $algorithm, $publicKey) + { + $this->keyTag = $keyTag; + $this->flags = $flags; + $this->algorithm = $algorithm; + $this->publicKey = $publicKey; + } +} + +?> diff --git a/Transip/DnsService.php b/Transip/DnsService.php new file mode 100644 index 0000000..8e7a50a --- /dev/null +++ b/Transip/DnsService.php @@ -0,0 +1,247 @@ +' . implode("

\n

", $errors) . '

'); + + $classMap = array( + 'DnsEntry' => 'Transip_DnsEntry', + 'DnsSecEntry' => 'Transip_DnsSecEntry', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('

Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('

Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const TRACK_ENDPOINT_NAME = 'Dns'; + + /** + * Sets the DnEntries for this Domain, will replace all existing dns entries with the new entries + * + * @param string $domainName the domainName to change the dns entries for

- domainName must meet the requirements for a domain name described in: RFC 952 + * @param Transip_DnsEntry[] $dnsEntries the list of new DnsEntries for this domain + * @example examples/DnsService-setDnsEntries.php + */ + public static function setDnsEntries($domainName, $dnsEntries) + { + return self::_getSoapClient(array_merge(array($domainName, $dnsEntries), array('__method' => 'setDnsEntries')))->setDnsEntries($domainName, $dnsEntries); + } + + /** + * Checks if the dnssec entries of a domain can be updated. + * + * @param string $domainName + * @return boolean + * @example examples/DnsService-setDnsSecEntries.php + */ + public static function canEditDnsSec($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'canEditDnsSec')))->canEditDnsSec($domainName); + } + + /** + * + * + * @param string $domainName + * @return Transip_DnsSecEntry[] + * @example examples/DnsService-getDnsSecEntries.php + */ + public static function getDnsSecEntries($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'getDnsSecEntries')))->getDnsSecEntries($domainName); + } + + /** + * Sets new DNSSEC key entries for a domain, replacing the current ones. + * + * @param string $domainName + * @param Transip_DnsSecEntry[] $dnssecKeyEntrySet + * @example examples/DnsService-setDnsSecEntries.php + */ + public static function setDnsSecEntries($domainName, $dnssecKeyEntrySet) + { + return self::_getSoapClient(array_merge(array($domainName, $dnssecKeyEntrySet), array('__method' => 'setDnsSecEntries')))->setDnsSecEntries($domainName, $dnssecKeyEntrySet); + } + + /** + * Remove all the DnsSecEntries from a domain. + * + * @param string $domainName + * @example examples/DnsService-setDnsSecEntries.php + */ + public static function removeAllDnsSecEntries($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'removeAllDnsSecEntries')))->removeAllDnsSecEntries($domainName); + } +} + +?> diff --git a/Transip/Domain.php b/Transip/Domain.php new file mode 100644 index 0000000..b7a6a3c --- /dev/null +++ b/Transip/Domain.php @@ -0,0 +1,105 @@ +RFC 952 + * + * @var string + */ + public $name = ''; + + /** + * The list of nameservers (with optional gluerecords) for this domain + * + * @var Transip_Nameserver[] + */ + public $nameservers = array(); + + /** + * The list of WhoisContacts for this domain + * + * @var Transip_WhoisContact[] + */ + public $contacts = array(); + + /** + * The list of DnsEntries for this domain + * + * @var Transip_DnsEntry[] + */ + public $dnsEntries = array(); + + /** + * The branding for this domain, some Tlds support additional + * whois- and transfer-branding which will be stored in this variable. + * Even if a Tld does not support branding, it will + * always be stored in this variable for consistency. + * + * @var Transip_DomainBranding + */ + public $branding; + + /** + * The authcode for this domain as generated by the registry. Read-only. + * + * @var string + * @readonly + */ + public $authCode = ''; + + /** + * If this domain supports locking, this flag is true when the domain is locked + * at the registry, false if not. Read-only. + * + * Use Transip_DomainService::setLock() to change the lock status of a domain. + * + * @var boolean + * @readonly + */ + public $isLocked = false; + + /** + * Registration date of the domain, in YYYY-mm-dd format. Read-only. + * + * @var string + * @readonly + */ + public $registrationDate = ''; + + /** + * Next renewal date of the domain, in YYYY-mm-dd format. Read-only. + * + * @var string + * @readonly + */ + public $renewalDate = ''; + + /** + * Constructs a new Domain + * + * @param string $name the domain name of the domain, including tld + * @param Nameserver[] $nameservers the list of nameservers (with optional gluerecords) for this domain + * @param WhoisContact[] $contacts the list of WhoisContacts for this domain + * @param DnsEntry[] $dnsEntries the list of DnsEntries for this domain + * @param DomainBranding $branding the branding for this domain, see the branding property for more info + */ + public function __construct($name, $nameservers = array(), $contacts = array(), $dnsEntries = array(), $branding = null) + { + $this->name = $name; + $this->nameservers = $nameservers; + $this->contacts = $contacts; + $this->dnsEntries = $dnsEntries; + $this->branding = $branding; + } +} + +?> diff --git a/Transip/DomainAction.php b/Transip/DomainAction.php new file mode 100644 index 0000000..ed0b56f --- /dev/null +++ b/Transip/DomainAction.php @@ -0,0 +1,35 @@ + diff --git a/Transip/DomainBranding.php b/Transip/DomainBranding.php new file mode 100644 index 0000000..72217f3 --- /dev/null +++ b/Transip/DomainBranding.php @@ -0,0 +1,62 @@ + diff --git a/Transip/DomainCheckResult.php b/Transip/DomainCheckResult.php new file mode 100644 index 0000000..4de75fa --- /dev/null +++ b/Transip/DomainCheckResult.php @@ -0,0 +1,45 @@ +RFC 952 + * + * @var string; + */ + public $domainName; + + /** + * The status for this domain, one of the Transip_DomainService::AVAILABILITY_* constants. + * + * @var string + */ + public $status; + + /** + * List of available actions to perform on this domain + * + * @var string[] + */ + public $actions; +} + +?> diff --git a/Transip/DomainService.php b/Transip/DomainService.php new file mode 100644 index 0000000..5650c93 --- /dev/null +++ b/Transip/DomainService.php @@ -0,0 +1,528 @@ +' . implode("

\n

", $errors) . '

'); + + $classMap = array( + 'DomainCheckResult' => 'Transip_DomainCheckResult', + 'Domain' => 'Transip_Domain', + 'Nameserver' => 'Transip_Nameserver', + 'WhoisContact' => 'Transip_WhoisContact', + 'DnsEntry' => 'Transip_DnsEntry', + 'DomainBranding' => 'Transip_DomainBranding', + 'Tld' => 'Transip_Tld', + 'DomainAction' => 'Transip_DomainAction', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('

Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('

Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const AVAILABILITY_INYOURACCOUNT = 'inyouraccount'; + const AVAILABILITY_UNAVAILABLE = 'unavailable'; + const AVAILABILITY_NOTFREE = 'notfree'; + const AVAILABILITY_FREE = 'free'; + const AVAILABILITY_INTERNALPULL = 'internalpull'; + const CANCELLATIONTIME_END = 'end'; + const CANCELLATIONTIME_IMMEDIATELY = 'immediately'; + const ACTION_REGISTER = 'register'; + const ACTION_TRANSFER = 'transfer'; + const ACTION_INTERNALPULL = 'internalpull'; + const TRACK_ENDPOINT_NAME = 'Domain'; + + /** + * Checks the availability of multiple domains. + * + * @param string[] $domainNames The domain names to check for availability.

- A maximum of 20 domainNames at once can be checked.
- domainNames must meet the requirements for a domain name described in: RFC 952 + * @example examples/DomainService-batchCheckAvailability.php + * @throws ApiException + * @return Transip_DomainCheckResult[] A list of DomainCheckResult objects, holding the domainName and the status per result. + */ + public static function batchCheckAvailability($domainNames) + { + return self::_getSoapClient(array_merge(array($domainNames), array('__method' => 'batchCheckAvailability')))->batchCheckAvailability($domainNames); + } + + /** + * Checks the availability of a domain. + * + * @param string $domainName The domain name to check for availability.

- domainName must meet the requirements for a domain name described in: RFC 952 + * @return string the availability status of the domain name:

- free the domain is free for registration
- notfree the domain is not free for new registration, but can possibly be transferred
- inyouraccount the domain is already in your account
- unavailable the domain is not available for registration + * @example examples/DomainService-checkAvailability.php + */ + public static function checkAvailability($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'checkAvailability')))->checkAvailability($domainName); + } + + /** + * Gets the whois of a domain name + * + * @param string $domainName the domain name to get the whois for

- domainName must meet the requirements for a domain name described in: RFC 952 + * @return string the whois data for the domain + * @throws ApiException + * @example examples/DomainService-getWhois.php + */ + public static function getWhois($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'getWhois')))->getWhois($domainName); + } + + /** + * Gets the names of all domains in your account. + * + * @return string[] A list of all domains in your account + * @example examples/DomainService-getDomainNames.php + */ + public static function getDomainNames() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getDomainNames')))->getDomainNames(); + } + + /** + * Get information about a domainName. + * + * @param string $domainName The domainName to get the information for.

- domainName must meet the requirements for a domain name described in: RFC 952 + * @example examples/DomainService-DomainService-getInfo.php + * @throws ApiException If the Domain could not be found. + * @return Transip_Domain A Domain object holding the data for the requested domainName. + */ + public static function getInfo($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'getInfo')))->getInfo($domainName); + } + + /** + * Get information about a list of Domain names. + * + * @param string[] $domainNames A list of Domain names you want information for.

- domainNames must meet the requirements for a domain name described in: RFC 952 + * @throws Exception If something else went wrong. + * @return Transip_Domain[] Domain objects. + */ + public static function batchGetInfo($domainNames) + { + return self::_getSoapClient(array_merge(array($domainNames), array('__method' => 'batchGetInfo')))->batchGetInfo($domainNames); + } + + /** + * Gets the Auth code for a domainName + * + * @param string $domainName the domainName to get the authcode for

- domainName must meet the requirements for a domain name described in: RFC 952 + * @deprecated + * @return string the authentication code for a domain name + * @example examples/DomainService-DomainService-getAuthCode.php + */ + public static function getAuthCode($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'getAuthCode')))->getAuthCode($domainName); + } + + /** + * Gets the lock status for a domainName + * + * @param string $domainName the domainName to get the lock status for

- domainName must meet the requirements for a domain name described in: RFC 952 + * @return boolean true iff the domain is locked at the registry + * @deprecated use getInfo() + */ + public static function getIsLocked($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'getIsLocked')))->getIsLocked($domainName); + } + + /** + * Registers a domain name, will automatically create and sign a proposition for it + * + * @param Transip_Domain $domain The Domain object holding information about the domain that needs to be registered. + * @requires readwrite mode + * @example examples/DomainService-DomainService-register-whois.php + * @return string proposition number + * @throws ApiException + */ + public static function register($domain) + { + return self::_getSoapClient(array_merge(array($domain), array('__method' => 'register')))->register($domain); + } + + /** + * Cancels a domain name, will automatically create and sign a cancellation document + * Please note that domains with webhosting cannot be cancelled through the API + * + * @param string $domainName The domainname that needs to be cancelled.

- domainName must meet the requirements for a domain name described in: RFC 952 + * @param string $endTime The time to cancel the domain (DomainService::CANCELLATIONTIME_END (end of contract) + * @requires readwrite mode + * @example examples/DomainService-DomainService-cancel.php + * @throws ApiException + */ + public static function cancel($domainName, $endTime) + { + return self::_getSoapClient(array_merge(array($domainName, $endTime), array('__method' => 'cancel')))->cancel($domainName, $endTime); + } + + /** + * Transfers a domain with changing the owner, not all TLDs support this (e.g. nl) + * + * @param Transip_Domain $domain the Domain object holding information about the domain that needs to be transfered + * @param string $authCode the authorization code for domains needing this for transfers (e.g. .com or .org transfers). Leave empty when n/a. + * @return string proposition number + * @requires readwrite mode + * @example examples/DomainService-DomainService-transfer.php + */ + public static function transferWithOwnerChange($domain, $authCode) + { + return self::_getSoapClient(array_merge(array($domain, $authCode), array('__method' => 'transferWithOwnerChange')))->transferWithOwnerChange($domain, $authCode); + } + + /** + * Transfers a domain without changing the owner + * + * @param Transip_Domain $domain the Domain object holding information about the domain that needs to be transfered + * @param string $authCode the authorization code for domains needing this for transfers (e.g. .com or .org transfers). Leave empty when n/a. + * @return string proposition number + * @requires readwrite mode + * @example examples/DomainService-DomainService-transfer.php + */ + public static function transferWithoutOwnerChange($domain, $authCode) + { + return self::_getSoapClient(array_merge(array($domain, $authCode), array('__method' => 'transferWithoutOwnerChange')))->transferWithoutOwnerChange($domain, $authCode); + } + + /** + * Starts a nameserver change for this domain, will replace all existing nameservers with the new nameservers + * + * @param string $domainName the domainName to change the nameservers for

domainName must meet the requirements for a domain name described in: RFC 952 + * @param Transip_Nameserver[] $nameservers the list of new nameservers for this domain + * @example examples/DomainService-DomainService-setNameservers.php + */ + public static function setNameservers($domainName, $nameservers) + { + return self::_getSoapClient(array_merge(array($domainName, $nameservers), array('__method' => 'setNameservers')))->setNameservers($domainName, $nameservers); + } + + /** + * Lock this domain in real time + * + * @param string $domainName the domainName to set the lock for

- domainName must meet the requirements for a domain name described in: RFC 952 + * @example examples/DomainService-DomainService-setLock.php + */ + public static function setLock($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'setLock')))->setLock($domainName); + } + + /** + * unlocks this domain in real time + * + * @param string $domainName the domainName to unlock

- domainName must meet the requirements for a domain name described in: RFC 952 + * @example examples/DomainService-DomainService-setLock.php + */ + public static function unsetLock($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'unsetLock')))->unsetLock($domainName); + } + + /** + * Sets the DnEntries for this Domain, will replace all existing dns entries with the new entries + * + * @param string $domainName the domainName to change the dns entries for

- domainName must meet the requirements for a domain name described in: RFC 952 + * @param Transip_DnsEntry[] $dnsEntries the list of new DnsEntries for this domain + * @deprecated Use DnsService.setDnsEntries instead. + */ + public static function setDnsEntries($domainName, $dnsEntries) + { + return self::_getSoapClient(array_merge(array($domainName, $dnsEntries), array('__method' => 'setDnsEntries')))->setDnsEntries($domainName, $dnsEntries); + } + + /** + * Starts an owner change of a Domain, brings additional costs with the following TLDs: + * .be + * + * @param string $domainName the domainName to change the owner for

- domainName must meet the requirements for a domain name described in: RFC 952 + * @param Transip_WhoisContact $registrantWhoisContact the new contact data for this + * @example examples/DomainService-DomainService-setOwner.php + * @throws ApiException + */ + public static function setOwner($domainName, $registrantWhoisContact) + { + return self::_getSoapClient(array_merge(array($domainName, $registrantWhoisContact), array('__method' => 'setOwner')))->setOwner($domainName, $registrantWhoisContact); + } + + /** + * Starts a contact change of a domain, this will replace all existing contacts + * + * @param string $domainName the domainName to change the contacts for

- domainName must meet the requirements for a domain name described in: RFC 952 + * @param Transip_WhoisContact[] $contacts the list of new contacts for this domain + * @throws ApiException + * @example examples/DomainService-DomainService-setContacts.php + */ + public static function setContacts($domainName, $contacts) + { + return self::_getSoapClient(array_merge(array($domainName, $contacts), array('__method' => 'setContacts')))->setContacts($domainName, $contacts); + } + + /** + * Get TransIP supported TLDs + * + * @return Transip_Tld[] Array of Tld objects + * @example examples/DomainService-DomainService-getAllTldInfos.php + */ + public static function getAllTldInfos() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAllTldInfos')))->getAllTldInfos(); + } + + /** + * Get info about a specific TLD + * + * @param string $tldName The tld to get information about.

- tldName must meet the requirements for a domain name described in: RFC 952 + * @example examples/DomainService-DomainService-getAllTldInfos.php + * @throws ApiException If the TLD could not be found. + * @return Transip_Tld Tld object with info about this Tld + */ + public static function getTldInfo($tldName) + { + return self::_getSoapClient(array_merge(array($tldName), array('__method' => 'getTldInfo')))->getTldInfo($tldName); + } + + /** + * Gets info about the action this domain is currently running + * + * @param string $domainName Name of the domain

- domainName must meet the requirements specified in: RFC 952. + * @return Transip_DomainAction if this domain is currently running an action, a corresponding DomainAction with info about the action will be returned. If there is no action running, null will be returned. + * @example examples/DomainService-DomainService-domainActions.php + */ + public static function getCurrentDomainAction($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'getCurrentDomainAction')))->getCurrentDomainAction($domainName); + } + + /** + * Retries a failed domain action with new domain data. The Domain#name field must contain + * the name of the Domain, the nameserver, contacts, dnsEntries fields contain the new data for this domain. + * Set a field to null to not change the data. + * + * @param Transip_Domain $domain The domain with data to retry + * @example examples/DomainService-DomainService-domainActions.php + * @throws ApiException + */ + public static function retryCurrentDomainActionWithNewData($domain) + { + return self::_getSoapClient(array_merge(array($domain), array('__method' => 'retryCurrentDomainActionWithNewData')))->retryCurrentDomainActionWithNewData($domain); + } + + /** + * Retry a transfer action with a new authcode + * + * @param Transip_Domain $domain The domain to try the transfer with a different authcode for + * @param string $newAuthCode New authorization code to try + * @example examples/DomainService-DomainService-domainActions.php + * @throws ApiException + */ + public static function retryTransferWithDifferentAuthCode($domain, $newAuthCode) + { + return self::_getSoapClient(array_merge(array($domain, $newAuthCode), array('__method' => 'retryTransferWithDifferentAuthCode')))->retryTransferWithDifferentAuthCode($domain, $newAuthCode); + } + + /** + * Cancels a failed domain action + * + * @param Transip_Domain $domain the domain to cancel the action for + * @example examples/DomainService-DomainService-domainActions.php + * @throws ApiException + */ + public static function cancelDomainAction($domain) + { + return self::_getSoapClient(array_merge(array($domain), array('__method' => 'cancelDomainAction')))->cancelDomainAction($domain); + } + + /** + * Request the authcode at the registry + * + * This function will request the authcode for domains at DNS.be and EURid from the registry + * + * @param string $domainName the domainNAme to request the autocode for

- domainName must meet the requirements for a domain name described in: RFC 952 + * @return string|null the authentication code for the domain name (or null) + * @throws ApiException + */ + public static function requestAuthCode($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'requestAuthCode')))->requestAuthCode($domainName); + } +} + +?> diff --git a/Transip/Forward.php b/Transip/Forward.php new file mode 100644 index 0000000..edf03f1 --- /dev/null +++ b/Transip/Forward.php @@ -0,0 +1,101 @@ +domainName = $domainName; + $this->forwardTo = $forwardTo; + $this->forwardMethod = $forwardMethod; + $this->frameTitle = $frameTitle; + $this->frameIcon = $frameIcon; + $this->forwardEverything = $forwardEverything; + $this->forwardSubdomains = $forwardSubdomains; + $this->forwardEmailTo = $forwardEmailTo; + } +} + +?> diff --git a/Transip/ForwardService.php b/Transip/ForwardService.php new file mode 100644 index 0000000..38fb036 --- /dev/null +++ b/Transip/ForwardService.php @@ -0,0 +1,240 @@ +' . implode("

\n

", $errors) . '

'); + + $classMap = array( + 'Forward' => 'Transip_Forward', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('

Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('

Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const CANCELLATIONTIME_END = 'end'; + const CANCELLATIONTIME_IMMEDIATELY = 'immediately'; + const TRACK_ENDPOINT_NAME = 'Forward'; + + /** + * Gets a list of all domains which have the Forward option enabled. + * + * @return string[] A list of all forwards enabled domains for the user + */ + public static function getForwardDomainNames() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getForwardDomainNames')))->getForwardDomainNames(); + } + + /** + * Gets information about a forwarded domain + * + * @param string $forwardDomainName The domain to get the info for + * @return Transip_Forward Forward object with all info if found, an exception otherwise + */ + public static function getInfo($forwardDomainName) + { + return self::_getSoapClient(array_merge(array($forwardDomainName), array('__method' => 'getInfo')))->getInfo($forwardDomainName); + } + + /** + * Order webhosting for a domain name + * + * @param Transip_Forward $forward info about the forward to order. Mandatory fields are $domainName. Other fields are optional. + */ + public static function order($forward) + { + return self::_getSoapClient(array_merge(array($forward), array('__method' => 'order')))->order($forward); + } + + /** + * Cancel webhosting for a domain + * + * @param string $forwardDomainName The domain name of the forward to cancel the forwarding service for + * @param string $endTime the time to cancel the domain (ForwardService::CANCELLATIONTIME_END (end of contract) or ForwardService::CANCELLATIONTIME_IMMEDIATELY (as soon as possible)) + */ + public static function cancel($forwardDomainName, $endTime) + { + return self::_getSoapClient(array_merge(array($forwardDomainName, $endTime), array('__method' => 'cancel')))->cancel($forwardDomainName, $endTime); + } + + /** + * Modify the options of a Forward. All fields set in the Forward object will be changed. + * + * @param Transip_Forward $forward The forward to modify + */ + public static function modify($forward) + { + return self::_getSoapClient(array_merge(array($forward), array('__method' => 'modify')))->modify($forward); + } +} + +?> diff --git a/Transip/Haip.php b/Transip/Haip.php new file mode 100644 index 0000000..9a593ef --- /dev/null +++ b/Transip/Haip.php @@ -0,0 +1,140 @@ + diff --git a/Transip/HaipService.php b/Transip/HaipService.php new file mode 100644 index 0000000..eee8324 --- /dev/null +++ b/Transip/HaipService.php @@ -0,0 +1,539 @@ +' . implode("

\n

", $errors) . '

'); + + $classMap = array( + 'Haip' => 'Transip_Haip', + 'Vps' => 'Transip_Vps', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('

Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('

Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const TRACK_ENDPOINT_NAME = 'HA-IP'; + const CANCELLATIONTIME_END = 'end'; + const CANCELLATIONTIME_IMMEDIATELY = 'immediately'; + + /** + * Get a HA-IP by name + * + * @param string $haipName The HA-IP name + * @throws ApiException + * @return Transip_Haip The vps objects + */ + public static function getHaip($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getHaip')))->getHaip($haipName); + } + + /** + * Get all HA-IPs + * + * @return Transip_Haip[] Array of HA-IP objects + */ + public static function getHaips() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getHaips')))->getHaips(); + } + + /** + * Changes the VPS connected to the HA-IP. + * + * @param string $haipName The HA-IP name + * @param string $vpsName The Vps name + * @throws ApiException + */ + public static function changeHaipVps($haipName, $vpsName) + { + return self::_getSoapClient(array_merge(array($haipName, $vpsName), array('__method' => 'changeHaipVps')))->changeHaipVps($haipName, $vpsName); + } + + /** + * Replaces currently attached VPSes to the HA-IP with the provided list of VPSes. + * + * @param string $haipName The HA-IP name + * @param string[] $vpsNames The Vps names + * @throws ApiException + */ + public static function setHaipVpses($haipName, $vpsNames) + { + return self::_getSoapClient(array_merge(array($haipName, $vpsNames), array('__method' => 'setHaipVpses')))->setHaipVpses($haipName, $vpsNames); + } + + /** + * Sets the provided IP setup for the HA-IP. + * + * @param string $haipName The HA-IP name + * @param string $ipSetup The IP setup ('both','noipv6','ipv6to4') + * @throws ApiException + */ + public static function setIpSetup($haipName, $ipSetup) + { + return self::_getSoapClient(array_merge(array($haipName, $ipSetup), array('__method' => 'setIpSetup')))->setIpSetup($haipName, $ipSetup); + } + + /** + * Sets the provided balancing mode for the HA-IP. The cookieName argument may be an empty string unless the + * balancing mode is set to 'cookie'. + * + * This is a HA-IP Pro feature. + * + * @param string $haipName The HA-IP name + * @param string $balancingMode The balancing mode ('roundrobin','cookie','source') + * @param string $cookieName The cookie name that pins the session if the balancing mode is 'cookie' + * @throws ApiException + */ + public static function setBalancingMode($haipName, $balancingMode, $cookieName) + { + return self::_getSoapClient(array_merge(array($haipName, $balancingMode, $cookieName), array('__method' => 'setBalancingMode')))->setBalancingMode($haipName, $balancingMode, $cookieName); + } + + /** + * Configures a HTTP health check for the HA-IP. To disable a HTTP health check use setTcpHealthCheck(). + * + * This is a HA-IP Pro feature. + * + * @param string $haipName The HA-IP name + * @param string $path The path that will be accessed when performing health checks + * @param int $port The port that will be used when performing health checks + * @throws ApiException + */ + public static function setHttpHealthCheck($haipName, $path, $port) + { + return self::_getSoapClient(array_merge(array($haipName, $path, $port), array('__method' => 'setHttpHealthCheck')))->setHttpHealthCheck($haipName, $path, $port); + } + + /** + * Configures a TCP health check for the HA-IP (this is the default health check). + * + * This is a HA-IP Pro feature. + * + * @param string $haipName The HA-IP name + * @throws ApiException + */ + public static function setTcpHealthCheck($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'setTcpHealthCheck')))->setTcpHealthCheck($haipName); + } + + /** + * Get a status report for the HA-IP. + * + * This is a HA-IP Pro feature. + * + * @param string $haipName The HA-IP name + * @throws ApiException + * @return array + */ + public static function getStatusReport($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getStatusReport')))->getStatusReport($haipName); + } + + /** + * Get all Certificates by Haip + * + * @param string $haipName + * @throws ApiException + * @return array + */ + public static function getCertificatesByHaip($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getCertificatesByHaip')))->getCertificatesByHaip($haipName); + } + + /** + * Get all available certificates ready to attach to your HAIP + * + * @param string $haipName + * @throws ApiException + * @return array + */ + public static function getAvailableCertificatesByHaip($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getAvailableCertificatesByHaip')))->getAvailableCertificatesByHaip($haipName); + } + + /** + * Add a HaipCertificate to this object + * + * @param string $haipName + * @param int $certificateId + * @throws ApiException + */ + public static function addCertificateToHaip($haipName, $certificateId) + { + return self::_getSoapClient(array_merge(array($haipName, $certificateId), array('__method' => 'addCertificateToHaip')))->addCertificateToHaip($haipName, $certificateId); + } + + /** + * Removes a Certificate from this HA-IP + * + * @param string $haipName + * @param int $certificateId + * @throws ApiException + */ + public static function deleteCertificateFromHaip($haipName, $certificateId) + { + return self::_getSoapClient(array_merge(array($haipName, $certificateId), array('__method' => 'deleteCertificateFromHaip')))->deleteCertificateFromHaip($haipName, $certificateId); + } + + /** + * Add EncryptCertificate to HA-IP + * + * @param string $haipName + * @param string $commonName + * @throws ApiException + */ + public static function startHaipLetsEncryptCertificateIssue($haipName, $commonName) + { + return self::_getSoapClient(array_merge(array($haipName, $commonName), array('__method' => 'startHaipLetsEncryptCertificateIssue')))->startHaipLetsEncryptCertificateIssue($haipName, $commonName); + } + + /** + * Returns the current ptr for the given HA-IP + * + * @param string $haipName + * @throws ApiException + * @return string + */ + public static function getPtrForHaip($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getPtrForHaip')))->getPtrForHaip($haipName); + } + + /** + * Update the ptr records for the given HA-IP + * + * @param string $haipName + * @param string $ptr + * @throws ApiException + */ + public static function setPtrForHaip($haipName, $ptr) + { + return self::_getSoapClient(array_merge(array($haipName, $ptr), array('__method' => 'setPtrForHaip')))->setPtrForHaip($haipName, $ptr); + } + + /** + * Update the description for HA-IP + * + * @param string $haipName + * @param string $description + * @throws ApiException + */ + public static function setHaipDescription($haipName, $description) + { + return self::_getSoapClient(array_merge(array($haipName, $description), array('__method' => 'setHaipDescription')))->setHaipDescription($haipName, $description); + } + + /** + * Get all port configurations for given HA-IP + * + * @param string $haipName The HA-IP name + * @deprecated Please use HaipService::getPortConfigurations() + * @throws ApiException + * @return array + */ + public static function getHaipPortConfigurations($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getHaipPortConfigurations')))->getHaipPortConfigurations($haipName); + } + + /** + * Get all port configurations for given HA-IP + * + * @param string $haipName The HA-IP name + * @throws ApiException + * @return array + */ + public static function getPortConfigurations($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'getPortConfigurations')))->getPortConfigurations($haipName); + } + + /** + * Set default port configurations for given HA-IP + * + * @param string $haipName The HA-IP name + * @throws ApiException + */ + public static function setDefaultPortConfiguration($haipName) + { + return self::_getSoapClient(array_merge(array($haipName), array('__method' => 'setDefaultPortConfiguration')))->setDefaultPortConfiguration($haipName); + } + + /** + * Add port configuration to HA-IP + * + * @param string $haipName The HA-IP name + * @param string $name The name describing the port configuration + * @param int $portNumber The port that is addressed on the HA-IP IP + * @param string $mode The port mode ('tcp','http','https','proxy') + * @deprecated Please use HaipService::addPortConfiguration() + * @throws ApiException + */ + public static function addHaipPortConfiguration($haipName, $name, $portNumber, $mode) + { + return self::_getSoapClient(array_merge(array($haipName, $name, $portNumber, $mode), array('__method' => 'addHaipPortConfiguration')))->addHaipPortConfiguration($haipName, $name, $portNumber, $mode); + } + + /** + * Add port configuration to HA-IP + * + * @param string $haipName The HA-IP name + * @param string $name The name describing the port configuration + * @param int $sourcePort The port that is addressed on the HA-IP IP + * @param int $targetPort The port that is addressed on the VPS + * @param string $mode The port mode ('tcp','http','https','proxy') + * @param string $endpointSslMode The SSL mode for the endpoint ('off','on','strict') + * @throws ApiException + */ + public static function addPortConfiguration($haipName, $name, $sourcePort, $targetPort, $mode, $endpointSslMode) + { + return self::_getSoapClient(array_merge(array($haipName, $name, $sourcePort, $targetPort, $mode, $endpointSslMode), array('__method' => 'addPortConfiguration')))->addPortConfiguration($haipName, $name, $sourcePort, $targetPort, $mode, $endpointSslMode); + } + + /** + * Update port configuration to HA-IP + * + * @param string $haipName The HA-IP name + * @param int $configurationId The identifier for the configuration + * @param string $name The name describing the port configuration + * @param int $portNumber The port that is addressed on the HA-IP IP + * @param string $mode The port mode ('tcp','http','https','proxy') + * @deprecated Please use HaipService::updatePortConfiguration() + * @throws ApiException + */ + public static function updateHaipPortConfiguration($haipName, $configurationId, $name, $portNumber, $mode) + { + return self::_getSoapClient(array_merge(array($haipName, $configurationId, $name, $portNumber, $mode), array('__method' => 'updateHaipPortConfiguration')))->updateHaipPortConfiguration($haipName, $configurationId, $name, $portNumber, $mode); + } + + /** + * Update port configuration to HA-IP + * + * @param string $haipName The HA-IP name + * @param int $configurationId The identifier for the configuration + * @param string $name The name describing the port configuration + * @param int $sourcePort The port that is addressed on the HA-IP IP + * @param int $targetPort The port that is addressed on the VPS + * @param string $mode The port mode ('tcp','http','https','proxy') + * @param string $endpointSslMode The SSL mode for the endpoint ('off','on','strict') + * @throws ApiException + */ + public static function updatePortConfiguration($haipName, $configurationId, $name, $sourcePort, $targetPort, $mode, $endpointSslMode) + { + return self::_getSoapClient(array_merge(array($haipName, $configurationId, $name, $sourcePort, $targetPort, $mode, $endpointSslMode), array('__method' => 'updatePortConfiguration')))->updatePortConfiguration($haipName, $configurationId, $name, $sourcePort, $targetPort, $mode, $endpointSslMode); + } + + /** + * Delete configuration with the provided id from the HA-IP. + * + * @param string $haipName The HA-IP name + * @param int $configurationId The identifier for the configuration + * @deprecated Please use HaipService::deletePortConfiguration() + * @throws ApiException + */ + public static function deleteHaipPortConfiguration($haipName, $configurationId) + { + return self::_getSoapClient(array_merge(array($haipName, $configurationId), array('__method' => 'deleteHaipPortConfiguration')))->deleteHaipPortConfiguration($haipName, $configurationId); + } + + /** + * + * + * @param string $haipName + * @param int $configurationId + * @throws ApiException + */ + public static function deletePortConfiguration($haipName, $configurationId) + { + return self::_getSoapClient(array_merge(array($haipName, $configurationId), array('__method' => 'deletePortConfiguration')))->deletePortConfiguration($haipName, $configurationId); + } + + /** + * Cancel a Haip + * + * @param string $haipName The vps to cancel + * @param string $endTime The time to cancel the haip (HaipService::CANCELLATIONTIME_END (end of contract) + * @throws ApiException on error + */ + public static function cancelHaip($haipName, $endTime) + { + return self::_getSoapClient(array_merge(array($haipName, $endTime), array('__method' => 'cancelHaip')))->cancelHaip($haipName, $endTime); + } +} + +?> diff --git a/Transip/MailBox.php b/Transip/MailBox.php new file mode 100644 index 0000000..db34c85 --- /dev/null +++ b/Transip/MailBox.php @@ -0,0 +1,80 @@ +address = $address; + $this->spamCheckerStrength = $spamCheckerStrength; + $this->maxDiskUsage = $maxDiskUsage; + $this->hasVacationReply = $hasVacationReply; + $this->vacationReplySubject = $vacationReplySubject; + $this->vacationReplyMessage = $vacationReplyMessage; + } +} + +?> diff --git a/Transip/MailForward.php b/Transip/MailForward.php new file mode 100644 index 0000000..b8f7342 --- /dev/null +++ b/Transip/MailForward.php @@ -0,0 +1,39 @@ +name = $name; + $this->targetAddress = $targetAddress; + } +} + +?> diff --git a/Transip/Nameserver.php b/Transip/Nameserver.php new file mode 100644 index 0000000..e492a9d --- /dev/null +++ b/Transip/Nameserver.php @@ -0,0 +1,50 @@ +hostname = $hostname; + $this->ipv4 = $ipv4; + $this->ipv6 = $ipv6; + } +} + +?> diff --git a/Transip/OperatingSystem.php b/Transip/OperatingSystem.php new file mode 100644 index 0000000..b7b1cb7 --- /dev/null +++ b/Transip/OperatingSystem.php @@ -0,0 +1,41 @@ + diff --git a/Transip/PrivateNetwork.php b/Transip/PrivateNetwork.php new file mode 100644 index 0000000..5c7a0f7 --- /dev/null +++ b/Transip/PrivateNetwork.php @@ -0,0 +1,20 @@ + diff --git a/Transip/Product.php b/Transip/Product.php new file mode 100644 index 0000000..9f84c26 --- /dev/null +++ b/Transip/Product.php @@ -0,0 +1,41 @@ + diff --git a/Transip/PropositionService.php b/Transip/PropositionService.php new file mode 100644 index 0000000..801a505 --- /dev/null +++ b/Transip/PropositionService.php @@ -0,0 +1,194 @@ +' . implode("

\n

", $errors) . '

'); + + $classMap = array( + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('

Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('

Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + /** + * Returns the status for a proposition number ('pending', 'finished' or 'invalid') + * + * @param string $propositionNumber + * @return string + * @throws ApiException + */ + public static function getPropositionStatus($propositionNumber) + { + return self::_getSoapClient(array_merge(array($propositionNumber), array('__method' => 'getPropositionStatus')))->getPropositionStatus($propositionNumber); + } +} + +?> diff --git a/Transip/Snapshot.php b/Transip/Snapshot.php new file mode 100644 index 0000000..f0d4310 --- /dev/null +++ b/Transip/Snapshot.php @@ -0,0 +1,41 @@ + diff --git a/Transip/SubDomain.php b/Transip/SubDomain.php new file mode 100644 index 0000000..dabc9ab --- /dev/null +++ b/Transip/SubDomain.php @@ -0,0 +1,30 @@ +name = $name; + } +} + +?> diff --git a/Transip/Tld.php b/Transip/Tld.php new file mode 100644 index 0000000..7cb301e --- /dev/null +++ b/Transip/Tld.php @@ -0,0 +1,70 @@ + diff --git a/Transip/Vps.php b/Transip/Vps.php new file mode 100644 index 0000000..5c6df40 --- /dev/null +++ b/Transip/Vps.php @@ -0,0 +1,125 @@ + diff --git a/Transip/VpsBackup.php b/Transip/VpsBackup.php new file mode 100644 index 0000000..6673bc3 --- /dev/null +++ b/Transip/VpsBackup.php @@ -0,0 +1,48 @@ + diff --git a/Transip/VpsService.php b/Transip/VpsService.php new file mode 100644 index 0000000..2d1f32e --- /dev/null +++ b/Transip/VpsService.php @@ -0,0 +1,702 @@ +' . implode("

\n

", $errors) . '

'); + + $classMap = array( + 'Product' => 'Transip_Product', + 'PrivateNetwork' => 'Transip_PrivateNetwork', + 'Vps' => 'Transip_Vps', + 'Snapshot' => 'Transip_Snapshot', + 'VpsBackup' => 'Transip_VpsBackup', + 'OperatingSystem' => 'Transip_OperatingSystem', + 'AvailabilityZone' => 'Transip_AvailabilityZone', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('

Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('

Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const CANCELLATIONTIME_END = 'end'; + const CANCELLATIONTIME_IMMEDIATELY = 'immediately'; + const TRACK_ENDPOINT_NAME = 'VPS'; + + /** + * Get available VPS products + * + * @return Transip_Product[] List of available VPS Products + */ + public static function getAvailableProducts() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAvailableProducts')))->getAvailableProducts(); + } + + /** + * Get available VPS addons + * + * @return Transip_Product[] List of available VPS Products + */ + public static function getAvailableAddons() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAvailableAddons')))->getAvailableAddons(); + } + + /** + * Get all the Active Addons for Vps + * + * @param string $vpsName The name of the VPS + * @return Transip_Product[] List of available VPS Products + */ + public static function getActiveAddonsForVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getActiveAddonsForVps')))->getActiveAddonsForVps($vpsName); + } + + /** + * Get available VPS upgrades for a specific Vps + * + * @param string $vpsName The name of the VPS + * @return Transip_Product[] List of available VPS Products + */ + public static function getAvailableUpgrades($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getAvailableUpgrades')))->getAvailableUpgrades($vpsName); + } + + /** + * Get available Addons for Vps + * + * @param string $vpsName The name of the VPS + * @return Transip_Product[] List of available VPS Products + */ + public static function getAvailableAddonsForVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getAvailableAddonsForVps')))->getAvailableAddonsForVps($vpsName); + } + + /** + * Get cancellable addons for specific Vps + * + * @param string $vpsName The name of the Vps + * @return Transip_Product[] List of cancellable addons for this Vps + */ + public static function getCancellableAddonsForVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getCancellableAddonsForVps')))->getCancellableAddonsForVps($vpsName); + } + + /** + * Order a VPS with optional Addons + * + * @param string $productName Name of the product + * @param string[] $addons array with additional addons + * @param string $operatingSystemName The name of the operatingSystem to install + * @param string $hostname The name for the host + * @throws Exception + */ + public static function orderVps($productName, $addons, $operatingSystemName, $hostname) + { + return self::_getSoapClient(array_merge(array($productName, $addons, $operatingSystemName, $hostname), array('__method' => 'orderVps')))->orderVps($productName, $addons, $operatingSystemName, $hostname); + } + + /** + * Order a VPS with optional Addons + * + * @param string $productName Name of the product + * @param string[] $addons array with additional addons + * @param string $operatingSystemName The name of the operatingSystem to install + * @param string $hostname The name for the host + * @param string $availabilityZone The availability zone the vps should be created in + * @throws Exception + */ + public static function orderVpsInAvailabilityZone($productName, $addons, $operatingSystemName, $hostname, $availabilityZone) + { + return self::_getSoapClient(array_merge(array($productName, $addons, $operatingSystemName, $hostname, $availabilityZone), array('__method' => 'orderVpsInAvailabilityZone')))->orderVpsInAvailabilityZone($productName, $addons, $operatingSystemName, $hostname, $availabilityZone); + } + + /** + * Clone a VPS + * + * @param string $vpsName The vps name + * @throws Exception + */ + public static function cloneVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'cloneVps')))->cloneVps($vpsName); + } + + /** + * Clone a VPS + * + * @param string $vpsName The vps name + * @param string $availabilityZone The availability zone the clone should be created in. + * @throws Exception + */ + public static function cloneVpsToAvailabilityZone($vpsName, $availabilityZone) + { + return self::_getSoapClient(array_merge(array($vpsName, $availabilityZone), array('__method' => 'cloneVpsToAvailabilityZone')))->cloneVpsToAvailabilityZone($vpsName, $availabilityZone); + } + + /** + * Order addons to a VPS + * + * @param string $vpsName The name of the VPS + * @param string[] $addons Array with Addons + * @throws ApiException on error + */ + public static function orderAddon($vpsName, $addons) + { + return self::_getSoapClient(array_merge(array($vpsName, $addons), array('__method' => 'orderAddon')))->orderAddon($vpsName, $addons); + } + + /** + * Order a private Network + * + * @throws ApiException on error + */ + public static function orderPrivateNetwork() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'orderPrivateNetwork')))->orderPrivateNetwork(); + } + + /** + * upgrade a Vps + * + * @param string $vpsName The name of the VPS + * @param string $upgradeToProductName The name of the product to upgrade to + * @throws ApiException on error + */ + public static function upgradeVps($vpsName, $upgradeToProductName) + { + return self::_getSoapClient(array_merge(array($vpsName, $upgradeToProductName), array('__method' => 'upgradeVps')))->upgradeVps($vpsName, $upgradeToProductName); + } + + /** + * Cancel a Vps + * + * @param string $vpsName The vps to cancel + * @param string $endTime The time to cancel the vps (VpsService::CANCELLATIONTIME_END (end of contract) + * @throws ApiException on error + */ + public static function cancelVps($vpsName, $endTime) + { + return self::_getSoapClient(array_merge(array($vpsName, $endTime), array('__method' => 'cancelVps')))->cancelVps($vpsName, $endTime); + } + + /** + * Cancel a Vps Addon + * + * @param string $vpsName The vps to cancel + * @param string $addonName name of the addon + * @throws ApiException on error + */ + public static function cancelAddon($vpsName, $addonName) + { + return self::_getSoapClient(array_merge(array($vpsName, $addonName), array('__method' => 'cancelAddon')))->cancelAddon($vpsName, $addonName); + } + + /** + * Cancel a PrivateNetwork + * + * @param string $privateNetworkName the name of the private network to cancel + * @param string $endTime The time to cancel the vps (VpsService::CANCELLATIONTIME_END (end of contract) + * @throws ApiException on error + */ + public static function cancelPrivateNetwork($privateNetworkName, $endTime) + { + return self::_getSoapClient(array_merge(array($privateNetworkName, $endTime), array('__method' => 'cancelPrivateNetwork')))->cancelPrivateNetwork($privateNetworkName, $endTime); + } + + /** + * Get Private networks for a specific vps + * + * @param string $vpsName The name of the VPS + * @return Transip_PrivateNetwork[] $privateNetworks Array of PrivateNetwork objects + */ + public static function getPrivateNetworksByVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getPrivateNetworksByVps')))->getPrivateNetworksByVps($vpsName); + } + + /** + * Get all Private networks in your account + * + * @return Transip_PrivateNetwork[] $privateNetworks Array of PrivateNetwork objects + */ + public static function getAllPrivateNetworks() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAllPrivateNetworks')))->getAllPrivateNetworks(); + } + + /** + * Add VPS to a private Network + * + * @param string $vpsName The name of the VPS + * @param string $privateNetworkName The name of the privateNetwork to add to + */ + public static function addVpsToPrivateNetwork($vpsName, $privateNetworkName) + { + return self::_getSoapClient(array_merge(array($vpsName, $privateNetworkName), array('__method' => 'addVpsToPrivateNetwork')))->addVpsToPrivateNetwork($vpsName, $privateNetworkName); + } + + /** + * Remove VPS from a private Network + * + * @param string $vpsName The name of the VPS + * @param string $privateNetworkName The name of the private Network + */ + public static function removeVpsFromPrivateNetwork($vpsName, $privateNetworkName) + { + return self::_getSoapClient(array_merge(array($vpsName, $privateNetworkName), array('__method' => 'removeVpsFromPrivateNetwork')))->removeVpsFromPrivateNetwork($vpsName, $privateNetworkName); + } + + /** + * Get Traffic information by vpsName for this contractPeriod + * + * @param string $vpsName The name of the VPS + * @throws ApiException on error + * @return array The traffic information for this VPS + */ + public static function getTrafficInformationForVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getTrafficInformationForVps')))->getTrafficInformationForVps($vpsName); + } + + /** + * Get PooledTraffic information for the account + * + * @return array + */ + public static function getPooledTrafficInformation() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getPooledTrafficInformation')))->getPooledTrafficInformation(); + } + + /** + * Start a Vps + * + * @param string $vpsName The vps name + * @throws ApiException on error + */ + public static function start($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'start')))->start($vpsName); + } + + /** + * Stop a Vps + * + * @param string $vpsName The vps name + * @throws ApiException on error + */ + public static function stop($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'stop')))->stop($vpsName); + } + + /** + * Reset a Vps + * + * @param string $vpsName The vps name + * @throws ApiException on error + */ + public static function reset($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'reset')))->reset($vpsName); + } + + /** + * Create a snapshot + * + * @param string $vpsName The vps name + * @param string $description The snapshot description + * @throws ApiException on error + */ + public static function createSnapshot($vpsName, $description) + { + return self::_getSoapClient(array_merge(array($vpsName, $description), array('__method' => 'createSnapshot')))->createSnapshot($vpsName, $description); + } + + /** + * Revert a snapshot + * + * @param string $vpsName The vps name + * @param string $snapshotName The snapshot name + * @throws ApiException on error + */ + public static function revertSnapshot($vpsName, $snapshotName) + { + return self::_getSoapClient(array_merge(array($vpsName, $snapshotName), array('__method' => 'revertSnapshot')))->revertSnapshot($vpsName, $snapshotName); + } + + /** + * Revert a snapshot to another VPS + * + * @param string $sourceVpsName The name of the VPS where the snapshot is made + * @param string $snapshotName The snapshot name + * @param string $destinationVpsName The name of the VPS where the snapshot should be reverted to + * @throws ApiException on error + */ + public static function revertSnapshotToOtherVps($sourceVpsName, $snapshotName, $destinationVpsName) + { + return self::_getSoapClient(array_merge(array($sourceVpsName, $snapshotName, $destinationVpsName), array('__method' => 'revertSnapshotToOtherVps')))->revertSnapshotToOtherVps($sourceVpsName, $snapshotName, $destinationVpsName); + } + + /** + * Remove a snapshot + * + * @param string $vpsName The vps name + * @param string $snapshotName The snapshot name + * @throws ApiException on error + */ + public static function removeSnapshot($vpsName, $snapshotName) + { + return self::_getSoapClient(array_merge(array($vpsName, $snapshotName), array('__method' => 'removeSnapshot')))->removeSnapshot($vpsName, $snapshotName); + } + + /** + * Revert a vps backup + * + * @param string $vpsName The vps name + * @param int $vpsBackupId The backup id + * @throws ApiException on error + */ + public static function revertVpsBackup($vpsName, $vpsBackupId) + { + return self::_getSoapClient(array_merge(array($vpsName, $vpsBackupId), array('__method' => 'revertVpsBackup')))->revertVpsBackup($vpsName, $vpsBackupId); + } + + /** + * Get a Vps by name + * + * @param string $vpsName The vps name + * @return Transip_Vps $vps The vps objects + */ + public static function getVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getVps')))->getVps($vpsName); + } + + /** + * Get all Vpses + * + * @return Transip_Vps[] Array of Vps objects + */ + public static function getVpses() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getVpses')))->getVpses(); + } + + /** + * Get all Snapshots for a vps + * + * @param string $vpsName The name of the VPS + * @return Transip_Snapshot[] $snapshotArray Array of snapshot objects + */ + public static function getSnapshotsByVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getSnapshotsByVps')))->getSnapshotsByVps($vpsName); + } + + /** + * Get all VpsBackups for a vps + * + * @param string $vpsName The name of the VPS + * @return Transip_VpsBackup[] $vpsBackupArray Array of snapshot objects + */ + public static function getVpsBackupsByVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getVpsBackupsByVps')))->getVpsBackupsByVps($vpsName); + } + + /** + * Get all operating systems + * + * @return Transip_OperatingSystem[] Array of OperatingSystem objects + */ + public static function getOperatingSystems() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getOperatingSystems')))->getOperatingSystems(); + } + + /** + * Install an operating system on a vps + * + * @param string $vpsName The name of the VPS + * @param string $operatingSystemName The name of the operating to install + * @param string $hostname preinstallable Only + */ + public static function installOperatingSystem($vpsName, $operatingSystemName, $hostname) + { + return self::_getSoapClient(array_merge(array($vpsName, $operatingSystemName, $hostname), array('__method' => 'installOperatingSystem')))->installOperatingSystem($vpsName, $operatingSystemName, $hostname); + } + + /** + * Install an operating system on a vps with a unattended installfile + * + * @param string $vpsName The name of the VPS + * @param string $operatingSystemName The name of the operating to install + * @param string $base64InstallText base64_encoded preseed/kickstart text + * @throws ApiException + */ + public static function installOperatingSystemUnattended($vpsName, $operatingSystemName, $base64InstallText) + { + return self::_getSoapClient(array_merge(array($vpsName, $operatingSystemName, $base64InstallText), array('__method' => 'installOperatingSystemUnattended')))->installOperatingSystemUnattended($vpsName, $operatingSystemName, $base64InstallText); + } + + /** + * Get Ips for a specific Vps + * + * @param string $vpsName The name of the Vps + * @return string[] $ipAddresses Array of ipAddresses + */ + public static function getIpsForVps($vpsName) + { + return self::_getSoapClient(array_merge(array($vpsName), array('__method' => 'getIpsForVps')))->getIpsForVps($vpsName); + } + + /** + * Get All ips + * + * @return string[] $ipAddresses Array of ipAddresses + */ + public static function getAllIps() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAllIps')))->getAllIps(); + } + + /** + * Add Ipv6 Address to Vps + * + * @param string $vpsName The name of the VPS + * @param string $ipv6Address The Ipv6 Address from your range + * @throws ApiException on error + */ + public static function addIpv6ToVps($vpsName, $ipv6Address) + { + return self::_getSoapClient(array_merge(array($vpsName, $ipv6Address), array('__method' => 'addIpv6ToVps')))->addIpv6ToVps($vpsName, $ipv6Address); + } + + /** + * Update PTR record (reverse DNS) for an ipAddress + * + * @param string $ipAddress The IP Address to update (ipv4 or ipv6) + * @param string $ptrRecord The PTR Record to update to + * @throws ApiException on error + */ + public static function updatePtrRecord($ipAddress, $ptrRecord) + { + return self::_getSoapClient(array_merge(array($ipAddress, $ptrRecord), array('__method' => 'updatePtrRecord')))->updatePtrRecord($ipAddress, $ptrRecord); + } + + /** + * Enable or Disable a Customer Lock for a Vps + * + * @param string $vpsName The name of the Vps + * @param boolean $enabled Enable (true) or Disable (false) the lock + * @throws ApiException on error + */ + public static function setCustomerLock($vpsName, $enabled) + { + return self::_getSoapClient(array_merge(array($vpsName, $enabled), array('__method' => 'setCustomerLock')))->setCustomerLock($vpsName, $enabled); + } + + /** + * Handover a VPS to another TransIP User + * + * @param string $vpsName The name of the Vps + * @param string $targetAccountname the target account name + * @throws ApiException on error + */ + public static function handoverVps($vpsName, $targetAccountname) + { + return self::_getSoapClient(array_merge(array($vpsName, $targetAccountname), array('__method' => 'handoverVps')))->handoverVps($vpsName, $targetAccountname); + } + + /** + * Returns an array of available AvailabilityZones + * + * @return Transip_AvailabilityZone[] an array of AvailabilityZones + */ + public static function getAvailableAvailabilityZones() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAvailableAvailabilityZones')))->getAvailableAvailabilityZones(); + } +} + +?> diff --git a/Transip/WebHost.php b/Transip/WebHost.php new file mode 100644 index 0000000..c630a0b --- /dev/null +++ b/Transip/WebHost.php @@ -0,0 +1,60 @@ + diff --git a/Transip/WebhostingPackage.php b/Transip/WebhostingPackage.php new file mode 100644 index 0000000..34b2412 --- /dev/null +++ b/Transip/WebhostingPackage.php @@ -0,0 +1,41 @@ + diff --git a/Transip/WebhostingService.php b/Transip/WebhostingService.php new file mode 100644 index 0000000..7f4062b --- /dev/null +++ b/Transip/WebhostingService.php @@ -0,0 +1,474 @@ +' . implode("

\n

", $errors) . '

'); + + $classMap = array( + 'WebhostingPackage' => 'Transip_WebhostingPackage', + 'WebHost' => 'Transip_WebHost', + 'Cronjob' => 'Transip_Cronjob', + 'MailBox' => 'Transip_MailBox', + 'Db' => 'Transip_Db', + 'MailForward' => 'Transip_MailForward', + 'SubDomain' => 'Transip_SubDomain', + ); + + $options = array( + 'classmap' => $classMap, + 'encoding' => 'utf-8', // lets support unicode + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338 + 'trace' => false, // can be used for debugging + ); + + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; + try + { + self::$_soapClient = new SoapClient($wsdlUri, $options); + } + catch(SoapFault $sf) + { + throw new Exception("Unable to connect to endpoint '{$endpoint}'"); + } + self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); + self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); + } + + $timestamp = time(); + $nonce = uniqid('', true); + + self::$_soapClient->__setCookie('timestamp', $timestamp); + self::$_soapClient->__setCookie('nonce', $nonce); + self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); + self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array( + '__service' => self::SERVICE, + '__hostname' => $endpoint, + '__timestamp' => $timestamp, + '__nonce' => $nonce + ))))); + + return self::$_soapClient; + } + + /** + * Calculates the hash to sign our request with based on the given parameters. + * + * @param mixed $parameters The parameters to sign. + * @return string Base64 encoded signing hash. + */ + protected static function _sign($parameters) + { + // Fixup our private key, copy-pasting the key might lead to whitespace faults + if(!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', Transip_ApiSettings::$privateKey, $matches)) + die('

Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + $key = $matches[2]; + $key = preg_replace('/\s*/s', '', $key); + $key = chunk_split($key, 64, "\n"); + + $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----"; + + $digest = self::_sha512Asn1(self::_encodeParameters($parameters)); + if(!@openssl_private_encrypt($digest, $signature, $key)) + die('

Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.

'); + + return base64_encode($signature); + } + + /** + * Creates a digest of the given data, with an asn1 header. + * + * @param string $data The data to create a digest of. + * @return string The digest of the data, with asn1 header. + */ + protected static function _sha512Asn1($data) + { + $digest = hash('sha512', $data, true); + + // this ASN1 header is sha512 specific + $asn1 = chr(0x30).chr(0x51); + $asn1 .= chr(0x30).chr(0x0d); + $asn1 .= chr(0x06).chr(0x09); + $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); + $asn1 .= chr(0x03).chr(0x04); + $asn1 .= chr(0x02).chr(0x03); + $asn1 .= chr(0x05).chr(0x00); + $asn1 .= chr(0x04).chr(0x40); + $asn1 .= $digest; + + return $asn1; + } + + /** + * Encodes the given paramaters into a url encoded string based upon RFC 3986. + * + * @param mixed $parameters The parameters to encode. + * @param string $keyPrefix Key prefix. + * @return string The given parameters encoded according to RFC 3986. + */ + protected static function _encodeParameters($parameters, $keyPrefix = null) + { + if(!is_array($parameters) && !is_object($parameters)) + return self::_urlencode($parameters); + + $encodedData = array(); + + foreach($parameters as $key => $value) + { + $encodedKey = is_null($keyPrefix) + ? self::_urlencode($key) + : $keyPrefix . '[' . self::_urlencode($key) . ']'; + + if(is_array($value) || is_object($value)) + { + $encodedData[] = self::_encodeParameters($value, $encodedKey); + } + else + { + $encodedData[] = $encodedKey . '=' . self::_urlencode($value); + } + } + + return implode('&', $encodedData); + } + + /** + * Our own function to encode a string according to RFC 3986 since. + * PHP < 5.3.0 encodes the ~ character which is not allowed. + * + * @param string $string The string to encode. + * @return string The encoded string according to RFC 3986. + */ + protected static function _urlencode($string) + { + $string = trim($string); + $string = rawurlencode($string); + return str_replace('%7E', '~', $string); + } + + const CANCELLATIONTIME_END = 'end'; + const CANCELLATIONTIME_IMMEDIATELY = 'immediately'; + const TRACK_ENDPOINT_NAME = 'Webhosting'; + + /** + * Get all domain names that have a webhosting package attached to them. + * + * @return string[] List of domain names that have a webhosting package + */ + public static function getWebhostingDomainNames() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getWebhostingDomainNames')))->getWebhostingDomainNames(); + } + + /** + * Get available webhosting packages + * + * @return Transip_WebhostingPackage[] List of available webhosting packages + */ + public static function getAvailablePackages() + { + return self::_getSoapClient(array_merge(array(), array('__method' => 'getAvailablePackages')))->getAvailablePackages(); + } + + /** + * Get information about existing webhosting on a domain. + * + * Please be aware that the information returned is outdated when + * a modifying function in Transip_WebhostingService is called (e.g. createCronjob()). + * + * Call this function again to refresh the info. + * + * @param string $domainName The domain name of the webhosting package to get the info for. Must be owned by this user + * @return Transip_WebHost WebHost object with all info about the requested webhosting package + */ + public static function getInfo($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'getInfo')))->getInfo($domainName); + } + + /** + * Order webhosting for a domain name + * + * @param string $domainName The domain name to order the webhosting for. Must be owned by this user + * @param Transip_WebhostingPackage $webhostingPackage The webhosting Package to order, one of the packages returned by Transip_WebhostingService::getAvailablePackages() + * @throws ApiException on error + */ + public static function order($domainName, $webhostingPackage) + { + return self::_getSoapClient(array_merge(array($domainName, $webhostingPackage), array('__method' => 'order')))->order($domainName, $webhostingPackage); + } + + /** + * Get available upgrades packages for a domain name with webhosting. Only those packages will be returned to which + * the given domain name can be upgraded to. + * + * @param string $domainName Domain to get upgrades for. Must be owned by the current user. + * @return Transip_WebhostingPackage[] Available packages to which the domain name can be upgraded to. + * @throws ApiException Throwns an Exception ig the domain is not found in the requester account + */ + public static function getAvailableUpgrades($domainName) + { + return self::_getSoapClient(array_merge(array($domainName), array('__method' => 'getAvailableUpgrades')))->getAvailableUpgrades($domainName); + } + + /** + * Upgrade the webhosting of a domain name to a new webhosting package to a given new package. + * + * @param string $domainName The domain to upgrade webhosting for. Must be owned by the current user. + * @param string $newWebhostingPackage The new webhosting package, must be one of the packages returned getAvailableUpgrades() for the given domain name + * @throws ApiException Throws an exception when the domain name does not belong to the requester (or is not found) or the package can't be upgraded + */ + public static function upgrade($domainName, $newWebhostingPackage) + { + return self::_getSoapClient(array_merge(array($domainName, $newWebhostingPackage), array('__method' => 'upgrade')))->upgrade($domainName, $newWebhostingPackage); + } + + /** + * Cancel webhosting for a domain + * + * @param string $domainName The domain to cancel the webhosting for + * @param string $endTime the time to cancel the domain (WebhostingService::CANCELLATIONTIME_END (end of contract) or WebhostingService::CANCELLATIONTIME_IMMEDIATELY (as soon as possible)) + * @throws ApiException Throws an exception when the domain name does not belong to the requester (or is not found). + */ + public static function cancel($domainName, $endTime) + { + return self::_getSoapClient(array_merge(array($domainName, $endTime), array('__method' => 'cancel')))->cancel($domainName, $endTime); + } + + /** + * Set a new FTP password for a webhosting package + * + * @param string $domainName Domain to set webhosting FTP password for + * @param string $newPassword The new FTP password for the webhosting package + * @throws ApiException When the new password is empty + */ + public static function setFtpPassword($domainName, $newPassword) + { + return self::_getSoapClient(array_merge(array($domainName, $newPassword), array('__method' => 'setFtpPassword')))->setFtpPassword($domainName, $newPassword); + } + + /** + * Create a cronjob + * + * @param string $domainName the domain name of the webhosting package to create cronjob for + * @param Transip_Cronjob $cronjob the cronjob to create. All fields must be valid. + * @throws ApiException When the new URL is either invalid or the URL is not a URL linking to the domain the CronJob is for. + */ + public static function createCronjob($domainName, $cronjob) + { + return self::_getSoapClient(array_merge(array($domainName, $cronjob), array('__method' => 'createCronjob')))->createCronjob($domainName, $cronjob); + } + + /** + * Delete a cronjob from a webhosting package. + * Note, all completely matching cronjobs will be removed + * + * @param string $domainName the domain name of the webhosting package to delete a cronjob + * @param Transip_Cronjob $cronjob Cronjob the cronjob to delete. Be aware that all matching cronjobs will be removed. + * @throws ApiException When the CronJob that needs to be deleted is not found. + */ + public static function deleteCronjob($domainName, $cronjob) + { + return self::_getSoapClient(array_merge(array($domainName, $cronjob), array('__method' => 'deleteCronjob')))->deleteCronjob($domainName, $cronjob); + } + + /** + * Creates a MailBox for a webhosting package. + * The address field of the MailBox object must be unique. + * + * @param string $domainName the domain name of the webhosting package to create the mailbox for + * @param Transip_MailBox $mailBox MailBox object to create + */ + public static function createMailBox($domainName, $mailBox) + { + return self::_getSoapClient(array_merge(array($domainName, $mailBox), array('__method' => 'createMailBox')))->createMailBox($domainName, $mailBox); + } + + /** + * Modifies MailBox settings + * + * @param string $domainName the domain name of the webhosting package to modify the mailbox for + * @param Transip_MailBox $mailBox the MailBox to modify + * @throws ApiException When the MailBox that needs to be modified is not found. + */ + public static function modifyMailBox($domainName, $mailBox) + { + return self::_getSoapClient(array_merge(array($domainName, $mailBox), array('__method' => 'modifyMailBox')))->modifyMailBox($domainName, $mailBox); + } + + /** + * Sets a new password for a MailBox + * + * @param string $domainName the domain name of the webhosting package to set the mailbox password for + * @param Transip_MailBox $mailBox the MailBox to set the password for + * @param string $newPassword the new password for the MailBox, cannot be empty. + * @throws ApiException When the MailBox that needs to be modified is not found. + */ + public static function setMailBoxPassword($domainName, $mailBox, $newPassword) + { + return self::_getSoapClient(array_merge(array($domainName, $mailBox, $newPassword), array('__method' => 'setMailBoxPassword')))->setMailBoxPassword($domainName, $mailBox, $newPassword); + } + + /** + * Deletes a MailBox from a webhosting package + * + * @param string $domainName the domain name of the webhosting package to remove the MailBox from + * @param Transip_MailBox $mailBox the mailbox object to remove + * @throws ApiException When the MailBox that needs to be deleted is not found. + */ + public static function deleteMailBox($domainName, $mailBox) + { + return self::_getSoapClient(array_merge(array($domainName, $mailBox), array('__method' => 'deleteMailBox')))->deleteMailBox($domainName, $mailBox); + } + + /** + * Creates a MailForward for a webhosting package + * + * @param string $domainName the domain name of the webhosting package to add the MailForward to + * @param Transip_MailForward $mailForward The MailForward object to create + */ + public static function createMailForward($domainName, $mailForward) + { + return self::_getSoapClient(array_merge(array($domainName, $mailForward), array('__method' => 'createMailForward')))->createMailForward($domainName, $mailForward); + } + + /** + * Changes an active MailForward object + * + * @param string $domainName the domain name of the webhosting package to modify the MailForward from + * @param Transip_MailForward $mailForward the MailForward to modify + * @throws ApiException When the MailForward that needs to be modified is not found. + */ + public static function modifyMailForward($domainName, $mailForward) + { + return self::_getSoapClient(array_merge(array($domainName, $mailForward), array('__method' => 'modifyMailForward')))->modifyMailForward($domainName, $mailForward); + } + + /** + * Deletes an active MailForward object + * + * @param string $domainName the domain name of the webhosting package to delete the MailForward from + * @param Transip_MailForward $mailForward the MailForward to delete + */ + public static function deleteMailForward($domainName, $mailForward) + { + return self::_getSoapClient(array_merge(array($domainName, $mailForward), array('__method' => 'deleteMailForward')))->deleteMailForward($domainName, $mailForward); + } + + /** + * Creates a new database + * + * @param string $domainName the domain name of the webhosting package to create the Db for + * @param Transip_Db $db Db object to create + */ + public static function createDatabase($domainName, $db) + { + return self::_getSoapClient(array_merge(array($domainName, $db), array('__method' => 'createDatabase')))->createDatabase($domainName, $db); + } + + /** + * Changes a Db object + * + * @param string $domainName the domain name of the webhosting package to change the Db for + * @param Transip_Db $db The db object to modify + */ + public static function modifyDatabase($domainName, $db) + { + return self::_getSoapClient(array_merge(array($domainName, $db), array('__method' => 'modifyDatabase')))->modifyDatabase($domainName, $db); + } + + /** + * Sets A database password for a Db + * + * @param string $domainName the domain name of the webhosting package of the Db to change the password for + * @param Transip_Db $db Modified database object to save + * @param string $newPassword New password for the database + */ + public static function setDatabasePassword($domainName, $db, $newPassword) + { + return self::_getSoapClient(array_merge(array($domainName, $db, $newPassword), array('__method' => 'setDatabasePassword')))->setDatabasePassword($domainName, $db, $newPassword); + } + + /** + * Deletes a Db object + * + * @param string $domainName the domain name of the webhosting package to delete the Db for + * @param Transip_Db $db Db object to remove + * @throws ApiException When the Database that needs to be deleted is not found. + */ + public static function deleteDatabase($domainName, $db) + { + return self::_getSoapClient(array_merge(array($domainName, $db), array('__method' => 'deleteDatabase')))->deleteDatabase($domainName, $db); + } + + /** + * Creates a SubDomain + * + * @param string $domainName the domain name of the webhosting package to create the SubDomain for + * @param Transip_SubDomain $subDomain SubDomain object to create + */ + public static function createSubdomain($domainName, $subDomain) + { + return self::_getSoapClient(array_merge(array($domainName, $subDomain), array('__method' => 'createSubdomain')))->createSubdomain($domainName, $subDomain); + } + + /** + * Deletes a SubDomain + * + * @param string $domainName the domain name of the webhosting package to delete the SubDomain for + * @param Transip_SubDomain $subDomain SubDomain object to delete + * @throws ApiException When the Subdomain that needs to be deleted is not found. + */ + public static function deleteSubdomain($domainName, $subDomain) + { + return self::_getSoapClient(array_merge(array($domainName, $subDomain), array('__method' => 'deleteSubdomain')))->deleteSubdomain($domainName, $subDomain); + } +} + +?> diff --git a/Transip/WhoisContact.php b/Transip/WhoisContact.php new file mode 100644 index 0000000..79307e0 --- /dev/null +++ b/Transip/WhoisContact.php @@ -0,0 +1,403 @@ + 'BV - Besloten Vennootschap', + 'BVI/O' => 'BV i.o. - BV in oprichting', + 'COOP' => 'Cooperatie', + 'CV' => 'CV - Commanditaire Vennootschap', + 'EENMANSZAAK' => 'Eenmanszaak', + 'KERK' => 'Kerkgenootschap', + 'NV' => 'NV - Naamloze Vennootschap', + 'OWM' => 'Onderlinge Waarborg Maatschappij', + 'REDR' => 'Rederij', + 'STICHTING' => 'Stichting', + 'VERENIGING' => 'Vereniging', + 'VOF' => 'VoF - Vennootschap onder firma', + 'BEG' => 'Buitenlandse EG vennootschap', + 'BRO' => 'Buitenlandse rechtsvorm/onderneming', + 'EESV' => 'Europees Economisch Samenwerkingsverband', + 'ANDERS' => 'Anders', + '' => 'Geen', + ); + + /** + * The possible country codes with their respective english names + * + * @var array + * @nosoap + */ + public static $possibleCountryCodes = array ( + 'af' => 'Afghanistan', + 'al' => 'Albania', + 'dz' => 'Algeria', + 'as' => 'American Samoa', + 'ad' => 'Andorra', + 'ao' => 'Angola', + 'ai' => 'Anguilla', + 'aq' => 'Antarctica', + 'ag' => 'Antigua and Barbuda', + 'ar' => 'Argentina', + 'am' => 'Armenia', + 'aw' => 'Aruba', + 'au' => 'Australia', + 'at' => 'Austria', + 'az' => 'Azerbaijan', + 'bs' => 'Bahamas', + 'bh' => 'Bahrain', + 'bd' => 'Bangladesh', + 'bb' => 'Barbados', + 'by' => 'Belarus', + 'be' => 'Belgium', + 'bz' => 'Belize', + 'bj' => 'Benin', + 'bm' => 'Bermuda', + 'bt' => 'Bhutan', + 'bo' => 'Bolivia', + 'ba' => 'Bosnia and Herzegovina', + 'bw' => 'Botswana', + 'bv' => 'Bouvet Island', + 'br' => 'Brazil', + 'io' => 'British Indian Ocean Territory', + 'bn' => 'Brunei Darussalem', + 'bg' => 'Bulgaria', + 'bf' => 'Burkina Faso', + 'bi' => 'Burundi', + 'kh' => 'Cambodia', + 'cm' => 'Cameroon', + 'ca' => 'Canada', + 'cv' => 'Cape Verde', + 'ky' => 'Cayman Islands', + 'cf' => 'Central African Republic', + 'td' => 'Chad', + 'cl' => 'Chile', + 'cn' => 'China', + 'cx' => 'Christmas Island', + 'cc' => 'Cocos (Keeling) Islands', + 'co' => 'Colombia', + 'km' => 'Comoros', + 'cg' => 'Congo', + 'cd' => 'Congo, the Democratic Republic of the', + 'ck' => 'Cook Islands', + 'cr' => 'Costa Rica', + 'hr' => 'Croatia', + 'cu' => 'Cuba', + 'cy' => 'Cyprus', + 'cz' => 'Czech Republic', + 'ci' => 'Côte d\'Ivoire', + 'dk' => 'Denmark', + 'dj' => 'Djibouti', + 'dm' => 'Dominica', + 'do' => 'Dominican Republic', + 'ec' => 'Ecuador', + 'eg' => 'Egypt', + 'sv' => 'El Salvador', + 'gq' => 'Equatorial Guinea', + 'er' => 'Eritrea', + 'ee' => 'Estonia', + 'et' => 'Ethiopia', + 'fk' => 'Falkland Islands (Malvinas)', + 'fo' => 'Faroe Islands', + 'fj' => 'Fiji', + 'fi' => 'Finland', + 'fr' => 'France', + 'gf' => 'French Guiana', + 'pf' => 'French Polynesia', + 'tf' => 'French Southern Territories', + 'ga' => 'Gabon', + 'gm' => 'Gambia', + 'ge' => 'Georgia', + 'de' => 'Germany', + 'gh' => 'Ghana', + 'gi' => 'Gibraltar', + 'gr' => 'Greece', + 'gl' => 'Greenland', + 'gd' => 'Grenada', + 'gp' => 'Guadeloupe', + 'gu' => 'Guam', + 'gt' => 'Guatemala', + 'gg' => 'Guernsey', + 'gn' => 'Guinea', + 'gw' => 'Guinea-Bissau', + 'gy' => 'Guyana', + 'ht' => 'Haiti', + 'hm' => 'Heard Island and McDonald Islands', + 'va' => 'Holy See (Vatican City State)', + 'hn' => 'Honduras', + 'hk' => 'Hong Kong', + 'hu' => 'Hungary', + 'is' => 'Iceland', + 'in' => 'India', + 'id' => 'Indonesia', + 'ir' => 'Iran, Islamic Republic of', + 'iq' => 'Iraq', + 'ie' => 'Ireland', + 'im' => 'Isle of Man', + 'il' => 'Israel', + 'it' => 'Italy', + 'jm' => 'Jamaica', + 'jp' => 'Japan', + 'je' => 'Jersey', + 'jo' => 'Jordan', + 'kz' => 'Kazakhstan', + 'ke' => 'Kenya', + 'ki' => 'Kiribati', + 'kp' => 'Korea, Democratic People\'s Republic of', + 'kr' => 'Korea, Republic of', + 'kw' => 'Kuwait', + 'kg' => 'Kyrgyzstan', + 'la' => 'Lao People\'s Democratic Republic', + 'lv' => 'Latvia', + 'lb' => 'Lebanon', + 'ls' => 'Lesotho', + 'lr' => 'Liberia', + 'ly' => 'Libyan Arab Jamahiriya', + 'li' => 'Liechtenstein', + 'lt' => 'Lithuania', + 'lu' => 'Luxembourg', + 'mo' => 'Macao', + 'mk' => 'Macedonia, the former Yugoslav Republic of', + 'mg' => 'Madagascar', + 'mw' => 'Malawi', + 'my' => 'Malaysia', + 'mv' => 'Maldives', + 'ml' => 'Mali', + 'mt' => 'Malta', + 'mh' => 'Marshall Islands', + 'mq' => 'Martinique', + 'mr' => 'Mauritania', + 'mu' => 'Mauritius', + 'yt' => 'Mayotte', + 'mx' => 'Mexico', + 'fm' => 'Micronesia, Federated States of', + 'md' => 'Moldova', + 'mc' => 'Monaco', + 'mn' => 'Mongolia', + 'me' => 'Montenegro', + 'ms' => 'Montserrat', + 'ma' => 'Morocco', + 'mz' => 'Mozambique', + 'mm' => 'Myanmar', + 'na' => 'Namibia', + 'nr' => 'Nauru', + 'np' => 'Nepal', + 'nl' => 'Netherlands', + 'an' => 'Netherlands Antilles', + 'nc' => 'New Caledonia', + 'nz' => 'New Zealand', + 'ni' => 'Nicaragua', + 'ne' => 'Niger', + 'ng' => 'Nigeria', + 'nu' => 'Niue', + 'nf' => 'Norfolk Island', + 'mp' => 'Northern Mariana Islands', + 'no' => 'Norway', + 'om' => 'Oman', + 'pk' => 'Pakistan', + 'pw' => 'Palau', + 'ps' => 'Palestinian Territory, Occupied', + 'pa' => 'Panama', + 'pg' => 'Papua New Guinea', + 'py' => 'Paraguay', + 'pe' => 'Peru', + 'ph' => 'Philippines', + 'pn' => 'Pitcairn', + 'pl' => 'Poland', + 'pt' => 'Portugal', + 'pr' => 'Puerto Rico', + 'qa' => 'Qatar', + 'ro' => 'Romania', + 'ru' => 'Russian Federation', + 'rw' => 'Rwanda', + 're' => 'Réunion', + 'bl' => 'Saint Barthélemy', + 'sh' => 'Saint Helena', + 'kn' => 'Saint Kitts and Nevis', + 'lc' => 'Saint Lucia', + 'mf' => 'Saint Martin (French part)', + 'pm' => 'Saint Pierre and Miquelon', + 'vc' => 'Saint Vincent and the Grenadines', + 'ws' => 'Samoa', + 'sm' => 'San Marino', + 'st' => 'Sao Tome and Principe', + 'sa' => 'Saudi Arabia', + 'sn' => 'Senegal', + 'rs' => 'Serbia', + 'sc' => 'Seychelles', + 'sl' => 'Sierra Leone', + 'sg' => 'Singapore', + 'sk' => 'Slovakia', + 'si' => 'Slovenia', + 'sb' => 'Solomon Islands', + 'so' => 'Somalia', + 'za' => 'South Africa', + 'gs' => 'South Georgia and the South Sandwich Islands', + 'es' => 'Spain', + 'lk' => 'Sri Lanka', + 'sd' => 'Sudan', + 'sr' => 'Suriname', + 'sj' => 'Svalbard and Jan Mayen', + 'sz' => 'Swaziland', + 'se' => 'Sweden', + 'ch' => 'Switzerland', + 'sy' => 'Syrian Arab Republic', + 'tw' => 'Taiwan, Province of China', + 'tj' => 'Tajikistan', + 'tz' => 'Tanzania, United Republic of', + 'th' => 'Thailand', + 'tl' => 'Timor-Leste', + 'tg' => 'Togo', + 'tk' => 'Tokelau', + 'to' => 'Tonga', + 'tt' => 'Trinidad and Tobago', + 'tn' => 'Tunisia', + 'tr' => 'Turkey', + 'tm' => 'Turkmenistan', + 'tc' => 'Turks and Caicos Islands', + 'tv' => 'Tuvalu', + 'ug' => 'Uganda', + 'ua' => 'Ukraine', + 'ae' => 'United Arab Emirates', + 'gb' => 'United Kingdom', + 'us' => 'United States', + 'um' => 'United States Minor Outlying Islands', + 'uy' => 'Uruguay', + 'uz' => 'Uzbekistan', + 'vu' => 'Vanuatu', + 've' => 'Venezuela', + 'vn' => 'Viet Nam', + 'vg' => 'Virgin Islands, British', + 'vi' => 'Virgin Islands, U.S.', + 'wf' => 'Wallis and Futuna', + 'eh' => 'Western Sahara', + 'ye' => 'Yemen', + 'zm' => 'Zambia', + 'zw' => 'Zimbabwe', + 'ax' => 'Åland Islands', + ); + + /** + * The type of this Contact, owner, administrative or technical + * + * @var string + */ + public $type; + + /** + * The firstName of this Contact + * + * @var string + */ + public $firstName; + + /** + * The middleName of this Contact + * + * @var string + */ + public $middleName; + + /** + * The lastName of this Contact + * + * @var string + */ + public $lastName; + + /** + * The companyName of this Contact, in case of a company + * + * @var string + */ + public $companyName; + + /** + * The kvk number of this Contact, in case of a company + * + * @var string + */ + public $companyKvk; + + /** + * The type number of this Contact, in case of a company + * + * @var string + */ + public $companyType; + + /** + * The street of the address of this Contact + * + * @var string + */ + public $street; + + /** + * The number part of the address of this Contact + * + * @var string + */ + public $number; + + /** + * The postalCode part of the address of this Contact + * + * @var string + */ + public $postalCode; + + /** + * The city part of the address of this Contact + * + * @var string + */ + public $city; + + /** + * The phoneNumber of this Contact + * + * @var string + */ + public $phoneNumber; + + /** + * The faxNumber of this Contact + * + * @var string + */ + public $faxNumber; + + /** + * The email of this Contact + * + * @var string + */ + public $email; + + /** + * The country of this Contact, one of the ISO country abbrevs, must be lowercase. + * + * @var string + */ + public $country; +} + +?> diff --git a/examples/ColocationService-createIpAddress.php b/examples/ColocationService-createIpAddress.php new file mode 100644 index 0000000..8bd2a3a --- /dev/null +++ b/examples/ColocationService-createIpAddress.php @@ -0,0 +1,23 @@ + + */ + + +require_once('Transip/ColocationService.php'); + +try +{ + // Creates an IpAddress and will assign it to the current user. + // Please note that 127.0.0.1 is an example address. + Transip_ColocationService::createIpAddress('127.0.0.1', 'reverse.example.com'); +} +catch(Exception $e) +{ + print "error: {$e->getMessage()}\n"; +} +?> diff --git a/examples/ColocationService-deleteIpAddress.php b/examples/ColocationService-deleteIpAddress.php new file mode 100644 index 0000000..dd42b0c --- /dev/null +++ b/examples/ColocationService-deleteIpAddress.php @@ -0,0 +1,22 @@ + + */ + + +require_once('Transip/ColocationService.php'); + +try +{ + // Please note that 127.0.0.1 is an example address + Transip_ColocationService::deleteIpAddress('127.0.0.1'); +} +catch(Exception $e) +{ + print "error: {$e->getMessage()}\n"; +} +?> diff --git a/examples/ColocationService-getColoOverview.php b/examples/ColocationService-getColoOverview.php new file mode 100644 index 0000000..7098bd7 --- /dev/null +++ b/examples/ColocationService-getColoOverview.php @@ -0,0 +1,54 @@ + + */ + +require_once('Transip/ColocationService.php'); + +try +{ + // retrieve all colocation items and loop + $coloNames = Transip_ColocationService::getColoNames(); + foreach($coloNames as $coloName) + { + echo $coloName . ':' . PHP_EOL; + + // for each colo, get the IPRanges used by this colo + $ipRanges = Transip_ColocationService::getIpRanges($coloName); + foreach($ipRanges as $ipRange) + { + echo '- IP range: ' . $ipRange . PHP_EOL; + } + + // get all IPAddresses attached to this colo and iterate over + // the addresses to get the reverse dns and print information. + $ipAddresses = Transip_ColocationService::getIpAddresses($coloName); + foreach($ipAddresses as $ipAddress) + { + $reverseDns = Transip_ColocationService::getReverseDns($ipAddress); + echo '- IP address: ' . $ipAddress . ' (rDNS "' . $reverseDns . '")' . PHP_EOL; + } + + echo PHP_EOL; + } +} +catch(Exception $exception) +{ + // When something goes wrong, an Exception will be thrown with relevant information. + echo "An Exception occured. Code: {$exception->getCode()}, message: {$exception->getMessage()}\n"; +} + +?> \ No newline at end of file diff --git a/examples/ColocationService-requestAccess.php b/examples/ColocationService-requestAccess.php new file mode 100644 index 0000000..eb11b87 --- /dev/null +++ b/examples/ColocationService-requestAccess.php @@ -0,0 +1,114 @@ + + */ + + +require_once('Transip/ColocationService.php'); + +if(isset($_POST['request']) && count($_POST['request']) > 0) +{ + extract($_POST['request']); + try + { + // filter out empty input fields + $visitor = array_filter($visitor, 'strlen'); + + $dataCenterVisitors = Transip_ColocationService::requestAccess( + $when, $duration, $visitor, $phoneNumber); + + $result = ''; + foreach($dataCenterVisitors as $dataCenterVisitor) + { + if($dataCenterVisitor->hasBeenRegisteredBefore) + { + $result .= "{$dataCenterVisitor->name} (no code needed)\n"; + } + else + { + $result .= "{$dataCenterVisitor->name}"; + $result .= " (reservation number: {$dataCenterVisitor->reservationNumber};"; + $result .= " access code: {$dataCenterVisitor->accessCode})\n"; + } + } + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} + +?> + + + + + +

TransIP API Datacenter Access Request

+
".$result."

":"")?> + Fill out the form to create an access request + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ Access date/time (YYYY-MM-DD hh:mm:ss) + + +
+ Visit duration (minutes) + + +
+ Visitor + + +
+ Mobile phone number + + " /> +
  + +
+
+ + + + \ No newline at end of file diff --git a/examples/ColocationService-requestRemoteHands.php b/examples/ColocationService-requestRemoteHands.php new file mode 100644 index 0000000..c4ae189 --- /dev/null +++ b/examples/ColocationService-requestRemoteHands.php @@ -0,0 +1,96 @@ + + */ + + +require_once('Transip/ColocationService.php'); + +if(isset($_POST['request']) && count($_POST['request']) > 0) +{ + extract($_POST['request']); + try + { + $dataCenterHandsRequest = Transip_ColocationService::requestRemoteHands( + $coloName, $contactName, $phoneNumber, $expectedDuration, $instructions); + $result = 'The request has been sent.'; + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} + +?> + + + TransIP API Datacenter Remote Hands Request + + + +

TransIP API Datacenter Remote Hands Request

+
'.$result.'

':'')?> + Fill out the form to create a remote hands request +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ Colocation name + + +
+ Contact name + + +
+ Contact phone number + + +
+ Expected duration of the task (in minutes) + + +
+ Instructions for the task
+ +
  + +
+
+ + + + diff --git a/examples/ColocationService-setReverseDns.php b/examples/ColocationService-setReverseDns.php new file mode 100644 index 0000000..c2697ef --- /dev/null +++ b/examples/ColocationService-setReverseDns.php @@ -0,0 +1,22 @@ + + */ + +require_once('Transip/ColocationService.php'); + +try +{ + // Change the reverse dns of an already active IPAddress assigned to the current user + // Please note that 127.0.0.1 is a example addresss + Transip_ColocationService::setReverseDns('127.0.0.1', 'reverse.example.com'); +} +catch(Exception $e) +{ + print "error: {$e->getMessage()}\n"; +} +?> diff --git a/examples/DnsService-getDnsSecEntries.php b/examples/DnsService-getDnsSecEntries.php new file mode 100644 index 0000000..57e5080 --- /dev/null +++ b/examples/DnsService-getDnsSecEntries.php @@ -0,0 +1,23 @@ + + */ + +// Include dnsservice +require_once('Transip/DnsService.php'); + +$domainName = 'example.com'; + +try { + // Get the dnssec entries from the transip system + $entries = Transip_DnsService::getDnsSecEntries($domainName); + var_dump($entries); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/DnsService-setDnsEntries.php b/examples/DnsService-setDnsEntries.php new file mode 100644 index 0000000..08097e2 --- /dev/null +++ b/examples/DnsService-setDnsEntries.php @@ -0,0 +1,30 @@ + + */ + +// Include dnsservice +require_once('Transip/DnsService.php'); + +$domainName = 'example.com'; + +// Create the dns entries we want +$dnsEntries = []; +$dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_A, '127.0.0.1'); +$dnsEntries[] = new Transip_DnsEntry('www', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); +$dnsEntries[] = new Transip_DnsEntry('mail', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); +$dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_MX, '10 mail.'); + +try { + // Save the dns entries in the transip system + Transip_DnsService::setDnsEntries($domainName, $dnsEntries); + echo 'The DNS Entries have been saved.'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/DnsService-setDnsSecEntries.php b/examples/DnsService-setDnsSecEntries.php new file mode 100644 index 0000000..17c5833 --- /dev/null +++ b/examples/DnsService-setDnsSecEntries.php @@ -0,0 +1,49 @@ + + */ + +// Include domainservice +require_once('Transip/DnsService.php'); + +$domainName = 'example.com'; + +$keyTag = ''; +/** + * @var $flag + * @see Transip_DnsSecEntry::ALL_FLAGS + */ +$flag = ''; +/** + * @var $algorithm + * @see Transip_DnsSecEntry::ALL_ALGORITHMS + */ +$algorithm = ''; +$publicKey = ''; + +if (!Transip_DnsService::canEditDnsSec($domainName)) { + die("Unable to update DNSSEC data."); +} + +// Create the dnssec entries we want +$dnsSecEntries = []; +$dnsSecEntries[] = new Transip_DnsSecEntry( + $keyTag, + $flag, + $algorithm, + $publicKey +); + +try { + // Save the dnssec entries in the transip system + Transip_DnsService::setDnsSecEntries($domainName, $dnsSecEntries); + echo 'The DNSSEC Entries have been saved.'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/DomainService-batchCheckAvailability.php b/examples/DomainService-batchCheckAvailability.php new file mode 100644 index 0000000..e8ae608 --- /dev/null +++ b/examples/DomainService-batchCheckAvailability.php @@ -0,0 +1,82 @@ + + */ + +require_once('../Transip/DomainService.php'); + +if(isset($_GET['domains']) && strlen($_GET['domains']) > 0) +{ + // seperate each line into a domain and trim off any whitespace + $domains = explode("\n", $_GET['domains']); + $domains = array_map('trim', $domains); + $result = ''; + + try + { + // Request the availability of multiple domains by using the Transip_DomainService API; + // we can get the following different statusses back with different meanings, wrapped in a Transip_DomainCheckResult. + $domainCheckResults = Transip_DomainService::batchCheckAvailability($domains); + foreach($domainCheckResults as $domainCheckResult) + { + switch($domainCheckResult->status) + { + case Transip_DomainService::AVAILABILITY_INYOURACCOUNT: + $result .= htmlspecialchars($domainCheckResult->domainName) + . ' is not available.
'; + break; + + case Transip_DomainService::AVAILABILITY_UNAVAILABLE: + $result .= htmlspecialchars($domainCheckResult->domainName) + . ' is not available for transfer.
'; + break; + + case Transip_DomainService::AVAILABILITY_FREE: + $result .= htmlspecialchars($domainCheckResult->domainName) + . ' is available for registration.
'; + break; + + + case Transip_DomainService::AVAILABILITY_NOTFREE: + $result .= htmlspecialchars($domainCheckResult->domainName) + . ' is registered. If you are the owner, + you could transfer it.
'; + break; + } + } + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} +else +{ + $domains = array(); + $result = ''; +} + +?> + + + + + +

TransIP API Batch DomainChecker Example

+ Fill in each domain on a seperate line. The maximum of domains is 20. +
+ +
+ +
+ + + + diff --git a/examples/DomainService-batchGetInfo.php b/examples/DomainService-batchGetInfo.php new file mode 100644 index 0000000..b78068f --- /dev/null +++ b/examples/DomainService-batchGetInfo.php @@ -0,0 +1,138 @@ + + */ + +require_once('../Transip/DomainService.php'); + +if(isset($_GET['domains']) && strlen($_GET['domains']) > 0) +{ + /** @var string[] $domainNames A list of domain names. */ + $domainNames = explode("\n", $_GET['domains']); + $domainNames = array_filter($domainNames, 'trim'); + + try + { + // Request information about a domain in your account by using the TransIP + // DomainService API; A domain Object will be returned holding all + // information available about the domain. + $domains = Transip_DomainService::batchGetInfo($domainNames); + + // INFO: A domain object holds all data directly available for a domain: + // + it has a list of nameservers, + // + a list of whois-contacts + // + a list of dns-entries if the domain is using TransIP nameservers + // + and, optionally, a Transip_DomainBranding object that holds + // information about branding (see reseller info for more) + // + // The domain object does not include registrar-lock and auth/epp-code + // information, since this information will always be fetched real-time + // from the registry. To get this information, you can use the + // getIsLocked() and getAuthCode API calls. + + + $result = "We got the following information about these domains:\n" . + htmlspecialchars(implode(",\n", $domainNames)) . "\n\n"; + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} +else +{ + $domainNames = array(); + $domains = array(); + $result = ''; +} + +?> + + + + + +

TransIP API GetInfo Example

+Fill in each domain on a seperate line. The maximum of domains is 20. +
+ +
+ +
+ + + + + + +

name?>

+

Nameservers

+ + +

WhoisContacts

+ contacts as $contact) + { + echo "

" . htmlspecialchars($contact->type) . "

"; + echo ""; + foreach($contact as $key => $value) + { + echo ""; + echo ""; + echo ""; + + echo ""; + } + + echo "
" . htmlspecialchars($key) . "" . htmlspecialchars($value) . "
"; + } + ?> +

DNS

+ + + + + + + + dnsEntries as $dnsEntry) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + } + ?> +
nameexpiretypecontent
" . htmlspecialchars($dnsEntry->name) . "" . htmlspecialchars($dnsEntry->expire) . "" . htmlspecialchars($dnsEntry->type) . "" . htmlspecialchars($dnsEntry->content) . "
+ + + + + + \ No newline at end of file diff --git a/examples/DomainService-cancel.php b/examples/DomainService-cancel.php new file mode 100644 index 0000000..6ffdded --- /dev/null +++ b/examples/DomainService-cancel.php @@ -0,0 +1,57 @@ + + */ + +require_once('Transip/DomainService.php'); + +if(isset($_POST['domain']) && strlen($_POST['domain']) > 0) +{ + $domain = $_POST['domain']; + $when = isset($_POST['when']) && !empty($_POST['when']) ? $_POST['when'] : 'end'; + try + { + // Request cancellation of a domain by using the Transip_DomainService API; + Transip_DomainService::cancel($domain, $when); + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} + +?> + + + + + +

TransIP API cancel Example

+ Fill in the domain you want to cancel. + +
+ +
+ Cancel when? +
+ +
+ +
+ +
+ + + + \ No newline at end of file diff --git a/examples/DomainService-checkAvailability.php b/examples/DomainService-checkAvailability.php new file mode 100644 index 0000000..e38bfec --- /dev/null +++ b/examples/DomainService-checkAvailability.php @@ -0,0 +1,75 @@ + + */ + +require_once('Transip/DomainService.php'); + +if(isset($_GET['domain']) && strlen($_GET['domain']) > 0) +{ + $domain = $_GET['domain']; + + try + { + // Request the availability of a domain by using the Transip_DomainService API; + // we can get the following different statusses back with different meanings. + $availability = Transip_DomainService::checkAvailability($domain); + switch($availability) + { + case Transip_DomainService::AVAILABILITY_INYOURACCOUNT: + $result = htmlspecialchars($domain) + . ' is not available.'; + break; + + case Transip_DomainService::AVAILABILITY_UNAVAILABLE: + $result = htmlspecialchars($domain) + . ' is not available for transfer.'; + break; + + case Transip_DomainService::AVAILABILITY_FREE: + $result = htmlspecialchars($domain) + . ' is available for registration.'; + break; + + + case Transip_DomainService::AVAILABILITY_NOTFREE: + $result = htmlspecialchars($domain) + . ' is registered. If you are the owner, + you could transfer it.'; + break; + } + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} +else +{ + $domain = ''; + $result = ''; +} + +?> + + + + + +

TransIP API DomainChecker Example

+ Fill in the domain you want to check and press Check. +
+ +
+ +
+ + + + diff --git a/examples/DomainService-domainActions.php b/examples/DomainService-domainActions.php new file mode 100644 index 0000000..e439764 --- /dev/null +++ b/examples/DomainService-domainActions.php @@ -0,0 +1,67 @@ + + */ + + +require_once('Transip/DomainService.php'); + +try +{ + $currentDomainAction = Transip_DomainService::getCurrentDomainAction($domainName); + + $result = ''; + if(is_null($currentDomainAction)) + { + // There is currently no action running on this domain + $result = "Currently no action for domain {$domainName}\n"; + } + + if($currentDomainAction->hasFailed !== true) + { + // There is currently an action running, and it has not failed yet. + $result = "Current action for domain is {$currentDomainAction->name}\n"; + } + else + { + // There was an action running on the domain, and it has failed. + // We retry with new nameservers for the domain. + $result = "Current action for domain is {$currentDomainAction->name} and has failed with message {$currentDomainAction->message}\n"; + $result .= "Retrying....\n"; + + $domain = Transip_DomainService::getInfo($domainName); + + // Create new nameserver entries we want + $nameservers = array(); + $nameservers[] = new Transip_Nameserver('ns1.mydomain.com'); + $nameservers[] = new Transip_Nameserver('ns2.mydomain.com', ''); + // Since ns.thedomaintomodify.com is a subdomain of the domain we are saving, + // the nameserver needs a glue record (ipv4 required, ipv6 optional) + $nameservers[] = new Transip_Nameserver('ns.thedomaintomodify.com', '99.99.99.99'); + $domain->nameServers = $nameServers; + + // We try the current action again, but now with our modified Transip_Domain object. + // Based on the error message one should modify the appropiate part of this object + Transip_DomainService::retryCurrentDomainActionWithNewData($domain); + + // If you need to change the authcode, please use the call below + // Transip_DomainService::retryTransferWithDifferentAuthCode($domain, $newAuthCode); + + // If you want to cancel the action use + // Beware, all changes will be rollbacked. + // Transip_DomainService::cancelDomainAction($domain) + } + + echo $result; +} +catch(Exception $exception) +{ + // When something goes wrong, an Exception will be thrown with relevant information. + echo "An Exception occured. Code: {$exception->getCode()}, message: {$exception->getMessage()}\n"; +} +?> diff --git a/examples/DomainService-getAllTldInfos.php b/examples/DomainService-getAllTldInfos.php new file mode 100644 index 0000000..006045e --- /dev/null +++ b/examples/DomainService-getAllTldInfos.php @@ -0,0 +1,30 @@ + + */ + + +// Include domainservice +require_once('Transip/DomainService.php'); + +try +{ + // Call the API, the result will be an array of all Tlds + $tldList = Transip_DomainService::getAllTldInfos(); + + // Output the Tlds + print_r($tldList); +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} + +?> diff --git a/examples/DomainService-getAuthCode.php b/examples/DomainService-getAuthCode.php new file mode 100644 index 0000000..ff804f9 --- /dev/null +++ b/examples/DomainService-getAuthCode.php @@ -0,0 +1,62 @@ + + */ + + +require_once('Transip/DomainService.php'); + +if(isset($_GET['domain']) && strlen($_GET['domain']) > 0) +{ + $domain = $_GET['domain']; + + try + { + // Request the authcode of a domain by using the Transip_DomainService API; + $info = Transip_DomainService::getInfo($domain); + if($info != null) + { + $authCode = $info->authCode; + } + else + { + $authCode = 'unknown'; + } + + $result = 'The authcode for the domain ' . htmlspecialchars($domain) + . ' is: ' . htmlspecialchars($authCode); + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $whois = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} +else +{ + $domain = ''; + $result = ''; +} + +?> + + + + + +

TransIP API GetAuthCode Example

+ Fill in the domain you want to get the authcode for and click on Get AuthCode. +
+ +
+ +
+ + + + \ No newline at end of file diff --git a/examples/DomainService-getDomainNames.php b/examples/DomainService-getDomainNames.php new file mode 100644 index 0000000..d11ddef --- /dev/null +++ b/examples/DomainService-getDomainNames.php @@ -0,0 +1,32 @@ + + */ + + +// Include domainservice +require_once('Transip/DomainService.php'); + +// Set the result variable +$domainList = array(); + +try +{ + // Call the API, the result will be an array of all your domain names + $domainList = Transip_DomainService::getDomainNames(); + + // Output the domain names + print_r($domainList); +} +catch(SoapFault $e) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $e->getMessage(), PHP_EOL; +} + +?> diff --git a/examples/DomainService-getInfo.php b/examples/DomainService-getInfo.php new file mode 100644 index 0000000..2db9e80 --- /dev/null +++ b/examples/DomainService-getInfo.php @@ -0,0 +1,130 @@ + + */ + +require_once('Transip/DomainService.php'); + +if(isset($_GET['domain']) && strlen($_GET['domain']) > 0) +{ + $domainName = $_GET['domain']; + + try + { + // Request information about a domain in your account by using the TransIP + // DomainService API; A domain Object will be returned holding all + // information available about the domain. + $domain = Transip_DomainService::getInfo($domainName); + + // INFO: A domain object holds all data directly available for a domain: + // + it has a list of nameservers, + // + a list of whois-contacts + // + a list of dns-entries if the domain is using TransIP nameservers + // + and, optionally, a Transip_DomainBranding object that holds + // information about branding (see reseller info for more) + // + // The domain object does not include registrar-lock and auth/epp-code + // information, since this information will always be fetched real-time + // from the registry. To get this information, you can use the + // getIsLocked() and getAuthCode API calls. + + + $result = 'We got the following information about the domain ' . + htmlspecialchars($domainName) . ':'; + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} +else +{ + $domainName = ''; + $domain = null; + $result = ''; +} + +?> + + + + + +

TransIP API GetInfo Example

+ Fill in the domain you want to get information about and click on Get Info. +
+ +
+ +
+ + + + +

Nameservers

+ + +

WhoisContacts

+ contacts as $contact) + { + echo "

" . htmlspecialchars($contact->type) . "

"; + echo ""; + foreach($contact as $key => $value) + { + echo ""; + echo ""; + echo ""; + + echo ""; + } + + echo "
" . htmlspecialchars($key) . "" . htmlspecialchars($value) . "
"; + } + ?> +

DNS

+ + + + + + + + dnsEntries as $dnsEntry) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + } + ?> +
nameexpiretypecontent
" . htmlspecialchars($dnsEntry->name) . "" . htmlspecialchars($dnsEntry->expire) . "" . htmlspecialchars($dnsEntry->type) . "" . htmlspecialchars($dnsEntry->content) . "
+ + + \ No newline at end of file diff --git a/examples/DomainService-getWhois.php b/examples/DomainService-getWhois.php new file mode 100644 index 0000000..cfbee3f --- /dev/null +++ b/examples/DomainService-getWhois.php @@ -0,0 +1,51 @@ + + */ + +require_once('Transip/DomainService.php'); + + +if(isset($_GET['domain']) && strlen($_GET['domain']) > 0) +{ + $domain = $_GET['domain']; + + try + { + // Request the WHOIS information of a domain by using the Transip_DomainService API. + $whois = Transip_DomainService::getWhois($domain); + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $whois = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} +else +{ + $domain = ''; + $whois = ''; +} + +?> + + + + + +

TransIP API Whois Example

+ Fill in the domain you want to get the whois for and click on Get Whois. +
+ +
+
+
+ + + + \ No newline at end of file diff --git a/examples/DomainService-register-dns.php b/examples/DomainService-register-dns.php new file mode 100644 index 0000000..db7b1fa --- /dev/null +++ b/examples/DomainService-register-dns.php @@ -0,0 +1,37 @@ + + */ + +// Include domainservice +require_once('Transip/DomainService.php'); + +try +{ + // obviously, there are several DNS entry types. these are defined in + // the class constants for ease of use + $dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_A, '80.69.67.46'); + $dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_MX, '10 @'); + $dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_MX, '20 relay.transip.nl.'); + $dnsEntries[] = new Transip_DnsEntry('ftp', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); + $dnsEntries[] = new Transip_DnsEntry('mail', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); + $dnsEntries[] = new Transip_DnsEntry('www', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); + + // you can now use the $dnsEntries array as the fourth parameter when instantiating + // a new Transip_Domain. For example: + $domain = new Transip_Domain('example.com', $nameservers = null, $contacts = null, $dnsEntries); + $propositionNumber = Transip_DomainService::register($domain); + echo 'The domain ' . $domain->name . ' has been requested with proposition number ' . $propositionNumber; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} + +?> \ No newline at end of file diff --git a/examples/DomainService-register-nameserver.php b/examples/DomainService-register-nameserver.php new file mode 100644 index 0000000..95a5601 --- /dev/null +++ b/examples/DomainService-register-nameserver.php @@ -0,0 +1,43 @@ + + */ + + +try +{ + // Include domainservice + require_once('Transip/DomainService.php'); + + // setting nameservers can be done in a few ways + // default nameservers require only the hostname + $nameservers[] = new Transip_Nameserver('ns1.transip.nl'); + + // if the hostname is a subdomain of the domain we are setting the nameservers + // for, a gluerecord is required. ipv4 is required, ipv6 is optional. + + // without ipv6 + $nameservers[] = new Transip_Nameserver('ns1.yourdomain.com', '127.0.0.1'); + + // with ipv6 (both adresses point to localhost) + $nameservers[] = new Transip_Nameserver('ns2.yourdomain.com', '127.0.0.1', '::1'); + + // you can now use the $nameservers array as the second parameter when instantiating + // a new Transip_Domain. For example: + $domain = new Transip_Domain('example.com', $nameservers); + $propositionNumber = Transip_DomainService::register($domain); + echo 'The domain ' . $domain->name . ' has been requested with proposition number ' . $propositionNumber; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} + + +?> \ No newline at end of file diff --git a/examples/DomainService-register-whois.php b/examples/DomainService-register-whois.php new file mode 100644 index 0000000..5f7782c --- /dev/null +++ b/examples/DomainService-register-whois.php @@ -0,0 +1,59 @@ + + */ + +// Include domainservice +require_once('Transip/DomainService.php'); + + +try +{ + $types = array( + Transip_WhoisContact::TYPE_REGISTRANT, + Transip_WhoisContact::TYPE_ADMINISTRATIVE, + Transip_WhoisContact::TYPE_TECHNICAL + ); + + // setting up whois records is quite easy + $contacts = array(); + foreach($types AS $type) + { + $contact = new Transip_WhoisContact(); + $contact->type = $type; + // please note that 'Sjaak de Waal' is a fictional character + // any resemblances to real persons are unintentional and coincidential + // Also, please note that the middleName field is not used, so you should + // put any middleName/infix in the lastName field. + $contact->firstName = 'Sjaak'; + $contact->lastName = 'de Waal'; + $contact->companyName = 'TransIP'; + $contact->companyKvk = '24345899'; + $contact->companyType = 'BV'; + $contact->street = 'Schipholweg'; + $contact->number = '11e'; + $contact->postalCode = '2316XB'; + $contact->city = 'Leiden'; + $contact->phoneNumber = '+31715241919'; + $contact->faxNumber = '+31715241918'; + $contact->email = 'support@transip.nl'; + $contact->country = 'NL'; + $contacts[] = $contact; + } + + // you can now use the $contacts array as the third parameter when instantiating + // a new Transip_Domain. For example: + $domain = new Transip_Domain($name, $nameservers, $contacts, $dnsEntries, $branding); + Transip_DomainService::register($domain); +} +catch(Exception $e) +{ + echo 'An error occured: '. $e->getMessage(), PHP_EOL; +} + + +?> diff --git a/examples/DomainService-register.php b/examples/DomainService-register.php new file mode 100644 index 0000000..39cbfc0 --- /dev/null +++ b/examples/DomainService-register.php @@ -0,0 +1,24 @@ +, , + // ); + $domain = new Transip_Domain('transip.nl'); + $propositionNumber = Transip_DomainService::register($domain); + echo 'The domain ' . $domain->name . ' has been requested with proposition number ' . $propositionNumber; +} +catch(SoapFault $e) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occured: '. $e->getMessage(), PHP_EOL; +} + +?> \ No newline at end of file diff --git a/examples/DomainService-setContacts.php b/examples/DomainService-setContacts.php new file mode 100644 index 0000000..f4417db --- /dev/null +++ b/examples/DomainService-setContacts.php @@ -0,0 +1,255 @@ + + */ + +require_once('Transip/DomainService.php'); + +// Maintain a list of all possible contact types +$contactTypes = array( + Transip_WhoisContact::TYPE_REGISTRANT, + Transip_WhoisContact::TYPE_ADMINISTRATIVE, + Transip_WhoisContact::TYPE_TECHNICAL); +$contacts = null; + +if(isset($_REQUEST['domain']) && strlen($_REQUEST['domain']) > 0) +{ + $domain = $_REQUEST['domain']; + + try + { + // Check to see if we an action was requested and if so, do it + if(isset($_POST['setContacts'])) + { + // Construct an array to hold Transip_WhoisContact objects for all contact types + $newContacts = array(); + foreach($contactTypes as $type) + { + // Construct a new Transip_WhoisContact object + $newContact = new Transip_WhoisContact(); + $newContact->type = $type; + $newContact->firstName = $_POST[$type]['firstName']; + $newContact->middleName = $_POST[$type]['middleName']; + $newContact->lastName = $_POST[$type]['lastName']; + $newContact->companyName = $_POST[$type]['companyName']; + $newContact->companyKvk = $_POST[$type]['companyKvk']; + $newContact->companyType = $_POST[$type]['companyType']; + $newContact->street = $_POST[$type]['street']; + $newContact->number = $_POST[$type]['number']; + $newContact->postalCode = $_POST[$type]['postalCode']; + $newContact->city = $_POST[$type]['city']; + $newContact->country = $_POST[$type]['country']; + $newContact->phoneNumber = $_POST[$type]['phoneNumber']; + $newContact->faxNumber = $_POST[$type]['faxNumber']; + $newContact->email = $_POST[$type]['email']; + + // Add new contact to the list + $newContacts[] = $newContact; + } + + // Set contacts for the domain by using the Transip_DomainService API; + Transip_DomainService::setContacts($domain, $newContacts); + } + + // Request the locked status of a domain by using the Transip_DomainService API; + $info = Transip_DomainService::getInfo($domain); + + // The Transip_Domain object contains an array of Transip_WhoisContact objects + // Each Transip_WhoisContact object has one of three types + // Iterate through contacts and save in array + foreach($info->contacts as $contact) + { + $contacts[$contact->type] = $contact; + } + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $error = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} +else +{ + $domain = ''; + $isLocked = false; +} + +?> + + + + + +

TransIP API Set Contacts Example

+ Fill in the domain you want to set the owner for and click on Get Owner. +
+ +

+
+ + +
+ + $error"; + } + else if($domain != '') + { + // Display a table with contact data for every contact type + foreach($contactTypes as $type) + { + // Get the contact for the current type + $contact = $contacts[$type]; + + // Use util to construct list of company type options + // Only these values are allowed as company types in a Transip_WhoisContact object + $companyTypeOptions = ''; + foreach(Transip_WhoisContact::$possibleCompanyTypes as $code => $desc) + { + $companyTypeOptions .= ''; + } + + // Use util to construct list of country code options + // Only these values are allowed as country codes in a Transip_WhoisContact object + $countryCodeOptions = ''; + foreach(Transip_WhoisContact::$possibleCountryCodes as $code => $name) + { + $countryCodeOptions .= ''; + } + + // A contact change will ignore some fields for the registrant contact + // These can only be updated with an owner change + $disabledForRegistrant = + $type == Transip_WhoisContact::TYPE_REGISTRANT + ? 'disabled="disabled"' + : ''; + + ?> +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
/>
/>
/>
/>
/>
/>
+ +
+
+ + + + \ No newline at end of file diff --git a/examples/DomainService-setLock.php b/examples/DomainService-setLock.php new file mode 100644 index 0000000..f0a5afd --- /dev/null +++ b/examples/DomainService-setLock.php @@ -0,0 +1,85 @@ + + */ + +require_once('Transip/DomainService.php'); + +if(isset($_REQUEST['domain']) && strlen($_REQUEST['domain']) > 0) +{ + $domain = $_REQUEST['domain']; + + try + { + // Check to see if we an action was requested and if so, do it + if(isset($_POST['lock'])) + { + // Lock the domain by using the Transip_DomainService API; + $isLocked = Transip_DomainService::setLock($domain); + } + + if(isset($_POST['unlock'])) + { + // Unlock the domain by using the Transip_DomainService API; + $isLocked = Transip_DomainService::unsetLock($domain); + } + + // Request the locked status of a domain by using the Transip_DomainService API; + $isLocked = Transip_DomainService::getIsLocked($domain); + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $whois = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} +else +{ + $domain = ''; + $isLocked = false; +} + +?> + + + + + +

TransIP API Locking Example

+ Fill in the domain you want to get the authcode for and click on Get LockStatus. +
+ +

+
+ + +
+ + $error"; + } + else if($domain != '') + { + if($isLocked) + { + ?>The domain is LOCKED +
The domain is UNLOCKED +
+
+ + \ No newline at end of file diff --git a/examples/DomainService-setNameservers.php b/examples/DomainService-setNameservers.php new file mode 100644 index 0000000..ed41fe2 --- /dev/null +++ b/examples/DomainService-setNameservers.php @@ -0,0 +1,33 @@ + + */ + +// Include domainservice +require_once('Transip/DomainService.php'); + +// Create the nameserver entries we want +$nameservers = array(); +$nameservers[] = new Transip_Nameserver('ns1.example.com'); +$nameservers[] = new Transip_Nameserver('ns2.example.com', ''); +// Since ns.thedomaintomodify.com is a subdomain of the domain we are saving, +// the nameserver needs a glue record (ipv4 required, ipv6 optional) +$nameservers[] = new Transip_Nameserver('ns.example.com', '99.99.99.99'); + +try +{ + // Save the nameservers in the transip system + Transip_DomainService::setNameservers('example.com', $nameservers); + echo 'The nameservers have been saved.'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} +?> diff --git a/examples/DomainService-setOwner.php b/examples/DomainService-setOwner.php new file mode 100644 index 0000000..1120254 --- /dev/null +++ b/examples/DomainService-setOwner.php @@ -0,0 +1,185 @@ + + */ + +require_once('Transip/DomainService.php'); + +$owner = null; +if(isset($_REQUEST['domain']) && strlen($_REQUEST['domain']) > 0) +{ + $domain = $_REQUEST['domain']; + + try + { + // Check to see if we an action was requested and if so, do it + if(isset($_POST['setOwner'])) + { + // Construct a new WhoisContact object + $newOwner = new Transip_WhoisContact(); + $newOwner->type = Transip_WhoisContact::TYPE_REGISTRANT; + $newOwner->firstName = $_POST['firstName']; + $newOwner->middleName = $_POST['middleName']; + $newOwner->lastName = $_POST['lastName']; + $newOwner->companyName = $_POST['companyName']; + $newOwner->companyKvk = $_POST['companyKvk']; + $newOwner->companyType = $_POST['companyType']; + $newOwner->street = $_POST['street']; + $newOwner->number = $_POST['number']; + $newOwner->postalCode = $_POST['postalCode']; + $newOwner->city = $_POST['city']; + $newOwner->country = $_POST['country']; + $newOwner->phoneNumber = $_POST['phoneNumber']; + $newOwner->faxNumber = $_POST['faxNumber']; + $newOwner->email = $_POST['email']; + + // Set owner for the domain by using the Transip_DomainService API; + Transip_DomainService::setOwner($domain, $newOwner); + } + + // Request the locked status of a domain by using the Transip_DomainService API; + $info = Transip_DomainService::getInfo($domain); + + // The Domain object contains an array of WhoisContact objects + // Each WhoisContact object has one of three types + // Iterate through contacts to find registrant (owner) + foreach($info->contacts as $contact) + { + if ($contact->type == Transip_WhoisContact::TYPE_REGISTRANT ) + { + $owner = $contact; + break; + } + } + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $error = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} +else +{ + $domain = ''; + $isLocked = false; +} + +?> + + + + + +

TransIP API Set Owner Example

+ Fill in the domain you want to set the owner for and click on Get Owner. +
+ +

+
+ + +
+ + $error"; + } + else if($domain != '') + { + // Use util to construct list of company type options + // Only these values are allowed as company types in a WhoisContact object + $companyTypeOptions = ''; + foreach(Transip_WhoisContact::$possibleCompanyTypes as $code => $desc) + { + $companyTypeOptions .= ''; + } + + // Use util to construct list of country code options + // Only these values are allowed as country codes in a WhoisContact object + $countryCodeOptions = ''; + foreach(Transip_WhoisContact::$possibleCountryCodes as $code => $name) + { + $countryCodeOptions .= ''; + } + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + \ No newline at end of file diff --git a/examples/DomainService-transfer.php b/examples/DomainService-transfer.php new file mode 100644 index 0000000..bc42641 --- /dev/null +++ b/examples/DomainService-transfer.php @@ -0,0 +1,57 @@ + + */ + + +// Include domainservice +require_once('Transip/DomainService.php'); + +try +{ + // Transfers a domain with your default settings + // It's also possible to transfer with custom settings, + // for this the call should be like: + // $domain = new Transip_Domain('transip.nl', , , + // ); + + $domainName = 'example.com'; + $authCode = '[AUTHCODE]'; + + + $domain = new Transip_Domain($domainName); + + $tldName = strstr($domainName, '.'); + $tldInfo = Transip_DomainService::getTldInfo($tldName); + if(in_array(Transip_Tld::CAPABILITY_CANTRANSFERWITHOWNERCHANGE, $tldInfo->capabilities)) + { + Transip_DomainService::transferWithOwnerChange($domain, $authCode); + } + elseif(in_array(Transip_Tld::CAPABILITY_CANTRANSFERWITHOUTOWNERCHANGE, $tldInfo->capabilities)) + { + Transip_DomainService::transferWithoutOwnerChange($domain, $authCode); + } + else + { + // The TLD does not support transfers at all + throw new Exception('TLD ' . $tldName . ' does not support domain transfers'); + } + + echo 'The domain ' . $domain->name . ' has been requested.'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . htmlspecialchars($f->getMessage()); +} +catch(Exception $e) +{ + echo htmlspecialchars($e->getMessage()); +} + +?> diff --git a/examples/ForwardService-order.php b/examples/ForwardService-order.php new file mode 100644 index 0000000..b83358b --- /dev/null +++ b/examples/ForwardService-order.php @@ -0,0 +1,30 @@ + + */ + +// Include forwardservice +require_once('Transip/ForwardService.php'); + +// Order a forward service for a domain name +try +{ + // Create a new forward object that directly forwards to example.org. + $forward = new Transip_Forward(); + $forward->domainName = 'example.com'; + $forward->forwardTo = 'http://www.example.org'; + $forward->forwardEmailTo = 'test@example.com'; + // Order the forward + Transip_ForwardService::order($forward); +} +catch(Exception $exception) +{ + // When something goes wrong, an Exception will be thrown with relevant information. + echo "An Exception occured. Code: {$exception->getCode()}, message: {$exception->getMessage()}\n"; +} + +?> diff --git a/examples/HaipService-addCertificateToHaip.php b/examples/HaipService-addCertificateToHaip.php new file mode 100644 index 0000000..f171edc --- /dev/null +++ b/examples/HaipService-addCertificateToHaip.php @@ -0,0 +1,20 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Aad certificate to haip by haip name and certificate id + Transip_HaipService::addCertificateToHaip('example-haip', 1); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-addHaipPortConfiguration.php b/examples/HaipService-addHaipPortConfiguration.php new file mode 100644 index 0000000..f1cc341 --- /dev/null +++ b/examples/HaipService-addHaipPortConfiguration.php @@ -0,0 +1,24 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Add configuration by HA-IP name + // mode ('tcp','http','https','proxy') + Transip_HaipService::addHaipPortConfiguration('example-haip', 'HTTP', 80, 'http'); + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-addPortConfiguration.php b/examples/HaipService-addPortConfiguration.php new file mode 100644 index 0000000..0344168 --- /dev/null +++ b/examples/HaipService-addPortConfiguration.php @@ -0,0 +1,23 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Add configuration by HA-IP name + // mode ('tcp','http','https','proxy') + // endpointSslMode ('off','on','strict') + Transip_HaipService::addPortConfiguration('example-haip', 'HTTP', 80, 80, 'http', 'off'); + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-cancelHaip.php b/examples/HaipService-cancelHaip.php new file mode 100644 index 0000000..6dca250 --- /dev/null +++ b/examples/HaipService-cancelHaip.php @@ -0,0 +1,23 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Cancel your haip by name at end of contract, use + // end-time is either: 'immediately' or 'end' (end means end of contract) + $haip = Transip_HaipService::cancelHaip('example-haip', 'end'); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-changeHaipVps.php b/examples/HaipService-changeHaipVps.php new file mode 100644 index 0000000..f8e8f04 --- /dev/null +++ b/examples/HaipService-changeHaipVps.php @@ -0,0 +1,20 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Change the attached Vps of the HA-IP + Transip_HaipService::changeHaipVps('example-haip', 'example-vps'); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-deleteCertificateFromHaip.php b/examples/HaipService-deleteCertificateFromHaip.php new file mode 100644 index 0000000..6bc8282 --- /dev/null +++ b/examples/HaipService-deleteCertificateFromHaip.php @@ -0,0 +1,21 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Remove certificate by HA-IP name and certificate id + Transip_HaipService::deleteCertificateFromHaip('example-haip', 1); + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-deleteHaipPortConfiguration.php b/examples/HaipService-deleteHaipPortConfiguration.php new file mode 100644 index 0000000..8ca1680 --- /dev/null +++ b/examples/HaipService-deleteHaipPortConfiguration.php @@ -0,0 +1,24 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Remove a port configuration by HA-IP name and port config id + $haip = Transip_HaipService::deleteHaipPortConfiguration('example-haip', 1); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-deletePortConfiguration.php b/examples/HaipService-deletePortConfiguration.php new file mode 100644 index 0000000..221a8db --- /dev/null +++ b/examples/HaipService-deletePortConfiguration.php @@ -0,0 +1,22 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Remove a port configuration by HA-IP name and port config id + $haip = Transip_HaipService::deletePortConfiguration('example-haip', 1); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-getAvailableCertificatesByHaip.php b/examples/HaipService-getAvailableCertificatesByHaip.php new file mode 100644 index 0000000..e76339b --- /dev/null +++ b/examples/HaipService-getAvailableCertificatesByHaip.php @@ -0,0 +1,22 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Get a haip available certificates by name + $haip = Transip_HaipService::getAvailableCertificatesByHaip('example-haip'); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-getCertificatesByHaip.php b/examples/HaipService-getCertificatesByHaip.php new file mode 100644 index 0000000..2b3eb29 --- /dev/null +++ b/examples/HaipService-getCertificatesByHaip.php @@ -0,0 +1,22 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Get haip certificates by haip name + $haip = Transip_HaipService::getCertificatesByHaip('example-haip'); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-getHaip.php b/examples/HaipService-getHaip.php new file mode 100644 index 0000000..7bd7b0c --- /dev/null +++ b/examples/HaipService-getHaip.php @@ -0,0 +1,22 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Get a haip by name + $haip = Transip_HaipService::getHaip('example-haip'); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-getHaipPortConfigurations.php b/examples/HaipService-getHaipPortConfigurations.php new file mode 100644 index 0000000..7deae05 --- /dev/null +++ b/examples/HaipService-getHaipPortConfigurations.php @@ -0,0 +1,24 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Get all port configuration by HA-IP name + $haip = Transip_HaipService::getHaipPortConfigurations('example-haip'); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-getHaips.php b/examples/HaipService-getHaips.php new file mode 100644 index 0000000..b937a59 --- /dev/null +++ b/examples/HaipService-getHaips.php @@ -0,0 +1,22 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Get a list of all Haip objects + $haipList = Transip_HaipService::getHaips(); + + print_r($haipList); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-getPortConfigurations.php b/examples/HaipService-getPortConfigurations.php new file mode 100644 index 0000000..29410f2 --- /dev/null +++ b/examples/HaipService-getPortConfigurations.php @@ -0,0 +1,22 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Get all port configuration by HA-IP name + $haip = Transip_HaipService::getPortConfigurations('example-haip'); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-getPtrForHaip.php b/examples/HaipService-getPtrForHaip.php new file mode 100644 index 0000000..332828e --- /dev/null +++ b/examples/HaipService-getPtrForHaip.php @@ -0,0 +1,22 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Get PTR's for Haip + $ptrs = Transip_HaipService::getPtrForHaip('example-haip'); + + print_r($ptrs); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-getStatusReport.php b/examples/HaipService-getStatusReport.php new file mode 100644 index 0000000..5e13a79 --- /dev/null +++ b/examples/HaipService-getStatusReport.php @@ -0,0 +1,20 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Retrieve status report data for a HA-IP as an array + $statusReport = Transip_HaipService::getStatusReport('example-haip'); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-setBalancingMode.php b/examples/HaipService-setBalancingMode.php new file mode 100644 index 0000000..36152bd --- /dev/null +++ b/examples/HaipService-setBalancingMode.php @@ -0,0 +1,31 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Change the HA-IP balancing mode to 'cookie', and pin sessions on the PHPSESSID cookie + Transip_HaipService::setBalancingMode('example-haip', 'cookie', 'PHPSESSID'); + + // ... + + // Change the HA-IP balancing mode to 'roundrobin' (this is the default mode) + Transip_HaipService::setBalancingMode('example-haip', 'roundrobin', ''); + + // ... + + // Change the HA-IP balancing mode to 'source' + Transip_HaipService::setBalancingMode('example-haip', 'source', ''); + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-setDefaultPortConfiguration.php b/examples/HaipService-setDefaultPortConfiguration.php new file mode 100644 index 0000000..a219d62 --- /dev/null +++ b/examples/HaipService-setDefaultPortConfiguration.php @@ -0,0 +1,21 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // set dafault port configuration by haip name + Transip_HaipService::setDefaultPortConfiguration('example-haip'); + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-setHaipDescription.php b/examples/HaipService-setHaipDescription.php new file mode 100644 index 0000000..41d0183 --- /dev/null +++ b/examples/HaipService-setHaipDescription.php @@ -0,0 +1,22 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // set description by HA-IP name + $haip = Transip_HaipService::setHaipDescription('example-haip', 'example.com-haip'); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-setHaipVpses.php b/examples/HaipService-setHaipVpses.php new file mode 100644 index 0000000..c1efc18 --- /dev/null +++ b/examples/HaipService-setHaipVpses.php @@ -0,0 +1,20 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Replaces currently attached VPSes to the HA-IP with the provided list of VPSes + Transip_HaipService::setHaipVpses('example-haip', ['example-vps1', 'example-vps2']); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-setHttpHealthCheck.php b/examples/HaipService-setHttpHealthCheck.php new file mode 100644 index 0000000..11d30e9 --- /dev/null +++ b/examples/HaipService-setHttpHealthCheck.php @@ -0,0 +1,20 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Configure a HTTP health check for the HA-IP that will access '/health.php' on port 80 + Transip_HaipService::setHttpHealthCheck('example-haip', '/health.php', 80); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-setIpSetup.php b/examples/HaipService-setIpSetup.php new file mode 100644 index 0000000..c9f187a --- /dev/null +++ b/examples/HaipService-setIpSetup.php @@ -0,0 +1,31 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Enable both IPv4 and IPv6 for the HA-IP + Transip_HaipService::setIpSetup('example-haip', 'both'); + + // ... + + // Disable IPv6 for the HA-IP + Transip_HaipService::setIpSetup('example-haip', 'noipv6'); + + // ... + + // Forward all IPv6 for the HA-IP to the IPv4 address on the VPS + Transip_HaipService::setIpSetup('example-haip', 'ipv6to4'); + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-setPtrForHaip.php b/examples/HaipService-setPtrForHaip.php new file mode 100644 index 0000000..eb8c20b --- /dev/null +++ b/examples/HaipService-setPtrForHaip.php @@ -0,0 +1,21 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Set a ptr by HA-IP name + Transip_HaipService::setPtrForHaip('example-haip', 'example.com'); + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-setTcpHealthCheck.php b/examples/HaipService-setTcpHealthCheck.php new file mode 100644 index 0000000..708f035 --- /dev/null +++ b/examples/HaipService-setTcpHealthCheck.php @@ -0,0 +1,20 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Configure the health check for the HA-IP to use TCP. This will disable a configured HTTP health check. + Transip_HaipService::setTcpHealthCheck('example-haip'); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-startHaipLetsEncryptCertificateIssue.php b/examples/HaipService-startHaipLetsEncryptCertificateIssue.php new file mode 100644 index 0000000..70d9ecc --- /dev/null +++ b/examples/HaipService-startHaipLetsEncryptCertificateIssue.php @@ -0,0 +1,21 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // issue a letsEncrypt certificate by HA-IP name and common Name + Transip_HaipService::startHaipLetsEncryptCertificateIssue('example-haip', 'commonName'); + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-updateHaipPortConfiguration.php b/examples/HaipService-updateHaipPortConfiguration.php new file mode 100644 index 0000000..0beccdf --- /dev/null +++ b/examples/HaipService-updateHaipPortConfiguration.php @@ -0,0 +1,26 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Update the HA-IP port configuration by haip name and port configuration id + // mode ('tcp','http','https','proxy') + // endpointSslMode ('off','on','strict') + $haip = Transip_HaipService::updateHaipPortConfiguration('example-haip', 1, 'HTTP', 80, 'http'); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/HaipService-updatePortConfiguration.php b/examples/HaipService-updatePortConfiguration.php new file mode 100644 index 0000000..16e0337 --- /dev/null +++ b/examples/HaipService-updatePortConfiguration.php @@ -0,0 +1,24 @@ + + */ + +// Include haipservice +require_once('Transip/HaipService.php'); + +try { + // Update the HA-IP port configuration by haip name and port configuration id + // mode ('tcp','http','https','proxy') + // endpointSslMode ('off','on','strict') + $haip = Transip_HaipService::updatePortConfiguration('example-haip', 1, 'HTTP', 80, 80, 'http', 'off'); + + print_r($haip); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/PropositionService-getPropositionStatus.php b/examples/PropositionService-getPropositionStatus.php new file mode 100644 index 0000000..9563ede --- /dev/null +++ b/examples/PropositionService-getPropositionStatus.php @@ -0,0 +1,21 @@ +getMessage(), PHP_EOL; +} + +?> \ No newline at end of file diff --git a/examples/VpsService-addIpv6ToVps.php b/examples/VpsService-addIpv6ToVps.php new file mode 100644 index 0000000..aaed3bf --- /dev/null +++ b/examples/VpsService-addIpv6ToVps.php @@ -0,0 +1,21 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // add ipv6 to specific VPS (Ipv6 has to be in you Ipv6 Range) + Transip_VpsService::addIpv6ToVps('vps-name','ipv6-address'); + echo 'added ipv6 to Vps'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-addVpsToPrivateNetwork.php b/examples/VpsService-addVpsToPrivateNetwork.php new file mode 100644 index 0000000..f966d33 --- /dev/null +++ b/examples/VpsService-addVpsToPrivateNetwork.php @@ -0,0 +1,21 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // add the VPS to private network + Transip_VpsService::addVpsToPrivateNetwork('vps-name','private-network-name'); + echo 'added Vps to private network'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} \ No newline at end of file diff --git a/examples/VpsService-cancelAddon.php b/examples/VpsService-cancelAddon.php new file mode 100644 index 0000000..79d0a06 --- /dev/null +++ b/examples/VpsService-cancelAddon.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // cancel the addon for specific VPS + Transip_VpsService::cancelAddon('vps-name','addon-name'); + echo 'Cancelled addon'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} \ No newline at end of file diff --git a/examples/VpsService-cancelPrivateNetwork.php b/examples/VpsService-cancelPrivateNetwork.php new file mode 100644 index 0000000..21b11bc --- /dev/null +++ b/examples/VpsService-cancelPrivateNetwork.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // cancel private network + // end-time is either: 'immediately' or 'end' (end means end of contract) + Transip_VpsService::cancelPrivateNetwork('privateNetwork-name', 'end-time'); + echo 'Cancelled private network'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} \ No newline at end of file diff --git a/examples/VpsService-cancelVps.php b/examples/VpsService-cancelVps.php new file mode 100644 index 0000000..a21d790 --- /dev/null +++ b/examples/VpsService-cancelVps.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // cancel VPS + // end-time is either: 'immediately' or 'end' (end means end of contract) + Transip_VpsService::cancelVps('vps-name', 'immediately'); + echo 'Cancelled Vps'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-cloneVps.php b/examples/VpsService-cloneVps.php new file mode 100644 index 0000000..98dcade --- /dev/null +++ b/examples/VpsService-cloneVps.php @@ -0,0 +1,24 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // clone this VPS to a new VPS with the same specs + Transip_VpsService::cloneVps('vps-name'); + echo 'The vps clone has been started.'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-createSnapshot.php b/examples/VpsService-createSnapshot.php new file mode 100644 index 0000000..87d13b8 --- /dev/null +++ b/examples/VpsService-createSnapshot.php @@ -0,0 +1,21 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Create snapshot for vps + Transip_VpsService::createSnapshot('vps-name', 'snapshot-description'); + echo 'Starting snapshot'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getActiveAddonsForVps.php b/examples/VpsService-getActiveAddonsForVps.php new file mode 100644 index 0000000..62de357 --- /dev/null +++ b/examples/VpsService-getActiveAddonsForVps.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of all addons for given Vps + $addons = Transip_VpsService::getActiveAddonsForVps('vps-name'); + + print_r($addons); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} \ No newline at end of file diff --git a/examples/VpsService-getAllIps.php b/examples/VpsService-getAllIps.php new file mode 100644 index 0000000..cffa0f3 --- /dev/null +++ b/examples/VpsService-getAllIps.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of all the Ips + $allIps = Transip_VpsService::getAllIps(); + + print_r($allIps); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getAllPrivateNetworks.php b/examples/VpsService-getAllPrivateNetworks.php new file mode 100644 index 0000000..3e20ffc --- /dev/null +++ b/examples/VpsService-getAllPrivateNetworks.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of all PrivateNetwork objects in your account + $privateNetworks = Transip_VpsService::getAllPrivateNetworks(); + + print_r($privateNetworks); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getAvailabilityZones.php b/examples/VpsService-getAvailabilityZones.php new file mode 100644 index 0000000..0290db9 --- /dev/null +++ b/examples/VpsService-getAvailabilityZones.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a vps by name + $zones = Transip_VpsService::getAvailableAvailabilityZones(); + + print_r($zones); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getAvailableAddons.php b/examples/VpsService-getAvailableAddons.php new file mode 100644 index 0000000..2184d33 --- /dev/null +++ b/examples/VpsService-getAvailableAddons.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of all available addons + $addons = Transip_VpsService::getAvailableAddons(); + + print_r($addons); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getAvailableAddonsForVps.php b/examples/VpsService-getAvailableAddonsForVps.php new file mode 100644 index 0000000..4023f51 --- /dev/null +++ b/examples/VpsService-getAvailableAddonsForVps.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of all the available addons for specific Vps + $addons = Transip_VpsService::getActiveAddonsForVps('vps-name'); + + print_r($addons); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getAvailableProducts.php b/examples/VpsService-getAvailableProducts.php new file mode 100644 index 0000000..d12436b --- /dev/null +++ b/examples/VpsService-getAvailableProducts.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of all the products + $products = Transip_VpsService::getAvailableProducts(); + + print_r($products); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getAvailableUpgrades.php b/examples/VpsService-getAvailableUpgrades.php new file mode 100644 index 0000000..9f7f27e --- /dev/null +++ b/examples/VpsService-getAvailableUpgrades.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of the possible upgrades for a specific VPS + $upgrades = Transip_VpsService::getAvailableUpgrades('vps-name'); + + print_r($upgrades); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getCancellableAddonsForVps.php b/examples/VpsService-getCancellableAddonsForVps.php new file mode 100644 index 0000000..adee73c --- /dev/null +++ b/examples/VpsService-getCancellableAddonsForVps.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of all addon objects + $addons = Transip_VpsService::getCancellableAddonsForVps('vps-name'); + + print_r($addons); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getIpsForVps.php b/examples/VpsService-getIpsForVps.php new file mode 100644 index 0000000..01b793c --- /dev/null +++ b/examples/VpsService-getIpsForVps.php @@ -0,0 +1,25 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // Get a list of Ip objects + $ips = Transip_VpsService::getIpsForVps('vps-name'); + + print_r($ips); +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getOperatingSystems.php b/examples/VpsService-getOperatingSystems.php new file mode 100644 index 0000000..bbaefe7 --- /dev/null +++ b/examples/VpsService-getOperatingSystems.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of all OperatingSystem objects + $operatingSystemList = Transip_VpsService::getOperatingSystems(); + + print_r($operatingSystemList); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getPooledTrafficInformation.php b/examples/VpsService-getPooledTrafficInformation.php new file mode 100644 index 0000000..dbc2f63 --- /dev/null +++ b/examples/VpsService-getPooledTrafficInformation.php @@ -0,0 +1,33 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get all the traffic information for the current contract period by vps name + + /** + * Returns Array with the following Elements: + * + * 'startDate' + * 'endDate' + * 'usedInBytes' + * 'usedTotalBytes' + * 'maxBytes' + */ + + $trafficInformation = Transip_VpsService::getPooledTrafficInformation(); + print_r($trafficInformation); + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getPrivateNetworksByVps.php b/examples/VpsService-getPrivateNetworksByVps.php new file mode 100644 index 0000000..7a5c6c8 --- /dev/null +++ b/examples/VpsService-getPrivateNetworksByVps.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of private network objects + $privateNetworks = Transip_VpsService::getPrivateNetworksByVps('vps-name'); + + print_r($privateNetworks); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getSnapshotsByVps.php b/examples/VpsService-getSnapshotsByVps.php new file mode 100644 index 0000000..c54e4d9 --- /dev/null +++ b/examples/VpsService-getSnapshotsByVps.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of all snapshots for a vps + $snapshotList = Transip_VpsService::getSnapshotsByVps('vps-name'); + + print_r($snapshotList); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getTrafficInformationForVps.php b/examples/VpsService-getTrafficInformationForVps.php new file mode 100644 index 0000000..b1d6c5e --- /dev/null +++ b/examples/VpsService-getTrafficInformationForVps.php @@ -0,0 +1,33 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get all the traffic information for the current contract period by vps name + + /** + * Returns Array with the following Elements: + * + * 'startDate' + * 'endDate' + * 'usedInBytes' + * 'usedTotalBytes' + * 'maxBytes' + */ + + $trafficInformation = Transip_VpsService::getTrafficInformationForVps('vps-name'); + print_r($trafficInformation); + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getVps.php b/examples/VpsService-getVps.php new file mode 100644 index 0000000..93bcb1d --- /dev/null +++ b/examples/VpsService-getVps.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a vps by name + $vps = Transip_VpsService::getVps('vpsName'); + + print_r($vps); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getVpsBackupsByVps.php b/examples/VpsService-getVpsBackupsByVps.php new file mode 100644 index 0000000..b944e34 --- /dev/null +++ b/examples/VpsService-getVpsBackupsByVps.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get backups + $backupList = Transip_VpsService::getVpsBackupsByVps('vps-name'); + + print_r($backupList); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-getVpses.php b/examples/VpsService-getVpses.php new file mode 100644 index 0000000..6b373b2 --- /dev/null +++ b/examples/VpsService-getVpses.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Get a list of all Vps objects + $vpsList = Transip_VpsService::getVpses(); + + print_r($vpsList); +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-handoverVps.php b/examples/VpsService-handoverVps.php new file mode 100644 index 0000000..438307c --- /dev/null +++ b/examples/VpsService-handoverVps.php @@ -0,0 +1,23 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // handover the vps to another account + Transip_VpsService::handoverVps('vps-name','target-account-name'); + + echo 'handover process started'; + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-installOperatingSystem.php b/examples/VpsService-installOperatingSystem.php new file mode 100644 index 0000000..375bc05 --- /dev/null +++ b/examples/VpsService-installOperatingSystem.php @@ -0,0 +1,22 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // hostname is only used when installing a "preinstalled image" like plesk, directadmin or cpanel + Transip_VpsService::installOperatingSystem('vps-name','operating-system-name','hostname'); + echo 'Operating system install in progress'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-installOperatingSystemUnattended.php b/examples/VpsService-installOperatingSystemUnattended.php new file mode 100644 index 0000000..88d2f67 --- /dev/null +++ b/examples/VpsService-installOperatingSystemUnattended.php @@ -0,0 +1,53 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + $base64InstallText = base64_encode(' +## Mirror settings +d-i mirror/country string manual +d-i mirror/http/hostname string mirror.transip.net +d-i mirror/http/directory string /debian/debian + +## Automatically choose keymapping, since VNC client will translate to the clients one +d-i keymap select us + +## Automatically select the networking interface +d-i netcfg/choose_interface select auto + +## Install ACPId so the machine is responsive to Ctrl+Alt+Del etc +d-i pkgsel/include string acpid + +# Any hostname and domain names assigned from dhcp take precedence over +# values set here. However, setting the values still prevents the questions +# from being shown, even if values come from dhcp. +d-i netcfg/get_hostname string test-vps +d-i netcfg/get_domain string example.com + +# Controls whether or not the hardware clock is set to UTC. +d-i clock-setup/utc boolean true + +# You may set this to any valid setting for $TZ; see the contents of +# /usr/share/zoneinfo/ for valid values. +d-i time/zone string Europe/Amsterdam + +# Controls whether to use NTP to set the clock during the install +d-i clock-setup/ntp boolean true +'); + + Transip_VpsService::installOperatingSystemUnattended('vps-name','debian-8',$base64InstallText); + echo 'Operating system install in progress'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-orderAddon.php b/examples/VpsService-orderAddon.php new file mode 100644 index 0000000..afffc9e --- /dev/null +++ b/examples/VpsService-orderAddon.php @@ -0,0 +1,23 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // order the addon for specific VPS, use array + $addon = array('addon-name'); + Transip_VpsService::orderAddon('vps-name',$addon); + echo 'Ordered addon'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} \ No newline at end of file diff --git a/examples/VpsService-orderPrivateNetwork.php b/examples/VpsService-orderPrivateNetwork.php new file mode 100644 index 0000000..a172851 --- /dev/null +++ b/examples/VpsService-orderPrivateNetwork.php @@ -0,0 +1,20 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + Transip_VpsService::orderPrivateNetwork(); + echo 'Ordered private network'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} \ No newline at end of file diff --git a/examples/VpsService-orderVps.php b/examples/VpsService-orderVps.php new file mode 100644 index 0000000..47b6419 --- /dev/null +++ b/examples/VpsService-orderVps.php @@ -0,0 +1,25 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + $productName = 'vps-bladevps-x1'; + $addons = array(); + $operatingSystemName = 'freebsd-10.2'; + $hostname = ''; + + Transip_VpsService::orderVpsInAvailabilityZone($productName, $addons, $operatingSystemName, $hostname, 'ams0'); + echo 'Ordered VPS'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-removeSnapshot.php b/examples/VpsService-removeSnapshot.php new file mode 100644 index 0000000..54d1999 --- /dev/null +++ b/examples/VpsService-removeSnapshot.php @@ -0,0 +1,24 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // Remove snapshot for vps + Transip_VpsService::removeSnapshot('vps-name', 'snapshot-name'); + echo 'Removing snapshot'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-removeVpsFromPrivateNetwork.php b/examples/VpsService-removeVpsFromPrivateNetwork.php new file mode 100644 index 0000000..d6a134b --- /dev/null +++ b/examples/VpsService-removeVpsFromPrivateNetwork.php @@ -0,0 +1,24 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // Remove the VPS from a private Network + Transip_VpsService::removeVpsFromPrivateNetwork('vps-name', 'private-network-name'); + echo 'Removing VPS from Private Network'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-reset.php b/examples/VpsService-reset.php new file mode 100644 index 0000000..bbbee9c --- /dev/null +++ b/examples/VpsService-reset.php @@ -0,0 +1,24 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // Reset a vps + Transip_VpsService::reset('vps-name'); + echo 'The vps has been resetted.'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-revertSnapshot.php b/examples/VpsService-revertSnapshot.php new file mode 100644 index 0000000..9a3624c --- /dev/null +++ b/examples/VpsService-revertSnapshot.php @@ -0,0 +1,24 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // Revert snapshot for vps + Transip_VpsService::revertSnapshot('vps-name', 'snapshot-name'); + echo 'Reverting snapshot'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-revertSnapshotToOtherVps.php b/examples/VpsService-revertSnapshotToOtherVps.php new file mode 100644 index 0000000..5f1b970 --- /dev/null +++ b/examples/VpsService-revertSnapshotToOtherVps.php @@ -0,0 +1,24 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // Revert snapshot taken from vps-name to destination-vps-name + Transip_VpsService::revertSnapshotToOtherVps('vps-name', 'snapshot-name', 'destination-vps-name'); + echo 'Reverting snapshot from vps-name'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-revertVpsBackup.php b/examples/VpsService-revertVpsBackup.php new file mode 100644 index 0000000..6f5beb9 --- /dev/null +++ b/examples/VpsService-revertVpsBackup.php @@ -0,0 +1,24 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // Revert backup for vps + Transip_VpsService::revertVpsBackup('vps-name', 'backup-id'); + echo 'Reverting backup'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-setCustomerLock.php b/examples/VpsService-setCustomerLock.php new file mode 100644 index 0000000..247b59b --- /dev/null +++ b/examples/VpsService-setCustomerLock.php @@ -0,0 +1,26 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + + // enable customer lock + Transip_VpsService::setCustomerLock('vps-name',true); + echo 'vps is customer locked'; + // disable customer lock + Transip_VpsService::setCustomerLock('vps-name',false); + echo 'vps is unlocked'; + +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-start.php b/examples/VpsService-start.php new file mode 100644 index 0000000..3fbfc16 --- /dev/null +++ b/examples/VpsService-start.php @@ -0,0 +1,24 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // Start a vps + Transip_VpsService::start('vps-name'); + echo 'The vps has been started.'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-stop.php b/examples/VpsService-stop.php new file mode 100644 index 0000000..6a3b7ab --- /dev/null +++ b/examples/VpsService-stop.php @@ -0,0 +1,24 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // Stop a vps + Transip_VpsService::stop('vps-name'); + echo 'The vps has been stopped.'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-updatePtrRecord.php b/examples/VpsService-updatePtrRecord.php new file mode 100644 index 0000000..2d0cf97 --- /dev/null +++ b/examples/VpsService-updatePtrRecord.php @@ -0,0 +1,24 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try +{ + // Update the PTR Record for a IP + Transip_VpsService::updatePtrRecord('ip-address','ptr-string'); + echo 'ptr string updated'; +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/VpsService-upgradeVps.php b/examples/VpsService-upgradeVps.php new file mode 100644 index 0000000..64d3810 --- /dev/null +++ b/examples/VpsService-upgradeVps.php @@ -0,0 +1,23 @@ + + */ + +// Include vpsservice +require_once('Transip/VpsService.php'); + +try { + // Upgrade a VPS + $operatingSystemList = Transip_VpsService::upgradeVps('vps-name','product-name'); + + echo 'Upgrading VPS'; +} catch (SoapFault $f) { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/WebhostingService-createMailBox.php b/examples/WebhostingService-createMailBox.php new file mode 100644 index 0000000..5804c14 --- /dev/null +++ b/examples/WebhostingService-createMailBox.php @@ -0,0 +1,28 @@ + + */ + +// Include webhostingservice +require_once('Transip/WebhostingService.php'); + +try +{ + // Create a MailBox for a webhosting package. + // with default settings + // It's also possible to create a mailbox with custom settings, + // for this the MailBox should be created with: + // $mailBox = new Transip_MailBox('info', , ) + $mailBox = new Transip_MailBox('info'); + Transip_WebhostingService::createMailBox('example.com', $mailBox); +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; +} diff --git a/examples/WebhostingService-getInfo.php b/examples/WebhostingService-getInfo.php new file mode 100644 index 0000000..e86a0b2 --- /dev/null +++ b/examples/WebhostingService-getInfo.php @@ -0,0 +1,178 @@ + + */ + +require_once('Transip/WebhostingService.php'); + +if(isset($_GET['domain']) && strlen($_GET['domain']) > 0) +{ + $domainName = $_GET['domain']; + + try + { + // Request information about a domain in your account by using the TransIP + // WebhostingService API; A WebHost Object will be returned holding all + // information available about the domain. + $domain = Transip_WebhostingService::getInfo($domainName); + + // INFO: A WebHost object holds all data directly available for a domain: + // + it has a list of MailBoxes, + // + a list of Cronjobs + // + a list of Dbs + // + a list of MailForwards + // + a list of subDomains + // + + $result = 'We got the following information about the domain ' . + htmlspecialchars($domainName) . ':'; + } + catch(SoapFault $e) + { + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); + } +} +else +{ + $domainName = ''; + $domain = null; + $result = ''; +} + +?> + + + + + +

TransIP API GetInfo Example

+ Fill in the domain you want to get information about and click on Get Info. +
+ +
+ +
+ + + + +

MailBoxes

+ + + + + + + + mailBoxes as $mailBox) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> +
mailboxspamCheckerStrengthmaxDiskUsageVacationReply
" . htmlspecialchars($mailBox->address) . "" . $mailBox->spamCheckerStrength . "" . $mailBox->maxDiskUsage . " MB"; + if($mailBox->hasVacationReply) + { + echo "Subject: " . htmlspecialchars($mailBox->vacationReplySubject) . "
"; + echo "Message: " . htmlspecialchars($mailBox->vacationReplyMessage) . "
"; + } + else + { + echo " "; + } + echo "
+ +

MailForwards

+ + + + + + mailForwards as $mailForward) + { + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> +
mailForwardtargetAddress
" . htmlspecialchars($mailForward->name) . "" . htmlspecialchars($mailForward->targetAddress) . "
+ +

Databases

+ + + + + dbs as $database) + { + echo ""; + echo ""; + echo ""; + } + ?> +
Database
" . htmlspecialchars($database->name) . "
+ +

Cronjobs

+ + + + + + + + cronjobs as $cronjob) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> +
nameurlemailTimeSpecification
" . htmlspecialchars($cronjob->name) . "" . htmlspecialchars($cronjob->url) . "" . htmlspecialchars($cronjob->email) . ""; + echo "minute: {$cronjob->minuteTrigger}
"; + echo "hour: {$cronjob->hourTrigger}
"; + echo "day: {$cronjob->dayTrigger}
"; + echo "month: {$cronjob->monthTrigger}
"; + echo "weekday: {$cronjob->weekdayTrigger}
"; + echo "
+ +

Subdomains

+ + + + + subDomains as $subDomain) + { + echo ""; + echo ""; + echo ""; + } + ?> +
subdomain
" . htmlspecialchars($subDomain->name) . "
+ + + + + diff --git a/examples/WebhostingService-getWebhostingDomainNames.php b/examples/WebhostingService-getWebhostingDomainNames.php new file mode 100644 index 0000000..3c08b1e --- /dev/null +++ b/examples/WebhostingService-getWebhostingDomainNames.php @@ -0,0 +1,31 @@ + + */ + +// Include webhosting service +require_once('Transip/WebhostingService.php'); + +// Set the result variable +$webhostingList = array(); + +try +{ + // Call the API, the result will be an array of all your webhosting names + $webhostingList = Transip_WebhostingService::getWebhostingDomainNames(); + + // Output the webhosting names + print_r($webhostingList); +} +catch(SoapFault $e) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $e->getMessage(), PHP_EOL; +} + +?> \ No newline at end of file diff --git a/examples/WebhostingService-order_and_upgrade.php b/examples/WebhostingService-order_and_upgrade.php new file mode 100644 index 0000000..b1d7952 --- /dev/null +++ b/examples/WebhostingService-order_and_upgrade.php @@ -0,0 +1,37 @@ + + */ + +// Include webhostingservice +require_once('Transip/WebhostingService.php'); + +try +{ + // Order webhosting for a domain you own + // + // We first need to get the available webhosting packages, so + // we can pick one to order + // This returns an array with the available WebhostingPackage objects. + // + // If we want to order an upgrade, we need to get the available upgrade packages and + // this call would be: + // $packages = Transip_WebhostingService::getAvailableUpgrades('transip.nl'); + $packages = Transip_WebhostingService::getAvailablePackages(); + + // Now order the first available package + // + // If we want to upgrade this call would be + // Transip_WebhostingService::upgrade('transip.nl', $packages[0]); + Transip_WebhostingService::order('example.com', $packages[0]); +} +catch(SoapFault $f) +{ + // It is possible that an error occurs when connecting to the TransIP Soap API, + // those errors will be thrown as a SoapFault exception. + echo 'An error occurred: ' . $f->getMessage() . PHP_EOL; +}