Skip to content

Commit 179b846

Browse files
committed
slcli ticket list command with --all, --limit refactoring
1 parent 92e1ea6 commit 179b846

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

SoftLayer/CLI/ticket/list.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@
1313
@click.option('--open / --closed', 'is_open', default=True,
1414
help="Display only open or closed tickets")
1515
@click.option('--limit', default=100, show_default=True, type=click.INT, help="Result limit")
16-
@click.option("--all", "-a", "all_open", is_flag=True, default=False, help="Results all Open tickets")
16+
@click.option("--all", "-a", "all_tickets", is_flag=True, default=False, help="Return all tickets")
1717
@environment.pass_env
18-
def cli(env, is_open, limit, all_open):
18+
def cli(env, is_open, limit, all_tickets):
1919
"""List tickets."""
2020
ticket_mgr = SoftLayer.TicketManager(env.client)
2121
table = formatting.Table([
2222
'id', 'Case_Number', 'assigned_user', 'title', 'last_edited', 'status', 'updates', 'priority'
2323
])
2424

25-
if all_open and is_open:
26-
tickets = ticket_mgr.list_tickets(open_status=is_open, closed_status=not is_open, limit=limit,
27-
all_tickets=all_open)
28-
else:
29-
tickets = ticket_mgr.list_tickets(open_status=is_open, closed_status=not is_open, limit=limit)
25+
tickets = ticket_mgr.list_tickets(open_status=is_open,
26+
closed_status=not is_open, limit=limit, all_tickets=all_tickets)
3027

3128
for ticket in tickets:
3229
user = formatting.blank()

SoftLayer/managers/ticket.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, client):
2222
self.account = self.client['Account']
2323
self.ticket = self.client['Ticket']
2424

25-
def list_tickets(self, open_status=True, closed_status=True, limit=None, all_tickets=None):
25+
def list_tickets(self, open_status=True, closed_status=True, limit=None, all_tickets=False):
2626
"""List all tickets.
2727
2828
:param boolean open_status: include open tickets
@@ -33,7 +33,6 @@ def list_tickets(self, open_status=True, closed_status=True, limit=None, all_tic
3333
createDate, lastEditDate, accountId, status, updateCount]"""
3434

3535
call = 'getTickets'
36-
# print('All Checks ',open_status, closed_status,all_tickets)
3736
if not all([open_status, closed_status]):
3837
if open_status:
3938
call = 'getOpenTickets'
@@ -42,10 +41,7 @@ def list_tickets(self, open_status=True, closed_status=True, limit=None, all_tic
4241
else:
4342
raise ValueError("open_status and closed_status cannot both be False")
4443

45-
if all([open_status, all_tickets]):
46-
return self.client.call('Account', call, mask=mask, iter=all_tickets, limit=limit)
47-
48-
return self.client.call('Account', call, mask=mask, iter=False, limit=limit)
44+
return self.client.call('Account', call, mask=mask, iter=all_tickets, limit=limit)
4945

5046
def list_subjects(self):
5147
"""List all ticket subjects."""

0 commit comments

Comments
 (0)