From 8f895908fcb250c212562d2d7c481dd1ee052ba3 Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Mon, 26 Oct 2020 15:45:58 +0100 Subject: [PATCH] [MM-29220] Adds a client function that retrieves the full status report (#15727) Co-authored-by: Mattermod --- model/client4.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/model/client4.go b/model/client4.go index 662d71dd0d..d280622d91 100644 --- a/model/client4.go +++ b/model/client4.go @@ -3272,6 +3272,21 @@ func (c *Client4) GetPingWithServerStatus() (string, *Response) { return MapFromJson(r.Body)["status"], BuildResponse(r) } +// GetPingWithFullServerStatus will return the full status if several basic server +// health checks all pass successfully. +func (c *Client4) GetPingWithFullServerStatus() (map[string]string, *Response) { + r, err := c.DoApiGet(c.GetSystemRoute()+"/ping?get_server_status="+c.boolString(true), "") + if r != nil && r.StatusCode == 500 { + defer r.Body.Close() + return map[string]string{"status": STATUS_UNHEALTHY}, BuildErrorResponse(r, err) + } + if err != nil { + return nil, BuildErrorResponse(r, err) + } + defer closeBody(r) + return MapFromJson(r.Body), BuildResponse(r) +} + // TestEmail will attempt to connect to the configured SMTP server. func (c *Client4) TestEmail(config *Config) (bool, *Response) { r, err := c.DoApiPost(c.GetTestEmailRoute(), config.ToJson())