Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/jamf_school/models/device.ts>Device

A simple, secure, correct, and modern Jamf School API wrapper. (Unofficial)
Latest
interface Device
import { type Device } from "https://deno.land/x/jamf_school@0.5.0/models/device.ts";

Device represents a single device.

Properties

readonly
type: "Device"

Discriminator for type checks.

readonly
udid: string

The unique device identifier.

The UDID is calculated based on the device's hardware rather than being randomly assigned during manufacturing.

readonly
serialNumber: string

The device's serial number.

Serial numbers are less unique than the UDID, but are easier for humans to reason about and type.

readonly
name: string

The name of the device.

readonly
isManaged: boolean

The management status of the device.

Management is a Jamf concept. Unmanaged devices are devices that haven't check in with Jamf in 7 days.

readonly
isSupervised: boolean

The supervision status of the device.

Jamf has greater control over supervised devices, as they are completely managed by Jamf. Most features enabled by supervision are not accessible though the API.

readonly
deviceClass: string

The device class is the kind of device (eg. ipad)

readonly
assetTag: string

The device's asset tag.

readonly
os: string

Human-friendly name of the operating system (eg. "iOS 15.0.0")

readonly
osPrefix: string

The operating system prefix (eg. "iOS")

readonly
osVersion: string

The version of the operating system (eg. "15.0.0")

readonly
modelName: string

Human-friendly model name of the device.

readonly
modelIdentifier: string

The model identifier is a string that identifies the device model (eg. iPad11,6). This is an internal identifier used by Apple.

readonly
modelType: string

The name for the category of device (eg. iPad)

readonly
batteryPercentage: number

The remaining charge as a percentage (number between 0 and 1)

readonly
storageTotal: number

The device's maximum storage space, in gigabytes.

readonly
storageRemaining: number

The device's free storage space, in gigabytes.

readonly
locationId: number

The ID of this device's location.

readonly
ownerId: number

The ID of this device's owner.

readonly
ownerName: string

The name of this device's owner.

readonly
enrollment: { readonly type: "dep" | "ac2" | "manual"; readonly pending: boolean; }

The type of enrollment used for this device.

"dep" is short for "Device Enrollment Program", which is an older name for Automated Device Enrollment. Devices purchased from a reseller use this kind of enrollment.

"ac2" is "Apple Configurator 2", which is Apple's software used to enroll devices that were not purchased from a device reseller.

"manual" is used for devices that have been enrolled by manually, either using the "On-device enrollment" portal or by installing the management profile. Currently, if the type is "manual", pending is guaranteed to be false.

readonly
batteryCapacity: number

The total capacity of the battery in watt-hours (Wh).

Jamf does not report the battery volatage or milliamp-hours.

You can calculate the milliamp hours if you know the battery voltage. Most of Apple's mobile devices use ~3.8V batteries.

const mAh = device.batteryCapacity * 1000 / V

You can calculate the voltage if you know the milliamp-hours.

const V = device.batteryCapacity / mAh * 1000

NOTE: I know nothing about electricity. If this is wrong, let me know!

Methods

toJSON(): unknown

Return the data used to create this object.

toString(): string

The name of the device.

update(): Promise<void>

(Read) Update this device's data.

Other devices created from the same data will not be updated.

getRegion(): { readonly name: string; readonly latitude: number; readonly longitude: number; } | null

The device's region.

This is set by matching its public IP address. Regions can be created and edited in the Jamf School website: "Organisation" > "Settings" > "Regions"

getOwner(): Promise<User | null>

(Read) Get the device's owner, if any.

setOwner(user: { id: number; }): Promise<void>

(Edit) Assign a new owner to this device.

This method will not update the device object. To update the object, call Device.update().

The owner can be set by using a User object.

const [device, user] = await Promise.all([
  client.getDeviceByName("Test MacBook"),
  client.getUserByName("Test Account"),
])
if (user === null || device === null) {
  Deno.exit(1);
}
await device.setOwner(user);

If you already know the ID of the user you want to use, an object literal may be easier than getting the user object.

await device.setOwner({ id: 4 });

To remove the owner, try Device.removeOwner.

This method is a no-op if the user ID is the same as the device's owner ID.

removeOwner(): Promise<void>

(Edit) Remove this device's owner.

This method will not update the device object. To update the object, call Device.update().

This method is a no-op if the device already has no owner.

setNotes(text: string): Promise<void>

(Add) Set this device's notes.

This method will not update the object. To update it, call Device.update().

This method is a no-op if the notes are the same as the current notes.

setAssetTag(text: string): Promise<void>

(Add) Set this device's asset tag.

This method will not update the object. To update it, call Device.update().

This method is a no-op if the asset tag is the same as the current asset tag.

getGroups(): Promise<DeviceGroup[]>

(Read) Get the device's groups.

restart(): Promise<void>

(Add) Schedule a restart.

wipe(): Promise<void>

(Add) Schedule a complete wipe.

getApps(): Promise<App[]>

(Read) Get the apps that are assigned to this device.

getLocation(): Promise<Location | null>

(Read) Get the location this device belongs to.

setLocation(location: { id: number; }): Promise<void>

(Edit) Set this device's location. Moving a device will also move its owner and the other devices they own.

This method will not update the object. To update it, call Device.update().

This method is a no-op if the location ID is the same as the device's current location ID.