code: public List<String> get_slaveNames() {
          return new AbstractList<String>() {
              final List<Node> nodes = Jenkins.getInstance().getNodes();
  
              public String get(int index) {
                  return nodes.get(index).getNodeName();
              }
  
              public int size() {
                  return nodes.size();
              }
          };
      }
docs: Gets all the agent names.