SoftLayer REST API 取消请求
SoftLayer REST API Cancellation Request
我想在将来的某个日期取消SoftLayer
设备,发现以下SoftLayer_Billing_Item_Cancellation_Request::createObject
。
如果我使用 json,request url
会是什么样子?POST parameters
会是什么样子?
谢谢
这是一个 Rest 示例,可以帮助您:
获取计费项目,请查看:
SoftLayer_Virtual_Guest::getBillingItem
此外,这是一个 Python 示例:
"""
Cancel a Virtual Guest.
It cancels the resource for a billing Item. The billing item will be cancelled
immediately and reclaim of the resource will begin shortly.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getObject
http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelService
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer.API
from pprint import pprint as pp
# Your SoftLayer API username and key.
API_USERNAME = 'set me'
# Generate one at https://control.softlayer.com/account/users
API_KEY = 'set me'
virtualGuestId = 9923645
client = SoftLayer.Client(
username=API_USERNAME,
api_key=API_KEY,
)
try:
# Getting the billing item id
mask = 'mask.billingItem.id'
cci = client['SoftLayer_Virtual_Guest'].getObject(mask=mask, id=virtualGuestId)
billingItemId = cci['billingItem']['id']
try:
# Canceling the Virtual Guest
result = client['Billing_Item'].cancelService(id=billingItemId)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to cancel the VSI faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to get the billing item id from VSI faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
在其他客户端也有很多例子可以帮助到你:
参考资料
SoftLayer_Billing_Item::cancelService
这可能是您要找的:
Post URL: https://api.softlayer.com/rest/v3.1/SoftLayer_Billing_Item_Cancellation_Request/createObject.json
Payload:
{
"parameters": [
{
"complexType": "SoftLayer_Billing_Item_Cancellation_Request",
"accountId": 321752,
"notes": "No notes provided",
"items": [
{
"complexType": "SoftLayer_Billing_Item_Cancellation_Request_Item",
"billingItemId": 25849466,
"scheduledCancellationDate": "5/15/2006"
}
]
}
]
}
希望对你有帮助
此致
对我有用的答案如下:
- https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[deviceID]/getBillingItem.json
- https://api.softlayer.com/rest/v3/SoftLayer_Billing_Item/[BillingItemID]/cancelServiceOnAnniversaryDate.json
两者都是 Get
请求。
我想在将来的某个日期取消SoftLayer
设备,发现以下SoftLayer_Billing_Item_Cancellation_Request::createObject
。
如果我使用 json,request url
会是什么样子?POST parameters
会是什么样子?
谢谢
这是一个 Rest 示例,可以帮助您:
获取计费项目,请查看:
SoftLayer_Virtual_Guest::getBillingItem
此外,这是一个 Python 示例:
"""
Cancel a Virtual Guest.
It cancels the resource for a billing Item. The billing item will be cancelled
immediately and reclaim of the resource will begin shortly.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getObject
http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelService
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer.API
from pprint import pprint as pp
# Your SoftLayer API username and key.
API_USERNAME = 'set me'
# Generate one at https://control.softlayer.com/account/users
API_KEY = 'set me'
virtualGuestId = 9923645
client = SoftLayer.Client(
username=API_USERNAME,
api_key=API_KEY,
)
try:
# Getting the billing item id
mask = 'mask.billingItem.id'
cci = client['SoftLayer_Virtual_Guest'].getObject(mask=mask, id=virtualGuestId)
billingItemId = cci['billingItem']['id']
try:
# Canceling the Virtual Guest
result = client['Billing_Item'].cancelService(id=billingItemId)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to cancel the VSI faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to get the billing item id from VSI faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
在其他客户端也有很多例子可以帮助到你:
参考资料
SoftLayer_Billing_Item::cancelService
这可能是您要找的:
Post URL: https://api.softlayer.com/rest/v3.1/SoftLayer_Billing_Item_Cancellation_Request/createObject.json
Payload:
{
"parameters": [
{
"complexType": "SoftLayer_Billing_Item_Cancellation_Request",
"accountId": 321752,
"notes": "No notes provided",
"items": [
{
"complexType": "SoftLayer_Billing_Item_Cancellation_Request_Item",
"billingItemId": 25849466,
"scheduledCancellationDate": "5/15/2006"
}
]
}
]
}
希望对你有帮助
此致
对我有用的答案如下:
- https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[deviceID]/getBillingItem.json
- https://api.softlayer.com/rest/v3/SoftLayer_Billing_Item/[BillingItemID]/cancelServiceOnAnniversaryDate.json
两者都是 Get
请求。