Documentation
¶
Overview ¶
Package devices provides typed access to Jamf Platform devices API endpoints.
Index ¶
- Variables
- func PrivilegesFor(method string) (jamfplatform.MethodPrivileges, bool)
- type ApiErrorRepresentation
- type ApiErrorRepresentationErrorsItem
- type Client
- func (c *Client) DeleteDevice(ctx context.Context, id string) error
- func (c *Client) GetDevice(ctx context.Context, id string) (*DeviceReadRepresentationV1, error)
- func (c *Client) ListDeviceApplications(ctx context.Context, id string, sort []string, filter string) ([]DeviceInstalledApplicationReadRepresentationV1, error)
- func (c *Client) ListDevices(ctx context.Context, sort []string, filter string) ([]DeviceListReadRepresentationV1, error)
- func (c *Client) ListDevicesForUser(ctx context.Context, userID string, sort []string, filter string) ([]DeviceListReadRepresentationV1, error)
- func (c *Client) ResolveDeviceByName(ctx context.Context, name string) (*DeviceListReadRepresentationV1, error)
- func (c *Client) ResolveDeviceBySerialNumber(ctx context.Context, name string) (*DeviceListReadRepresentationV1, error)
- func (c *Client) ResolveDeviceIDByName(ctx context.Context, name string) (string, error)
- func (c *Client) ResolveDeviceIDBySerialNumber(ctx context.Context, name string) (string, error)
- func (c *Client) UpdateDevice(ctx context.Context, id string, request *DeviceUpdateRepresentationV1) error
- type DeviceHardwareReadRepresentationV1
- type DeviceHardwareReadRepresentationV1BatteryHealth
- type DeviceInstalledApplicationReadRepresentationV1
- type DeviceListReadRepresentationV1
- type DeviceNetworkReadRepresentationV1
- type DeviceOperatingSystemReadRepresentationV1
- type DeviceReadRepresentationV1
- type DeviceSecurityReadRepresentationV1
- type DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus
- type DeviceUpdateRepresentationV1
- type PaginatedDeviceInstalledApplicationReadRepresentationV1
- type PaginatedDeviceResponseRepresentation
- type PaginatedResponseRepresentation
Constants ¶
This section is empty.
Variables ¶
var Privileges = map[string]jamfplatform.MethodPrivileges{ "DeleteDevice": {Method: "DeleteDevice", HTTPMethod: "DELETE", Path: "/v1/devices/{id}", Scopes: []jamfplatform.ScopeKind{jamfplatform.ScopeEnvironment}, ScopesSource: "spec", Scoped: []string{"destructive-device-actions:execute"}, Legacy: nil, Source: "spec"}, "GetDevice": {Method: "GetDevice", HTTPMethod: "GET", Path: "/v1/devices/{id}", Scopes: []jamfplatform.ScopeKind{jamfplatform.ScopeEnvironment}, ScopesSource: "spec", Scoped: []string{"devices:read"}, Legacy: nil, Source: "spec"}, "ListDeviceApplications": {Method: "ListDeviceApplications", HTTPMethod: "GET", Path: "/v1/devices/{id}/applications", Scopes: []jamfplatform.ScopeKind{jamfplatform.ScopeEnvironment}, ScopesSource: "spec", Scoped: []string{"devices:read"}, Legacy: nil, Source: "spec"}, "ListDevices": {Method: "ListDevices", HTTPMethod: "GET", Path: "/v1/devices", Scopes: []jamfplatform.ScopeKind{jamfplatform.ScopeEnvironment}, ScopesSource: "spec", Scoped: []string{"devices:read"}, Legacy: nil, Source: "spec"}, "ListDevicesForUser": {Method: "ListDevicesForUser", HTTPMethod: "GET", Path: "/v1/users/{id}/devices", Scopes: []jamfplatform.ScopeKind{jamfplatform.ScopeEnvironment}, ScopesSource: "spec", Scoped: []string{"devices:read"}, Legacy: nil, Source: "spec"}, "UpdateDevice": {Method: "UpdateDevice", HTTPMethod: "PATCH", Path: "/v1/devices/{id}", Scopes: []jamfplatform.ScopeKind{jamfplatform.ScopeEnvironment}, ScopesSource: "spec", Scoped: []string{"devices:update"}, Legacy: nil, Source: "spec"}, }
Privileges maps each devices SDK method name to the Jamf API privileges it requires, sourced from the x-required-privileges vendor extensions in the Jamf OpenAPI specs. Identifiers are GA capability permissions in {capability}:{action} form and a multi-entry Scoped slice means all of them are required.
Source names where each entry's Scoped set came from: "spec" for the operation's own x-required-privileges, "gateway-policy" for one the published spec omits and this SDK supplies from the gateway's authorization policy, and "" when Scoped is empty. An empty Scoped slice means nothing declares a privilege for the endpoint, which is NOT the same as none being required — see jamfplatform.MethodPrivileges. Do not render it as "no permission needed".
Scopes lists the scope kinds each endpoint accepts. It is an alternatives set: a client carries one scope, so a consumer needs a credential matching one of the listed kinds. ScopesSource names where the set came from — "spec" for the spec root's own x-scope-types, "config-override" for one this SDK supplies because the published spec understates what the gateway serves or declares no extension at all. A spec-sourced set is what the spec declares, which for the Platform APIs is currently stricter than the gateway — see jamfplatform.MethodPrivileges.
Synthetic Resolve<X>ByName / Apply<X> methods are not present; document the privileges of the operations they call instead.
Functions ¶
func PrivilegesFor ¶
func PrivilegesFor(method string) (jamfplatform.MethodPrivileges, bool)
PrivilegesFor returns the privilege metadata for the named SDK method and true when the method is present in the registry, or the zero value and false otherwise.
Types ¶
type ApiErrorRepresentation ¶
type ApiErrorRepresentation struct {
Errors []ApiErrorRepresentationErrorsItem `json:"errors"`
// HTTP status of the response.
HttpStatus int `json:"httpStatus"`
TraceID string `json:"traceId"`
}
ApiErrorRepresentation represents a api error representation.
type ApiErrorRepresentationErrorsItem ¶
type ApiErrorRepresentationErrorsItem struct {
// Error-specific code that can be used to identify localization string, etc.
Code string `json:"code"`
// A general description of error for troubleshooting/debugging. Generally this text should not be
// displayed to a user; instead refer to errorCode and its localized text.
Description string `json:"description"`
// Name of the field that caused the error.
Field string `json:"field"`
// id of object with error. Optional.
ID string `json:"id"`
}
ApiErrorRepresentationErrorsItem represents a api error representation errors item.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides typed methods for devices operations.
func New ¶
func New(base *jamfplatform.Client) *Client
New creates a devices client that shares the authenticated transport of the given root client.
func (*Client) DeleteDevice ¶
DeleteDevice delete a device.
Required privileges: destructive-device-actions:execute.
Parameters:
- id: The ID of the device, in UUID format.
func (*Client) GetDevice ¶
GetDevice get a device by ID.
Required privileges: devices:read.
Parameters:
- id: The ID of the device, in UUID format.
func (*Client) ListDeviceApplications ¶
func (c *Client) ListDeviceApplications(ctx context.Context, id string, sort []string, filter string) ([]DeviceInstalledApplicationReadRepresentationV1, error)
ListDeviceApplications get installed applications for a device.
Required privileges: devices:read.
Parameters:
- id: The ID of the device, in UUID format.
- sort: Fields to sort by and their orders. Fields allowed in the query: `name`, `version`.
- filter: Filter query in RSQL format. Includes all results, by default. Fields allowed in the query: `name`, `version`. Example: `name=="*Safari*" and version>="26.0.0"`.
func (*Client) ListDevices ¶
func (c *Client) ListDevices(ctx context.Context, sort []string, filter string) ([]DeviceListReadRepresentationV1, error)
ListDevices get all devices.
Required privileges: devices:read.
Parameters:
- sort: Fields to sort by and their orders. Fields allowed in the query: `id`, `name`, `model`, `modelIdentifier`, `serialNumber`, `lastInventoryUpdateTime`, `lastCheckInTime`, `operatingSystemVersion`, `userId`, `enrollmentType`, `lastEnrollmentTime`.
- filter: Filter query in RSQL format. Includes all results, by default. Fields allowed in the query: `id`, `name`, `model`, `modelIdentifier`, `serialNumber`, `lastInventoryUpdateTime`, `lastCheckInTime`, `operatingSystemVersion`, `enrollmentType`, `lastEnrollmentTime`. Dates are specified in ISO 8601 format. Example: `name=="*iPhone*" and lastInventoryUpdateTime>="2025-01-31T18:09:00.000Z"`.
func (*Client) ListDevicesForUser ¶
func (c *Client) ListDevicesForUser(ctx context.Context, userID string, sort []string, filter string) ([]DeviceListReadRepresentationV1, error)
ListDevicesForUser get devices for a user.
Required privileges: devices:read.
Parameters:
- userID: The ID of the user, in UUID format.
- sort: Fields to sort by and their orders. Fields allowed in the query: `id`, `name`, `model`, `modelIdentifier`, `serialNumber`, `lastInventoryUpdateTime`, `lastCheckInTime`, `operatingSystemVersion`, `userId`, `enrollmentType`, `lastEnrollmentTime`.
- filter: Filter query in RSQL format. Includes all results, by default. Fields allowed in the query: `id`, `name`, `model`, `modelIdentifier`, `serialNumber`, `lastInventoryUpdateTime`, `lastCheckInTime`, `operatingSystemVersion`, `enrollmentType`, `lastEnrollmentTime`. Dates are specified in ISO 8601 format. Example: `name=="*iPhone*" and lastInventoryUpdateTime>="2025-01-31T18:09:00.000Z"`.
func (*Client) ResolveDeviceByName ¶
func (c *Client) ResolveDeviceByName(ctx context.Context, name string) (*DeviceListReadRepresentationV1, error)
ResolveDeviceByName looks up a Device by its name field and returns the decoded resource. Shares the same HTTP call as the ID-only variant; error semantics are identical.
func (*Client) ResolveDeviceBySerialNumber ¶
func (c *Client) ResolveDeviceBySerialNumber(ctx context.Context, name string) (*DeviceListReadRepresentationV1, error)
ResolveDeviceBySerialNumber looks up a Device by its serialNumber field and returns the decoded resource. Shares the same HTTP call as the ID-only variant; error semantics are identical.
func (*Client) ResolveDeviceIDByName ¶
ResolveDeviceIDByName looks up a Device by its name field and returns the ID. Returns *APIResponseError with HasStatus(404) when no match exists, or *AmbiguousMatchError when multiple resources share the name.
func (*Client) ResolveDeviceIDBySerialNumber ¶
ResolveDeviceIDBySerialNumber looks up a Device by its serialNumber field and returns the ID. Returns *APIResponseError with HasStatus(404) when no match exists, or *AmbiguousMatchError when multiple resources share the name.
func (*Client) UpdateDevice ¶
func (c *Client) UpdateDevice(ctx context.Context, id string, request *DeviceUpdateRepresentationV1) error
UpdateDevice update a device.
Required privileges: devices:update.
Parameters:
- id: The ID of the device, in UUID format.
type DeviceHardwareReadRepresentationV1 ¶
type DeviceHardwareReadRepresentationV1 struct {
// Battery health status of the device.
// Allowed values: see the DeviceHardwareReadRepresentationV1BatteryHealth constants.
BatteryHealth string `json:"batteryHealth"`
// MAC address of the device.
MacAddress string `json:"macAddress"`
// Make of the device.
Make string `json:"make"`
// Model of the device.
Model string `json:"model"`
// Unique identifier of the device model.
ModelIdentifier string `json:"modelIdentifier"`
// Serial number of the device.
SerialNumber string `json:"serialNumber"`
// Total storage capacity of the device, in megabytes.
StorageCapacity int `json:"storageCapacity"`
// Used storage space on the device, in megabytes.
StorageUsed int `json:"storageUsed"`
// Unique device identifier (UDID) of the device.
UDID string `json:"udid"`
}
DeviceHardwareReadRepresentationV1 represents a device hardware read representation v1.
type DeviceHardwareReadRepresentationV1BatteryHealth ¶
type DeviceHardwareReadRepresentationV1BatteryHealth = string
DeviceHardwareReadRepresentationV1BatteryHealth is the set of values accepted by DeviceHardwareReadRepresentationV1.BatteryHealth.
const ( DeviceHardwareReadRepresentationV1BatteryHealthNonGenuine DeviceHardwareReadRepresentationV1BatteryHealth = "NON_GENUINE" DeviceHardwareReadRepresentationV1BatteryHealthNormal DeviceHardwareReadRepresentationV1BatteryHealth = "NORMAL" DeviceHardwareReadRepresentationV1BatteryHealthServiceRecommended DeviceHardwareReadRepresentationV1BatteryHealth = "SERVICE_RECOMMENDED" DeviceHardwareReadRepresentationV1BatteryHealthUnknown DeviceHardwareReadRepresentationV1BatteryHealth = "UNKNOWN" DeviceHardwareReadRepresentationV1BatteryHealthUnsupported DeviceHardwareReadRepresentationV1BatteryHealth = "UNSUPPORTED" )
DeviceHardwareReadRepresentationV1BatteryHealth values accepted by the Jamf API. The alias above is a string, so these constants pass to any parameter or field declared as a plain string.
func DeviceHardwareReadRepresentationV1BatteryHealthValues ¶
func DeviceHardwareReadRepresentationV1BatteryHealthValues() []DeviceHardwareReadRepresentationV1BatteryHealth
DeviceHardwareReadRepresentationV1BatteryHealthValues returns every value the Jamf API accepts for DeviceHardwareReadRepresentationV1BatteryHealth, in the order the spec declares them. Returns a fresh slice per call, so no caller can corrupt the set for the rest of the process — which a package level var would allow. Suits attribute validation (Terraform's stringvalidator.OneOf, say) and anything that needs to enumerate the set rather than name one member.
type DeviceInstalledApplicationReadRepresentationV1 ¶
type DeviceInstalledApplicationReadRepresentationV1 struct {
// The name of the installed application.
Name string `json:"name"`
// The version of the installed application.
Version string `json:"version"`
}
DeviceInstalledApplicationReadRepresentationV1 represents a device installed application read representation v1.
type DeviceListReadRepresentationV1 ¶
type DeviceListReadRepresentationV1 struct {
// The type of enrollment of a device.
EnrollmentType string `json:"enrollmentType"`
// The ID of the device, in UUID format.
ID string `json:"id"`
// The last time the device checked in, in ISO 8601 format, or `null` if the device is not a computer.
LastCheckInTime *time.Time `json:"lastCheckInTime,omitempty"`
// The last time the device was enrolled, in ISO 8601 format.
LastEnrollmentTime *time.Time `json:"lastEnrollmentTime,omitempty"`
// The last time the device inventory was updated, in ISO 8601 format.
LastInventoryUpdateTime *time.Time `json:"lastInventoryUpdateTime,omitempty"`
// Model of the device.
Model string `json:"model"`
// Unique identifier of the device model.
ModelIdentifier string `json:"modelIdentifier"`
// Name of the device.
Name string `json:"name"`
// The operating system version of the device.
OperatingSystemVersion string `json:"operatingSystemVersion"`
// Serial number of the device.
SerialNumber string `json:"serialNumber"`
// The ID of the user associated with the device, in UUID format, if assigned; otherwise, null.
UserID *string `json:"userId,omitempty"`
}
DeviceListReadRepresentationV1 represents a device list read representation v1.
type DeviceNetworkReadRepresentationV1 ¶
type DeviceNetworkReadRepresentationV1 struct {
// The last observed IP address of the device, in either IPv4 or IPv6 format.
LastIPAddress *string `json:"lastIpAddress,omitempty"`
// The last reported IPv4 address of the device, or null if not available or applicable.
LastReportedIPV4Address *string `json:"lastReportedIpV4Address,omitempty"`
// The last reported IPv6 address of the device, or null if not available or applicable.
LastReportedIPV6Address *string `json:"lastReportedIpV6Address,omitempty"`
}
DeviceNetworkReadRepresentationV1 represents a device network read representation v1.
type DeviceOperatingSystemReadRepresentationV1 ¶
type DeviceOperatingSystemReadRepresentationV1 struct {
// Build number of the operating system.
Build string `json:"build"`
// Name of the operating system.
Name string `json:"name"`
// Rapid security response version of the operating system, if applicable.
RapidSecurityResponse *string `json:"rapidSecurityResponse,omitempty"`
// Supplemental build version of the operating system, if applicable.
SupplementalBuildVersion *string `json:"supplementalBuildVersion,omitempty"`
// Version of the operating system.
Version string `json:"version"`
}
DeviceOperatingSystemReadRepresentationV1 represents a device operating system read representation v1.
type DeviceReadRepresentationV1 ¶
type DeviceReadRepresentationV1 struct {
// The type of enrollment of a device.
EnrollmentType string `json:"enrollmentType"`
Hardware *DeviceHardwareReadRepresentationV1 `json:"hardware,omitempty"`
// The ID of the device, in UUID format.
ID string `json:"id"`
// The last time the device checked in, in ISO 8601 format, or `null` if the device is not a computer.
LastCheckInTime *time.Time `json:"lastCheckInTime,omitempty"`
// The last time the device was enrolled, in ISO 8601 format.
LastEnrollmentTime *time.Time `json:"lastEnrollmentTime,omitempty"`
// The last time the device inventory was updated, in ISO 8601 format.
LastInventoryUpdateTime *time.Time `json:"lastInventoryUpdateTime,omitempty"`
// Whether the device is managed.
Managed bool `json:"managed"`
// Whether the device is capable of communicating via MDM.
// Note: This field will be `false` for Jamf Pro versions prior to 11.27.0, regardless of the MDM
// capability of the device.
MDMCapable bool `json:"mdmCapable"`
// Name of the device.
Name string `json:"name"`
Network *DeviceNetworkReadRepresentationV1 `json:"network,omitempty"`
OperatingSystem *DeviceOperatingSystemReadRepresentationV1 `json:"operatingSystem,omitempty"`
Security *DeviceSecurityReadRepresentationV1 `json:"security,omitempty"`
// Whether the device is supervised.
Supervised bool `json:"supervised"`
// The ID of the user associated with the device, in UUID format, if assigned; otherwise, null.
UserID *string `json:"userId,omitempty"`
}
DeviceReadRepresentationV1 represents a device read representation v1.
type DeviceSecurityReadRepresentationV1 ¶
type DeviceSecurityReadRepresentationV1 struct {
// The status of the bootstrap token for the device.
// Allowed values: see the DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus constants.
BootstrapTokenEscrowedStatus string `json:"bootstrapTokenEscrowedStatus"`
// Whether hardware encryption is enabled on the device, or null if the device is a computer.
HardwareEncryption *bool `json:"hardwareEncryption,omitempty"`
// Whether Lost Mode is enabled on the device, or null if the device is a computer.
LostModeEnabled *bool `json:"lostModeEnabled,omitempty"`
// Whether the passcode on the device is compliant with the passcode policy, or null if the device is a
// computer.
PasscodeCompliant *bool `json:"passcodeCompliant,omitempty"`
// Whether a passcode is present on the device, or null if the device is a computer.
PasscodePresent *bool `json:"passcodePresent,omitempty"`
}
DeviceSecurityReadRepresentationV1 represents a device security read representation v1.
type DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus ¶
type DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus = string
DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus is the set of values accepted by DeviceSecurityReadRepresentationV1.BootstrapTokenEscrowedStatus.
const ( DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatusNotSupported DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus = "NOT_SUPPORTED" DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatusEscrowed DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus = "ESCROWED" DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatusNotEscrowed DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus = "NOT_ESCROWED" )
DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus values accepted by the Jamf API. The alias above is a string, so these constants pass to any parameter or field declared as a plain string.
func DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatusValues ¶
func DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatusValues() []DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus
DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatusValues returns every value the Jamf API accepts for DeviceSecurityReadRepresentationV1BootstrapTokenEscrowedStatus, in the order the spec declares them. Returns a fresh slice per call, so no caller can corrupt the set for the rest of the process — which a package level var would allow. Suits attribute validation (Terraform's stringvalidator.OneOf, say) and anything that needs to enumerate the set rather than name one member.
type DeviceUpdateRepresentationV1 ¶
type DeviceUpdateRepresentationV1 struct {
// Name of the device. If provided, must not be empty.
Name *string `json:"name,omitempty"`
// The ID of the user to associate with the device, in UUID format. Set to null to unassign the device
// from any user. Defaults to empty string (no change to current assignment).
UserID *string `json:"userId,omitempty"`
}
DeviceUpdateRepresentationV1 represents a device update representation v1.
type PaginatedDeviceInstalledApplicationReadRepresentationV1 ¶
type PaginatedDeviceInstalledApplicationReadRepresentationV1 struct {
// Whether there is a next page.
HasNext bool `json:"hasNext"`
// Whether there is a previous page.
HasPrevious bool `json:"hasPrevious"`
// Current page number (0-based).
Page int `json:"page"`
// Number of items per page.
PageSize int `json:"pageSize"`
// List of installed applications for the specified device and page.
Results []DeviceInstalledApplicationReadRepresentationV1 `json:"results"`
// Total number of results across all pages.
TotalCount int `json:"totalCount"`
// Total number of pages.
TotalPages int `json:"totalPages"`
}
PaginatedDeviceInstalledApplicationReadRepresentationV1 represents a paginated device installed application read representation v1.
type PaginatedDeviceResponseRepresentation ¶
type PaginatedDeviceResponseRepresentation struct {
// Whether there is a next page.
HasNext bool `json:"hasNext"`
// Whether there is a previous page.
HasPrevious bool `json:"hasPrevious"`
// Current page number (0-based).
Page int `json:"page"`
// Number of items per page.
PageSize int `json:"pageSize"`
// List of devices for the specified page.
Results []DeviceListReadRepresentationV1 `json:"results"`
// Total number of results across all pages.
TotalCount int `json:"totalCount"`
// Total number of pages.
TotalPages int `json:"totalPages"`
}
PaginatedDeviceResponseRepresentation represents a paginated device response representation.
type PaginatedResponseRepresentation ¶
type PaginatedResponseRepresentation struct {
// Whether there is a next page.
HasNext bool `json:"hasNext"`
// Whether there is a previous page.
HasPrevious bool `json:"hasPrevious"`
// Current page number (0-based).
Page int `json:"page"`
// Number of items per page.
PageSize int `json:"pageSize"`
// Total number of results across all pages.
TotalCount int `json:"totalCount"`
// Total number of pages.
TotalPages int `json:"totalPages"`
}
PaginatedResponseRepresentation represents a paginated response representation.