aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/hashicorp/vault/api/help.go
blob: 472ca0395ead5f8d76b01e495600c877af5a6bd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package api

import (
	"context"
	"fmt"
)

// Help reads the help information for the given path.
func (c *Client) Help(path string) (*Help, error) {
	r := c.NewRequest("GET", fmt.Sprintf("/v1/%s", path))
	r.Params.Add("help", "1")

	ctx, cancelFunc := context.WithCancel(context.Background())
	defer cancelFunc()
	resp, err := c.RawRequestWithContext(ctx, r)
	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"`
}