duanchendu69495 2015-11-19 15:18
浏览 68

SoftLayer API:用于取消网络产品的API方法,如Netscaler,负载均衡器,IpsecVPN,子网

For the following Network devices: Netscaler, Load balancing, IPSecVPN Subnet,

which is the right Softlayer API method to cancel these devices?

Is the "SoftLayer_Billing_Item::cancelService" the right one to cancel them with billingId?

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

There's also a method in SoftLayer_ticket

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

Is the SoftLayer_Ticket::createCancelServerTicket only for cancelling Bare Metal server using the bare metal server Id? Or can I use SoftLayer_Ticket::createCancelServerTicket to cancel network devices by providing a network device Id ?

Thanks.

  • 写回答

1条回答 默认 最新

  • dqrdlqpo775594 2015-11-19 18:51
    关注

    Yes, SoftLayer_Billing_Item::cancelService should be used to cancel items like: Load balancer, iPsec VPN, Netscaler, etc., even “SoftLayer_Billing_Item::cancelItem” is other option to use.

    However, http://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createCancelServerTicket cannot be used for services (e.g. Network products), the SLDN document says that it should be used only for servers (bar metals)

    Here are some examples to cancel services:

    Cancel “IpSec VPN” using “cancelService”:

    <?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();
    }
    

    Cancel “IpSec VPN” using “cancelItem”:

    <?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();
    }
    

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

    评论

报告相同问题?

悬赏问题

  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了