Search code examples
rubyibm-cloud-infrastructure

Can't Query Product Package Server Relational & Count Properties


In my Ruby script, I can't seem to get the Softlayer_Product_Package_Server relational properties from the SoftLayer API endpoint. My Ruby code:

packageServerList = client['SoftLayer_Product_Package_Server'].getAllObjects
packageServerList.each do |packageServer|
     packageServer['package']
end

The packageServer['package'] just gives me a null object. Some of the other relations have the same issue ("brand", "catalog", "itemPrice"), but "item" seems to work. Taken from:

This is confusing because the REST request works and shows the data from a 'package' object mask.


Solution

  • To get relational or/and count properties, it's necessary to use an Object Masks, please make the below change in your code:

    packageServerList = client['SoftLayer_Product_Package_Server'].object_mask('mask[package, brand, caralog]').getAllObjects 
    

    References: