List Packages
A handy script with a few examples on how to interact with packages
import SoftLayer
from pprint import pprint as pp
class example():
def __init__(self):
self.client = SoftLayer.Client()
def main(self):
"""
Gets ALL packages, and prints their name and price descriptions
"""
mask = "mask[hourlyBillingAvailableFlag]"
result = self.client['Product_Package'].getAllObjects();
for product in result:
print str(product['id']) + " - " + product['name']
def getPackage(self, package_id=0):
"""
Gets a specific package and prints out some useful information
"""
mask = "mask[items[prices]]"
result = self.client['Product_Package'].getObject(mask=mask,id=package_id)
for item in result['items']:
print str(item['id']) + " - " + item['description'] + " --- " + item['keyName']
for prices in item['prices']:
print "\t" + str(prices['id']) + " - locationGroupId: " + str(prices['locationGroupId'])
def getAllLocations(self):
mask = "mask[id,locations[id,name]]"
result = self.client['SoftLayer_Location_Group_Pricing'].getAllObjects(mask=mask);
pp(result)
if __name__ == "__main__":
main = example()
main.main()
main.getPackage(126)
main.getAllLocations()