Skip to content

Instantly share code, notes, and snippets.

@underscorephil
Last active October 12, 2015 18:18
Show Gist options
  • Save underscorephil/4067364 to your computer and use it in GitHub Desktop.
Save underscorephil/4067364 to your computer and use it in GitHub Desktop.
Retrieve required price options
import SoftLayer
apiUsername = ''
apiKey = ''
package = 46
client = SoftLayer.Client(username=apiUsername, api_key=apiKey)
categoryObjectMask = "mask[isRequired, itemCategory[id, name]]"
configurations = client['Product_Package'].getConfiguration(
id=package, mask=categoryObjectMask)
pricesObjectMask = "mask[id;item.description;categories.id]"
prices = client['Product_Package'].getItemPrices(
id=package, mask=pricesObjectMask)
headerFormat = '%s - %s:'
priceFormat = ' %s -- %s'
for configuration in configurations:
if (not configuration['isRequired']):
continue
print headerFormat % (configuration['itemCategory']['name'],
configuration['itemCategory']['id'])
for price in prices:
if ('categories' not in price):
continue
if any((category.get('id') == configuration['itemCategory']['id']
for category in price['categories'])):
print priceFormat % (price['id'], price['item']['description'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment