Last active
December 16, 2015 04:29
-
-
Save ryanrhanson/5377817 to your computer and use it in GitHub Desktop.
Domain deletion script - Removes all dns zones on an account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$single_use = true; | |
if ($single_use) { | |
if(!isset($_SERVER['argv'][1]) || !isset($_SERVER['argv'][2])){ | |
die("single_use is set, please supply API Username and Key"); | |
} | |
require_once('SoftLayer/SoapClient.class.php'); | |
$apiUsername = $argv[1]; | |
$apiKey = $argv[2]; | |
} | |
else { | |
require_once('configuration/apiconfig.php'); | |
} | |
//Access the 'SoftLayer_Account service | |
$client = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, $apiUsername, $apiKey); | |
//Run getDomains against the SoftLayer_Account service, returns all dns zones on the account. | |
$doms = $client->getDomains(); | |
//Loop through each domain returned in the above array. | |
foreach ($doms as $domains) { | |
//Delete all domains on the account. | |
$domservice = SoftLayer_SoapClient::getClient('SoftLayer_Dns_Domain', $domains->id, $apiUsername, $apiKey); | |
echo "Deleting domain " . $domains->id . " - Name: " . $domains->name . "\n\r"; | |
$domservice->deleteObject(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment