How to use object filter with softlayer rest api?

1.3k views Asked by At

I read this article and have some problems trying to follow the examples. The following is one of the examples given in that article. The first parameter in the object filter is virtualGuests. This object filter can be used in api https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests.

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

I want to use the object filter in other api methods, like SoftLayer_Account/getBlockDeviceTemplateGroups for example. My question is how to get/set the first parameter like virtualGuests? I tried several times but failed.

1

There are 1 answers

3
Ruber Cuellar Valenzuela On BEST ANSWER

Try to follow these recomendations: Getting first parameter through Service Datatype or How to define the first parameter as simple way?


Getting first parameter through Service Datatype

You are trying to get

As you see, you are using SoftLayer_Account service, you need to open its datatype from this service:

So, you need to start here, the method that you are using is getBlockDeviceTemplateGroups, if you want to get this information in the datatypes, you should skip the word "get" and looking for "BlockDeviceTemplateGroups" property, so you will have the correct parameter that you need to set at first.

enter image description here


How to define the first parameter as simple way?

If you notice, the only changes were: skip "get" word from the method, in this case is "getBlockDeviceTemplateGroups", so it will be:

"BlockDeviceTemplateGroups"

The next step should be set the first char in lowercase like:

"blockDeviceTemplateGroups"

So, it should be the filter:

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

References: