Php SoftLayer API:使用哪种API方法来取消网络产品,如Netscaler、负载均衡器、IpsecVPN、子网
对于以下网络设备: Netscaler、负载平衡、IPSecVPN子网、 哪种是取消这些设备的正确Softlayer API方法 “SoftLayer\u Billing\u Item::cancelService”是使用billingId取消它们的正确选项吗 在SoftLayer_票证中也有一种方法 SoftLayer_票证::CreateCancelServer票证 SoftLayer_Ticket::createCancelServerTicket是否仅用于使用裸机服务器Id取消裸机服务器? 或者我可以使用SoftLayer_Ticket::createCancelServerTicket通过提供网络设备Id来取消网络设备吗Php SoftLayer API:使用哪种API方法来取消网络产品,如Netscaler、负载均衡器、IpsecVPN、子网,php,api,ibm-cloud-infrastructure,Php,Api,Ibm Cloud Infrastructure,对于以下网络设备: Netscaler、负载平衡、IPSecVPN子网、 哪种是取消这些设备的正确Softlayer API方法 “SoftLayer\u Billing\u Item::cancelService”是使用billingId取消它们的正确选项吗 在SoftLayer_票证中也有一种方法 SoftLayer_票证::CreateCancelServer票证 SoftLayer_Ticket::createCancelServerTicket是否仅用于使用裸机服务器Id取消裸机服
谢谢 是的,SoftLayer\u Billing\u Item::cancelService应用于取消诸如负载平衡器、iPsec VPN、Netscaler等项目,甚至“SoftLayer\u Billing\u Item::cancelItem”也是可以使用的其他选项 但是,不能用于服务(如网络产品),SLDN文件规定它只能用于服务器(条形金属) 以下是一些取消服务的示例: 使用“取消服务”取消“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();
}
<?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();
}