open-vault/api/sys_leases.go

49 lines
1,002 B
Go
Raw Normal View History

2015-03-12 00:46:25 +00:00
package api
2015-04-14 00:37:39 +00:00
func (c *Sys) Renew(id string, increment int) (*Secret, error) {
r := c.c.NewRequest("PUT", "/v1/sys/leases/renew")
2015-04-14 00:37:39 +00:00
body := map[string]interface{}{
"increment": increment,
"lease_id": id,
}
2015-04-14 00:37:39 +00:00
if err := r.SetJSONBody(body); err != nil {
return nil, err
}
2015-03-12 00:46:25 +00:00
resp, err := c.c.RawRequest(r)
if err != nil {
return nil, err
}
defer resp.Body.Close()
return ParseSecret(resp.Body)
2015-03-12 00:46:25 +00:00
}
func (c *Sys) Revoke(id string) error {
r := c.c.NewRequest("PUT", "/v1/sys/leases/revoke/"+id)
2015-03-12 00:46:25 +00:00
resp, err := c.c.RawRequest(r)
2015-04-01 02:21:02 +00:00
if err == nil {
defer resp.Body.Close()
}
2015-03-12 00:46:25 +00:00
return err
}
2015-04-01 02:23:52 +00:00
func (c *Sys) RevokePrefix(id string) error {
r := c.c.NewRequest("PUT", "/v1/sys/leases/revoke-prefix/"+id)
2015-04-01 02:23:52 +00:00
resp, err := c.c.RawRequest(r)
if err == nil {
defer resp.Body.Close()
}
return err
}
func (c *Sys) RevokeForce(id string) error {
r := c.c.NewRequest("PUT", "/v1/sys/leases/revoke-force/"+id)
resp, err := c.c.RawRequest(r)
if err == nil {
defer resp.Body.Close()
}
return err
}