Python 3.x softlayer api从待定发票列表获取订单参考
SoftLayer API:如何从待定发票列表中获取订单参考Python 3.x softlayer api从待定发票列表获取订单参考,python-3.x,ibm-cloud-infrastructure,Python 3.x,Ibm Cloud Infrastructure,SoftLayer API:如何从待定发票列表中获取订单参考 import SoftLayer client = SoftLayer.Client(api_key ='XXXXXX', username = 'xxxxxx') pending_invoice_list = client['Account'].getPendingInvoice(mask='mask.items') 我只能获取发票行项目,如何获取订单参考也许此代码可以帮助您: #!/usr/bin/env python
import SoftLayer
client = SoftLayer.Client(api_key ='XXXXXX', username = 'xxxxxx')
pending_invoice_list = client['Account'].getPendingInvoice(mask='mask.items')
我只能获取发票行项目,如何获取订单参考也许此代码可以帮助您:
#!/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 )
代码aboce将返回待决发票及其关联订单的InvoiveTopLevel项目。其不返回订单id仅返回账单id如果您无法看到订单id,则billingItem是包含订单id的对象,因为您没有足够的权限,我建议您使用主用户测试iti是否尝试使用主帐户返回订单id为空?您的账单发票是否包含裸机服务器或虚拟来宾?他们应该有orderidi am主品牌帐户,我有n个客户,他们下虚拟客户和裸机服务器的订单,而我从主帐户发送发票需要指定订单id给客户
""""
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")