All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jclouds.docker.domain.HostConfig Maven / Gradle / Ivy

Go to download

Patched classes required for Clocker. Will be removed when dependencies are updated and merged.

There is a newer version: 1.2.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jclouds.docker.domain;

import static org.jclouds.docker.internal.NullSafeCopies.copyOf;
import static org.jclouds.docker.internal.NullSafeCopies.copyWithNullOf;

import java.util.List;
import java.util.Map;

import com.google.auto.value.AutoValue;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;

@AutoValue
public abstract class HostConfig {
   @Nullable public abstract String containerIDFile();

   @Nullable public abstract List binds();

   public abstract List> lxcConf();

   public abstract boolean privileged();

   @Nullable public abstract List dns();

   @Nullable public abstract List dnsSearch();

   public abstract Map>> portBindings();

   @Nullable public abstract List links();

   @Nullable public abstract List extraHosts();

   public abstract boolean publishAllPorts();

   @Nullable public abstract List volumesFrom();

   @Nullable public abstract String networkMode();

   HostConfig() {
   }

   @SerializedNames({ "ContainerIDFile", "Binds", "LxcConf", "Privileged", "Dns", "DnsSearch", "PortBindings",
         "Links", "ExtraHosts", "PublishAllPorts", "VolumesFrom", "NetworkMode" })
   public static HostConfig create(String containerIDFile, List binds, List> lxcConf,
         boolean privileged, List dns, List dnsSearch, Map>> portBindings,
         List links, List extraHosts, boolean publishAllPorts, List volumesFrom, String networkMode) {
      return new AutoValue_HostConfig(containerIDFile, copyWithNullOf(binds), copyOf(lxcConf), privileged, copyWithNullOf(dns), copyWithNullOf(dnsSearch),
            copyOf(portBindings), copyWithNullOf(links), copyWithNullOf(extraHosts), publishAllPorts, copyWithNullOf(volumesFrom), networkMode);
   }

   public static Builder builder() {
      return new Builder();
   }

   public Builder toBuilder() {
      return builder().fromHostConfig(this);
   }

   public static final class Builder {

      private String containerIDFile;
      private List binds;
      private List> lxcConf = Lists.newArrayList();
      private boolean privileged;
      private List dns;
      private List dnsSearch;
      private Map>> portBindings = Maps.newLinkedHashMap();
      private List links;
      private List extraHosts;
      private boolean publishAllPorts;
      private List volumesFrom;
      private String networkMode;

      public Builder containerIDFile(String containerIDFile) {
         this.containerIDFile = containerIDFile;
         return this;
      }

      public Builder binds(List binds) {
         this.binds = binds;
         return this;
      }

      public Builder lxcConf(List> lxcConf) {
         this.lxcConf = lxcConf;
         return this;
      }

      public Builder privileged(boolean privileged) {
         this.privileged = privileged;
         return this;
      }

      public Builder dns(List dns) {
         this.dns = dns;
         return this;
      }

      public Builder dnsSearch(List dnsSearch) {
         this.dnsSearch = dnsSearch;
         return this;
      }

      public Builder links(List links) {
         this.links = links;
         return this;
      }

      public Builder extraHosts(List extraHosts) {
         this.extraHosts = extraHosts;
         return this;
      }

      public Builder portBindings(Map>> portBindings) {
         this.portBindings = portBindings;
         return this;
      }

      public Builder publishAllPorts(boolean publishAllPorts) {
         this.publishAllPorts = publishAllPorts;
         return this;
      }

      public Builder volumesFrom(List volumesFrom) {
         this.volumesFrom = volumesFrom;
         return this;
      }

      public Builder networkMode(String networkMode) {
         this.networkMode = networkMode;
         return this;
      }

      public HostConfig build() {
         return HostConfig.create(containerIDFile, binds, lxcConf, privileged, dns, dnsSearch, portBindings, links,
               extraHosts, publishAllPorts, volumesFrom, networkMode);
      }

      public Builder fromHostConfig(HostConfig in) {
         return this.containerIDFile(in.containerIDFile()).binds(in.binds()).lxcConf(in.lxcConf())
               .privileged(in.privileged()).dns(in.dns()).dnsSearch(in.dnsSearch()).links(in.links())
               .extraHosts(in.extraHosts()).portBindings(in.portBindings()).publishAllPorts(in.publishAllPorts())
               .volumesFrom(in.volumesFrom()).networkMode(in.networkMode());
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy