docs: def do_alarm_list(mc, args):
      '''List alarms for this tenant.'''
      fields = {}
      if args.alarm_definition_id:
          fields['alarm_definition_id'] = args.alarm_definition_id
      if args.metric_name:
          fields['metric_name'] = args.metric_name
      if args.metric_dimensions:
          fields['metric_dimensions'] = utils.format_dimensions_query(args.metric_dimensions)
      if args.state:
          if args.state.upper() not in state_types:
              errmsg = ('Invalid state, not one of [' +
                        ', '.join(state_types) + ']')
              print(errmsg)
              return
          fields['state'] = args.state
      if args.severity:
          if not _validate_severity(args.severity):
              return
          fields['severity'] = args.severity
      if args.state_updated_start_time:
          fields['state_updated_start_time'] = args.state_updated_start_time
      if args.lifecycle_state:
          fields['lifecycle_state'] = args.lifecycle_state
      if args.link:
          fields['link'] = args.link
      if args.limit:
          fields['limit'] = args.limit
      if args.offset:
          fields['offset'] = args.offset
      if args.sort_by:
          sort_by = args.sort_by.split(',')
          for field in sort_by:
              field_values = field.lower().split()
              if len(field_values) > 2:
                  print("Invalid sort_by value {}".format(field))
              if field_values[0] not in allowed_alarm_sort_by:
                  print("Sort-by field name {} is not in [{}]".format(field_values[0],
                                                                      allowed_alarm_sort_by))
                  return
              if len(field_values) > 1 and field_values[1] not in ['asc', 'desc']:
                  print("Invalid value {}, must be asc or desc".format(field_values[1]))
          fields['sort_by'] = args.sort_by
      try:
          alarm = mc.alarms.list(**fields)
      except (osc_exc.ClientException, k_exc.HttpError) as he:
          raise osc_exc.CommandError('%s\n%s' % (he.message, he.details))
      else:
          if args.json:
              print(utils.json_formatter(alarm))
              return
          cols = ['id', 'alarm_definition_id', 'alarm_definition_name', 'metric_name',
                  'metric_dimensions', 'severity', 'state', 'lifecycle_state', 'link',
                  'state_updated_timestamp', 'updated_timestamp', "created_timestamp"]
          formatters = {
              'id': lambda x: x['id'],
              'alarm_definition_id': lambda x: x['alarm_definition']['id'],
              'alarm_definition_name': lambda x: x['alarm_definition']['name'],
              'metric_name': lambda x: format_metric_name(x['metrics']),
              'metric_dimensions': lambda x: format_metric_dimensions(x['metrics']),
              'severity': lambda x: x['alarm_definition']['severity'],
              'state': lambda x: x['state'],
              'lifecycle_state': lambda x: x['lifecycle_state'],
              'link': lambda x: x['link'],
              'state_updated_timestamp': lambda x: x['state_updated_timestamp'],
              'updated_timestamp': lambda x: x['updated_timestamp'],
              'created_timestamp': lambda x: x['created_timestamp'],
          }
          if isinstance(alarm, list):
              # print the list
              utils.print_list(alarm, cols, formatters=formatters)
          else:
              # add the dictionary to a list, so print_list works
              alarm_list = list()
              alarm_list.append(alarm)
              utils.print_list(alarm_list, cols, formatters=formatters)