// Path: src/main/java/org/jenkinsci/plugins/mesos/MesosAgentSpecTemplate.java
// public static class ContainerInfo extends AbstractDescribableImpl<ContainerInfo> {
// 
//   private final String type;
//   private final String dockerImage;
//   private final List<Volume> volumes;
//   private final Network networking;
//   private final boolean dockerPrivilegedMode;
//   private final boolean dockerForcePullImage;
//   private boolean isDind;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient List<Object> portMappings;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient boolean dockerImageCustomizable;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient List<Object> parameters;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient List<Object> networkInfos;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient boolean useCustomDockerCommandShell;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient String customDockerCommandShell;
// 
//   @DataBoundConstructor
//   public ContainerInfo(
//       String type,
//       String dockerImage,
//       boolean isDind,
//       boolean dockerPrivilegedMode,
//       boolean dockerForcePullImage,
//       List<Volume> volumes,
//       Network networking) {
//     this.type = type;
//     this.dockerImage = dockerImage;
//     this.dockerPrivilegedMode = dockerPrivilegedMode;
//     this.dockerForcePullImage = dockerForcePullImage;
//     this.volumes = volumes;
//     this.isDind = isDind;
//     this.networking =
//         (networking != null) ? networking : ContainerInfoTaskInfoBuilder.DEFAULT_NETWORKING;
//   }
// 
//   public boolean getIsDind() {
//     return this.isDind;
//   }
// 
//   public Network getNetworking() {
//     return this.networking;
//   }
// 
//   public String getType() {
//     return type;
//   }
// 
//   public String getDockerImage() {
//     return dockerImage;
//   }
// 
//   public boolean getDockerPrivilegedMode() {
//     return dockerPrivilegedMode;
//   }
// 
//   public boolean getDockerForcePullImage() {
//     return dockerForcePullImage;
//   }
// 
//   public List<Volume> getVolumes() {
//     return volumes;
//   }
// 
//   public List<Volume> getVolumesOrEmpty() {
//     return (this.volumes != null) ? this.volumes : Collections.emptyList();
//   }
// 
//   @Extension
//   public static final class DescriptorImpl extends Descriptor<ContainerInfo> {
// 
//     public DescriptorImpl() {
//       load();
//     }
//   }
// }


import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.mesosphere.usi.core.models.PodId;
import com.mesosphere.usi.core.models.commands.LaunchPod;
import com.mesosphere.usi.core.models.constraints.AgentFilter;
import com.mesosphere.usi.core.models.constraints.AttributeStringIsFilter;
import com.mesosphere.usi.core.models.faultdomain.DomainFilter;
import com.mesosphere.usi.core.models.faultdomain.HomeRegionFilter$;
import com.mesosphere.usi.core.models.resources.ScalarRequirement;
import com.mesosphere.usi.core.models.template.FetchUri;
import com.mesosphere.usi.core.models.template.RunTemplate;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import jenkins.model.Jenkins;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jenkinsci.plugins.mesos.MesosAgentSpecTemplate.ContainerInfo;
import scala.Option;
package org.jenkinsci.plugins.mesos.api;


/**
 * A simpler factory for building {@link com.mesosphere.usi.core.models.commands.LaunchPod} for
 * Jenkins agents.
 */
public class LaunchCommandBuilder {

  public LaunchCommandBuilder() {}

  private static final String AGENT_JAR_URI_SUFFIX = "jnlpJars/agent.jar";

  // We allocate extra memory for the JVM
  private static final int JVM_XMX = 32;

  public static enum AgentCommandStyle {
    Linux,
    Windows
  }

  private static final String LINUX_AGENT_COMMAND_TEMPLATE =
      "java -DHUDSON_HOME=jenkins -server -Xmx%dm %s -jar ${MESOS_SANDBOX-.}/agent.jar %s %s -jnlpUrl %s";
  private static final String WINDOWS_AGENT_COMMAND_TEMPLATE =
      "java -DHUDSON_HOME=jenkins -server -Xmx%dm %s -jar %%MESOS_SANDBOX%%/agent.jar %s %s -jnlpUrl %s";

  private static final String JNLP_SECRET_FORMAT = "-secret %s";

  private PodId id = null;
  private ScalarRequirement cpus = null;
  private ScalarRequirement memory = null;
  private ScalarRequirement disk = null;
  private String role = null;
  private List<FetchUri> additionalFetchUris = Collections.emptyList();
// Path: src/main/java/org/jenkinsci/plugins/mesos/MesosAgentSpecTemplate.java
// public static class ContainerInfo extends AbstractDescribableImpl<ContainerInfo> {
// 
//   private final String type;
//   private final String dockerImage;
//   private final List<Volume> volumes;
//   private final Network networking;
//   private final boolean dockerPrivilegedMode;
//   private final boolean dockerForcePullImage;
//   private boolean isDind;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient List<Object> portMappings;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient boolean dockerImageCustomizable;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient List<Object> parameters;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient List<Object> networkInfos;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient boolean useCustomDockerCommandShell;
// 
//   @SuppressFBWarnings("UUF_UNUSED_FIELD")
//   private transient String customDockerCommandShell;
// 
//   @DataBoundConstructor
//   public ContainerInfo(
//       String type,
//       String dockerImage,
//       boolean isDind,
//       boolean dockerPrivilegedMode,
//       boolean dockerForcePullImage,
//       List<Volume> volumes,
//       Network networking) {
//     this.type = type;
//     this.dockerImage = dockerImage;
//     this.dockerPrivilegedMode = dockerPrivilegedMode;
//     this.dockerForcePullImage = dockerForcePullImage;
//     this.volumes = volumes;
//     this.isDind = isDind;
//     this.networking =
//         (networking != null) ? networking : ContainerInfoTaskInfoBuilder.DEFAULT_NETWORKING;
//   }
// 
//   public boolean getIsDind() {
//     return this.isDind;
//   }
// 
//   public Network getNetworking() {
//     return this.networking;
//   }
// 
//   public String getType() {
//     return type;
//   }
// 
//   public String getDockerImage() {
//     return dockerImage;
//   }
// 
//   public boolean getDockerPrivilegedMode() {
//     return dockerPrivilegedMode;
//   }
// 
//   public boolean getDockerForcePullImage() {
//     return dockerForcePullImage;
//   }
// 
//   public List<Volume> getVolumes() {
//     return volumes;
//   }
// 
//   public List<Volume> getVolumesOrEmpty() {
//     return (this.volumes != null) ? this.volumes : Collections.emptyList();
//   }
// 
//   @Extension
//   public static final class DescriptorImpl extends Descriptor<ContainerInfo> {
// 
//     public DescriptorImpl() {
//       load();
//     }
//   }
// }


// Path: src/main/java/org/jenkinsci/plugins/mesos/api/LaunchCommandBuilder.java
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.mesosphere.usi.core.models.PodId;
import com.mesosphere.usi.core.models.commands.LaunchPod;
import com.mesosphere.usi.core.models.constraints.AgentFilter;
import com.mesosphere.usi.core.models.constraints.AttributeStringIsFilter;
import com.mesosphere.usi.core.models.faultdomain.DomainFilter;
import com.mesosphere.usi.core.models.faultdomain.HomeRegionFilter$;
import com.mesosphere.usi.core.models.resources.ScalarRequirement;
import com.mesosphere.usi.core.models.template.FetchUri;
import com.mesosphere.usi.core.models.template.RunTemplate;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import jenkins.model.Jenkins;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jenkinsci.plugins.mesos.MesosAgentSpecTemplate.ContainerInfo;
import scala.Option;

package org.jenkinsci.plugins.mesos.api;


/**
 * A simpler factory for building {@link com.mesosphere.usi.core.models.commands.LaunchPod} for
 * Jenkins agents.
 */
public class LaunchCommandBuilder {

  public LaunchCommandBuilder() {}

  private static final String AGENT_JAR_URI_SUFFIX = "jnlpJars/agent.jar";

  // We allocate extra memory for the JVM
  private static final int JVM_XMX = 32;

  public static enum AgentCommandStyle {
    Linux,
    Windows
  }

  private static final String LINUX_AGENT_COMMAND_TEMPLATE =
      "java -DHUDSON_HOME=jenkins -server -Xmx%dm %s -jar ${MESOS_SANDBOX-.}/agent.jar %s %s -jnlpUrl %s";
  private static final String WINDOWS_AGENT_COMMAND_TEMPLATE =
      "java -DHUDSON_HOME=jenkins -server -Xmx%dm %s -jar %%MESOS_SANDBOX%%/agent.jar %s %s -jnlpUrl %s";

  private static final String JNLP_SECRET_FORMAT = "-secret %s";

  private PodId id = null;
  private ScalarRequirement cpus = null;
  private ScalarRequirement memory = null;
  private ScalarRequirement disk = null;
  private String role = null;
  private List<FetchUri> additionalFetchUris = Collections.emptyList();
  private Optional<ContainerInfo> containerInfo = Optional.empty();