class Jamf::MobileDevice
This class represents a Mobile Device stored in the JSS
.
Adding devices to the JSS
¶ ↑
When creating new MobileDevices in the JSS
with this class (using {Jamf::MobileDevice.make}) you must specify a udid, and serial_number
before calling ‘create` or `save`. You can provide these values with the `.make` call, or afterward using setters.
Management History & Logs¶ ↑
MobileDevice
Management History and logs can now be retrieved both from a MobileDevice
instance, and directly via class methods without fetching an instance. This is handled by the mixed-in {Jamf::ManagementHistory} module, Q.V. for details.
MDM
Commands¶ ↑
See the {Jamf::MDM} mixin module for Class and Instance methods for sending MDM
commands to mobiledevices.
To send MDM
commands without fetching mobiledevice instances, use the class methods, which can take multiple identifiers at once.
NOTE: If the {#name=} method is used to change the name of a supervized device, the DeviceName MDM
command will be sent to the device when the changes are sent to the server via {#save} or {#update}
Constants
- HW_PREFIX_IPAD
- HW_PREFIX_IPHONE
- HW_PREFIX_TV
- EXT_ATTRIB_CLASS
This is the class for relevant Extension Attributes
- MDM_COMMAND_TARGET
What kind of devices are we for
MDM
purposes?- NON_UNIQUE_NAMES
- OBJECT_HISTORY_OBJECT_TYPE
the object type for this object in the object history table. See {APIObject#add_object_history_entry}
- OTHER_LOOKUP_KEYS
these keys, as well as :id and :name, can be used to look up objects of this class in the
JSS
the wierd alises wifi_mac_addresse, mac_addresse and macaddresse are for proper pluralization of ‘mac_address’ and such- RSRC_BASE
The base for REST resources of this class
- RSRC_LIST_KEY
the hash key used for the JSON list output of all objects in the
JSS
- RSRC_OBJECT_KEY
The hash key used for the JSON object output. It’s also used in various error messages
- SEARCH_CLASS
An
AdvancedComputerSearch
in theJSS
@see
Jamf::AdvancedSearch
@see
Jamf::APIObject
- SITE_SUBSET
Where is the
Site
data in the API JSON?- UPLOAD_TYPES
file uploads can send attachments to the
JSS
using :mobiledevices as the sub-resource.
Attributes
@return [String] the airplay passwd on devices that can receive AirPlay (i.e. apple tvs)
@return [Array<Hash>] the applications on the device
@return [String]
@return [Intger] how much space available on the device?
@return [Intger] how much space available on the device?
@return [Integer] what percentage of the battery is remaining
@return [Integer] what percentage of the battery is remaining
@return [Boolean] is this device ble_capable
?
@return [String] the bluetooth mac addr
@return [Integer] total storage on the device
@return [Integer] total storage on the device
@return [Array<Hash>]
The certificates on the device
Each has has two keys:
-
:identity => Boolean
-
:common_name =>
String
, possibly a udid
@return [Array<Hash>]
One for each ConfigurationProfile
on the device
The Hash
keys are:
-
:identifier => a unique id, often the sams as the uuid
-
:display_name => its name in the
JSS
-
:uuid => the
ConfigurationProfile
uuid -
:version => a
String
@return [String] An Apple TV identifier
@return [String]
@return [String] the device_ownership_level
@return [String] the phone number of the device’s SIM card
@return [String]
@return [String]
@return [Time] uses the value from the API’s initial_entry_date_epoch
@return [String] the IP addr
@return [String] the languages
@return [Time] uses the value from the API’s last_backup_time_epoch
@return [Time] uses the value from the API’s last_backup_time_epoch
@return [Time] uses the value from the API’s last_backup_time_epoch
@return [Time] last_cloud_backup_date
@return [Time] the last time this device enrolled in Jamf
@return [Time] uses the value from the API’s last_inventory_update_utc
@return [String] the locales
@return [Boolean] is this device managed?
@return [Boolean] is this device managed?
@return [String] the display name of the model
@return [String] the display name of the model
@return [String] the model identifier
@return [String] the display name of the model
@return [String] the model firmware
@return [Hash]
A Hash
of network data
The Hash
keys are:
-
:voice_roaming_enabled=>“Disabled”,
-
:current_mobile_network_code=>“nnn”,
-
:imei=>“nn nnnnnn nnnnnn n”,
-
:home_mobile_country_code=>“nnn”,
-
:iccid=>“nnnn nnnn nnnn nnnn nnnn”,
-
:home_mobile_network_code=>“nnn”,
-
:current_carrier_network=>“”,
-
:data_roaming_enabled=>false,
-
:home_carrier_network=>“AT&T”,
-
:carrier_settings_version=>“16.0”,
-
:roaming=>false,
-
:cellular_technology=>“GSM”,
-
:current_mobile_country_code=>“nnn”
@return [String] the OS build
@return [String] the OS type
@return [String] the OS version
@return [Integer] how much of the capacity is in use?
@return [Array<Hash>]
One per provisioning profile
@return [String]
@return [String]
@return [String] the phone number of the device’s SIM card
@return [String]
@return [Boolean] is this device supervised?
@return [Boolean] is this device supervised?
@return [String] the tether state of the device
@return [String]
@return [String] the wifi mac addr
Public Class Methods
@return [Array<Hash>] the list of all managed mobile devices
# File lib/jamf/api/classic/api_objects/mobile_device.rb 160 def self.all_managed(refresh = false, api: nil, cnx: Jamf.cnx) 161 cnx = api if api 162 163 all(refresh, cnx: cnx).select { |d| d[:managed] } 164 end
@return [Array<Hash>] the list of all unmanaged mobile devices
# File lib/jamf/api/classic/api_objects/mobile_device.rb 167 def self.all_unmanaged(refresh = false, api: nil, cnx: Jamf.cnx) 168 cnx = api if api 169 170 all(refresh, cnx: cnx).reject { |d| d[:managed] } 171 end
@see APIObject#initialize
When creating new records with .make, udid:, serial_number
:, and asset_tag
: can be provided in the args.
Jamf::APIObject::new
# File lib/jamf/api/classic/api_objects/mobile_device.rb 438 def initialize(**args) 439 super 440 if @in_jss 441 442 gen = @init_data[:general] 443 444 # identifiers 445 @serial_number = gen[:serial_number] 446 @udid = gen[:udid] 447 @asset_tag = gen[:asset_tag] 448 @device_id = gen[:device_id] 449 @device_name = gen[:device_name] 450 @display_name = gen[:display_name] 451 @exchange_activesync_device_identifier = gen[:exchange_activesync_device_identifier] 452 453 # settings 454 @managed = gen[:managed] 455 @supervised = gen[:supervised] 456 @device_ownership_level = gen[:device_ownership_level] 457 @tethered = gen[:tethered] 458 @shared = gen[:shared] 459 @ble_capable = gen[:ble_capable] 460 461 @airplay_password = gen[:airplay_password] 462 @languages = gen[:languages] 463 @locales = gen[:locales] 464 465 # software 466 @os_type = gen[:os_type] 467 @os_build = gen[:os_build] 468 @os_version = gen[:os_version] 469 @modem_firmware = gen[:modem_firmware] 470 471 # hardware 472 @model = gen[:model] 473 @model_number = gen[:model_number] 474 @model_identifier = gen[:model_identifier] 475 @model_display = gen[:model_display] 476 477 # usage 478 @capacity_mb = gen[:capacity_mb] 479 @available_mb = gen[:available_mb] 480 @percentage_used = gen[:percentage_used] 481 @battery_level = gen[:battery_level] 482 483 # network 484 @bluetooth_mac_address = gen[:bluetooth_mac_address] 485 @wifi_mac_address = gen[:wifi_mac_address] 486 @sim_phone_number = gen[:phone_number] 487 @ip_address = gen[:ip_address] 488 489 # timestamps 490 @initial_entry_date = JSS.epoch_to_time gen[:initial_entry_date_epoch] 491 @last_backup_time = JSS.epoch_to_time gen[:last_backup_time_epoch] 492 @last_cloud_backup_date = JSS.epoch_to_time gen[:last_cloud_backup_date_epoch] 493 @last_inventory_update = JSS.epoch_to_time gen[:last_inventory_update_epoch] 494 @last_enrollment = JSS.epoch_to_time gen[:last_enrollment_epoch] 495 496 # subsets 497 @mobile_device_groups = @init_data[:mobile_device_groups] 498 @network = @init_data[:network] 499 @extension_attributes = @init_data[:extension_attributes] 500 @certificates = @init_data[:certificates] 501 @configuration_profiles = @init_data[:configuration_profiles] 502 @provisioning_profiles = @init_data[:provisioning_profiles] 503 @security = @init_data[:security] 504 @applications = @init_data[:applications] 505 else 506 @udid = args[:udid] 507 @serial_number = args[:serial_number] 508 @asset_tag = args[:asset_tag] 509 end 510 end
Private Class Methods
@return [Array<Hash>] the list of all iPads
# File lib/jamf/api/classic/api_objects/mobile_device.rb 202 def self.all_apple_tvs(refresh = false, api: nil, cnx: Jamf.cnx) 203 cnx = api if api 204 205 all(refresh, cnx: cnx).select { |d| d[:model_identifier].start_with? 'AppleTV' } 206 end
@return [Array<Hash>] the list of all iPads
# File lib/jamf/api/classic/api_objects/mobile_device.rb 195 def self.all_ipads(refresh = false, api: nil, cnx: Jamf.cnx) 196 cnx = api if api 197 198 all(refresh, cnx: cnx).select { |d| d[:model].start_with? 'iPad' } 199 end
@return [Array<Hash>] the list of all iPhones
# File lib/jamf/api/classic/api_objects/mobile_device.rb 188 def self.all_iphones(refresh = false, api: nil, cnx: Jamf.cnx) 189 cnx = api if api 190 191 all(refresh, cnx: cnx).select { |d| d[:model].start_with? 'iPhone' } 192 end
@return [Array<String>] all mobiledevice phone numbers
# File lib/jamf/api/classic/api_objects/mobile_device.rb 153 def self.all_phone_numbers(refresh = false, api: nil, cnx: Jamf.cnx) 154 cnx = api if api 155 156 all(refresh, cnx: cnx).map { |i| i[:phone_number] }.reject(&:empty?) 157 end
@return [Array<Hash>] the list of all supervised mobile devices
# File lib/jamf/api/classic/api_objects/mobile_device.rb 174 def self.all_supervised(refresh = false, api: nil, cnx: Jamf.cnx) 175 cnx = api if api 176 177 all(refresh, cnx: cnx).select { |d| d[:supervised] } 178 end
@return [Array<Hash>] the list of all unsupervised mobile devices
# File lib/jamf/api/classic/api_objects/mobile_device.rb 181 def self.all_unsupervised(refresh = false, api: nil, cnx: Jamf.cnx) 182 cnx = api if api 183 184 all(refresh, cnx: cnx).reject { |d| d[:supervised] } 185 end
Public Instance Methods
# File lib/jamf/api/classic/api_objects/mobile_device.rb 544 def asset_tag=(new_val) 545 new_val = new_val.strip 546 return nil if @asset_tag == new_val 547 548 @asset_tag = new_val 549 @need_to_update = true 550 end
# File lib/jamf/api/classic/api_objects/mobile_device.rb 530 def serial_number=(new_val) 531 return nil if new_val == @serial_number 532 533 @serial_number = new_val.empty? ? new_val : Jamf::Validate.doesnt_already_exist(self.class, :serial_number, new_val, cnx: cnx) 534 @need_to_update = true 535 end
# File lib/jamf/api/classic/api_objects/mobile_device.rb 537 def udid=(new_val) 538 return nil if new_val == @udid 539 540 @udid = new_val.empty? ? new_val : Jamf::Validate.doesnt_already_exist(self.class, :udid, new_val, cnx: cnx) 541 @need_to_update = true 542 end
@param no_mdm_rename should a MDM
‘set device name` command be sent
if the device is managed and supervised?
Jamf::APIObject#update
# File lib/jamf/api/classic/api_objects/mobile_device.rb 554 def update(no_mdm_rename: false) 555 super() 556 return @id if no_mdm_rename || !@needs_mdm_name_change 557 558 set_device_name @name if managed? && supervised? 559 @needs_mdm_name_change = false 560 @id 561 end
Private Instance Methods
# File lib/jamf/api/classic/api_objects/mobile_device.rb 517 def ipad? 518 model_identifier.start_with? HW_PREFIX_IPAD 519 end
# File lib/jamf/api/classic/api_objects/mobile_device.rb 521 def iphone? 522 model_identifier.start_with? HW_PREFIX_IPHONE 523 end
Jamf::Updatable#name=
# File lib/jamf/api/classic/api_objects/mobile_device.rb 525 def name=(new_name) 526 super 527 @needs_mdm_name_change = true if managed? && supervised? 528 end
private methods
# File lib/jamf/api/classic/api_objects/mobile_device.rb 568 def rest_xml 569 doc = REXML::Document.new Jamf::Connection::XML_HEADER 570 md = doc.add_element self.class::RSRC_OBJECT_KEY.to_s 571 general = md.add_element('general') 572 general.add_element('name').text = @name 573 general.add_element('udid').text = @udid 574 general.add_element('serial_number').text = @serial_number 575 general.add_element('asset_tag').text = @asset_tag 576 577 md << ext_attr_xml if unsaved_eas? 578 md << location_xml if has_location? 579 md << purchasing_xml if has_purchasing? 580 add_site_to_xml doc 581 doc.to_s 582 end
# File lib/jamf/api/classic/api_objects/mobile_device.rb 512 def tv? 513 model_identifier.start_with? HW_PREFIX_TV 514 end