ObjectFilter in SoftLayer doesn't work

扶醉桌前 提交于 2019-12-02 13:32:14

问题


I find ObjectFilter doesn't work in SoftLayer.

I even tried the example provided in the SoftLayer webpage here:

https://sldn.softlayer.com/article/object-filters

REST:

List the ID and hostname of all servers in dal05

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

When I ran this command, it still returns all the virtual guests, regardless what data center that virtual guest belongs to.


回答1:


try this request:

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

The issue with your request is that you are missing the "virtualGuests" property, keep in mind that the objectFilter is filtering over the data in the database, so you need to tell it over what table work and over what record of the table work. e.g. using the "SoftLayer_Account" that implies that all the work will be over the "SoftLayer_Account" table now you need to tell id over what property/record of that table work in this case you need to work over the "virtualGuests" and so on. Please keep in mind that and you review the documentation about the valid properties/records e.g. these are the valid properties/record for Softlayer_Account:

http://sldn.softlayer.com/reference/datatypes/SoftLayer_Account

Regards




回答2:


Maybe you can try adding virtualGuestsin the filter, something like this:

objectFilter={ "virtualGuests": { "datacenter": { "longName": { "operation": "Dallas 6" } } } }

or please see the first examples of https://sldn.softlayer.com/article/object-filters, like this:

object_filter = {
    'virtualGuests': {
        'datacenter': {
            'name': {'operation': 'dal05'}
        }
    }
}


来源:https://stackoverflow.com/questions/41997010/objectfilter-in-softlayer-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!