0
votes

I am in trouble with using ObjectFilter on softlayer API.

I'm testing Softlayer API to retrieve host IQN, username and password of block storage.

I have tried with the command below, but objectFilter is not working at all.

curl -g 'https://username:[email protected]/rest/v3/SoftLayer_Network_Storage/storage_ID/getObject?objectMask=mask[id,username,allowedIpAddresses[ipAddress,allowedHost[name,credential[username,password]]]]'

It returns 3 network objects including IQN, username , password as I expected.

So I want to make filter by "ip address" by below api command but not worked. (It seems objectFilter is ignoring)

curl -g 'https://username:[email protected]/rest/v3/SoftLayer_Network_Storage/storage_ID/getObject?objectMask=mask[id,username,allowedIpAddresses[ipAddress,allowedHost[name,credential[username,password]]]]&objectFilter={"object":{"allowedIpAddresses":{"ipAddress":{"operation":"1.2.3.4"}}}}'

Is this something wrong with my API usage?

1

1 Answers

0
votes

Actually the filter is working but you won't notice as there is a slight difference between object mask and filters, remember that Object filters can be used to limit the results returned by the API, they differ from object masks in that they determine what Data Type objects are returned (in this particular case the whole SoftLayer_Network_Storage single object and the relational properties you can see returned by using your object mask, for example [allowedIpAddresses] array), while Object Masks define what properties to retrieve from the returned objects.

For example, another way to retrieve and demonstrate how filters work, you may try the following request:

curl -g "https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getNetworkStorage?objectMask=mask[id,username,allowedIpAddresses[ipAddress,allowedHost[name,credential[username,password]]]]&objectFilter=%7B%22networkStorage%22%3A%7B%22allowedIpAddresses%22%3A%7B%22ipAddress%22%3A%7B%22operation%22%3A%22[ipAddress]%22%7D%7D%7D%7D"

This method retrieves an Array of all the account's associated storage volumes, including Lockbox, NAS, EVault, and iSCSI volumes (among them your block storage on it).

You may use the request without the object filter and verify all the objects returned by just using your object Mask, and then use the complete request with the object filter verifying that it narrowed the objects returned to the single object of your block storage by using the ipAddress you define on it.

For more information please see below:

https://sldn.softlayer.com/blog/bpotter/going-further-softlayer-api-python-client-part-1

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

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