Skip to content

Commit adb1eee

Browse files
committed
slcli ticket list command with user limit option
1 parent e5b143f commit adb1eee

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

SoftLayer/CLI/ticket/list.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1313
@click.option('--open / --closed', 'is_open', default=True,
1414
help="Display only open or closed tickets")
15+
@click.option('--limit', default=100, show_default=True, type=click.INT, help="Result limit")
1516
@environment.pass_env
16-
def cli(env, is_open):
17+
def cli(env, is_open, limit):
1718
"""List tickets."""
1819
ticket_mgr = SoftLayer.TicketManager(env.client)
1920
table = formatting.Table([
2021
'id', 'Case_Number', 'assigned_user', 'title', 'last_edited', 'status', 'updates', 'priority'
2122
])
2223

23-
tickets = ticket_mgr.list_tickets(open_status=is_open, closed_status=not is_open)
24+
tickets = ticket_mgr.list_tickets(open_status=is_open, closed_status=not is_open, limit=limit)
2425
for ticket in tickets:
2526
user = formatting.blank()
2627
if ticket.get('assignedUser'):

SoftLayer/managers/ticket.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ 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):
25+
def list_tickets(self, open_status=True, closed_status=True, limit=None):
2626
"""List all tickets.
2727
2828
:param boolean open_status: include open tickets
2929
:param boolean closed_status: include closed tickets
30+
:param int limit: result limit
3031
"""
3132
mask = """mask[id, serviceProviderResourceId, title, assignedUser[firstName, lastName], priority,
3233
createDate, lastEditDate, accountId, status, updateCount]"""
@@ -39,7 +40,8 @@ def list_tickets(self, open_status=True, closed_status=True):
3940
call = 'getClosedTickets'
4041
else:
4142
raise ValueError("open_status and closed_status cannot both be False")
42-
return self.client.call('Account', call, mask=mask, iter=False, limit=100)
43+
44+
return self.client.call('Account', call, mask=mask, iter=False, limit=limit)
4345

4446
def list_subjects(self):
4547
"""List all ticket subjects."""

0 commit comments

Comments
 (0)