Softlayer API:通过OS referenceCode

时间:2015-11-17 16:15:15

标签: api ibm-cloud-infrastructure

我正在尝试过滤掉list of images by OS reference code。这是我正在尝试的网址:

https://api.softlayer.com/rest/v3/SoftLayer_Account/getBlockDeviceTemplateGroups.json?objectMask=mask[flexImageFlag]&objectFilter={'children': {'blockDevices': {'diskImage': {'softwareReferences': {'softwareDescription': {'referenceCode': {'operation': 'REDHAT_6_64'}}}}}}}

但是我一直收到以下错误信息:

{"error":"Unable to parse object filter.","code":"SoftLayer_Exception_Public"}

任何人都可以帮我看看有什么问题吗?提前谢谢!

Q.Z。

2 个答案:

答案 0 :(得分:1)

过滤器错误,但在我的测试中,过滤器无法使用" referenceCode"属性;您需要使用其他属性,例如名称,版本或两者。见下面的例子:

使用名称和版本属性

https://api.softlayer.com/rest/v3/SoftLayer_Account/getBlockDeviceTemplateGroups?objectMask=mask[flexImageFlag]&objectFilter={"blockDeviceTemplateGroups": {"children":{"blockDevices":{"diskImage":{"softwareReferences":{"softwareDescription":{"name":{"operation":"CentOS"}, "version":{"operation":"6.3-32"}}}}}}}}

仅使用属性(在本例中为name)

https://api.softlayer.com/rest/v3/SoftLayer_Account/getBlockDeviceTemplateGroups?objectMask=mask[flexImageFlag]&objectFilter={"blockDeviceTemplateGroups": {"children":{"blockDevices":{"diskImage":{"softwareReferences":{"softwareDescription":{"name":{"operation":"CentOS"}}}}}}}}

此致

答案 1 :(得分:0)

看起来您正在使用REST API。中的例子 API reference,建议此参数应采用JSON格式:

https://api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests?objectMask=mask[id,hostname]&objectFilter={"datacenter":{"name":{"operation":"dal05"}}}

您的错误显示"无法解析对象过滤器。",因此错误可能只是您的参数无效JSON:JSON standard只接受双引号。

尝试替换

{'children': {'blockDevices': {'diskImage': {'softwareReferences': {'softwareDescription': {'referenceCode': {'operation': 'REDHAT_6_64'}}}}}}}

使用相应的有效json:

{"children": {"blockDevices": {"diskImage": {"softwareReferences": {"softwareDescription": {"referenceCode": {"operation": "REDHAT_6_64"}}}}}}}