Documentation
¶
Index ¶
- Variables
- func APIErrorMessage(status int, body []byte) string
- type Client
- func (c *Client) Delete(path string, queryParams map[string]string) (any, http.Header, error)
- func (c *Client) DeleteWithBody(path string, queryParams map[string]string, body any) (any, http.Header, error)
- func (c *Client) DoRaw(r Request) (*http.Response, error)
- func (c *Client) DoRequest(r Request) (any, http.Header, error)
- func (c *Client) DoStream(r Request, timeout time.Duration) (*http.Response, error)
- func (c *Client) Get(path string, queryParams map[string]string) (any, http.Header, error)
- func (c *Client) Patch(path string, queryParams map[string]string, body any) (any, http.Header, error)
- func (c *Client) PatchRaw(path string, queryParams map[string]string, body, contentType string) (any, http.Header, error)
- func (c *Client) Post(path string, queryParams map[string]string, body any) (any, http.Header, error)
- func (c *Client) PostRaw(path string, queryParams map[string]string, body, contentType string) (any, http.Header, error)
- func (c *Client) Put(path string, queryParams map[string]string, body any) (any, http.Header, error)
- func (c *Client) PutRaw(path string, queryParams map[string]string, body, contentType string) (any, http.Header, error)
- type Request
Constants ¶
This section is empty.
Variables ¶
var ErrRequestPreviewed = errors.New("request previewed")
Functions ¶
func APIErrorMessage ¶
Types ¶
type Client ¶
type Client struct {
// NoAccountID, when true, omits the accountIdentifier query param from every
// request made by this Client. Set by callers that build requests via the
// Get/Post/Put/Delete/etc. shorthand methods, which don't accept per-request options.
NoAccountID bool
// contains filtered or unexported fields
}
Client makes authenticated HTTP requests to the Harness API.
func NewWithAuth ¶
func NewWithAuth(ctx context.Context, resolved *auth.ResolvedAuth) *Client
NewWithAuth creates a Client from a bare context and resolved auth, with no CLI command metadata. Used for pre-command flows like login that have no Ctx.
func (*Client) DeleteWithBody ¶
func (c *Client) DeleteWithBody(path string, queryParams map[string]string, body any) (any, http.Header, error)
DeleteWithBody performs a DELETE request with a JSON body.
func (*Client) DoRaw ¶
DoRaw executes a Request and returns the raw *http.Response. The caller is responsible for closing resp.Body. Use this for binary responses or large downloads.
func (*Client) DoRequest ¶
DoRequest executes a Request and returns the decoded JSON response body, response headers, and any error. If Body is a string, it is sent as-is using BodyContentType. Otherwise Body is JSON-marshaled and BodyContentType defaults to "application/json". Extra per-request headers may be set via Headers.
func (*Client) DoStream ¶
DoStream executes a Request using a long-lived HTTP client suitable for streaming responses (e.g. SSE). Returns the raw *http.Response; the caller is responsible for closing resp.Body.
func (*Client) Patch ¶
func (c *Client) Patch(path string, queryParams map[string]string, body any) (any, http.Header, error)
Patch performs a PATCH request with an optional JSON body.
func (*Client) PatchRaw ¶
func (c *Client) PatchRaw(path string, queryParams map[string]string, body, contentType string) (any, http.Header, error)
PatchRaw performs a PATCH request with a raw string body and explicit Content-Type.
func (*Client) Post ¶
func (c *Client) Post(path string, queryParams map[string]string, body any) (any, http.Header, error)
Post performs a POST request with an optional JSON body.
func (*Client) PostRaw ¶
func (c *Client) PostRaw(path string, queryParams map[string]string, body, contentType string) (any, http.Header, error)
PostRaw performs a POST request with a raw string body and explicit Content-Type.
type Request ¶
type Request struct {
Method string
Path string
QueryParams map[string]string
// Body is always fully materialized: string → sent as-is with BodyContentType;
// any other type → JSON-marshaled, BodyContentType defaults to "application/json".
Body any
BodyContentType string
Headers map[string]string
// NoAccountID, when true, omits the accountIdentifier query param for this request.
NoAccountID bool
}
Request describes a single HTTP request to the Harness API.