Documentation
¶
Overview ¶
Package jamfplatform provides a Go client for the Jamf Platform API.
Create a root client with NewClient, then construct service clients from the sub-packages under jamfplatform/ (devices, devicegroups, deviceactions, blueprints, ddmreport, compliancebenchmarks, pro, ...) to call typed methods.
c := jamfplatform.NewClient(
"https://your-tenant.apigw.jamf.com",
os.Getenv("JAMFPLATFORM_CLIENT_ID"),
os.Getenv("JAMFPLATFORM_CLIENT_SECRET"),
jamfplatform.WithTenantID(os.Getenv("JAMFPLATFORM_TENANT_ID")),
)
ds, err := devices.New(c).ListDevices(ctx, nil, "")
The root client handles OAuth2 authentication and token refresh automatically; each sub-package shares the same transport via its [New] constructor.
Error handling uses *APIResponseError for structured API errors:
d, err := devices.New(c).GetDevice(ctx, id)
if errors.As(err, &apiErr) && apiErr.HasStatus(404) {
// handle not found
}
Response headers ¶
Generated methods return the decoded body only. Response headers — including Location on 201 Created, Retry-After on 429 (which the transport already honors with a bounded single retry), and Deprecation on soon-to-be-removed endpoints (logged automatically) — are available to consumers via the WithLogger option. Install a Logger whose LogResponse receives http.Header if you need to inspect Location or any other per-request header.
Note that the body returned by create endpoints already carries an "href" field pointing at the new resource, equivalent to Location.
Index ¶
- Variables
- func PollUntil(ctx context.Context, interval time.Duration, ...) error
- type APIResponseError
- type AmbiguousMatchError
- type Client
- type ErrorDetail
- type Logger
- type Option
- func WithFileCookieJar(dir string) Option
- func WithFileTokenCache(dir string) Option
- func WithHTTPClient(httpClient *http.Client) Option
- func WithLogger(logger Logger) Option
- func WithRetryOn4xx(enabled bool) Option
- func WithTenantID(id string) Option
- func WithTokenCache(cache TokenCache) Option
- func WithUserAgent(userAgent string) Option
- type RSQLClause
- type TokenCache
Constants ¶
This section is empty.
Variables ¶
var BuildRSQLExpression = client.BuildRSQLExpression
var FormatArgument = client.FormatArgument
Functions ¶
Types ¶
type APIResponseError ¶
type APIResponseError = client.APIResponseError
APIResponseError is returned for any non-success HTTP status. Consumers should inspect it via AsAPIError plus the accessor methods (HasStatus/Details/FieldErrors/Summary) rather than string-matching the Error() output. Non-HTTP errors (denylist refusal, context cancellation, IO failures, etc.) surface as plain wrapped errors — format them with err.Error().
func AsAPIError ¶ added in v0.5.0
func AsAPIError(err error) *APIResponseError
AsAPIError unwraps err and returns the underlying *APIResponseError if present, otherwise nil. Shorthand for errors.As that saves callers from managing the target pointer and importing the concrete error type.
type AmbiguousMatchError ¶ added in v0.5.0
type AmbiguousMatchError = client.AmbiguousMatchError
AmbiguousMatchError is returned by Resolve<Resource>ByName methods when multiple resources share the requested name. Matches carries the IDs of all colliding resources so consumers can surface disambiguation options.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides typed methods for all Jamf Platform API operations.
func (*Client) AccessToken ¶
AccessToken returns a valid OAuth2 token from the client's credentials configuration.
type ErrorDetail ¶ added in v0.5.0
ErrorDetail is a single structured error entry parsed from an API response body. Consumers receive these via APIResponseError.Details() or APIResponseError.FieldErrors().
type Option ¶
type Option func(*clientConfig)
Option configures a Client.
func WithFileCookieJar ¶ added in v0.5.0
WithFileCookieJar enables file-based cookie jar persistence in the given directory. The cookie jar survives across process invocations so sticky-session cookies keep pointing a CLI-style caller at the same app node between runs.
func WithFileTokenCache ¶ added in v0.2.0
WithFileTokenCache enables file-based token caching in the given directory.
func WithHTTPClient ¶
WithHTTPClient overrides the default HTTP client.
func WithLogger ¶
WithLogger sets a logger for HTTP request/response logging.
func WithRetryOn4xx ¶ added in v0.6.0
WithRetryOn4xx opts the client into retrying unexpected 4xx responses (400–499, excluding 401 and 403) with exponential backoff. Intended for API families that exhibit eventual consistency — e.g. a device-group DELETE returning 400 HAS_DEPENDENCIES immediately after the referencing blueprint was deleted. Backoff starts at 2s, caps at 10s; context timeout is the only bound. Default is off.
func WithTenantID ¶ added in v0.2.0
WithTenantID configures the tenant ID used to build API URL paths. When set, all API paths include /tenant/{tenantID} in the URL. When not set, legacy internal paths are used.
func WithTokenCache ¶ added in v0.2.0
func WithTokenCache(cache TokenCache) Option
WithTokenCache sets a custom token cache for persisting tokens across process restarts.
func WithUserAgent ¶
WithUserAgent sets a custom user agent string.
type RSQLClause ¶
type RSQLClause = client.RSQLClause
Directories
¶
| Path | Synopsis |
|---|---|
|
Package blueprints provides typed access to Jamf Platform blueprints API endpoints.
|
Package blueprints provides typed access to Jamf Platform blueprints API endpoints. |
|
Package compliancebenchmarks provides typed access to Jamf Platform compliancebenchmarks API endpoints.
|
Package compliancebenchmarks provides typed access to Jamf Platform compliancebenchmarks API endpoints. |
|
Package ddmreport provides typed access to Jamf Platform ddmreport API endpoints.
|
Package ddmreport provides typed access to Jamf Platform ddmreport API endpoints. |
|
Package deviceactions provides typed access to Jamf Platform deviceactions API endpoints.
|
Package deviceactions provides typed access to Jamf Platform deviceactions API endpoints. |
|
Package devicegroups provides typed access to Jamf Platform devicegroups API endpoints.
|
Package devicegroups provides typed access to Jamf Platform devicegroups API endpoints. |
|
Package devices provides typed access to Jamf Platform devices API endpoints.
|
Package devices provides typed access to Jamf Platform devices API endpoints. |
|
Package pro provides typed access to Jamf Platform pro API endpoints.
|
Package pro provides typed access to Jamf Platform pro API endpoints. |
|
Package proclassic provides typed access to Jamf Platform proclassic API endpoints.
|
Package proclassic provides typed access to Jamf Platform proclassic API endpoints. |