code: def example_list(a, args):
      
  
      if len(args) == 0:
          what = "all"
      else:
          what = args[0]
  
      md = a.list_topics(timeout=10)
  
      print("Cluster {} metadata (response from broker {}):".format(md.cluster_id, md.orig_broker_name))
  
      if what in ("all", "brokers"):
          print(" {} brokers:".format(len(md.brokers)))
          for b in iter(md.brokers.values()):
              if b.id == md.controller_id:
                  print("  {}  (controller)".format(b))
              else:
                  print("  {}".format(b))
  
      if what not in ("all", "topics"):
          return
  
      print(" {} topics:".format(len(md.topics)))
      for t in iter(md.topics.values()):
          if t.error is not None:
              errstr = ": {}".format(t.error)
          else:
              errstr = ""
  
          print("  \"{}\" with {} partition(s){}".format(t, len(t.partitions), errstr))
  
          for p in iter(t.partitions.values()):
              if p.error is not None:
                  errstr = ": {}".format(p.error)
              else:
                  errstr = ""
  
              print("    partition {} leader: {}, replicas: {}, isrs: {}".format(
                  p.id, p.leader, p.replicas, p.isrs, errstr))
docs: list topics and cluster metadata