diff --git a/src/main/java/com/ecwid/consul/v1/agent/model/NewService.java b/src/main/java/com/ecwid/consul/v1/agent/model/NewService.java index e690e45..e85c4c1 100644 --- a/src/main/java/com/ecwid/consul/v1/agent/model/NewService.java +++ b/src/main/java/com/ecwid/consul/v1/agent/model/NewService.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.SerializedName; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -13,6 +14,11 @@ public class NewService { public static class Check { + /** + * Should only be used for Consul after 1.0 + * For newer versions, {@link #args} should be used instead of script + */ + @Deprecated @SerializedName("Script") private String script; @@ -22,6 +28,12 @@ public static class Check { @SerializedName("Shell") private String shell; + /** + * Should be used for consul before 1.0 + */ + @SerializedName("Args") + private String[] args; + @SerializedName("Interval") private String interval; @@ -52,10 +64,20 @@ public static class Check { @SerializedName("Status") private String status; + /** + * Should only be used for Consul < 1.0 + * For newer versions, {@link #getArgs()} should be used instead of script + */ + @Deprecated public String getScript() { return script; } + /** + * Should only be used for Consul < 1.0 + * For newer versions, {@link #setArgs(String)} should be used instead of script + */ + @Deprecated public void setScript(String script) { this.script = script; } @@ -76,6 +98,14 @@ public void setShell(String shell) { this.shell = shell; } + public String[] getArgs() { + return args; + } + + public void setArgs(String script) { + this.args = script.split(" "); + } + public String getInterval() { return interval; } @@ -160,6 +190,7 @@ public void setStatus(String status) { public String toString() { return "Check{" + "script='" + script + '\'' + + ", args='" + Arrays.deepToString(args) + '\'' + ", interval='" + interval + '\'' + ", ttl='" + ttl + '\'' + ", http='" + http + '\'' +