首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Netscaler、负载均衡、IpsecVPN、SoftLayer等取消网络产品的接口方式

Netscaler、负载均衡、IpsecVPN、SoftLayer等取消网络产品的接口方式
EN

Stack Overflow用户
提问于 2015-11-19 23:18:03
回答 1查看 108关注 0票数 0

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

哪种是取消这些设备的正确Softlayer API方法?

用billingId取消它们,"SoftLayer_Billing_Item::cancelService“是正确的吗?

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的裸机服务器?或者,我是否可以通过提供网络设备Id来使用SoftLayer_Ticket::createCancelServerTicket取消网络设备?

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2015-11-20 02:51:43

是的,SoftLayer_Billing_Item::cancelService应该用来取消诸如:负载均衡器、iPsec虚拟专用网、Netscaler等项目,即使“SoftLayer_Billing_Item::cancelItem”是其他选项也可以使用。

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

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

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

代码语言:javascript
复制
<?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();
}

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

代码语言:javascript
复制
<?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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33807756

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档