def update_table(event): """Formats a basic event update table""" update_number = 0 for update in event.get('updates', []): update_number = update_number + 1 header = "======= Update #%s on %s =======" % (update_number, utils.clean_time(update.get('startDate'))) click.secho(header, fg='green') text = update.get('contents') # deals with all the \r\n from the API click.secho(utils.clean_splitlines(text))
def update_table(event): """Formats a basic event update table""" update_number = 0 for update in event.get('updates', []): header = "======= Update #%s on %s =======" % (update_number, utils.clean_time(update.get('startDate'))) click.secho(header, fg='green') update_number = update_number + 1 text = update.get('contents') # deals with all the \r\n from the API click.secho(utils.clean_splitlines(text))
def basic_event_table(event): """Formats a basic event table""" table = formatting.Table(["Id", "Status", "Type", "Start", "End"], title=utils.clean_splitlines(event.get('subject'))) table.add_row([ event.get('id'), utils.lookup(event, 'statusCode', 'name'), utils.lookup(event, 'notificationOccurrenceEventType', 'keyName'), utils.clean_time(event.get('startDate')), utils.clean_time(event.get('endDate')) ]) return table
def announcement_event_table(events): """Formats a table for events""" announcement_table = formatting.Table([ 'Id', 'Event ID', 'Subject', 'Status', 'Items', 'Acknowledged', 'Updates' ], title="Announcement Events") announcement_table.align['Subject'] = 'l' announcement_table.align['Impacted Resources'] = 'l' for event in events: announcement_table.add_row([ event.get('id'), event.get('systemTicketId'), # Some subjects can have \r\n for some reason. utils.clean_splitlines(event.get('subject')), utils.lookup(event, 'statusCode', 'name'), event.get('impactedResourceCount'), event.get('acknowledgedFlag'), event.get('updateCount') ]) return announcement_table
def event_table(events): """Formats a table for events""" table = formatting.Table([ "Id", "Start Date", "End Date", "Subject", "Status", "Acknowledged", "Updates", "Impacted Resources" ], title="Upcoming Events") table.align['Subject'] = 'l' table.align['Impacted Resources'] = 'l' for event in events: table.add_row([ event.get('id'), utils.clean_time(event.get('startDate')), utils.clean_time(event.get('endDate')), # Some subjects can have \r\n for some reason. utils.clean_splitlines(event.get('subject')), utils.lookup(event, 'statusCode', 'name'), event.get('acknowledgedFlag'), event.get('updateCount'), event.get('impactedResourceCount') ]) return table
def unplanned_event_table(events): """Formats a table for events""" unplanned_table = formatting.Table([ 'Id', 'Event ID', 'Subject', 'Status', 'Items', 'Start Date', 'Last Updated', 'Acknowledged', 'Updates' ], title="Unplanned Events") unplanned_table.align['Subject'] = 'l' unplanned_table.align['Impacted Resources'] = 'l' for event in events: unplanned_table.add_row([ event.get('id'), event.get('systemTicketId'), # Some subjects can have \r\n for some reason. utils.clean_splitlines(event.get('subject')), utils.lookup(event, 'statusCode', 'name'), event.get('impactedResourceCount'), utils.clean_time(event.get('startDate')), utils.clean_time(event.get('modifyDate')), event.get('acknowledgedFlag'), event.get('updateCount'), ]) return unplanned_table