From d51c2a464ef38885bfdaf628b4098d695f4e28bf Mon Sep 17 00:00:00 2001 From: Dan Peters Date: Thu, 5 Aug 2021 15:29:26 +0100 Subject: [PATCH] Add service checks and node checks to session objects --- .../consul/v1/session/model/NewSession.java | 26 ++++++++++++++ .../consul/v1/session/model/ServiceCheck.java | 36 +++++++++++++++++++ .../consul/v1/session/model/Session.java | 28 +++++++++++++++ 3 files changed, 90 insertions(+) create mode 100755 src/main/java/com/ecwid/consul/v1/session/model/ServiceCheck.java diff --git a/src/main/java/com/ecwid/consul/v1/session/model/NewSession.java b/src/main/java/com/ecwid/consul/v1/session/model/NewSession.java index 5530eb7..349b616 100644 --- a/src/main/java/com/ecwid/consul/v1/session/model/NewSession.java +++ b/src/main/java/com/ecwid/consul/v1/session/model/NewSession.java @@ -18,9 +18,19 @@ public class NewSession { @SerializedName("Node") private String node; + /** + * @deprecated this field is deprecated as of consul 1.7, the fields nodeChecks and serviceChecks should be used instead + */ + @Deprecated @SerializedName("Checks") private List checks; + @SerializedName("NodeChecks") + private List nodeChecks; + + @SerializedName("ServiceChecks") + private List serviceChecks; + @SerializedName("Behavior") private Session.Behavior behavior; @@ -59,6 +69,22 @@ public void setChecks(List checks) { this.checks = checks; } + public List getNodeChecks() { + return nodeChecks; + } + + public void setNodeChecks(List nodeChecks) { + this.nodeChecks = nodeChecks; + } + + public List getServiceChecks() { + return serviceChecks; + } + + public void setServiceChecks(List serviceChecks) { + this.serviceChecks = serviceChecks; + } + public Session.Behavior getBehavior() { return behavior; } diff --git a/src/main/java/com/ecwid/consul/v1/session/model/ServiceCheck.java b/src/main/java/com/ecwid/consul/v1/session/model/ServiceCheck.java new file mode 100755 index 0000000..14c6fd1 --- /dev/null +++ b/src/main/java/com/ecwid/consul/v1/session/model/ServiceCheck.java @@ -0,0 +1,36 @@ +package com.ecwid.consul.v1.session.model; + +import com.google.gson.annotations.SerializedName; + +public class ServiceCheck { + + @SerializedName("ID") + private String id; + + @SerializedName("Namespace") + private String namespace; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + @Override + public String toString() { + return "ServiceCheck{" + + "id='" + id + '\'' + + ", namespace='" + namespace + '\'' + + '}'; + } +} diff --git a/src/main/java/com/ecwid/consul/v1/session/model/Session.java b/src/main/java/com/ecwid/consul/v1/session/model/Session.java index 021d822..a374650 100644 --- a/src/main/java/com/ecwid/consul/v1/session/model/Session.java +++ b/src/main/java/com/ecwid/consul/v1/session/model/Session.java @@ -20,9 +20,19 @@ public static enum Behavior { @SerializedName("LockDelay") private long lockDelay; + /** + * @deprecated this field is deprecated as of consul 1.7, the fields nodeChecks and serviceChecks should be used instead + */ + @Deprecated @SerializedName("Checks") private List checks; + @SerializedName("NodeChecks") + private List nodeChecks; + + @SerializedName("ServiceChecks") + private List serviceChecks; + @SerializedName("Node") private String node; @@ -60,6 +70,22 @@ public void setChecks(List checks) { this.checks = checks; } + public List getNodeChecks() { + return nodeChecks; + } + + public void setNodeChecks(List nodeChecks) { + this.nodeChecks = nodeChecks; + } + + public List getServiceChecks() { + return serviceChecks; + } + + public void setServiceChecks(List serviceChecks) { + this.serviceChecks = serviceChecks; + } + public String getNode() { return node; } @@ -121,6 +147,8 @@ public String toString() { return "Session{" + "lockDelay=" + lockDelay + ", checks=" + checks + + ", nodeChecks=" + nodeChecks + + ", serviceChecks=" + serviceChecks + ", node='" + node + '\'' + ", id='" + id + '\'' + ", name='" + name + '\'' +