0

对于以下网络设备:Netscaler、负载平衡、IPSecVPN 子网、

取消这些设备的正确 Softlayer API 方法是什么?

“SoftLayer_Billing_Item::cancelService”是否适合使用 billingId 取消它们?

http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelService

SoftLayer_ticket 里面还有一个方法

SoftLayer_Ticket::createCancelServerTicket http://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createCancelServerTicket

SoftLayer_Ticket::createCancelServerTicket 是否仅用于取消使用裸机服务器 ID 的裸机服务器?或者我可以使用 SoftLayer_Ticket::createCancelServerTicket 通过提供网络设备 ID 来取消网络设备吗?

谢谢。

4

1 回答 1

0

是的,SoftLayer_Billing_Item::cancelService 应该用于取消以下项目:负载均衡器、iPsec VPN、Netscaler 等,甚至“SoftLayer_Billing_Item::cancelItem”也是可以使用的其他选项。

但是,http ://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createCancelServerTicket 不能用于服务(例如网络产品),SLDN 文件说它只能用于服务器(金属条)

以下是一些取消服务的示例:

使用“cancelService”取消“IpSec VPN”:

<?php
require_once(dirname(__FILE__) . '/SoftLayer/SoapClient.class.php');
/**
 * Set your SoftLayer API username and key.
 */
$apiUsername = 'set me';
$apiKey = 'set me';

/**
 * Set the service to use
 */
$ipSecService ='SoftLayer_Network_Tunnel_Module_Context';
$billingItemService = 'SoftLayer_Billing_Item';

$ipSecId = 77;


/**
 * Create a client to the API service.
 */
$ipSecClient = SoftLayer_SoapClient::getClient($ipSecService, $ipSecId, $apiUsername, $apiKey);

$mask = new SoftLayer_ObjectMask();
$mask = 'mask[id,billingItem.id]';
$ipSecClient->setObjectMask($mask);

try {
       $ipSecItem = $ipSecClient->getObject();
    $billingItemId = $ipSecItem->billingItem->id; 
    print_r($billingItemId);


    try {
        $billingItemClient = SoftLayer_SoapClient::getClient($billingItemService, $billingItemId, $apiUsername, $apiKey, $endpointUrl);
        $result = $billingItemClient->cancelService();
        print_r($result);

    } catch(Exception $e) {
        echo 'Unable to cancel the item: ' . $e->getMessage();
    }


} catch (Exception $e) {
    echo 'Failed ... Unable to get item: ' . $e->getMessage();
}

使用“cancelItem”取消“IpSec VPN”:

<?php
require_once(dirname(__FILE__) . '/SoftLayer/SoapClient.class.php');
/**
 * Set your SoftLayer API username and key.
 */
$apiUsername = 'set me';
$apiKey = 'set me';
/**
 * Set the service to use
 */
$ipSecService ='SoftLayer_Network_Tunnel_Module_Context';
$billingItemService = 'SoftLayer_Billing_Item';

$ipSecId = 77;


/**
 * Create a client to the API service.
 */
$ipSecClient = SoftLayer_SoapClient::getClient($ipSecService, $ipSecId, $apiUsername, $apiKey, $endpointUrl);
//$ipSecClient = SoftLayer_SoapClient::getClient($ipSecService, $ipSecId, $apiUsername, $apiKey);

$mask = new SoftLayer_ObjectMask();
$mask = 'mask[id,billingItem.id]';
$ipSecClient->setObjectMask($mask);

try {
    $ipSecItem = $ipSecClient->getObject();
    $billingItemId = $ipSecItem->billingItem->id; 
    print_r($billingItemId);


    try {
        $billingItemClient = SoftLayer_SoapClient::getClient($billingItemService, $billingItemId, $apiUsername, $apiKey, $endpointUrl);
        $result = $billingItemClient->cancelItem(   False,
            False,
            'No longer needed',
            'Api test');
        print_r($result);

    } catch(Exception $e) {
        echo 'Unable to cancel the item: ' . $e->getMessage();
    }


} catch (Exception $e) {
    echo 'Failed ... Unable to get item: ' . $e->getMessage();
}

参考: http: //sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelService http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelItem

于 2015-11-19T18:51:42.857 回答