首页 > 解决方案 > 如何使用 Python API 从 sotlayer 保存的报价中检索对象

问题描述

我正在尝试检索存储在特定 Softlayer 帐户的已保存报价下的对象/项目(服务器名称、主机名、域名、位置等)。有人可以帮助如何检索报价中的对象吗?我可以找到一个 REST API (Python) 来检索报价详细信息(报价 ID、状态等),但找不到在报价中获取对象的方法。

谢谢!

此致,

凯兰帕特尔

标签: pythonrestibm-cloudibm-cloud-infrastructure

解决方案


如果您尝试检索您在放置报价时发送的相同订单信息结构,那么您需要使用方法getRecalculatedOrderContainer,它应该返回 packageId、presetId、位置、项目价格等,但据我所知,主机名、域、sshKeys、provisionScripts、vlan 不在报价中,因为无论用户在下订单之前是否需要新值,或者由于 vlan 和子网等资源的可用性而避免系统错误,这些值可能会随着时间的推移而改变。

https://[username]:[apikey]api.softlayer.com/rest/v3/SoftLayer_Billing_Order_Quote/[quoteID]/getRecalculatedOrderContainer
Method: GET

现在,如果您想检索 orderId、item 等,那么无论您是使用这些方法还是它们都在列表中或作为单个对象返回数据类型SoftLayer_Billing_Order_Quote ,都需要使用对象掩码功能。Account::getQuotesSoftLayer_Billing_Order_Quote::getObject

帐户::getQuotes

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Account/getQuotes?objectMask=mask[id,name,order[id,status,items[id,description,domainName,hostName,location]]]

Method: GET

SoftLayer_Billing_Order_Quote::getObject

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Billing_Order_Quote/[quoteID]/getObject?objectMask=mask[id,name,order[id,status,items[id,description,location]]]

Method: GET

参考:

https://softlayer.github.io/reference/services/SoftLayer_Account/getQuotes/

https://softlayer.github.io/reference/services/SoftLayer_Billing_Order_Quote/

https://softlayer.github.io/reference/datatypes/SoftLayer_Billing_Order_Quote/


推荐阅读