Reputation: 1
Our code is to cancel all billing items ordered. But there is an error when cancel the billing item Gateway Appliance Cluster
, saying "SoftLayerAPIError(SoftLayer_Exception_Public): This billing items category cannot be cancelled.".
Can you please advise how to cancel this billing item? Thanks.
Upvotes: 0
Views: 68
Reputation: 728
To cancel a gateway appliance you can use SoftLayer_Billing_Item::cancelItem
To get all gateways and their billing item ids in you account you can use the following rest api call:
Method: GET
https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getHardware?objectMask=mask[id,networkGatewayMemberFlag,billingItem[id]]&objectFilter={"hardware":{"networkGatewayMemberFlag":{"operation":1}}}
To cancel the gateway appliance see the following python script example:
import SoftLayer
from pprint import pprint as pp
# Use the hardware gateway id from request above.
hardware_id = 85467
client = SoftLayer.Client()
hardwareResult = client['SoftLayer_Hardware'].getBillingItem(id=hardware_id)
billingItemId = hardwareResult['id']
try:
result = client['SoftLayer_Billing_Item'].cancelItem(
False,
True,
"No longer needed",
"Api test",
id=billingItemId)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to get billing item information faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
Reference:
https://cloud.ibm.com/docs/gateway-appliance?topic=gateway-appliance-cancel-gateway-appliance
Upvotes: 0