From dc96b755fb63b01fe92dce24e7e3e4d1f55627b0 Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Fri, 13 Dec 2024 09:01:30 +0100 Subject: [PATCH] Adds a number of helper structs for z responses These are used by the cli and other tools to decode the responses from the z endpoints Signed-off-by: R.I.Pienaar --- server/events.go | 67 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/server/events.go b/server/events.go index 1928e64d741..7c891b423d8 100644 --- a/server/events.go +++ b/server/events.go @@ -1947,7 +1947,9 @@ type ServerAPIResponse struct { compress compressionType } -// Specialized response types for unmarshalling. +// Specialized response types for unmarshalling. These structures are not +// used in the server code and only there for users of the Z endpoints to +// unmarshal the data without having to create these structs in their code // ServerAPIConnzResponse is the response type connz type ServerAPIConnzResponse struct { @@ -1956,6 +1958,69 @@ type ServerAPIConnzResponse struct { Error *ApiError `json:"error,omitempty"` } +// ServerAPIRoutezResponse is the response type for routez +type ServerAPIRoutezResponse struct { + Server *ServerInfo `json:"server"` + Data *Routez `json:"data,omitempty"` + Error *ApiError `json:"error,omitempty"` +} + +// ServerAPIGatewayzResponse is the response type for gatewayz +type ServerAPIGatewayzResponse struct { + Server *ServerInfo `json:"server"` + Data *Gatewayz `json:"data,omitempty"` + Error *ApiError `json:"error,omitempty"` +} + +// ServerAPIJszResponse is the response type for jsz +type ServerAPIJszResponse struct { + Server *ServerInfo `json:"server"` + Data *JSInfo `json:"data,omitempty"` + Error *ApiError `json:"error,omitempty"` +} + +// ServerAPIHealthzResponse is the response type for healthz +type ServerAPIHealthzResponse struct { + Server *ServerInfo `json:"server"` + Data *HealthStatus `json:"data,omitempty"` + Error *ApiError `json:"error,omitempty"` +} + +// ServerAPIVarzResponse is the response type for varz +type ServerAPIVarzResponse struct { + Server *ServerInfo `json:"server"` + Data *Varz `json:"data,omitempty"` + Error *ApiError `json:"error,omitempty"` +} + +// ServerAPISubszResponse is the response type for subsz +type ServerAPISubszResponse struct { + Server *ServerInfo `json:"server"` + Data *Subsz `json:"data,omitempty"` + Error *ApiError `json:"error,omitempty"` +} + +// ServerAPILeafzResponse is the response type for leafz +type ServerAPILeafzResponse struct { + Server *ServerInfo `json:"server"` + Data *Leafz `json:"data,omitempty"` + Error *ApiError `json:"error,omitempty"` +} + +// ServerAPIAccountzResponse is the response type for accountz +type ServerAPIAccountzResponse struct { + Server *ServerInfo `json:"server"` + Data *Accountz `json:"data,omitempty"` + Error *ApiError `json:"error,omitempty"` +} + +// ServerAPIExpvarzResponse is the response type for expvarz +type ServerAPIExpvarzResponse struct { + Server *ServerInfo `json:"server"` + Data *ExpvarzStatus `json:"data,omitempty"` + Error *ApiError `json:"error,omitempty"` +} + // statszReq is a request for us to respond with current statsz. func (s *Server) statszReq(sub *subscription, c *client, _ *Account, subject, reply string, hdr, msg []byte) { if !s.EventsEnabled() {