1// Copyright 2015 Niels Freier
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//     http://www.apache.org/licenses/LICENSE-2.0
6// Unless required by applicable law or agreed to in writing, software
7// distributed under the License is distributed on an "AS IS" BASIS,
8// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9// See the License for the specific language governing permissions and
10// limitations under the License.
11
12package elastigo
13
14import (
15	"encoding/json"
16)
17
18func (c *Conn) NodesStats() (NodeStatsResponse, error) {
19	var retval NodeStatsResponse
20
21	body, err := c.DoCommand("GET", "/_nodes/stats", nil, nil)
22	if err != nil {
23		return retval, err
24	}
25	// marshall into json
26	jsonErr := json.Unmarshal(body, &retval)
27	if jsonErr != nil {
28		return retval, jsonErr
29	}
30	return retval, err
31}
32