2015-05-28 01:05:23 +00:00
|
|
|
package api
|
|
|
|
|
2018-07-24 22:49:55 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
)
|
2015-05-28 01:05:23 +00:00
|
|
|
|
|
|
|
func (c *Sys) Rotate() error {
|
|
|
|
r := c.c.NewRequest("POST", "/v1/sys/rotate")
|
2018-07-24 22:49:55 +00:00
|
|
|
|
|
|
|
ctx, cancelFunc := context.WithCancel(context.Background())
|
|
|
|
defer cancelFunc()
|
|
|
|
resp, err := c.c.RawRequestWithContext(ctx, r)
|
2015-05-28 01:05:23 +00:00
|
|
|
if err == nil {
|
|
|
|
defer resp.Body.Close()
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Sys) KeyStatus() (*KeyStatus, error) {
|
|
|
|
r := c.c.NewRequest("GET", "/v1/sys/key-status")
|
2018-07-24 22:49:55 +00:00
|
|
|
|
|
|
|
ctx, cancelFunc := context.WithCancel(context.Background())
|
|
|
|
defer cancelFunc()
|
|
|
|
resp, err := c.c.RawRequestWithContext(ctx, r)
|
2015-05-28 01:05:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
2016-08-14 18:52:45 +00:00
|
|
|
result := new(KeyStatus)
|
|
|
|
err = resp.DecodeJSON(result)
|
|
|
|
return result, err
|
2015-05-28 01:05:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type KeyStatus struct {
|
2016-08-14 18:52:45 +00:00
|
|
|
Term int `json:"term"`
|
2015-05-28 01:05:23 +00:00
|
|
|
InstallTime time.Time `json:"install_time"`
|
|
|
|
}
|