SoftLayer API:如何从待处理发票清单中获取订单参考
import SoftLayer
client = SoftLayer.Client(api_key ='XXXXXX', username = 'xxxxxx')
pending_invoice_list = client['Account'].getPendingInvoice(mask='mask.items')
我只能获得发票行项目,我如何获得订单参考
答案 0 :(得分:0)
也许这段代码可以帮到你:
#!/usr/bin/env python
#Get Next Invoice TOP level Items.
import SoftLayer
from pprint import pprint as pp
# A valid Username
USERNAME = 'set me'
API_KEY = 'set me'
client = SoftLayer.create_client_from_env(username=USERNAME,
api_key=API_KEY)
accountService = client['SoftLayer_Account']
object_Mask="mask[createDate, description, hostName, domainName, lastBillDate, orderItem[id,order[id]]]"
try:
result = accountService.getNextInvoiceTopLevelBillingItems(mask = object_Mask)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
""""
If there was an error returned from the SoftLayer API then bomb out with the
error message.
"""""
print("Unable to retrieve the Account?s latest pending Invoice " )
print(e )
""""
Get pending Invoice.
This script retrieve an account's latest open (pending) invoice.
See below for more details.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Account
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Account
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getPendingInvoice
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Billing_Invoice
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Billing_Invoice_Item
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. sldn@softlayer.com
"""""
import SoftLayer
from pprint import pprint as pp
# A valid Username
USERNAME = 'set-me'
# A valid ApiKey token, generate one for you or your users, or view yours at https://control.softlayer.com/account/users
API_KEY = 'set-me'
client = SoftLayer.create_client_from_env(username=USERNAME,
api_key=API_KEY)
accountService = client['SoftLayer_Account']
object_Mask='mask[id, invoiceTopLevelItems[categoryCode, description, billingItemId, id, domainName, ' \
'hostName, billingItem[id,orderItem[id,order[id]]]]]' #Retrieves only specified properties
#in the object mask.
try:
""""
getPendingInvoice() method will an retrieve a SoftLayer_Billing_Item object.
""""",
result = accountService.getPendingInvoice(mask = object_Mask)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
""""
If there was an error returned from the SoftLayer API then bomb out with the
error message.
"""""
print("Unable to retrieve the Account’s latest pending Invoice")
代码aboce将返回您的待处理发票及其相关订单的InvoiveTopLevel项目。