Created
October 22, 2013 17:46
-
-
Save ryanrhanson/7104908 to your computer and use it in GitHub Desktop.
Cancel Subnet by IP
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 | |
// Grab an IP address | |
$ip = readline("IP: "); | |
require_once dirname(__FILE__) . '/SoftLayer/SoapClient.class.php'; | |
$apiUsername = 'set me'; | |
$apiKey = 'set me too'; | |
$client = SoftLayer_SoapClient::getClient('SoftLayer_Network_Subnet_IpAddress', null, $apiUser, $apiKey); | |
// Set our object mask. We want subnet/billingItem info, as well as the VLAN (for display later) | |
$mask = new SoftLayer_ObjectMask(); | |
$mask->subnet; | |
$mask->subnet->billingItem; | |
$mask->subnet->networkVlan; | |
$client->setObjectMask($mask); | |
// Retrieve records for this ip. | |
$subnetToCancel = $client->getByIpAddress($ip); | |
// Echo out the subnet and its associated VLAN. | |
echo "Subnet: " . $subnetToCancel->subnet->billingItem->resourceName. "\n\r"; | |
echo "VLAN: " . $subnetToCancel->subnet->networkVlan->vlanNumber. "\n\r"; | |
// Submit an immediate cancellation for the subnet we specified above. Usually takes ~5 minutes to finish processing. | |
$billingClient = SoftLayer_SoapClient::getclient('SoftLayer_Billing_Item', $subnetToCancel->subnet->billingItem->id, $apiUser, $apiKey); | |
$billingClient->cancelItem(1,0,"Cancel Subnet - API Test"); | |
echo "Cancellation submitted for " . $subnetToCancel->subnet->billingItem->resourceName . " with billing item ID ". $subnetToCancel->subnet->billingItem->id . "\n\r"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment