微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用SoftLayer Python客户端获取开票项目详细信息?

如何解决如何使用SoftLayer Python客户端获取开票项目详细信息?

如何使用Python SoftLayer客户端(使用v5.7.1)确定NFS计费项目(续航存储)的位置(例如:dal10)?

我在SO上使用了其他一些示例,并提出了这个建议,但是呼叫失败:

objectFilter = {"billingItem": {"id": {"operation": "12345"}}}
account.getAllBillingItems(filter=objectFilter)
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/SoftLayer/transports.py",line 240,in __call__
    raise _es(ex.faultCode,ex.faultString)
SoftLayer.exceptions.softLayerAPIError: SoftLayerAPIError(SOAP-ENV:Server): Internal Error

解决方法

尝试使用以下python脚本来获取结算项目的详细信息和位置。

导入json

import SoftLayer

API_USERNAME = 'set me'

API_KEY = 'set me'

client = SoftLayer.create_client_from_env(username=API_USERNAME,api_key=API_KEY)

billingItemId = 1234
mask = "mask[location]"

try:
    response = client['SoftLayer_Billing_Item'].getObject(mask=mask,id=billingItemId)
    print(response)
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 billing item information. "
          % (e.faultCode,e.faultString))

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。