api: Support sys/leader endpoint

This commit is contained in:
Armon Dadgar 2015-04-20 12:04:13 -07:00
parent ebd1e88872
commit 39cb908662
1 changed files with 20 additions and 0 deletions

20
api/sys_leader.go Normal file
View File

@ -0,0 +1,20 @@
package api
func (c *Sys) Leader() (*LeaderResponse, error) {
r := c.c.NewRequest("GET", "/v1/sys/leader")
resp, err := c.c.RawRequest(r)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result LeaderResponse
err = resp.DecodeJSON(&result)
return &result, err
}
type LeaderResponse struct {
HAEnabled bool `json:"ha_enabled"`
IsSelf bool `json:"is_self"`
LeaderAddress string `json:"leader_address"`
}