From f2898927f1b92d3c8cd9e7c63ce27dee7e6ae88f Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Thu, 29 Jun 2017 22:40:14 +0100 Subject: PLT-6474: Server: Add elasticsearch/test endpoint to API. (#6792) --- model/client4.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'model/client4.go') diff --git a/model/client4.go b/model/client4.go index 89fed55ff..33a906429 100644 --- a/model/client4.go +++ b/model/client4.go @@ -230,6 +230,10 @@ func (c *Client4) GetBrandRoute() string { return fmt.Sprintf("/brand") } +func (c *Client4) GetElasticsearchRoute() string { + return fmt.Sprintf("/elasticsearch") +} + func (c *Client4) GetCommandsRoute() string { return fmt.Sprintf("/commands") } @@ -2514,6 +2518,19 @@ func (c *Client4) DeauthorizeOAuthApp(appId string) (bool, *Response) { } } +// Elasticsearch Section + +// TestElasticsearch will attempt to connect to the configured Elasticsearch server and return OK if configured +// correctly. +func (c *Client4) TestElasticsearch() (bool, *Response) { + if r, err := c.DoApiPost(c.GetElasticsearchRoute()+"/test", ""); err != nil { + return false, BuildErrorResponse(r, err) + } else { + defer closeBody(r) + return CheckStatusOK(r), BuildResponse(r) + } +} + // Commands Section // CreateCommand will create a new command if the user have the right permissions. -- cgit v1.2.3-1-g7c22