diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/model/ServicePlacement.java b/docker-java-api/src/main/java/com/github/dockerjava/api/model/ServicePlacement.java index 9c2f0223a..777be8668 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/model/ServicePlacement.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/model/ServicePlacement.java @@ -28,6 +28,12 @@ public class ServicePlacement implements Serializable { @JsonProperty("Platforms") private List platforms; + /** + * @since 1.40 + */ + @JsonProperty("MaxReplicas") + private Integer maxReplicas; + /** * @see #constraints */ @@ -54,4 +60,31 @@ public List getPlatforms() { public void setPlatforms(List platforms) { this.platforms = platforms; } + + /** + * Specifies the maximum amount of replicas / tasks that can run on one node. + * 0 means unlimited replicas per node. + * + * @param maxReplicas Max number of replicas + * @return This instance of ServicePlacement + * @throws IllegalArgumentException if maxReplicas is less than 0 + */ + public ServicePlacement withMaxReplicas(int maxReplicas) { + if (maxReplicas < 0) { + throw new IllegalArgumentException("The Value for MaxReplicas must be greater or equal to 0"); + } + + this.maxReplicas = maxReplicas; + return this; + } + + /** + * Getter for maxReplicas + * + * @return The maximum amount of replicas / tasks that can run on one node. + */ + public Integer getMaxReplicas() { + return this.maxReplicas; + } + }