@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>def do_notification_list(mc, args):
fields = {}<EOL>if args.limit:<EOL><INDENT>fields['<STR_LIT>'] = args.limit<EOL><DEDENT>if args.offset:<EOL><INDENT>fields['<STR_LIT>'] = args.offset<EOL><DEDENT>if args.sort_by:<EOL><INDENT>sort_by = args.sort_by.split('<STR_LIT:U+002C>')<EOL>for field in sort_by:<EOL><INDENT>field_values = field.lower().split()<EOL>if len(field_values) > <NUM_LIT:2>:<EOL><INDENT>print("<STR_LIT>".format(field))<EOL><DEDENT>if field_values[<NUM_LIT:0>] not in allowed_notification_sort_by:<EOL><INDENT>print("<STR_LIT>".format(field_values[<NUM_LIT:0>],<EOL>allowed_notification_sort_by))<EOL>return<EOL><DEDENT>if len(field_values) > <NUM_LIT:1> and field_values[<NUM_LIT:1>] not in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>print("<STR_LIT>".format(field_values[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>fields['<STR_LIT>'] = args.sort_by<EOL><DEDENT>try:<EOL><INDENT>notification = mc.notifications.list(**fields)<EOL><DEDENT>except osc_exc.ClientException as he:<EOL><INDENT>raise osc_exc.CommandError(<EOL>'<STR_LIT>' %<EOL>(he.code, he.message))<EOL><DEDENT>else:<EOL><INDENT>if args.json:<EOL><INDENT>print(utils.json_formatter(notification))<EOL>return<EOL><DEDENT>cols = ['<STR_LIT:name>', '<STR_LIT:id>', '<STR_LIT:type>', '<STR_LIT:address>', '<STR_LIT>']<EOL>formatters = {<EOL>'<STR_LIT:name>': lambda x: x['<STR_LIT:name>'],<EOL>'<STR_LIT:id>': lambda x: x['<STR_LIT:id>'],<EOL>'<STR_LIT:type>': lambda x: x['<STR_LIT:type>'],<EOL>'<STR_LIT:address>': lambda x: x['<STR_LIT:address>'],<EOL>'<STR_LIT>': lambda x: x['<STR_LIT>'],<EOL>}<EOL>if isinstance(notification, list):<EOL><INDENT>utils.print_list(<EOL>notification,<EOL>cols,<EOL>formatters=formatters)<EOL><DEDENT>else:<EOL><INDENT>notif_list = list()<EOL>notif_list.append(notification)<EOL>utils.print_list(notif_list, cols, formatters=formatters)<EOL><DEDENT><DEDENT>
List notifications for this tenant.