OrderingManager

class SoftLayer.managers.OrderingManager(client)[source]

Manager to help ordering via the SoftLayer API.

Parameters:

client (SoftLayer.API.BaseClient) – the client instance

__init__(client)[source]

Methods

__init__(client)

delete_quote(quote_id)

Delete the quote of an order.

filter_outlet_packages(packages)

Remove packages designated as OUTLET.

generate_order(package_keyname, location, ...)

Generates an order with the given package and prices.

generate_order_template(quote_id, extra[, ...])

Generate a complete order template.

get_all_cancelation([limit])

returns the all cancelations, completed orders

get_item_capacity(items, item_keynames)

Get item capacity.

get_item_price_id(core, prices[, term])

get item price id

get_item_prices(package_id)

Get item prices.

get_item_prices_by_location(location, ...)

Returns the item prices by location.

get_items(package_id[, storage_filter, mask])

"Returns the items .

get_location_id(location)

Finds the location ID of a given datacenter

get_only_active_packages(packages)

Return only active packages.

get_order_container(quote_id)

Generate an order container from a quote object.

get_order_detail(order_id[, mask])

Get order details.

get_package_by_key(package_keyname[, mask])

Get a single package with a given key.

get_package_by_type(package_type[, mask])

Get a single package of a given type.

get_package_id_by_type(package_type)

Return the package ID of a Product Package with a given type.

get_packages_of_type(package_types[, mask])

Get packages that match a certain type.

get_preset_by_key(package_keyname, ...[, mask])

Gets a single preset with the given key.

get_preset_prices(preset)

Get preset item prices.

get_price_id_list(package_keyname, item_keynames)

Converts a list of item keynames to a list of price IDs.

get_quote_details(quote_id)

Retrieve quote details.

get_quotes()

Retrieve a list of active quotes.

get_regions(package_id[, location])

returns the all regions.

list_categories(package_keyname, **kwargs)

List the categories for the given package.

list_items(package_keyname, **kwargs)

List the items for the given package.

list_packages(**kwargs)

List active packages.

list_presets(package_keyname, **kwargs)

Gets active presets for the given package.

order_quote(quote_id, extra)

Places an order using a quote

package_locations(package_keyname)

List datacenter locations for a package keyname

place_order(package_keyname, location, ...)

Places an order with the given package and prices.

place_quote(package_keyname, location, ...)

Place a quote with the given package and prices.

resolve_location_name(location_key)

Resolves a location name using a string location key.

save_quote(quote_id)

Save a quote.

verify_order(package_keyname, location, ...)

Verifies an order with the given package and prices.

verify_quote(quote_id, extra)

Verifies that a quote order is valid.

delete_quote(quote_id)[source]

Delete the quote of an order.

Parameters:

quote_id – ID number of target quote

static filter_outlet_packages(packages)[source]

Remove packages designated as OUTLET.

Those type of packages must be handled in a different way, and they are not supported at the moment.

Parameters:

packages – Dictionary of packages. Name and description keys must be present in each of them.

generate_order(package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1)[source]

Generates an order with the given package and prices.

This function takes in parameters needed for an order and generates an order dictionary. This dictionary can then be used in either verify or placeOrder().

Parameters:
  • package_keyname (str) – The keyname for the package being ordered

  • location (str) – The datacenter location string for ordering (Ex: DALLAS13)

  • item_keynames (list) – The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or slcli order item-list)

  • complex_type (str) – The complex type to send with the order. Typically begins with SoftLayer_Container_Product_Order_.

  • hourly (bool) – If true, uses hourly billing, otherwise uses monthly billing

  • preset_keyname (string) – If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or slcli order preset-list)

  • extras (dict) – The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {‘virtualGuests’: [{‘hostname’: ‘test’, ‘domain’: ‘softlayer.com’}]}

  • quantity (int) – The number of resources to order

generate_order_template(quote_id, extra, quantity=1)[source]

Generate a complete order template.

Parameters:
  • quote_id (int) – ID of target quote

  • extra (dictionary) – Overrides for the defaults of SoftLayer_Container_Product_Order

  • quantity (int) – Number of items to order.

get_all_cancelation(limit=50)[source]

returns the all cancelations, completed orders

get_item_capacity(items, item_keynames)[source]

Get item capacity.

static get_item_price_id(core, prices, term=0)[source]

get item price id

core: None or a number to match against capacityRestrictionType prices: list of SoftLayer_Product_Item_Price term: int to match against SoftLayer_Product_Item_Price.termLength

get_item_prices(package_id)[source]

Get item prices.

Retrieve a SoftLayer_Product_Package item prices record.

Parameters:

package_id (int) – package identifier.

Returns:

A list of price IDs associated with the given package.

get_item_prices_by_location(location, package_keyname)[source]

Returns the item prices by location.

Parameters:
  • package_keyname (string) – The package for which to get the items.

  • location (string) – location name or keyname to get the item prices.

get_items(package_id, storage_filter=None, mask=None)[source]

“Returns the items .

Parameters:
  • package_id (int) – The package for which to get the items.

  • storage_filter (dict) – object filter.

get_location_id(location)[source]

Finds the location ID of a given datacenter

This is mostly used so either a dc name, or regions keyname can be used when ordering :param str location: Region Keyname (DALLAS13) or datacenter name (dal13) :returns: integer id of the datacenter

static get_only_active_packages(packages)[source]

Return only active packages.

If a package is active, it is eligible for ordering This will inspect the ‘isActive’ property on the provided packages

Parameters:

packages – Dictionary of packages, isActive key must be present

get_order_container(quote_id)[source]

Generate an order container from a quote object.

Parameters:

quote_id – ID number of target quote

get_order_detail(order_id, mask=None)[source]

Get order details.

Parameters:
  • order_id (int) – to specify the order that we want to retrieve.

  • mask (string) – Mask to specify the properties we want to retrieve.

get_package_by_key(package_keyname, mask=None)[source]

Get a single package with a given key.

If no packages are found, returns None

Parameters:
  • package_keyname – string representing the package key name we are interested in.

  • mask (string) – Mask to specify the properties we want to retrieve

get_package_by_type(package_type, mask=None)[source]

Get a single package of a given type.

Syntactic sugar to retrieve a single package of a given type. If multiple packages share the given type, this will return the first one returned by the API. If no packages are found, returns None

Parameters:

package_type (string) – representing the package type key name we are interested in

get_package_id_by_type(package_type)[source]

Return the package ID of a Product Package with a given type.

Parameters:

package_type (string) – representing the package type key name we are interested in

Raises:

ValueError – when no package of the given type is found

get_packages_of_type(package_types, mask=None)[source]

Get packages that match a certain type.

Each ordering package has a type, so return all packages that match the types we are looking for

Parameters:
  • package_types (list) – List of strings representing the package type keynames we are interested in.

  • mask (string) – Mask to specify the properties we want to retrieve

get_preset_by_key(package_keyname, preset_keyname, mask=None)[source]

Gets a single preset with the given key.

get_preset_prices(preset)[source]

Get preset item prices.

Retrieve a SoftLayer_Product_Package_Preset record.

Parameters:

preset (int) – preset identifier.

Returns:

A list of price IDs associated with the given preset_id.

get_price_id_list(package_keyname, item_keynames, core=None)[source]

Converts a list of item keynames to a list of price IDs.

This function is used to convert a list of item keynames into a list of price IDs that are used in the Product_Order verifyOrder() and placeOrder() functions.

Parameters:
  • package_keyname (str) – The package associated with the prices

  • item_keynames (list) – A list of item keyname strings

  • core (str) – preset guest core capacity.

Returns:

A list of price IDs associated with the given item keynames in the given package

get_quote_details(quote_id)[source]

Retrieve quote details.

Parameters:

quote_id – ID number of target quote

get_quotes()[source]

Retrieve a list of active quotes.

Returns:

a list of SoftLayer_Billing_Order_Quote

get_regions(package_id, location=None)[source]

returns the all regions.

Parameters:

package_id (int) – The package for which to get the items.

list_categories(package_keyname, **kwargs)[source]

List the categories for the given package.

Parameters:

package_keyname (str) – The package for which to get the categories.

Returns:

List of categories associated with the package

list_items(package_keyname, **kwargs)[source]

List the items for the given package.

Parameters:

package_keyname (str) – The package for which to get the items.

Returns:

List of items in the package

list_packages(**kwargs)[source]

List active packages.

Returns:

List of active packages.

list_presets(package_keyname, **kwargs)[source]

Gets active presets for the given package.

Parameters:

package_keyname (str) – The package for which to get presets

Returns:

A list of package presets that can be used for ordering

order_quote(quote_id, extra)[source]

Places an order using a quote

extras = {
    'hardware': {'hostname': 'test', 'domain': 'testing.com'},
    'quantity': 2
}
manager = ordering.OrderingManager(env.client)
result = manager.order_quote(12345, extras)
Parameters:
  • quote_id (int) – ID for the target quote

  • extra (dictionary) – Overrides for the defaults of SoftLayer_Container_Product_Order

  • quantity (int) – Quantity to override default

package_locations(package_keyname)[source]

List datacenter locations for a package keyname

Parameters:

package_keyname (str) – The package for which to get the items.

Returns:

List of locations a package is orderable in

place_order(package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1)[source]

Places an order with the given package and prices.

This function takes in parameters needed for an order and places the order.

Parameters:
  • package_keyname (str) – The keyname for the package being ordered

  • location (str) – The datacenter location string for ordering (Ex: DALLAS13)

  • item_keynames (list) – The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or slcli order item-list)

  • complex_type (str) – The complex type to send with the order. Typically begins with SoftLayer_Container_Product_Order_.

  • hourly (bool) – If true, uses hourly billing, otherwise uses monthly billing

  • preset_keyname (string) – If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or slcli order preset-list)

  • extras (dict) – The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {‘virtualGuests’: [{‘hostname’: ‘test’, domain’: ‘softlayer.com’}]}

  • quantity (int) – The number of resources to order

place_quote(package_keyname, location, item_keynames, complex_type=None, preset_keyname=None, extras=None, quantity=1, quote_name=None, send_email=False)[source]

Place a quote with the given package and prices.

This function takes in parameters needed for an order and places the quote.

Parameters:
  • package_keyname (str) – The keyname for the package being ordered

  • location (str) – The datacenter location string for ordering (Ex: DALLAS13)

  • item_keynames (list) – The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or slcli order item-list)

  • complex_type (str) – The complex type to send with the order. Typically begins with SoftLayer_Container_Product_Order_.

  • preset_keyname (string) – If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or slcli order preset-list)

  • extras (dict) – The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {‘virtualGuests’: [{‘hostname’: ‘test’, domain’: ‘softlayer.com’}]}

  • quantity (int) – The number of resources to order

  • quote_name (string) – A custom name to be assigned to the quote (optional).

  • send_email (bool) – This flag indicates that the quote should be sent to the email address associated with the account or order.

resolve_location_name(location_key)[source]

Resolves a location name using a string location key.

Parameters:

location_key (string) – A string location used to resolve the location name.

Returns:

An location name.

save_quote(quote_id)[source]

Save a quote.

Parameters:

quote_id – ID number of target quote

verify_order(package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1)[source]

Verifies an order with the given package and prices.

This function takes in parameters needed for an order and verifies the order to ensure the given items are compatible with the given package.

Parameters:
  • package_keyname (str) – The keyname for the package being ordered

  • location (str) – The datacenter location string for ordering (Ex: DALLAS13)

  • item_keynames (list) – The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or slcli order item-list)

  • complex_type (str) – The complex type to send with the order. Typically begins with SoftLayer_Container_Product_Order_.

  • hourly (bool) – If true, uses hourly billing, otherwise uses monthly billing

  • preset_keyname (string) – If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or slcli order preset-list)

  • extras (dict) – The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: ‘virtualGuests’: [{‘hostname’: ‘test’, ‘domain’: ‘softlayer.com’}]}

  • quantity (int) – The number of resources to order

verify_quote(quote_id, extra)[source]

Verifies that a quote order is valid.

extras = {
    'hardware': {'hostname': 'test', 'domain': 'testing.com'},
    'quantity': 2
}
manager = ordering.OrderingManager(env.client)
result = manager.verify_quote(12345, extras)
Parameters:
  • quote_id (int) – ID for the target quote

  • extra (dictionary) – Overrides for the defaults of SoftLayer_Container_Product_Order

  • quantity (int) – Quantity to override default