November 23, 2017


get_active_presets.py

get_active_presets.py
"""
List the active presets for a package.

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getActivePresets
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Package_Preset/

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""

import SoftLayer
import json

# Your SoftLayer API username and key.
API_USERNAME = 'set-me'

# Generate one at https://control.softlayer.com/account/users
API_KEY = 'set-me'

client = SoftLayer.create_client_from_env(username=API_USERNAME, api_key=API_KEY)
packageService = client['SoftLayer_Product_Package']

packageId = 200

try:
    presets = packageService.getActivePresets(id=packageId)
    print(json.dumps(presets, sort_keys=True, indent=2, separators=(',', ': ')))
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to list the presets for the package: \nfaultCode= %s, \nfaultString= %s"
          % (e.faultCode, e.faultString))

Feedback?

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