class Jamf::MobileDeviceExtensionAttribute
An extension attribute as defined in the JSS
@see Jamf::APIObject
Constants
- ALL_TARGETS_CRITERION
A criterion that will return all members of the
TARGET_CLASS
- OBJECT_HISTORY_OBJECT_TYPE
the object type for this object in the object history table. See {APIObject#add_object_history_entry}
- 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
- TARGET_CLASS
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 aMobileDevice
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}
Public Instance Methods
Return an Array
of Hashes showing the history of reported values for this EA on one MobileDevice
.
Each hash contains these 2 keys:
This method requires a MySQL database connection established via Jamf::DB_CNX.connect
@see Jamf::DBConnection
@param mobiledevice the id or name of the MobileDevice
.
@return [Array<Hash{:timestamp=>Time,:value=>String,Integer,Time}>]
# File lib/jamf/api/classic/api_objects/mobile_device_extension_attribute.rb 94 def history(mobiledevice) 95 raise Jamf::NoSuchItemError, "EA Not In JSS! Use #create to create this #{RSRC_OBJECT_KEY}." unless @in_jss 96 raise Jamf::InvalidConnectionError, "Database connection required for 'history' query." unless Jamf::DB_CNX.connected? 97 98 mobile_device_id = Jamf::MobileDevice.valid_id mobiledevice, cnx: @cnx 99 raise Jamf::NoSuchItemError, "No MobileDevice found matching '#{mobiledevice}'" unless mobile_device_id 100 101 the_query = <<-END_Q 102 SELECT eav.value_on_client AS value, r.date_entered_epoch AS timestamp_epoch 103 FROM mobile_device_extension_attribute_values eav JOIN reports r ON eav.report_id = r.report_id 104 WHERE r.mobile_device_id = #{mobile_device_id} 105 AND eav.mobile_device_extension_attribute_id = #{@id} 106 ORDER BY timestamp_epoch 107 END_Q 108 109 qrez = Jamf::DB_CNX.db.query the_query 110 history = [] 111 qrez.each_hash do |entry| 112 value = 113 case @data_type 114 when 'String' then entry['value'] 115 when 'Integer' then entry['value'].to_i 116 when 'Date' then Jamf.parse_time(entry['value']) 117 end # case 118 newhash = { value: value, timestamp: JSS.epoch_to_time(entry['timestamp_epoch']) } 119 history << newhash 120 end # each hash 121 122 history 123 end
@see Jamf::ExtensionAttribute#input_type=
Jamf::ExtensionAttribute#input_type=
# File lib/jamf/api/classic/api_objects/mobile_device_extension_attribute.rb 74 def input_type=(new_val) 75 raise Jamf::InvalidDataError, "Mobile Device Extension Attribute input_type cannot be '#{INPUT_TYPE_SCRIPT}'" if new_val == INPUT_TYPE_SCRIPT 76 77 super 78 end
@see Jamf::ExtensionAttribute#web_display=
Jamf::ExtensionAttribute#web_display=
# File lib/jamf/api/classic/api_objects/mobile_device_extension_attribute.rb 66 def web_display=(new_val) 67 raise Jamf::InvalidDataError, "Mobile Device Extension Attributes web_display cannot be '#{WEB_DISPLAY_CHOICE_OS}'" if new_val == WEB_DISPLAY_CHOICE_OS 68 69 super 70 end