diff --git a/SoftLayer/CLI/licenses/create_options.py b/SoftLayer/CLI/licenses/create_options.py new file mode 100644 index 000000000..80e8268a2 --- /dev/null +++ b/SoftLayer/CLI/licenses/create_options.py @@ -0,0 +1,29 @@ +"""Licenses order options for a given VMware licenses.""" +# :license: MIT, see LICENSE for more details. + +import click + +from SoftLayer.CLI import environment +from SoftLayer.CLI import formatting +from SoftLayer.managers.licenses import LicensesManager +from SoftLayer import utils + + +@click.command() +@environment.pass_env +def cli(env): + """Server order options for a given chassis.""" + + licenses_manager = LicensesManager(env.client) + + options = licenses_manager.get_create_options() + + table = formatting.Table(['Id', 'description', 'keyName', 'capacity', 'recurringFee']) + for item in options: + table.add_row([item.get('id'), + utils.trim_to(item.get('description'), 40), + item.get('keyName'), + item.get('capacity'), + item.get('prices')[0]['recurringFee']]) + + env.fout(table) diff --git a/SoftLayer/CLI/routes.py b/SoftLayer/CLI/routes.py index 27c4842b9..bd4363cbe 100644 --- a/SoftLayer/CLI/routes.py +++ b/SoftLayer/CLI/routes.py @@ -125,6 +125,9 @@ ('email:detail', 'SoftLayer.CLI.email.detail:cli'), ('email:edit', 'SoftLayer.CLI.email.edit:cli'), + ('licenses', 'SoftLayer.CLI.licenses'), + ('licenses:create-options', 'SoftLayer.CLI.licenses.create_options:cli'), + ('event-log', 'SoftLayer.CLI.event_log'), ('event-log:get', 'SoftLayer.CLI.event_log.get:cli'), ('event-log:types', 'SoftLayer.CLI.event_log.types:cli'), diff --git a/SoftLayer/fixtures/SoftLayer_Product_Package.py b/SoftLayer/fixtures/SoftLayer_Product_Package.py index 2ec118f3a..273ec9970 100644 --- a/SoftLayer/fixtures/SoftLayer_Product_Package.py +++ b/SoftLayer/fixtures/SoftLayer_Product_Package.py @@ -2076,7 +2076,7 @@ "itemId": 9567, "laborFee": "0", "locationGroupId": None, - "oneTimeFee": "0", + "recurringFee": "0", "setupFee": "0", "sort": 0, } diff --git a/SoftLayer/managers/licenses.py b/SoftLayer/managers/licenses.py new file mode 100644 index 000000000..3f2dbb7c4 --- /dev/null +++ b/SoftLayer/managers/licenses.py @@ -0,0 +1,25 @@ +""" + SoftLayer.license + ~~~~~~~~~~~~~~~ + License Manager + :license: MIT, see LICENSE for more details. +""" + +# pylint: disable=too-many-public-methods + +LICENSE_PACKAGE_ID = 301 + + +class LicensesManager(object): + """Manages account lincese.""" + + def __init__(self, client): + self.client = client + + def get_create_options(self): + """Returns valid options for ordering Licenses. + + """ + + return self.client.call('SoftLayer_Product_Package', 'getItems', + id=LICENSE_PACKAGE_ID) diff --git a/docs/cli/licenses.rst b/docs/cli/licenses.rst index 55ca0fe10..bc6e3d4d5 100644 --- a/docs/cli/licenses.rst +++ b/docs/cli/licenses.rst @@ -3,6 +3,9 @@ licenses Commands ================= +.. click:: SoftLayer.CLI.licenses.create_options:cli + :prog: licenses create-options + .. click:: SoftLayer.CLI.licenses.create:cli :prog: licenses create :show-nested: diff --git a/tests/CLI/modules/licenses_test.py b/tests/CLI/modules/licenses_test.py index b769e80bd..245c623c9 100644 --- a/tests/CLI/modules/licenses_test.py +++ b/tests/CLI/modules/licenses_test.py @@ -6,8 +6,8 @@ """ from SoftLayer.fixtures import SoftLayer_Product_Order -from SoftLayer.fixtures import SoftLayer_Product_Package +from SoftLayer.fixtures import SoftLayer_Product_Package from SoftLayer import testing @@ -31,4 +31,5 @@ def test_cancel(self): 'cancel', 'ABCDE-6CJ8L-J8R9H-000R0-CDR70', '--immediate']) + result = self.run_command(['licenses', 'create-options']) self.assert_no_fail(result)