September 1, 2014

Required price IDs for package

For any package retrieve a list of options organized by required category
import SoftLayer
package = 46

client = SoftLayer.Client()
categoryObjectMask = "mask[isRequired, itemCategory[id, name]]"

configurations = client['Product_Package'].getConfiguration(
    id=package, mask=categoryObjectMask)

pricesObjectMask = "mask[id;item.description;]"

prices = client['Product_Package'].getItemPrices(
    id=package, mask=pricesObjectMask)

headerFormat = '%s - %s:'
priceFormat = '    %s -- %s'
for configuration in configurations:
    if (not configuration['isRequired']):
    print headerFormat % (configuration['itemCategory']['name'],
    for price in prices:
        if ('categories' not in price):
        if any((category.get('id') == configuration['itemCategory']['id']
                for category in price['categories'])):
            print priceFormat % (price['id'], price['item']['description'])


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue