- 对于SoftLayer_Security_Certificate,您只需要其中的标识符,您可以使用以下方法检索安全证书标识符:
方法:SoftLayer_Account::getSecurityCertificates 链接:http ://sldn.softlayer.com/reference/services/SoftLayer_Account/getSecurityCertificates
然后您可以使用SoftLayer_Security_Certificate:deleteObject方法删除它。
这里有一个例子:
<?php
/**
* Delete Security Certificate
*
* This script deletes a security certificate
*
* Important manual pages:
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Security_Certificate/deleteObject
*
* @license <http://sldn.softlayer.com/wiki/index.php/license>
* @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
require_once '\vendor\autoload.php';
/**
* Your SoftLayer API username
* @var string
*/
$username = "set me";
/**
* Your SoftLayer API key
* Generate one at: https://control.softlayer.com/account/users
* @var string
*/
$apiKey = "set me";
/**
* Define the security certificate identifier. You can retrieve the identifiers from them using
* SoftLayer_Account::getSecurityCertificates
* @var int
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Account/getSecurityCertificates
*/
$securityCertificateId = 14584;
// Create a SoftLayer API client object for "SoftLayer_Security_Certificate" service
$client = \SoftLayer\SoapClient::getClient('SoftLayer_Security_Certificate', null, $username, $apiKey);
// Set init parameters
$client -> setInitParameter($securityCertificateId);
try {
$result = $client -> deleteObject();
print_r($result);
} catch(Exception $e) {
echo "Unable to delete Security Certificate " . $e -> getMessage();
}
?>
关于您帐户中的SoftLayer_Container_Product_Order_Network_Protection_Firewall_Dedicated对象,您可以通过以下 Rest 请求获取所有这些对象及其 billingItems:
https://$user:$apiKey@api.softlayer.com/rest/v3.1/SoftLayer_Search/advancedSearch?objectMask=mask[resource(SoftLayer_Network_Vlan_Firewall)[billingItem]]
Method: Post
{
"parameters":[
"_objectType:SoftLayer_Network_Vlan_Firewall _sort:[fullyQualifiedDomainName:asc]"
]
}
从 Firewall Dedicated获得billingItem后,您可以使用以下 php 脚本将其删除:
<?php
/**
* This script cancels the resource or service for a billing item
*
* Important manual pages:
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelService
*
* @license <http://sldn.softlayer.com/wiki/index.php/license>
* @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
require_once '\vendor\autoload.php';
/**
* Your SoftLayer API username
* @var string
*/
$username = "set me";
/**
* Your SoftLayer API key
* Generate one at: https://control.softlayer.com/account/users
* @var string
*/
$apiKey = "set me";
$endPoint = "http://stable.application.qadal0501.softlayer.local/v3.1/sldn/soap/";
/**
* Declare the billing item identifier from Network Protection Firewall Dedicated
* @var int
*/
$billingItemId = 26382998;
// Create a SoftLayer API client object for "SoftLayer_Billing_Item" service
$client = \SoftLayer\SoapClient::getClient('SoftLayer_Billing_Item', null, $username, $apiKey, $endPoint);
// Set init parameters
$client -> setInitParameter($billingItemId);
try {
$result = $client -> cancelService();
print_r($result);
} catch(Exception $e) {
echo "Unable to Cancel Service: " . $e -> getMessage();
}
?>
对于监控包对象,以下脚本将帮助获取虚拟访客及其计费项目的监控包:
<?php
/**
* This script retrieves a billing item of "monitoring_package" category code from a virtual guest
*
* Important manual pages:
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Billing_Item
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getBillingItem
*
* @license <http://sldn.softlayer.com/wiki/index.php/license>
* @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
require_once '\vendor\autoload.php';
/**
* Your SoftLayer API username
* @var string
*/
$username = "set me";
/**
* Your SoftLayer API key
* Generate one at: https://control.softlayer.com/account/users
* @var string
*/
$apiKey = "set me";
// Declare the server identifier
$serverId = 14463961;
// Create a SoftLayer API client object for "SoftLayer_Account" service
$guestService = \SoftLayer\SoapClient::getClient('SoftLayer_Virtual_Guest', $serverId, $username, $apiKey);
// Declare an object mask to relational properties
$objectMask = "mask[activeAssociatedChildren]";
$guestService -> setObjectMask($objectMask);
try {
$billingItems = $guestService -> getBillingItem();
foreach($billingItems -> activeAssociatedChildren as $billingItem)
{
if($billingItem -> categoryCode == "monitoring_package")
{
print_r($billingItem);
}
}
} catch(Exception $e) {
echo "Unable to get billing item: " . $e -> getMessage();
}
?>
从监控包中获得billingItem后,您可以使用SoftLayer_Billing_Item::cancelService取消它。
PHP SoftLayer 客户端:
https ://github.com/softlayer/softlayer-api-php-client