【问题标题】:How to get billing item details using the SoftLayer Python client?如何使用 SoftLayer Python 客户端获取计费项目详细信息?
【发布时间】:2020-11-10 03:30:51
【问题描述】:

如何使用 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-3.x rest filter ibm-cloud-infrastructure


【解决方案1】:

尝试使用以下 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))

【讨论】:

    猜你喜欢
    • 2015-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-20
    • 2016-10-24
    • 2010-11-01
    • 2017-08-04
    • 1970-01-01
    相关资源
    最近更新 更多