mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 18:48:08 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			860 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			860 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package api
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"fmt"
 | |
| )
 | |
| 
 | |
| // Help wraps HelpWithContext using context.Background.
 | |
| 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("GET", fmt.Sprintf("/v1/%s", path))
 | |
| 	r.Params.Add("help", "1")
 | |
| 
 | |
| 	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"`
 | |
| 	OpenAPI map[string]interface{} `json:"openapi"`
 | |
| }
 | 
