open-vault/api/help.go

38 lines
881 B
Go
Raw Normal View History

2015-04-03 05:21:33 +00:00
package api
2015-04-03 05:26:34 +00:00
import (
"context"
2015-04-03 05:26:34 +00:00
"fmt"
"net/http"
2015-04-03 05:26:34 +00:00
)
// Help wraps HelpWithContext using context.Background.
2015-04-03 05:26:34 +00:00
func (c *Client) Help(path string) (*Help, error) {
return c.HelpWithContext(context.Background(), path)
}
// HelpWithContext reads the help information for the given path.
func (c *Client) HelpWithContext(ctx context.Context, path string) (*Help, error) {
ctx, cancelFunc := c.withConfiguredTimeout(ctx)
defer cancelFunc()
r := c.NewRequest(http.MethodGet, fmt.Sprintf("/v1/%s", path))
2015-04-03 05:42:05 +00:00
r.Params.Add("help", "1")
resp, err := c.rawRequestWithContext(ctx, r)
2015-04-03 05:26:34 +00:00
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result Help
err = resp.DecodeJSON(&result)
return &result, err
}
type Help struct {
Help string `json:"help"`
SeeAlso []string `json:"see_also"`
OpenAPI map[string]interface{} `json:"openapi"`
2015-04-03 05:21:33 +00:00
}