Search code examples
apiibm-cloud-infrastructure

Softlayer API for getting processors values for packages based on datacenter


https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/271/getItems.json

For this its giving me 3 servers

  • 1)Quad Intel Xeon E7-4850 v2 (48 Cores, 2.30 GHz)
  • 2)Quad Intel Xeon E7-4820 v2 (32 Cores, 2.00 GHz)
  • 3)Quad Intel Xeon E7-4890 v2 (60 Cores, 2.80 GHz)

but if I select Washington-01 on softlayer it gives me only two servers:-

  • 1)Quad Intel Xeon E7-4850 v2 (48 Cores, 2.30 GHz)
  • 2)Quad Intel Xeon E7-4820 v2 (32 Cores, 2.00 GHz)

How do I filter this response based on datacenter?


Solution

  • The reason why the portal is displaying a different quantity is because it has several algorithms to narrow the best options through location conflicts, item conflicts, etc.,

    You could use the following Rest api example for filter through DC:

    https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/271/getItems?objectMask=mask[attributes[attributeTypeKeyName], itemCategory[questions[fieldType, itemCategoryReferences]], prices[attributes[itemPriceAttributeType],categories[categoryCode],pricingLocationGroup[locations]],activeUsagePrices[pricingLocationGroup[locations]],locationConflicts]&objectFilter={"items":{"prices":{"pricingLocationGroup":{"locations":{"name":{"operation":"*= wdc"}}}}}}
    

    It will return the locations, locationConflicts among others by using masks, also it makes use of filters to search by datacenter as you required, on the other hand take into account that locationGroupId is "null" when the it is a Standard price, it means it`ll work on any DC.

    UPDATE

    Currently the portal use the Product_Package_Server::getAllObjects, and you`ll see the the list of all available locations inside property "datacenters" (this is how the portal narrows the available locations per server), at the moment Quad Intel Xeon E7-4890 v2 (60 Cores, 2.80 GHz) is not available on wdc01 as you could verify through the following request :

    https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package_Server/getAllObjects?objectFilter={"datacenters":{"operation":"*= wdc01"}}
    

    For more information see below:

    https://softlayer.github.io/article/object-filters/

    https://softlayer.github.io/article/object-masks/