From 6dae28c790c94e444561ceed9759e63e9749ce9f Mon Sep 17 00:00:00 2001 From: Daniel Cabero Barrios Date: Fri, 20 Sep 2019 14:32:52 -0400 Subject: [PATCH 1/4] add the new services id --- SoftLayer/CLI/ticket/__init__.py | 1 + SoftLayer/CLI/ticket/list.py | 3 ++- SoftLayer/fixtures/SoftLayer_Account.py | 3 +++ SoftLayer/fixtures/SoftLayer_Ticket.py | 4 ++++ SoftLayer/managers/ticket.py | 5 ++--- tests/CLI/modules/ticket_tests.py | 5 ++++- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/SoftLayer/CLI/ticket/__init__.py b/SoftLayer/CLI/ticket/__init__.py index 11fe2a879..9886aa686 100644 --- a/SoftLayer/CLI/ticket/__init__.py +++ b/SoftLayer/CLI/ticket/__init__.py @@ -32,6 +32,7 @@ def get_ticket_results(mgr, ticket_id, update_count=1): table.align['value'] = 'l' table.add_row(['id', ticket['id']]) + table.add_row(['Case_Number', ticket['serviceProviderResourceId']]) table.add_row(['title', ticket['title']]) table.add_row(['priority', PRIORITY_MAP[ticket.get('priority', 0)]]) if ticket.get('assignedUser'): diff --git a/SoftLayer/CLI/ticket/list.py b/SoftLayer/CLI/ticket/list.py index 64c8b7dd6..c123b8234 100644 --- a/SoftLayer/CLI/ticket/list.py +++ b/SoftLayer/CLI/ticket/list.py @@ -16,7 +16,7 @@ def cli(env, is_open): """List tickets.""" ticket_mgr = SoftLayer.TicketManager(env.client) table = formatting.Table([ - 'id', 'assigned_user', 'title', 'last_edited', 'status', 'updates', 'priority' + 'id', 'Case_Number', 'assigned_user', 'title', 'last_edited', 'status', 'updates', 'priority' ]) tickets = ticket_mgr.list_tickets(open_status=is_open, closed_status=not is_open) @@ -27,6 +27,7 @@ def cli(env, is_open): table.add_row([ ticket['id'], + ticket['serviceProviderResourceId'], user, click.wrap_text(ticket['title']), ticket['lastEditDate'], diff --git a/SoftLayer/fixtures/SoftLayer_Account.py b/SoftLayer/fixtures/SoftLayer_Account.py index cf884aefd..4239b9b5d 100644 --- a/SoftLayer/fixtures/SoftLayer_Account.py +++ b/SoftLayer/fixtures/SoftLayer_Account.py @@ -340,6 +340,7 @@ getTickets = [ { "accountId": 1234, + "serviceProviderResourceId": "CS123456", "assignedUserId": 12345, "createDate": "2013-08-01T14:14:04-07:00", "id": 100, @@ -355,6 +356,7 @@ }, { "accountId": 1234, + "serviceProviderResourceId": "CS123456", "assignedUserId": 12345, "createDate": "2013-08-01T14:14:04-07:00", "id": 101, @@ -370,6 +372,7 @@ }, { "accountId": 1234, + "serviceProviderResourceId": "CS123456", "assignedUserId": 12345, "createDate": "2014-03-03T09:44:01-08:00", "id": 102, diff --git a/SoftLayer/fixtures/SoftLayer_Ticket.py b/SoftLayer/fixtures/SoftLayer_Ticket.py index ea230f98e..b84031f55 100644 --- a/SoftLayer/fixtures/SoftLayer_Ticket.py +++ b/SoftLayer/fixtures/SoftLayer_Ticket.py @@ -1,6 +1,7 @@ createCancelServerTicket = {'id': 1234, 'title': 'Server Cancellation Request'} getObject = { "accountId": 1234, + "serviceProviderResourceId": "CS123456", "assignedUserId": 12345, "createDate": "2013-08-01T14:14:04-07:00", "id": 100, @@ -26,6 +27,7 @@ createStandardTicket = { "assignedUserId": 12345, + "serviceProviderResourceId": "CS123456", "id": 100, "contents": "body", "subjectId": 1004, @@ -34,6 +36,8 @@ edit = True addUpdate = {} +list = getObject + addAttachedHardware = { "id": 123, "createDate": "2013-08-01T14:14:04-07:00", diff --git a/SoftLayer/managers/ticket.py b/SoftLayer/managers/ticket.py index 04f8470b0..9ff361d4b 100644 --- a/SoftLayer/managers/ticket.py +++ b/SoftLayer/managers/ticket.py @@ -28,7 +28,7 @@ def list_tickets(self, open_status=True, closed_status=True): :param boolean open_status: include open tickets :param boolean closed_status: include closed tickets """ - mask = """mask[id, title, assignedUser[firstName, lastName], priority, + mask = """mask[id, serviceProviderResourceId, title, assignedUser[firstName, lastName], priority, createDate, lastEditDate, accountId, status, updateCount]""" call = 'getTickets' @@ -39,7 +39,6 @@ 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) def list_subjects(self): @@ -53,7 +52,7 @@ def get_ticket(self, ticket_id): :returns: dict -- information about the specified ticket """ - mask = """mask[id, title, assignedUser[firstName, lastName],status, + mask = """mask[id, serviceProviderResourceId, title, assignedUser[firstName, lastName],status, createDate,lastEditDate,updates[entry,editor],updateCount, priority]""" return self.ticket.getObject(id=ticket_id, mask=mask) diff --git a/tests/CLI/modules/ticket_tests.py b/tests/CLI/modules/ticket_tests.py index 3f338cf1c..4acf56965 100644 --- a/tests/CLI/modules/ticket_tests.py +++ b/tests/CLI/modules/ticket_tests.py @@ -21,6 +21,7 @@ def test_list(self): expected = [{ 'assigned_user': 'John Smith', + 'Case_Number': 'CS123456', 'id': 102, 'last_edited': '2013-08-01T14:16:47-07:00', 'priority': 0, @@ -34,6 +35,7 @@ def test_detail(self): result = self.run_command(['ticket', 'detail', '1']) expected = { + 'Case_Number': 'CS123456', 'created': '2013-08-01T14:14:04-07:00', 'edited': '2013-08-01T14:16:47-07:00', 'id': 100, @@ -235,6 +237,7 @@ def test_init_ticket_results(self): def test_init_ticket_results_asigned_user(self): mock = self.set_mock('SoftLayer_Ticket', 'getObject') mock.return_value = { + "serviceProviderResourceId": "CS12345", "id": 100, "title": "Simple Title", "priority": 1, @@ -296,4 +299,4 @@ def test_ticket_update_no_body(self, edit_mock): edit_mock.return_value = 'Testing1' result = self.run_command(['ticket', 'update', '100']) self.assert_no_fail(result) - self.assert_called_with('SoftLayer_Ticket', 'addUpdate', args=({'entry': 'Testing1'},), identifier=100) + self.assert_called_with('SoftLayer_Ticket', 'addUpdate', args=({'entry': 'Testing1'},), identifier=100) \ No newline at end of file From aa445e9d50fe01242ca1e80c1078b4345af97cc5 Mon Sep 17 00:00:00 2001 From: Daniel Cabero Barrios Date: Fri, 20 Sep 2019 14:57:10 -0400 Subject: [PATCH 2/4] add the line blank --- tests/CLI/modules/ticket_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/CLI/modules/ticket_tests.py b/tests/CLI/modules/ticket_tests.py index 4acf56965..6422ce3d6 100644 --- a/tests/CLI/modules/ticket_tests.py +++ b/tests/CLI/modules/ticket_tests.py @@ -299,4 +299,5 @@ def test_ticket_update_no_body(self, edit_mock): edit_mock.return_value = 'Testing1' result = self.run_command(['ticket', 'update', '100']) self.assert_no_fail(result) - self.assert_called_with('SoftLayer_Ticket', 'addUpdate', args=({'entry': 'Testing1'},), identifier=100) \ No newline at end of file + self.assert_called_with('SoftLayer_Ticket', 'addUpdate', args=({'entry': 'Testing1'},), identifier=100) + \ No newline at end of file From 4e8d17c594e67d961c400f312ed28e404f110a4a Mon Sep 17 00:00:00 2001 From: Daniel Cabero Barrios Date: Fri, 20 Sep 2019 15:06:50 -0400 Subject: [PATCH 3/4] fix identation and errors --- tests/CLI/modules/ticket_tests.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/CLI/modules/ticket_tests.py b/tests/CLI/modules/ticket_tests.py index 6422ce3d6..2a47e782e 100644 --- a/tests/CLI/modules/ticket_tests.py +++ b/tests/CLI/modules/ticket_tests.py @@ -300,4 +300,3 @@ def test_ticket_update_no_body(self, edit_mock): result = self.run_command(['ticket', 'update', '100']) self.assert_no_fail(result) self.assert_called_with('SoftLayer_Ticket', 'addUpdate', args=({'entry': 'Testing1'},), identifier=100) - \ No newline at end of file From 93cda54139ca89e4a3a70bd071813e1bd57374f9 Mon Sep 17 00:00:00 2001 From: Daniel Cabero Barrios Date: Fri, 20 Sep 2019 15:22:38 -0400 Subject: [PATCH 4/4] fix identation and errors in fixtures --- SoftLayer/fixtures/SoftLayer_Ticket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SoftLayer/fixtures/SoftLayer_Ticket.py b/SoftLayer/fixtures/SoftLayer_Ticket.py index b84031f55..ece702f28 100644 --- a/SoftLayer/fixtures/SoftLayer_Ticket.py +++ b/SoftLayer/fixtures/SoftLayer_Ticket.py @@ -36,7 +36,7 @@ edit = True addUpdate = {} -list = getObject +gatList = getObject addAttachedHardware = { "id": 123,