{"modulePath":"github.com/CubePathInc/cubecli","version":"v1.23.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\n## Types\n\n```go\ntype APIError struct {\n\tStatusCode int\n\tDetail     string\n\tRetryAfter string // Retry-After header, when the server sent one\n}\n```\n\n```go\nfunc (e *APIError) Error() string\n```\n\n```go\ntype Client struct {\n\tBaseURL    string\n\tAuth       TokenSource\n\tHTTPClient *http.Client\n}\n```\n\n```go\nfunc NewClient(baseURL, token string) *Client\n```\n\n```go\nfunc NewClientWithAuth(baseURL string, auth TokenSource) *Client\n```\n\n```go\nfunc (c *Client) Delete(path string) (json.RawMessage, error)\n```\n\n```go\nfunc (c *Client) Get(path string) (json.RawMessage, error)\n```\n\n```go\nfunc (c *Client) GraphQL(query string, variables map[string]interface{}) (json.RawMessage, error)\n```\nGraphQL runs a query against POST /graphql and returns its \"data\" object. Metrics and BMC sensors are only served through GraphQL. A GraphQL error comes back as an \\*APIError; NOT\\_FOUND maps to 404.\n\n```go\nfunc (c *Client) Patch(path string, body interface{}) (json.RawMessage, error)\n```\n\n```go\nfunc (c *Client) Post(path string, body interface{}) (json.RawMessage, error)\n```\n\n```go\nfunc (c *Client) PostFile(path, field, fileName string, content []byte) (json.RawMessage, error)\n```\nPostFile uploads one file as multipart/form-data under the form field \\`field\\`.\n\n```go\nfunc (c *Client) Put(path string, body interface{}) (json.RawMessage, error)\n```\n\n```go\ntype StaticToken string\n```\nStaticToken is a TokenSource for API tokens, which cannot be refreshed.\n\n```go\nfunc (t StaticToken) Refresh(string) (string, error)\n```\n\n```go\nfunc (t StaticToken) Token() (string, error)\n```\n\n```go\ntype TokenSource interface {\n\tToken() (string, error)\n\tRefresh(stale string) (string, error)\n}\n```\nTokenSource supplies the bearer token. Refresh is called once when the API answers 401 to a request sent with \\`stale\\`.\n\n","path":"github.com/CubePathInc/cubecli/internal/api","name":"api","synopsis":"","isRedistributable":true}
