Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMultipartFileUpload ¶ added in v1.13.0
func NewMultipartFileUpload(fieldName string, f *os.File) (body io.ReadSeeker, contentType string, contentLength int64, err error)
NewMultipartFileUpload builds a streaming multipart/form-data body wrapping a single file part and returns the body, Content-Type, and exact Content-Length.
The returned io.ReadSeeker streams directly from the underlying *os.File — no in-memory copy of the file. Seek(0, SeekStart) rewinds the body so Client.Upload can retry on HTTP 429.
The caller owns the file and must close it after Upload returns. filename in the multipart header is derived from filepath.Base(f.Name()).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the HTTP client for Jamf Pro API
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, method, path string, body io.Reader) (*http.Response, error)
Do executes an HTTP request with authentication and retry logic
func (*Client) Upload ¶
func (c *Client) Upload(ctx context.Context, path string, body io.Reader, contentType string, contentLength int64) (*http.Response, error)
Upload executes a streaming HTTP request with a caller-specified Content-Type and Content-Length. The body is never buffered, so multi-GB files stream straight through.
429 retry: when body implements io.Seeker (e.g. *os.File, *bytes.Reader, or the seekable multipart body from NewMultipartFileUpload), Upload retries up to 3 times on HTTP 429, honoring Retry-After. Non-seekable bodies surface 429 to the caller immediately — retrying would corrupt the upload.
type Option ¶
type Option func(*Client)
Option configures the client
func WithCookieJar ¶
WithCookieJar sets the cookie jar on the HTTP client. Sharing a jar with the auth provider enables sticky session affinity cookies (e.g. APBALANCEID on Jamf Cloud) to persist from the token exchange through all API calls.
func WithTenantID ¶
WithTenantID enables platform gateway mode, where API paths are rewritten to include the tenant identifier for routing through the Jamf Platform Gateway.