Skip to content

Commit 17eacd4

Browse files
committed
slcli ticket list command with --all option for all the open tickets
1 parent adb1eee commit 17eacd4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

SoftLayer/CLI/ticket/list.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,21 @@
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")
1617
@environment.pass_env
17-
def cli(env, is_open, limit):
18+
def cli(env, is_open, limit, all_open):
1819
"""List tickets."""
1920
ticket_mgr = SoftLayer.TicketManager(env.client)
2021
table = formatting.Table([
2122
'id', 'Case_Number', 'assigned_user', 'title', 'last_edited', 'status', 'updates', 'priority'
2223
])
2324

24-
tickets = ticket_mgr.list_tickets(open_status=is_open, closed_status=not is_open, limit=limit)
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)
30+
2531
for ticket in tickets:
2632
user = formatting.blank()
2733
if ticket.get('assignedUser'):

SoftLayer/managers/ticket.py

Lines changed: 5 additions & 1 deletion
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):
25+
def list_tickets(self, open_status=True, closed_status=True, limit=None, all_tickets=None):
2626
"""List all tickets.
2727
2828
:param boolean open_status: include open tickets
@@ -33,6 +33,7 @@ def list_tickets(self, open_status=True, closed_status=True, limit=None):
3333
createDate, lastEditDate, accountId, status, updateCount]"""
3434

3535
call = 'getTickets'
36+
# print('All Checks ',open_status, closed_status,all_tickets)
3637
if not all([open_status, closed_status]):
3738
if open_status:
3839
call = 'getOpenTickets'
@@ -41,6 +42,9 @@ def list_tickets(self, open_status=True, closed_status=True, limit=None):
4142
else:
4243
raise ValueError("open_status and closed_status cannot both be False")
4344

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

4650
def list_subjects(self):

0 commit comments

Comments
 (0)