Help us shape the future of Go! Take the 2026 Go Developer Survey

resolve

package
v1.35.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package resolve provides device identifier resolution for Jamf Pro. It translates serial numbers, device names, and numeric IDs into the full set of identifiers (ID, managementId, UDID) required by various API endpoints.

Index

Constants

This section is empty.

Variables

View Source
var ErrAmbiguousDevice = errors.New("identifier matches more than one device")

ErrAmbiguousDevice is what an identifier matching more than one device answers errors.Is with, so a batch can count it against the entry rather than abort.

View Source
var ErrNoDeviceMatch = errors.New("no matching device")

ErrNoDeviceMatch is what a NoDeviceMatchError answers errors.Is with, so a caller can tell "nothing is called that" from a failed lookup.

Functions

func EscapeRSQL

func EscapeRSQL(s string) string

EscapeRSQL escapes a value for use inside one double-quoted RSQL literal, so the value cannot close the quote. A `*` stays a wildcard, so a caller acting on the result compares the returned record's value itself.

func FormatDeviceDesc

func FormatDeviceDesc(d *DeviceIdentifiers) string

FormatDeviceDesc returns a human-readable device description for confirmation messages. Example: "Neil's MacBook" (serial: C02X1234, id: 42)

func IsNumericID added in v1.32.0

func IsNumericID(s string) bool

IsNumericID reports whether s contains only digits, so it can be a Jamf Pro ID rather than a serial number or a name.

func ResolveClassicComputerGroupID

func ResolveClassicComputerGroupID(ctx context.Context, client registry.HTTPClient, groupName string) (string, error)

ResolveClassicComputerGroupID resolves a computer group name to its Classic API numeric ID. Works for both smart and static computer groups.

func ResolveClassicMobileGroupID

func ResolveClassicMobileGroupID(ctx context.Context, client registry.HTTPClient, groupName string) (string, error)

ResolveClassicMobileGroupID resolves a mobile device group name to its Classic API numeric ID. Works for both smart and static mobile device groups.

func ResolveComputerGroupMemberIDs added in v1.33.0

func ResolveComputerGroupMemberIDs(ctx context.Context, client registry.HTTPClient, groupName string) ([]string, error)

ResolveComputerGroupMemberIDs returns the numeric IDs of a smart or static computer group's members, for a caller that resolves them itself.

func ResolveMobileDeviceGroupMemberIDs added in v1.33.0

func ResolveMobileDeviceGroupMemberIDs(ctx context.Context, client registry.HTTPClient, groupName string) ([]string, error)

ResolveMobileDeviceGroupMemberIDs is ResolveComputerGroupMemberIDs for mobile device groups.

Types

type AmbiguousEntryError added in v1.33.0

type AmbiguousEntryError struct {
	Label string
	Value string
	IDs   []string
}

AmbiguousEntryError reports an identifier that matched more than one device.

func (*AmbiguousEntryError) Error added in v1.33.0

func (e *AmbiguousEntryError) Error() string

func (*AmbiguousEntryError) Is added in v1.33.0

func (e *AmbiguousEntryError) Is(target error) bool

Is makes errors.Is(err, ErrAmbiguousDevice) hold.

type ClassicGroup added in v1.32.0

type ClassicGroup struct {
	ID   string
	Name string
}

ClassicGroup is a resolved Classic group: its id and its name as stored.

func ResolveClassicComputerGroup added in v1.32.0

func ResolveClassicComputerGroup(ctx context.Context, client registry.HTTPClient, groupName string) (ClassicGroup, error)

ResolveClassicComputerGroup resolves a computer group name to exactly one Classic group. Works for both smart and static computer groups.

func ResolveClassicMobileGroup added in v1.32.0

func ResolveClassicMobileGroup(ctx context.Context, client registry.HTTPClient, groupName string) (ClassicGroup, error)

ResolveClassicMobileGroup resolves a mobile device group name to exactly one Classic group. Works for both smart and static mobile device groups.

type DeviceIdentifiers

type DeviceIdentifiers struct {
	ID           string // numeric ID (string form, e.g. "42")
	ManagementID string // UUID for blank-push, ddm-sync
	UDID         string // device UDID for renew-mdm
	Name         string // display name for confirmation messages
	SerialNumber string // serial number for confirmation messages
	// Managed is whether Jamf Pro manages the device, or nil when the record
	// read did not say. A static group refuses an unmanaged member.
	Managed *bool
}

DeviceIdentifiers holds all ID forms needed by different action endpoints.

func ResolveComputer

func ResolveComputer(ctx context.Context, client registry.HTTPClient, serial, name, id string) (*DeviceIdentifiers, error)

ResolveComputer looks up a computer by serial, name, or ID using the v4 computers-inventory API and returns all identifier forms. Exactly one of serial, name, or id must be non-empty.

func ResolveComputerByManagementID added in v1.22.0

func ResolveComputerByManagementID(ctx context.Context, client registry.HTTPClient, managementID string) (*DeviceIdentifiers, error)

ResolveComputerByManagementID looks up a computer by its MDM management ID (UUID).

func ResolveComputerByUDID added in v1.22.0

func ResolveComputerByUDID(ctx context.Context, client registry.HTTPClient, udid string) (*DeviceIdentifiers, error)

ResolveComputerByUDID looks up a computer by its UDID.

func ResolveComputerEntries added in v1.33.0

func ResolveComputerEntries(ctx context.Context, client registry.HTTPClient, entries []string) ([]*DeviceIdentifiers, int, error)

ResolveComputerEntries resolves identifiers already in hand — repeated flag values, say — with the same batching and failure policy as ResolveComputersFromFile.

func ResolveComputerGroup

func ResolveComputerGroup(ctx context.Context, client registry.HTTPClient, groupName string) ([]*DeviceIdentifiers, error)

ResolveComputerGroup resolves all members of a computer group by name. Uses the Classic API to list group members, then batch-resolves each via the v3 inventory API to get managementId/UDID.

func ResolveComputerIdentifier added in v1.32.0

func ResolveComputerIdentifier(ctx context.Context, client registry.HTTPClient, value string) (*DeviceIdentifiers, error)

ResolveComputerIdentifier resolves a value that may be a computer's Jamf Pro ID, name, UDID or serial number to one computer, in a single request.

See resolveIdentifier for how a value matching more than one record is handled.

func ResolveComputersFromFile

func ResolveComputersFromFile(ctx context.Context, client registry.HTTPClient, path string) ([]*DeviceIdentifiers, int, error)

ResolveComputersFromFile reads computer identifiers from a file (one per line) and resolves them to full identifiers. Blank lines and #-comments are skipped. An entry may be a numeric ID, a serial number, a UDID, a management ID or a name — see resolveEntries for how each is told apart.

Returns the resolved devices and the number of entries that could not be resolved. Each unresolvable entry warns to stderr and is skipped — matching the per-member soft-fail of the --group path (batchResolveComputers) so one bad line doesn't abort the whole batch — and the count is returned so callers can fold it into their success/failure tally and exit code. If no entry at all resolves, an error is returned rather than an empty list: a wholly stale file must not read as a successful no-op batch.

Entries are looked up in chunked RSQL `=in=` queries, so an N-line file costs O(N/batchChunkSize) requests rather than one per line.

func ResolveMobileDevice

func ResolveMobileDevice(ctx context.Context, client registry.HTTPClient, serial, name, id string) (*DeviceIdentifiers, error)

ResolveMobileDevice looks up a mobile device by serial, name, or ID using the v2 mobile-devices API and returns all identifier forms.

func ResolveMobileDeviceEntries added in v1.33.0

func ResolveMobileDeviceEntries(ctx context.Context, client registry.HTTPClient, entries []string) ([]*DeviceIdentifiers, int, error)

ResolveMobileDeviceEntries is ResolveComputerEntries for mobile devices.

func ResolveMobileDeviceGroup

func ResolveMobileDeviceGroup(ctx context.Context, client registry.HTTPClient, groupName string) ([]*DeviceIdentifiers, error)

ResolveMobileDeviceGroup resolves all members of a mobile device group by name.

func ResolveMobileDeviceIdentifier added in v1.32.0

func ResolveMobileDeviceIdentifier(ctx context.Context, client registry.HTTPClient, value string) (*DeviceIdentifiers, error)

ResolveMobileDeviceIdentifier is ResolveComputerIdentifier for mobile devices.

func ResolveMobileDevicesFromFile

func ResolveMobileDevicesFromFile(ctx context.Context, client registry.HTTPClient, path string) ([]*DeviceIdentifiers, int, error)

ResolveMobileDevicesFromFile reads mobile device identifiers from a file and resolves them. Same contract as ResolveComputersFromFile — see there for the failure policy.

type NoDeviceMatchError added in v1.32.0

type NoDeviceMatchError struct {
	Label string // "computer" / "mobile device"
	Value string
}

NoDeviceMatchError reports a value that names no device.

func (*NoDeviceMatchError) Error added in v1.32.0

func (e *NoDeviceMatchError) Error() string

func (*NoDeviceMatchError) Is added in v1.32.0

func (e *NoDeviceMatchError) Is(target error) bool

Is makes errors.Is(err, ErrNoDeviceMatch) hold.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL