code: public static String getLocalIPv4() throws IOException {
          String url = getMetadataUrl() + "/local-ipv4";
          String localIPv4 = invokeUrl(url);
  
          if ((localIPv4 == null) || (localIPv4.trim().length() == 0)) {
              String msg = "No local IPv4 assigned to the instance";
              throw new IllegalStateException(msg);
          }
  
          return localIPv4.trim();
      }
docs: Returns the local address (IPv4) of the instance.  The local address
  is defined to be
  Public IP address if launched with direct addressing; private IP
  address if launched with public addressing.
  
  @return local IP address (IPv4) of the instance
  @throws java.io.IOException