Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/com/github/dockerjava/api/DockerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.github.dockerjava.api.command.ListImagesCmd;
import com.github.dockerjava.api.command.ListNetworksCmd;
import com.github.dockerjava.api.command.ListServicesCmd;
import com.github.dockerjava.api.command.ListTasksCmd;
import com.github.dockerjava.api.command.ListVolumesCmd;
import com.github.dockerjava.api.command.LoadImageCmd;
import com.github.dockerjava.api.command.LogContainerCmd;
Expand Down Expand Up @@ -347,6 +348,14 @@ public interface DockerClient extends Closeable {
*/
RemoveServiceCmd removeServiceCmd(String serviceId);

/**
* List tasks in the swarm cluster
*
* @return the command
* @since 1.24
*/
ListTasksCmd listTasksCmd();

@Override
void close() throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ public interface DockerCmdExecFactory extends Closeable {
*/
UpdateSwarmNodeCmd.Exec updateSwarmNodeCmdExec();

/**
* Update a node. Node operations require the engine to be part of a swarm
*
* @since {@link RemoteApiVersion#VERSION_1_24}
*/
ListTasksCmd.Exec listTasksCmdExec();

@Override
void close() throws IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.github.dockerjava.api.command;

import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.Task;

import javax.annotation.CheckForNull;

public interface InspectTaskCmd extends SyncDockerCmd<Task> {
@CheckForNull
String getTaskId();

InspectTaskCmd withTaskId();

@Override
Task exec() throws NotFoundException;

interface Exec extends DockerCmdSyncExec<InspectTaskCmd, Task> {
}
}
56 changes: 56 additions & 0 deletions src/main/java/com/github/dockerjava/api/command/ListTasksCmd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.github.dockerjava.api.command;

import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.Task;
import com.github.dockerjava.api.model.TaskState;

import javax.annotation.CheckForNull;
import java.util.List;
import java.util.Map;

public interface ListTasksCmd extends SyncDockerCmd<List<Task>> {
@CheckForNull
Map<String, List<String>> getFilters();

/**
* @param labels - Show only tasks with the passed labels.
* Labels is a {@link Map} that contains label keys and values
*/
ListTasksCmd withLabelFilter(Map<String, String> labels);

/**
* @param labels - Show only tasks with the passed labels.
*/
ListTasksCmd withLabelFilter(String... labels);

/**
* @param ids Task id(s)
*/
ListTasksCmd withIdFilter(String... ids);

/**
* @param names Task name(s)
*/
ListTasksCmd withNameFilter(String... names);

/**
* @param nodeNames Node id(s) or name(s)
*/
ListTasksCmd withNodeFilter(String... nodeNames);

/**
* @param serviceNames Service name(s)
*/
ListTasksCmd withServiceFilter(String... serviceNames);

/**
* @param desiredState The desired-state filter can take the values running, shutdown, or accepted.
*/
ListTasksCmd withStateFilter(TaskState... desiredState);

@Override
List<Task> exec() throws NotFoundException;

interface Exec extends DockerCmdSyncExec<ListTasksCmd, List<Task>> {
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.dockerjava.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.dockerjava.core.RemoteApiVersion;
import org.apache.commons.lang.builder.EqualsBuilder;
Expand All @@ -17,6 +18,7 @@
*
* @since {@link RemoteApiVersion#VERSION_1_24}
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class ContainerSpec implements Serializable {
public static final Long serialVersionUID = 1L;

Expand All @@ -36,7 +38,7 @@ public class ContainerSpec implements Serializable {
* @since 1.24
*/
@JsonProperty("Command")
private String command;
private List<String> command;

/**
* @since 1.24
Expand Down Expand Up @@ -122,14 +124,14 @@ public ContainerSpec withLabels(Map<String, String> labels) {
* @see #command
*/
@CheckForNull
public String getCommand() {
public List<String> getCommand() {
return command;
}

/**
* @see #command
*/
public ContainerSpec withCommand(String command) {
public ContainerSpec withCommand(List<String> command) {
this.command = command;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.dockerjava.api.model;

import java.io.Serializable;

public class DiscreteResourceSpec extends GenericResource<String> implements Serializable {
private static final long serialVersionUID = 1L;
}
32 changes: 32 additions & 0 deletions src/main/java/com/github/dockerjava/api/model/GenericResource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.github.dockerjava.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;

public abstract class GenericResource<T> implements Serializable {
private static final long serialVersionUID = 1L;

@JsonProperty("Kind")
String kind;
@JsonProperty("Value")
T value = null;

public String getKind() {
return kind;
}

public GenericResource withKind(String kind) {
this.kind = kind;
return this;
}

public T getValue() {
return value;
}

public GenericResource withValue(T value) {
this.value = value;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.github.dockerjava.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.github.dockerjava.core.RemoteApiVersion;

import java.io.Serializable;

/**
* @since {@link RemoteApiVersion#VERSION_1_24}
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class NamedResourceSpec extends GenericResource<Integer> implements Serializable {
private static final long serialVersionUID = 1L;
}
40 changes: 40 additions & 0 deletions src/main/java/com/github/dockerjava/api/model/ObjectVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.github.dockerjava.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.dockerjava.core.RemoteApiVersion;

import java.io.Serializable;

/**
* @since {@link RemoteApiVersion#VERSION_1_24}
* The version number of the object such as node, service, etc. This is needed to avoid conflicting writes.
* The client must send the version number along with the modified specification when updating these objects.
* This approach ensures safe concurrency and determinism in that the change on the object may not be applied
* if the version number has changed from the last read. In other words, if two update requests specify the
* same base version, only one of the requests can succeed. As a result, two separate update requests that
* happen at the same time will not unintentionally overwrite each other.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ObjectVersion implements Serializable {
private static final long serialVersionUID = 1L;

@JsonProperty("Index")
private Integer index = null;

public Integer getIndex() {
return index;
}

public ObjectVersion withIndex(Integer index) {
this.index = index;
return this;
}

@Override
public String toString() {
return String.valueOf(index);
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/github/dockerjava/api/model/PortConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public class PortConfig implements Serializable {
@JsonProperty("PublishedPort")
private int publishedPort;

/**
* @since 1.25
* docker 1.13
* https://github.com/mrjana/docker/blob/14ac9f60d0174256e0713701ebffaf5ca827da71/api/types/swarm/network.go
*/
@JsonProperty("PublishMode")
private PublishMode publishMode;

/**
* @see #name
*/
Expand Down Expand Up @@ -103,6 +111,16 @@ public PortConfig withPublishedPort(int publishedPort) {
return this;
}

@CheckForNull
public PublishMode getPublishMode() {
return publishMode;
}

public PortConfig withPublishMode(PublishMode publishMode) {
this.publishMode = publishMode;
return this;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
Expand All @@ -117,4 +135,13 @@ public boolean equals(Object o) {
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}

public enum PublishMode {
//ingress load balancing using routing mesh.
@JsonProperty("ingress")
ingress,
//direct host level access on the host where the task is running.
@JsonProperty("host")
host
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public enum PortConfigProtocol {
TCP,

@JsonProperty("udp")
udp
UDP

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.dockerjava.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.dockerjava.core.RemoteApiVersion;
import org.apache.commons.lang.builder.EqualsBuilder;
Expand All @@ -14,6 +15,7 @@
/**
* @since {@link RemoteApiVersion#VERSION_1_24}
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class ServicePlacement implements Serializable {
public static final Long serialVersionUID = 1L;

Expand All @@ -23,6 +25,12 @@ public class ServicePlacement implements Serializable {
@JsonProperty("Constraints")
private List<String> constraints;

/**
* @since 1.30
*/
@JsonProperty("Platforms")
private List<SwarmNodePlatform> platforms;

/**
* @see #constraints
*/
Expand All @@ -39,6 +47,17 @@ public ServicePlacement withConstraints(List<String> constraints) {
return this;
}

/**
* @see #platforms
*/
public List<SwarmNodePlatform> getPlatforms() {
return platforms;
}

public void setPlatforms(List<SwarmNodePlatform> platforms) {
this.platforms = platforms;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
Expand Down
Loading