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

io.fabric8.maven.docker.access.VolumeCreateConfig Maven / Gradle / Ivy

There is a newer version: 0.45.0
Show newest version
package io.fabric8.maven.docker.access;

import java.util.Map;

import org.json.JSONObject;

public class VolumeCreateConfig
{
    private final JSONObject createConfig = new JSONObject();

    public VolumeCreateConfig(String name) {
        add("Name", name);
    }

    public VolumeCreateConfig driver(String driver) {
       return add("Driver", driver);
    }

    public VolumeCreateConfig opts(Map opts) {
       if (opts != null && opts.size() > 0) {
          add("DriverOpts", new JSONObject(opts));
       }
       return this;
    }

    public VolumeCreateConfig labels(Map labels) {
        if (labels != null && labels.size() > 0) {
           add("Labels", new JSONObject(labels));
        }
        return this;
    }

    public String getName() {
        return createConfig.getString("Name");
    }

    /**
     * Get JSON which is used for creating a volume
     *
     * @return string representation for JSON representing creating a volume
     */
    public String toJson() {
        return createConfig.toString();
    }

    // =======================================================================

    private VolumeCreateConfig add(String name, Object value) {
        if (value != null) {
            createConfig.put(name, value);
        }
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy