Repository: softlayer/softlayer-python

Issue:
enableSnapshots method not working
Hi,

I'm trying to enable HOURLY/DAILY/WEEKLY snapshots using slcli as follows:

slcli call-api Network_Storage enableSnapshots --id=XXXXXX --retentionCount=3 --scheduleType=HOURLY --minute=59
Error: no such option: --retentionCount

According to the WSDL all these parameters are required.

Thanks,

Sadek


Discussion:

Patch:
diff --git a/SoftLayer/CLI/call_api.py b/SoftLayer/CLI/call_api.py
index 4d89cf74..e24e185d 100644
--- a/SoftLayer/CLI/call_api.py
+++ b/SoftLayer/CLI/call_api.py
@@ -9,21 +9,24 @@
 @click.command('call', short_help="Call arbitrary API endpoints.")
 @click.argument('service')
 @click.argument('method')
+@click.argument('parameters', nargs=-1)
 @click.option('--id', '_id', help="Init parameter")
 @click.option('--mask', help="String-based object mask")
 @click.option('--limit', type=click.INT, help="Result limit")
 @click.option('--offset', type=click.INT, help="Result offset")
 @environment.pass_env
-def cli(env, service, method, _id, mask, limit, offset):
+def cli(env, service, method, parameters, _id, mask, limit, offset):
     """Call arbitrary API endpoints with the given SERVICE and METHOD.
 
     \b
     Examples:
     slcli call-api Account getObject
     slcli call-api Account getVirtualGuests --limit=10 --mask=id,hostname
-    slcli call-api Virtual_Guest getObject --id=2710344
+    slcli call-api Virtual_Guest getObject --id=12345
+    slcli call-api Metric_Tracking_Object getBandwidthData --id=1234 \\
+        "2015-01-01 00:00:00" "2015-01-1 12:00:00" public
     """
-    result = env.client.call(service, method,
+    result = env.client.call(service, method, *parameters,
                              id=_id,
                              mask=mask,
                              limit=limit,


Test patch:
diff --git a/SoftLayer/tests/CLI/modules/call_api_tests.py b/SoftLayer/tests/CLI/modules/call_api_tests.py
index b14cd9f1..2555b8e8 100644
--- a/SoftLayer/tests/CLI/modules/call_api_tests.py
+++ b/SoftLayer/tests/CLI/modules/call_api_tests.py
@@ -119,6 +119,17 @@ def test_list_table(self):
 :......:......:.......:.....:........:
 """)
 
+    def test_parameters(self):
+        mock = self.set_mock('SoftLayer_Service', 'method')
+        mock.return_value = {}
+
+        result = self.run_command(['call-api', 'Service', 'method',
+                                   'arg1', '1234'])
+
+        self.assertEqual(result.exit_code, 0)
+        self.assert_called_with('SoftLayer_Service', 'method',
+                                args=('arg1', '1234'))
+
 
 class CallCliHelperTests(testing.TestCase):