Repository: softlayer/softlayer-python
Pull request #1808 (2022-12-13 21:42:58)

add a limit and sortby on data time on ticket list command on result …
[#issue1806](https://github.com/softlayer/softlayer-python/issues/1806)

![image](https://user-images.githubusercontent.com/22535437/207450030-25a8d950-8d92-440f-891c-06b629d3372d.png)



Patch:
diff --git a/SoftLayer/CLI/subnet/detail.py b/SoftLayer/CLI/subnet/detail.py
index 905f8e0b..403f6f03 100644
--- a/SoftLayer/CLI/subnet/detail.py
+++ b/SoftLayer/CLI/subnet/detail.py
@@ -38,7 +38,7 @@ def cli(env, identifier, no_vs, no_hardware):
     table.add_row(['identifier',
                    '%s/%s' % (subnet['networkIdentifier'],
                               str(subnet['cidr']))])
-    table.add_row(['subnet type', subnet.get('subnetType', formatting.blank())])
+    table.add_row(['subnet type', subnet['subnetType']])
     table.add_row(['network space',
                    utils.lookup(subnet, 'networkVlan', 'networkSpace')])
     table.add_row(['gateway', subnet.get('gateway', formatting.blank())])
diff --git a/SoftLayer/CLI/ticket/list.py b/SoftLayer/CLI/ticket/list.py
index 8ff27ad1..ea0febfe 100644
--- a/SoftLayer/CLI/ticket/list.py
+++ b/SoftLayer/CLI/ticket/list.py
@@ -2,6 +2,7 @@
 # :license: MIT, see LICENSE for more details.
 
 import click
+from SoftLayer import utils
 
 import SoftLayer
 from SoftLayer.CLI import environment
@@ -30,7 +31,7 @@ def cli(env, is_open):
             ticket['serviceProviderResourceId'],
             user,
             click.wrap_text(ticket['title']),
-            ticket['lastEditDate'],
+            utils.clean_time(ticket.get('lastEditDate'), out_format="%Y-%m-%d"),
             ticket['status']['name'],
             ticket.get('updateCount', 0),
             ticket.get('priority', 0)
diff --git a/SoftLayer/managers/network.py b/SoftLayer/managers/network.py
index 5e73e0b4..327c1c80 100644
--- a/SoftLayer/managers/network.py
+++ b/SoftLayer/managers/network.py
@@ -503,7 +503,9 @@ def list_subnets(self, identifier=None, datacenter=None, version=0,
             _filter['subnets']['version'] = utils.query_filter(version)
         if subnet_type:
             _filter['subnets']['subnetType'] = utils.query_filter(subnet_type)
-
+        else:
+            # This filters out global IPs from the subnet listing.
+            _filter['subnets']['subnetType'] = {'operation': '!= GLOBAL_IP'}
         if network_space:
             _filter['subnets']['networkVlan']['networkSpace'] = (
                 utils.query_filter(network_space))
@@ -696,7 +698,7 @@ def _list_subnets_by_identifier(self, identifier):
         """
         identifier = identifier.split('/', 1)[0]
 
-        results = self.list_subnets()
+        results = self.list_subnets(identifier=identifier, mask='id')
         return [result['id'] for result in results]
 
     def _list_vlans_by_name(self, name):
diff --git a/SoftLayer/managers/ticket.py b/SoftLayer/managers/ticket.py
index bbd2eddd..006ebb8a 100644
--- a/SoftLayer/managers/ticket.py
+++ b/SoftLayer/managers/ticket.py
@@ -39,7 +39,7 @@ def list_tickets(self, open_status=True, closed_status=True):
                 call = 'getClosedTickets'
             else:
                 raise ValueError("open_status and closed_status cannot both be False")
-        return self.client.call('Account', call, mask=mask, iter=True)
+        return self.client.call('Account', call, mask=mask, iter=False, limit=100)
 
     def list_subjects(self):
         """List all ticket subjects."""


Test patch:
diff --git a/tests/CLI/modules/account_tests.py b/tests/CLI/modules/account_tests.py
index b8932a8f..b02b7303 100644
--- a/tests/CLI/modules/account_tests.py
+++ b/tests/CLI/modules/account_tests.py
@@ -71,9 +71,8 @@ def test_invoice_detail_csv_output_format(self):
         result_output = result.output.replace('\r', '').split('\n')
         self.assert_no_fail(result)
         self.assertEqual(result_output[0], 'Item Id,Category,Description,Single,Monthly,Create Date,Location')
-        self.assertEqual(result_output[1], '724951323,Private (only) Secondary VLAN IP Addresses,'
-                                           '64 Portable Private IP Addresses (bleg.beh.com),'
-                                           '$0.00,$0.00,2018-04-04,fra02')
+        self.assertEqual(result_output[1], '724951323,Private (only) Secondary VLAN IP Addresses,64 Portable Private'
+                                           ' IP Addresses (bleg.beh.com),$0.00,$0.00,2018-04-04,fra02')
 
     # slcli account invoices
     def test_invoices(self):
diff --git a/tests/CLI/modules/ticket_tests.py b/tests/CLI/modules/ticket_tests.py
index 4fbdbff0..fb5ff8ec 100644
--- a/tests/CLI/modules/ticket_tests.py
+++ b/tests/CLI/modules/ticket_tests.py
@@ -39,7 +39,7 @@ def test_list(self):
             'assigned_user': 'John Smith',
             'Case_Number': 'CS123456',
             'id': 102,
-            'last_edited': '2013-08-01T14:16:47-07:00',
+            'last_edited': '2013-08-01',
             'priority': 0,
             'status': 'Open',
             'title': 'Cloud Instance Cancellation - 08/01/13',
diff --git a/tests/managers/network_tests.py b/tests/managers/network_tests.py
index aa86fe24..12cee4bc 100644
--- a/tests/managers/network_tests.py
+++ b/tests/managers/network_tests.py
@@ -310,6 +310,15 @@ def test_list_global_ips_with_filter(self):
                                 filter=_filter)
 
     def test_list_subnets_default(self):
+        result = self.network.list_subnets()
+
+        self.assertEqual(result, fixtures.SoftLayer_Account.getSubnets)
+        _filter = {'subnets': {'subnetType': {'operation': '!= GLOBAL_IP'}}}
+        self.assert_called_with('SoftLayer_Account', 'getSubnets',
+                                mask='mask[%s]' % network.DEFAULT_SUBNET_MASK,
+                                filter=_filter)
+
+    def test_list_subnets_with_filters(self):
         result = self.network.list_subnets(
             identifier='10.0.0.1',
             datacenter='dal00',
@@ -317,6 +326,7 @@ def test_list_subnets_default(self):
             subnet_type='PRIMARY',
             network_space='PUBLIC',
         )
+
         self.assertEqual(result, fixtures.SoftLayer_Account.getSubnets)
         _filter = {
             'subnets': {
@@ -334,14 +344,6 @@ def test_list_subnets_default(self):
                                 mask='mask[%s]' % network.DEFAULT_SUBNET_MASK,
                                 filter=_filter)
 
-    def test_list_subnets_with_filters(self):
-        result = self.network.list_subnets()
-
-        self.assertEqual(result, fixtures.SoftLayer_Account.getSubnets)
-
-        self.assert_called_with('SoftLayer_Account', 'getSubnets',
-                                mask='mask[%s]' % network.DEFAULT_SUBNET_MASK)
-
     def test_list_vlans_default(self):
         result = self.network.list_vlans()