private static Instance createInstanceTemplate(String userEmail,String projectId,String zoneId,List<String> scopes){
  Instance instance=new Instance();
  instance.setMachineType(String.format(ENUMERATION_TEST_MACHINE_TYPE,projectId,zoneId));
  NetworkInterface ifc=new NetworkInterface();
  ifc.setNetwork(String.format(NETWORK_INTERFACE,projectId));
  List<AccessConfig> configs=new ArrayList<>();
  AccessConfig config=new AccessConfig();
  config.setType(NETWORK_INTERFACE_CONFIG);
  config.setName(NETWORK_ACCESS_CONFIG);
  configs.add(config);
  ifc.setAccessConfigs(configs);
  instance.setNetworkInterfaces(Collections.singletonList(ifc));
  AttachedDisk disk=new AttachedDisk();
  disk.setBoot(true);
  disk.setAutoDelete(true);
  disk.setType(DISK_TYPE_PERSISTENT);
  AttachedDiskInitializeParams params=new AttachedDiskInitializeParams();
  params.setSourceImage(SOURCE_IMAGE);
  params.setDiskType(String.format(DISK_TYPE,projectId,zoneId));
  disk.setInitializeParams(params);
  instance.setDisks(Collections.singletonList(disk));
  ServiceAccount account=new ServiceAccount();
  account.setEmail(userEmail);
  account.setScopes(scopes);
  instance.setServiceAccounts(Collections.singletonList(account));
  return instance;
}

private static Instance createInstanceTemplate ( String userEmail , String projectId , String zoneId , List < String > scopes ) { Instance instance = new Instance ( ) ; instance . setMachineType ( String . format ( ENUMERATION_TEST_MACHINE_TYPE , projectId , zoneId ) ) ; NetworkInterface ifc = new NetworkInterface ( ) ; ifc . setNetwork ( String . format ( NETWORK_INTERFACE , projectId ) ) ; List < AccessConfig > configs = new ArrayList < > ( ) ; AccessConfig config = new AccessConfig ( ) ; config . setType ( NETWORK_INTERFACE_CONFIG ) ; config . setName ( NETWORK_ACCESS_CONFIG ) ; configs . add ( config ) ; ifc . setAccessConfigs ( configs ) ; instance . setNetworkInterfaces ( Collections . singletonList ( ifc ) ) ; AttachedDisk disk = new AttachedDisk ( ) ; disk . setBoot ( true ) ; disk . setAutoDelete ( true ) ; disk . setType ( DISK_TYPE_PERSISTENT ) ; AttachedDiskInitializeParams params = new AttachedDiskInitializeParams ( ) ; params . setSourceImage ( SOURCE_IMAGE ) ; params . setDiskType ( String . format ( DISK_TYPE , projectId , zoneId ) ) ; disk . setInitializeParams ( params ) ; instance . setDisks ( Collections . singletonList ( disk ) ) ; ServiceAccount account = new ServiceAccount ( ) ; account . setEmail ( userEmail ) ; account . setScopes ( scopes ) ; instance . setServiceAccounts ( Collections . singletonList ( account ) ) ; return instance ; }
create an instance template for later provisioning .
