- 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();
}
?>
Monitoring Package からbillingItemを取得したら、 SoftLayer_Billing_Item::cancelServiceでこれをキャンセルできます。
PHP SoftLayer クライアント:
https://github.com/softlayer/softlayer-api-php-client