1

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.

DerApe
  • 3,097
  • 2
  • 35
  • 55
Fan Zhang
  • 59
  • 7

2 Answers2

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

0

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'}
        }
    }
}
mcruz
  • 1,534
  • 2
  • 11
  • 14
  • I confirm this time it works. Thanks for the explanation. Should need someone update the online webpage otherwise it's really misleading. – Fan Zhang Feb 02 '17 at 12:36
  • you're welcome :). You're right the webpage needs to be updated. – mcruz Feb 02 '17 at 13:38