ruby-jss 0.10.2 → 0.11.0a5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGES.md +49 -2
- data/README.md +14 -7
- data/lib/jss/api_connection.rb +48 -24
- data/lib/jss/api_object/advanced_search.rb +5 -1
- data/lib/jss/api_object/computer.rb +204 -402
- data/lib/jss/api_object/computer_invitation.rb +5 -3
- data/lib/jss/api_object/ebook.rb +5 -0
- data/lib/jss/api_object/extendable.rb +13 -0
- data/lib/jss/api_object/group/computer_group.rb +4 -0
- data/lib/jss/api_object/group/mobile_device_group.rb +4 -1
- data/lib/jss/api_object/group.rb +6 -1
- data/lib/jss/api_object/mac_application.rb +5 -0
- data/lib/jss/api_object/management_history/audit_event.rb +45 -0
- data/lib/jss/api_object/management_history/casper_imaging_log.rb +37 -0
- data/lib/jss/api_object/management_history/casper_remote_log.rb +37 -0
- data/lib/jss/api_object/management_history/computer_usage_log.rb +43 -0
- data/lib/jss/api_object/management_history/ebook.rb +70 -0
- data/lib/jss/api_object/management_history/mac_app_store_app.rb +69 -0
- data/lib/jss/api_object/management_history/mdm_command.rb +96 -0
- data/lib/jss/api_object/management_history/mobile_device_app.rb +99 -0
- data/lib/jss/api_object/management_history/policy_log.rb +60 -0
- data/lib/jss/api_object/management_history/screen_sharing_log.rb +41 -0
- data/lib/jss/api_object/management_history/user_location_change.rb +66 -0
- data/lib/jss/api_object/management_history.rb +865 -0
- data/lib/jss/api_object/mdm.rb +1298 -0
- data/lib/jss/api_object/mobile_device.rb +241 -644
- data/lib/jss/api_object/mobile_device_application.rb +6 -0
- data/lib/jss/api_object/mobile_device_configuration_profile.rb +36 -0
- data/lib/jss/api_object/osx_configuration_profile.rb +115 -151
- data/lib/jss/api_object/patch.rb +38 -0
- data/lib/jss/api_object/patch_policy.rb +38 -0
- data/lib/jss/api_object/peripheral.rb +5 -7
- data/lib/jss/api_object/policy.rb +5 -0
- data/lib/jss/api_object/restricted_software.rb +5 -0
- data/lib/jss/api_object/scopable/scope.rb +367 -411
- data/lib/jss/api_object/self_servable.rb +15 -4
- data/lib/jss/api_object/sitable.rb +197 -0
- data/lib/jss/api_object/site.rb +45 -76
- data/lib/jss/api_object/user.rb +7 -3
- data/lib/jss/api_object.rb +75 -4
- data/lib/jss/utility.rb +21 -0
- data/lib/jss/version.rb +1 -1
- data/lib/jss.rb +6 -0
- metadata +42 -6
@@ -39,14 +39,14 @@ module JSS
|
|
39
39
|
# This class represents a Mobile Device stored in the JSS.
|
40
40
|
#
|
41
41
|
# ---
|
42
|
-
# ===Adding devices to the JSS
|
42
|
+
# === Adding devices to the JSS
|
43
43
|
#
|
44
44
|
# This class cannot be used to add new mobile devices to the JSS. That can only be done
|
45
45
|
# via the enrollment process. See JSS::MobileDeviceInvitation for sending
|
46
46
|
# an enrollment invite to a device.
|
47
47
|
#
|
48
48
|
# ---
|
49
|
-
# ===Editing values
|
49
|
+
# === Editing values
|
50
50
|
#
|
51
51
|
# Only a few values can be changed via the API, using these methods, q.v:
|
52
52
|
# - #asset_tag= String
|
@@ -57,35 +57,32 @@ module JSS
|
|
57
57
|
# After modfying any values, #save must be called to save changes to the JSS.
|
58
58
|
#
|
59
59
|
# ---
|
60
|
-
# ===MDM Commands
|
60
|
+
# === MDM Commands
|
61
61
|
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
# the Management Commands section of the Management tab of the Mobile Device details page in the JSS UI.
|
62
|
+
# See the {JSS::MDM} mixin module for Class and Instance methods for
|
63
|
+
# sending MDM commands to mobiledevices.
|
65
64
|
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
# - update_inventory (alias recon)
|
69
|
-
# - device_lock (aliases lock, lock_device)
|
70
|
-
# - erase_device (aliases wipe)
|
71
|
-
# - clear_passcode
|
72
|
-
# - unmanage_device (alias unmanage)
|
73
|
-
#
|
74
|
-
# Each returns true if the command as sent.
|
75
|
-
#
|
76
|
-
# @see JSS::APIObject
|
65
|
+
# To send MDM commands without fetching mobiledevice instances, use the class
|
66
|
+
# methods, which can take multiple identifiers at once.
|
77
67
|
#
|
68
|
+
# NOTE: If the {#name=} method is used to change the name of a supervized device,
|
69
|
+
# the DeviceName MDM command will be sent to the device when
|
70
|
+
# the changes are sent to the server via {#save} or {#update}
|
78
71
|
#
|
79
72
|
class MobileDevice < JSS::APIObject
|
80
73
|
|
81
74
|
# Mix-Ins
|
82
75
|
#####################################
|
83
76
|
|
77
|
+
include JSS::Creatable
|
84
78
|
include JSS::Updatable
|
85
79
|
include JSS::Locatable
|
86
80
|
include JSS::Purchasable
|
87
81
|
include JSS::Uploadable
|
88
82
|
include JSS::Extendable
|
83
|
+
include JSS::Sitable
|
84
|
+
include JSS::MDM
|
85
|
+
include JSS::ManagementHistory
|
89
86
|
|
90
87
|
extend JSS::Matchable
|
91
88
|
|
@@ -102,6 +99,9 @@ module JSS
|
|
102
99
|
# It's also used in various error messages
|
103
100
|
RSRC_OBJECT_KEY = :mobile_device
|
104
101
|
|
102
|
+
# Where is the Site data in the API JSON?
|
103
|
+
SITE_SUBSET = :general
|
104
|
+
|
105
105
|
# these keys, as well as :id and :name, are present in valid API JSON data for this class
|
106
106
|
VALID_DATA_KEYS = %i[device_name capacity tethered].freeze
|
107
107
|
|
@@ -120,232 +120,191 @@ module JSS
|
|
120
120
|
# This is the class for relevant Extension Attributes
|
121
121
|
EXT_ATTRIB_CLASS = JSS::MobileDeviceExtensionAttribute
|
122
122
|
|
123
|
-
#
|
124
|
-
|
125
|
-
|
126
|
-
# The MDM commands sendable via the api
|
127
|
-
# and alternative versions
|
128
|
-
#
|
129
|
-
MDM_COMMANDS = {
|
130
|
-
blank_push: 'BlankPush',
|
131
|
-
send_blank_push: 'BlankPush',
|
132
|
-
blank: 'BlankPush',
|
133
|
-
noop: 'BlankPush',
|
134
|
-
|
135
|
-
settings: 'Settings',
|
136
|
-
|
137
|
-
update_inventory: 'UpdateInventory',
|
138
|
-
recon: 'UpdateInventory',
|
139
|
-
|
140
|
-
device_lock: 'DeviceLock',
|
141
|
-
lock: 'DeviceLock',
|
142
|
-
lock_device: 'DeviceLock',
|
143
|
-
|
144
|
-
erase_device: 'EraseDevice',
|
145
|
-
erase: 'EraseDevice',
|
146
|
-
wipe: 'EraseDevice',
|
147
|
-
|
148
|
-
clear_passcode: 'ClearPasscode',
|
149
|
-
|
150
|
-
clear_restrictions_password: 'ClearRestrictionsPassword',
|
151
|
-
|
152
|
-
enable_data_roaming: 'SettingsEnableDataRoaming',
|
153
|
-
disable_data_roaming: 'SettingsDisableDataRoaming',
|
154
|
-
|
155
|
-
enable_voice_roaming: 'SettingsEnableVoiceRoaming',
|
156
|
-
disable_voice_roaming: 'SettingsDisableVoiceRoaming',
|
157
|
-
|
158
|
-
enable_app_analytics: 'SettingsEnableAppAnalytics',
|
159
|
-
disable_app_analytics: 'SettingsDisableAppAnalytics',
|
160
|
-
|
161
|
-
enable_diagnostic_submission: 'SettingsEnableDiagnosticSubmission',
|
162
|
-
disable_diagnostic_submission: 'SettingsDisableDiagnosticSubmission',
|
163
|
-
|
164
|
-
# wallpaper: 'Wallpaper',
|
165
|
-
|
166
|
-
device_name: 'DeviceName',
|
167
|
-
|
168
|
-
shutdown_device: 'ShutDownDevice',
|
169
|
-
shutdown: 'ShutDownDevice',
|
170
|
-
|
171
|
-
restart_device: 'RestartDevice',
|
172
|
-
restart: 'RestartDevice',
|
173
|
-
|
174
|
-
# passcode_lock_grace_period: 'PasscodeLockGracePeriod',
|
175
|
-
|
176
|
-
unmanage_device: 'UnmanageDevice',
|
177
|
-
unmanage: 'UnmanageDevice'
|
178
|
-
|
179
|
-
}.freeze
|
180
|
-
|
181
|
-
# These MDM commands need extra data.
|
182
|
-
MDM_COMMANDS_REQUIRING_DATA = %w[DeviceLock DeviceName Wallpaper].freeze
|
183
|
-
|
184
|
-
# The History resource
|
185
|
-
HISTORY_RSRC = 'mobiledevicehistory'.freeze
|
186
|
-
|
187
|
-
# Available history subsets
|
188
|
-
HISTORY_SUBSETS = %i[management_commands user_location audits applications ebooks].freeze
|
123
|
+
# What kind of devices are we for MDM purposes?
|
124
|
+
MDM_COMMAND_TARGET = :mobiledevices
|
189
125
|
|
190
126
|
# the object type for this object in
|
191
127
|
# the object history table.
|
192
128
|
# See {APIObject#add_object_history_entry}
|
193
129
|
OBJECT_HISTORY_OBJECT_TYPE = 21
|
194
130
|
|
195
|
-
|
196
131
|
# Class Methods
|
197
132
|
#####################################
|
198
133
|
|
199
134
|
# @return [Array<String>] all mobiledevice serial_numbers
|
200
135
|
def self.all_serial_numbers(refresh = false, api: JSS.api)
|
201
|
-
all(refresh, api:
|
136
|
+
all(refresh, api: api).map { |i| i[:serial_number] }
|
202
137
|
end
|
203
138
|
|
204
139
|
# @return [Array<String>] all mobiledevice phone numbers
|
205
140
|
def self.all_phone_numbers(refresh = false, api: JSS.api)
|
206
|
-
all(refresh, api:
|
141
|
+
all(refresh, api: api).map { |i| i[:phone_number] }.reject(&:empty?)
|
207
142
|
end
|
208
143
|
|
209
144
|
# @return [Array<String>] all mobiledevice wifi mac addrs
|
210
145
|
def self.all_wifi_mac_addresses(refresh = false, api: JSS.api)
|
211
|
-
all(refresh, api:
|
146
|
+
all(refresh, api: api).map { |i| i[:wifi_mac_address] }
|
212
147
|
end
|
213
148
|
|
214
149
|
# @return [Array<String>] all mobiledevice wifi mac addrs
|
215
150
|
def self.all_mac_addresses(refresh = false, api: JSS.api)
|
216
|
-
all_wifi_mac_addresses(refresh, api:
|
151
|
+
all_wifi_mac_addresses(refresh, api: api)
|
217
152
|
end
|
218
153
|
|
219
154
|
# @return [Array<String>] all mobiledevice udids
|
220
155
|
def self.all_udids(refresh = false, api: JSS.api)
|
221
|
-
all(refresh, api:
|
156
|
+
all(refresh, api: api).map { |i| i[:udid] }
|
222
157
|
end
|
223
158
|
|
224
159
|
# @return [Array<Hash>] the list of all managed mobile devices
|
225
160
|
def self.all_managed(refresh = false, api: JSS.api)
|
226
|
-
all(refresh, api:
|
161
|
+
all(refresh, api: api).select { |d| d[:managed] }
|
227
162
|
end
|
228
163
|
|
229
164
|
# @return [Array<Hash>] the list of all unmanaged mobile devices
|
230
165
|
def self.all_unmanaged(refresh = false, api: JSS.api)
|
231
|
-
all(refresh, api:
|
166
|
+
all(refresh, api: api).reject { |d| d[:managed] }
|
167
|
+
end
|
168
|
+
|
169
|
+
# @return [Array<Hash>] the list of all supervised mobile devices
|
170
|
+
def self.all_supervised(refresh = false, api: JSS.api)
|
171
|
+
all(refresh, api: api).select { |d| d[:supervised] }
|
172
|
+
end
|
173
|
+
|
174
|
+
# @return [Array<Hash>] the list of all unsupervised mobile devices
|
175
|
+
def self.all_unsupervised(refresh = false, api: JSS.api)
|
176
|
+
all(refresh, api: api).reject { |d| d[:supervised] }
|
232
177
|
end
|
233
178
|
|
234
179
|
# @return [Array<Hash>] the list of all iPhones
|
235
180
|
def self.all_iphones(refresh = false, api: JSS.api)
|
236
|
-
all(refresh, api:
|
181
|
+
all(refresh, api: api).select { |d| d[:model].start_with? 'iPhone' }
|
237
182
|
end
|
238
183
|
|
239
184
|
# @return [Array<Hash>] the list of all iPads
|
240
185
|
def self.all_ipads(refresh = false, api: JSS.api)
|
241
|
-
all(refresh, api:
|
186
|
+
all(refresh, api: api).select { |d| d[:model].start_with? 'iPad' }
|
242
187
|
end
|
243
188
|
|
244
189
|
# @return [Array<Hash>] the list of all iPads
|
245
190
|
def self.all_apple_tvs(refresh = false, api: JSS.api)
|
246
|
-
all(refresh, api:
|
191
|
+
all(refresh, api: api).select { |d| d[:model_identifier].start_with? 'AppleTV' }
|
247
192
|
end
|
248
193
|
|
249
|
-
#
|
250
|
-
|
251
|
-
#
|
252
|
-
# @param targets[String,Integer,Array<String,Integer>]
|
253
|
-
# the name or id of the mobile devices to receive the command, or
|
254
|
-
# an array of such names or ids, or a comma-separated string
|
255
|
-
# of them.
|
256
|
-
# @param command[Symbol] the command to send, one of the keys
|
257
|
-
# of MDM_COMMANDS
|
258
|
-
#
|
259
|
-
# @param data[String] Some commands require extra data.
|
260
|
-
#
|
261
|
-
# @param api[JSS::APIConnection] the APi to query. Defaults to the
|
262
|
-
# currently active API, see {JSS::APIConnection}
|
263
|
-
#
|
264
|
-
# @return [String] The uuid of the MDM command sent, if applicable
|
265
|
-
# (blank pushes do not generate uuids)
|
266
|
-
#
|
267
|
-
def self.send_mdm_command(targets, command, data = nil, api: JSS.api)
|
268
|
-
raise JSS::NoSuchItemError, "Unknown command '#{command}'" unless MDM_COMMANDS.keys.include? command
|
194
|
+
# Attributes
|
195
|
+
#####################################
|
269
196
|
|
270
|
-
|
271
|
-
|
197
|
+
############
|
198
|
+
# The values returned in the General subset are stored as direct attributes
|
272
199
|
|
273
|
-
|
274
|
-
|
275
|
-
cmd_rsrc << "/#{data}"
|
276
|
-
end
|
200
|
+
# identifiers
|
201
|
+
###########################
|
277
202
|
|
278
|
-
|
203
|
+
# @return [String]
|
204
|
+
attr_reader :serial_number
|
205
|
+
alias sn serial_number
|
206
|
+
alias serialnumber serial_number
|
279
207
|
|
280
|
-
|
281
|
-
|
282
|
-
if all_ids(api: api).include? md.to_i
|
283
|
-
md.to_i
|
284
|
-
elsif all_names(api: api).include? md
|
285
|
-
map_all_ids_to(:name, api: api.invert[md])
|
286
|
-
else
|
287
|
-
raise JSS::NoSuchItemError, "No mobile device found matching '#{md}'"
|
288
|
-
end # if
|
289
|
-
end # map!
|
208
|
+
# @return [String]
|
209
|
+
attr_reader :udid
|
290
210
|
|
291
|
-
|
211
|
+
# @return [String]
|
212
|
+
attr_reader :asset_tag
|
292
213
|
|
293
|
-
|
294
|
-
|
295
|
-
Regexp.last_match(1)
|
296
|
-
end
|
214
|
+
# @return [String]
|
215
|
+
attr_reader :display_name
|
297
216
|
|
298
|
-
|
299
|
-
|
300
|
-
if identifier.is_a? Integer
|
301
|
-
id = identifier
|
302
|
-
else
|
303
|
-
key = case identifier
|
304
|
-
when *all_names(api: api) then :name
|
305
|
-
when *all_serial_numbers(api: api) then :serial_number
|
306
|
-
when *all_mac_addresses(api: api) then :mac_address
|
307
|
-
when *all_udids(api: api) then :udid
|
308
|
-
end
|
309
|
-
id = map_all_ids_to(key, api: api).invert[identifier]
|
310
|
-
end # if identifier.is_a? Integer
|
311
|
-
|
312
|
-
raise JSS::NoSuchItemError, "No MobileDevice found matching #{identifier}" unless id && all_ids(api: api).include?(id)
|
313
|
-
|
314
|
-
rsrc = "#{HISTORY_RSRC}/id/#{id}"
|
315
|
-
|
316
|
-
if subset
|
317
|
-
raise "subset must be one of: :#{HISTORY_SUBSETS.join ', :'}" unless HISTORY_SUBSETS.include? subset
|
318
|
-
rsrc << "/subset/#{subset}"
|
319
|
-
end
|
217
|
+
# @return [String]
|
218
|
+
attr_reader :device_name
|
320
219
|
|
321
|
-
|
322
|
-
|
323
|
-
end
|
220
|
+
# @return [String] An Apple TV identifier
|
221
|
+
attr_reader :device_id
|
324
222
|
|
325
|
-
#
|
326
|
-
|
223
|
+
# @return [String]
|
224
|
+
attr_reader :exchange_activesync_device_identifier
|
327
225
|
|
328
|
-
|
329
|
-
|
330
|
-
|
226
|
+
# settings
|
227
|
+
###########################
|
228
|
+
|
229
|
+
# @return [Boolean] is this device managed?
|
230
|
+
attr_reader :managed
|
231
|
+
alias managed? managed
|
232
|
+
|
233
|
+
# @return [Boolean] is this device supervised?
|
234
|
+
attr_reader :supervised
|
235
|
+
alias supervised? supervised
|
236
|
+
|
237
|
+
# @return [String] the device_ownership_level
|
238
|
+
attr_reader :device_ownership_level
|
239
|
+
|
240
|
+
# @return [String] the tether state of the device
|
241
|
+
attr_reader :tethered
|
242
|
+
|
243
|
+
# @return [Boolean] is this device shared?
|
244
|
+
attr_reader :shared
|
245
|
+
|
246
|
+
# @return [Boolean] is this device ble_capable?
|
247
|
+
attr_reader :ble_capable
|
331
248
|
|
332
249
|
# @return [String] the airplay passwd on devices that can receive AirPlay (i.e. apple tvs)
|
333
250
|
attr_reader :airplay_password
|
334
251
|
|
335
|
-
# @return [String] the
|
336
|
-
attr_reader :
|
252
|
+
# @return [String] the languages
|
253
|
+
attr_reader :languages
|
254
|
+
|
255
|
+
# @return [String] the locales
|
256
|
+
attr_reader :locales
|
257
|
+
|
258
|
+
# software
|
259
|
+
###########################
|
260
|
+
|
261
|
+
# @return [String] the model firmware
|
262
|
+
attr_reader :modem_firmware
|
263
|
+
|
264
|
+
# @return [String] the OS version
|
265
|
+
attr_reader :os_version
|
266
|
+
|
267
|
+
# @return [String] the OS build
|
268
|
+
attr_reader :os_build
|
269
|
+
|
270
|
+
# @return [String] the OS type
|
271
|
+
attr_reader :os_type
|
272
|
+
|
273
|
+
# hardware
|
274
|
+
###########################
|
275
|
+
|
276
|
+
# @return [String] the display name of the model
|
277
|
+
attr_reader :model
|
278
|
+
|
279
|
+
# @return [String] the display name of the model
|
280
|
+
attr_reader :model_number
|
281
|
+
|
282
|
+
# @return [String] the display name of the model
|
283
|
+
attr_reader :model_display
|
284
|
+
|
285
|
+
# @return [String] the model identifier
|
286
|
+
attr_reader :model_identifier
|
287
|
+
|
288
|
+
# usage
|
289
|
+
##########################
|
337
290
|
|
338
291
|
# @return [Intger] how much space available on the device?
|
339
292
|
attr_reader :available_mb
|
293
|
+
alias available available_mb
|
340
294
|
|
341
295
|
# @return [Integer] total storage on the device
|
342
296
|
attr_reader :capacity_mb
|
297
|
+
alias capacity capacity_mb
|
343
298
|
|
344
299
|
# @return [Integer] how much of the capacity is in use?
|
345
300
|
attr_reader :percentage_used
|
346
301
|
|
347
302
|
# @return [Integer] what percentage of the battery is remaining
|
348
303
|
attr_reader :battery_level
|
304
|
+
alias battery_percent battery_level
|
305
|
+
|
306
|
+
# network
|
307
|
+
##########################
|
349
308
|
|
350
309
|
# @return [String] the bluetooth mac addr
|
351
310
|
attr_reader :bluetooth_mac_address
|
@@ -353,26 +312,23 @@ module JSS
|
|
353
312
|
# @return [String] the wifi mac addr
|
354
313
|
attr_reader :wifi_mac_address
|
355
314
|
|
356
|
-
# @return [
|
357
|
-
attr_reader :
|
315
|
+
# @return [String] the IP addr
|
316
|
+
attr_reader :ip_address
|
358
317
|
|
359
|
-
# @return [String]
|
360
|
-
attr_reader :
|
318
|
+
# @return [String] the phone number of the device's SIM card
|
319
|
+
attr_reader :sim_phone_number
|
320
|
+
alias device_phone_number sim_phone_number
|
361
321
|
|
362
|
-
#
|
363
|
-
|
322
|
+
# timestamps
|
323
|
+
##########################
|
364
324
|
|
365
325
|
# @return [Time] uses the value from the API's initial_entry_date_epoch
|
366
326
|
attr_reader :initial_entry_date
|
367
327
|
|
368
|
-
# @return [String] the IP addr
|
369
|
-
attr_reader :ip_address
|
370
|
-
|
371
|
-
# @return [String] the language setting
|
372
|
-
attr_reader :languages
|
373
|
-
|
374
328
|
# @return [Time] uses the value from the API's last_backup_time_epoch
|
375
329
|
attr_reader :last_backup_time
|
330
|
+
alias last_backup_date last_backup_time
|
331
|
+
alias last_backup last_backup_time
|
376
332
|
|
377
333
|
# @return [Time] uses the value from the API's last_inventory_update_utc
|
378
334
|
attr_reader :last_inventory_update
|
@@ -380,50 +336,12 @@ module JSS
|
|
380
336
|
# @return [Time] the last time this device enrolled in Jamf
|
381
337
|
attr_reader :last_enrollment
|
382
338
|
|
383
|
-
# @return [
|
384
|
-
attr_reader :
|
385
|
-
|
386
|
-
# @return [Boolean] is this device managed?
|
387
|
-
attr_reader :managed
|
388
|
-
|
389
|
-
# @return [Boolean] is this device supervised?
|
390
|
-
attr_reader :supervised
|
391
|
-
|
392
|
-
# @return [String] the display name of the model
|
393
|
-
attr_reader :model_display
|
394
|
-
alias model model_display
|
395
|
-
|
396
|
-
# @return [String] the model identifier
|
397
|
-
attr_reader :model_identifier
|
339
|
+
# @return [Time] last_cloud_backup_date
|
340
|
+
attr_reader :last_cloud_backup_date
|
398
341
|
|
399
|
-
#
|
400
|
-
attr_reader :modem_firmware
|
401
|
-
|
402
|
-
# @return [String] the OS version
|
403
|
-
attr_reader :os_version
|
404
|
-
|
405
|
-
# @return [String] the OS build
|
406
|
-
attr_reader :os_build
|
407
|
-
|
408
|
-
# @return [String] the phone number of the device's SIM card
|
409
|
-
attr_reader :phone_number
|
342
|
+
# subsets
|
410
343
|
|
411
|
-
# @return [
|
412
|
-
attr_reader :serial_number
|
413
|
-
|
414
|
-
# @return [String] the site associated with this device
|
415
|
-
attr_reader :site
|
416
|
-
|
417
|
-
# @return [Boolean] Is this device supervised?
|
418
|
-
attr_reader :supervised
|
419
|
-
|
420
|
-
# @return [String] the tether state of the device
|
421
|
-
attr_reader :tethered
|
422
|
-
|
423
|
-
# @return [String] the udid
|
424
|
-
attr_reader :udid
|
425
|
-
|
426
|
-
# @return [Array<Hash>] the applications on the devices
|
344
|
+
# @return [Array<Hash>] the applications on the device
|
427
345
|
attr_reader :applications
|
428
346
|
|
429
347
|
# @return [Array<Hash>]
|
@@ -494,449 +412,124 @@ module JSS
|
|
494
412
|
# - :file_level_encryption_capable=>true
|
495
413
|
attr_reader :security
|
496
414
|
|
497
|
-
#####################################
|
498
415
|
# Instance Methods
|
499
416
|
#####################################
|
500
417
|
|
501
|
-
#
|
502
418
|
# @see APIObject#initialize
|
503
419
|
#
|
420
|
+
# When creating new records with .make,
|
421
|
+
# udid:, serial_number:, and asset_tag: can be provided in
|
422
|
+
# the args.
|
423
|
+
#
|
504
424
|
def initialize(args = {})
|
505
425
|
super args
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
# Send a device_lock MDM command
|
572
|
-
#
|
573
|
-
# @param message[String] The message to display on the lock screen.
|
574
|
-
#
|
575
|
-
# @see MobileDevice.send_mdm_command
|
576
|
-
#
|
577
|
-
# @return [String] The command uuid
|
578
|
-
#
|
579
|
-
def device_lock(message)
|
580
|
-
self.class.send_mdm_command @id, :device_lock, message, api: @api
|
581
|
-
end
|
582
|
-
|
583
|
-
# Send an erase_device MDM command
|
584
|
-
#
|
585
|
-
# @see MobileDevice.send_mdm_command
|
586
|
-
#
|
587
|
-
# @return [String] The command uuid
|
588
|
-
#
|
589
|
-
def erase_device
|
590
|
-
self.class.send_mdm_command @id, :erase_device, api: @api
|
591
|
-
end
|
592
|
-
|
593
|
-
# Send a clear_passcode MDM command
|
594
|
-
#
|
595
|
-
# @see MobileDevice.send_mdm_command
|
596
|
-
#
|
597
|
-
# @return [String] The command uuid
|
598
|
-
#
|
599
|
-
def clear_passcode
|
600
|
-
self.class.send_mdm_command @id, :clear_passcode, api: @api
|
601
|
-
end
|
602
|
-
|
603
|
-
# Send a unmanage_device MDM command
|
604
|
-
#
|
605
|
-
# @see MobileDevice.send_mdm_command
|
606
|
-
#
|
607
|
-
# @return [String] The command uuid
|
608
|
-
#
|
609
|
-
def unmanage_device
|
610
|
-
@managed = false if self.class.send_mdm_command(@id, :unmanage_device, api: @api)
|
611
|
-
end
|
612
|
-
|
613
|
-
# Send a ClearRestrictionsPassword MDM command
|
614
|
-
#
|
615
|
-
# @see MobileDevice.send_mdm_command
|
616
|
-
#
|
617
|
-
# @return [String] The command uuid
|
618
|
-
#
|
619
|
-
def clear_restrictions_password
|
620
|
-
self.class.send_mdm_command @id, :clear_restrictions_password, api: @api
|
621
|
-
end
|
622
|
-
|
623
|
-
# Send a SettingsEnableDataRoaming MDM command
|
624
|
-
#
|
625
|
-
# @see MobileDevice.send_mdm_command
|
626
|
-
#
|
627
|
-
# @return [String] The command uuid
|
628
|
-
#
|
629
|
-
def enable_data_roaming
|
630
|
-
self.class.send_mdm_command @id, :enable_data_roaming, api: @api
|
631
|
-
end
|
632
|
-
|
633
|
-
# Send a disable_data_roaming MDM command
|
634
|
-
#
|
635
|
-
# @see MobileDevice.send_mdm_command
|
636
|
-
#
|
637
|
-
# @return [String] The command uuid
|
638
|
-
#
|
639
|
-
def disable_data_roaming
|
640
|
-
self.class.send_mdm_command @id, :disable_data_roaming, api: @api
|
641
|
-
end
|
642
|
-
|
643
|
-
# Send a enable_voice_roaming MDM command
|
644
|
-
#
|
645
|
-
# @see MobileDevice.send_mdm_command
|
646
|
-
#
|
647
|
-
# @return [String] The command uuid
|
648
|
-
#
|
649
|
-
def enable_voice_roaming
|
650
|
-
self.class.send_mdm_command @id, :enable_voice_roaming, api: @api
|
651
|
-
end
|
652
|
-
|
653
|
-
# Send a disable_voice_roaming MDM command
|
654
|
-
#
|
655
|
-
# @see MobileDevice.send_mdm_command
|
656
|
-
#
|
657
|
-
# @return [String] The command uuid
|
658
|
-
#
|
659
|
-
def disable_voice_roaming
|
660
|
-
self.class.send_mdm_command @id, :disable_voice_roaming, api: @api
|
661
|
-
end
|
662
|
-
|
663
|
-
# Send a enable_app_analytics MDM command
|
664
|
-
#
|
665
|
-
# @see MobileDevice.send_mdm_command
|
666
|
-
#
|
667
|
-
# @return [String] The command uuid
|
668
|
-
#
|
669
|
-
def enable_app_analytics
|
670
|
-
self.class.send_mdm_command @id, :enable_app_analytics, api: @api
|
671
|
-
end
|
672
|
-
|
673
|
-
# Send a disable_app_analytics MDM command
|
674
|
-
#
|
675
|
-
# @see MobileDevice.send_mdm_command
|
676
|
-
#
|
677
|
-
# @return [String] The command uuid
|
678
|
-
#
|
679
|
-
def disable_app_analytics
|
680
|
-
self.class.send_mdm_command @id, :disable_app_analytics, api: @api
|
681
|
-
end
|
682
|
-
|
683
|
-
# Send a enable_diagnostic_submission MDM command
|
684
|
-
#
|
685
|
-
# @see MobileDevice.send_mdm_command
|
686
|
-
#
|
687
|
-
# @return [String] The command uuid
|
688
|
-
#
|
689
|
-
def enable_diagnostic_submission
|
690
|
-
self.class.send_mdm_command @id, :enable_diagnostic_submission, api: @api
|
691
|
-
end
|
692
|
-
|
693
|
-
# Send a disable_diagnostic_submission MDM command
|
694
|
-
#
|
695
|
-
# @see MobileDevice.send_mdm_command
|
696
|
-
#
|
697
|
-
# @return [String] The command uuid
|
698
|
-
#
|
699
|
-
def disable_diagnostic_submission
|
700
|
-
self.class.send_mdm_command @id, :disable_diagnostic_submission, api: @api
|
701
|
-
end
|
702
|
-
|
703
|
-
# Send a device_name MDM command
|
704
|
-
#
|
705
|
-
# @param new_name[String] The name for the device
|
706
|
-
#
|
707
|
-
# @see MobileDevice.send_mdm_command
|
708
|
-
#
|
709
|
-
# @return [String] The command uuid
|
710
|
-
#
|
711
|
-
def device_name(new_name)
|
712
|
-
self.class.send_mdm_command @id, :device_name, new_name, api: @api
|
713
|
-
end
|
714
|
-
|
715
|
-
# Send a shutdown device MDM command
|
716
|
-
#
|
717
|
-
# @see MobileDevice.send_mdm_command
|
718
|
-
#
|
719
|
-
# @return [String] The command uuid
|
720
|
-
#
|
721
|
-
def shutdown
|
722
|
-
self.class.send_mdm_command @id, :shutdown, api: @api
|
723
|
-
end
|
724
|
-
|
725
|
-
# Send a restart device MDM command
|
726
|
-
#
|
727
|
-
# @see MobileDevice.send_mdm_command
|
728
|
-
#
|
729
|
-
# @return [String] The command uuid
|
730
|
-
#
|
731
|
-
def restart
|
732
|
-
self.class.send_mdm_command @id, :restart, api: @api
|
733
|
-
end
|
734
|
-
|
735
|
-
# The full management History data for this Mobile Device
|
736
|
-
#
|
737
|
-
# @return [Hash] Keys are:
|
738
|
-
# general: Hash of identifiers
|
739
|
-
# user_location: see user_location_history
|
740
|
-
# management_commands: see management_command_history
|
741
|
-
# audits: see audit_history
|
742
|
-
# applications: see managed_app_history
|
743
|
-
# ebooks: see managed
|
744
|
-
#
|
745
|
-
def management_history
|
746
|
-
self.class.management_history @id, api: @api
|
747
|
-
end
|
748
|
-
|
749
|
-
# The user_location subset of the full history
|
750
|
-
#
|
751
|
-
# @return [Array<Hash>] Each hash contains user and location data
|
752
|
-
# and the timestamp as a JSS epoch value or string.
|
753
|
-
# use JSS.epoch_to_time or JSS.parse_time to convert them to Time
|
754
|
-
# objects
|
755
|
-
#
|
756
|
-
def user_location_history
|
757
|
-
self.class.management_history @id, :user_location, api: @api
|
758
|
-
end
|
759
|
-
|
760
|
-
# The management_commands subset of the full history
|
761
|
-
#
|
762
|
-
# @return [Hash] A hash of :completed, :pending, and :failed
|
763
|
-
# mdm commands, each being an array of hashes.
|
764
|
-
# see #completed_mdm_commands, #pending_mdm_commands and
|
765
|
-
# #failed_mdm_commands
|
766
|
-
#
|
767
|
-
def management_command_history
|
768
|
-
self.class.management_history @id, :management_commands, api: @api
|
769
|
-
end
|
770
|
-
alias mdm_command_history management_command_history
|
771
|
-
|
772
|
-
# The history of completed mdm commands.
|
773
|
-
#
|
774
|
-
# @return [Array<Hash>] Each hash contains a command name and
|
775
|
-
# and the timestamp as a JSS epoch value or string.
|
776
|
-
# use JSS.epoch_to_time or JSS.parse_time to convert them to Time
|
777
|
-
# objects
|
778
|
-
#
|
779
|
-
def completed_mdm_commands
|
780
|
-
management_command_history[:completed]
|
781
|
-
end
|
782
|
-
|
783
|
-
# The currently pending mdm commands.
|
784
|
-
#
|
785
|
-
# @return [Array<Hash>] Each hash contains a command name and a :status
|
786
|
-
# and a a timestamp as a JSS epoch value or string.
|
787
|
-
# use JSS.epoch_to_time or JSS.parse_time to convert them to Time
|
788
|
-
# objects
|
789
|
-
#
|
790
|
-
def pending_mdm_commands
|
791
|
-
management_command_history[:pending]
|
792
|
-
end
|
793
|
-
|
794
|
-
# The history of failed mdm commands.
|
795
|
-
#
|
796
|
-
# @return [Array<Hash>] Each hash contains a command name and an :error
|
797
|
-
# message and timestamps for issuance and failure as JSS epoch values
|
798
|
-
# or strings. use JSS.epoch_to_time or JSS.parse_time to convert them to
|
799
|
-
# Time objects
|
800
|
-
#
|
801
|
-
def failed_mdm_commands
|
802
|
-
management_command_history[:failed]
|
803
|
-
end
|
804
|
-
|
805
|
-
# The applications subset of the full history
|
806
|
-
#
|
807
|
-
# @return [Hash] Keys are :installed, :pending, and :failed
|
808
|
-
# See #installed_managed_apps, #pending_managed_apps and
|
809
|
-
# #failed_managed_apps
|
810
|
-
#
|
811
|
-
def managed_app_history
|
812
|
-
self.class.management_history @id, :applications, api: @api
|
813
|
-
end
|
814
|
-
|
815
|
-
# The apps that have been installed via MDM
|
816
|
-
#
|
817
|
-
# @param from[Symbol] :in_house, :app_store, :other, or :all.
|
818
|
-
# Defaults to :all
|
819
|
-
#
|
820
|
-
# @return [Hash{Array<Hash>}] When from = :all, all three sources.
|
821
|
-
#
|
822
|
-
# @return [Array<Hash>] When from = :in_house, :app_store, or :other
|
823
|
-
# the managed apps that have been installed from that source.
|
824
|
-
# Each Hash includes these keys:
|
825
|
-
# name:
|
826
|
-
# version:
|
827
|
-
# short_version:
|
828
|
-
# management_status:
|
829
|
-
# bundle_size:
|
830
|
-
# dynamic_size:
|
831
|
-
#
|
832
|
-
def installed_managed_apps(from = :all)
|
833
|
-
all = managed_app_history[:installed]
|
834
|
-
case from
|
835
|
-
when :all
|
836
|
-
all
|
837
|
-
when :in_house
|
838
|
-
all[:in_house_from_mobile_device_app_catalog]
|
839
|
-
when :app_store
|
840
|
-
all[:app_store_from_mobile_device_app_catalog]
|
841
|
-
when :other
|
842
|
-
all[:other]
|
426
|
+
if @in_jss
|
427
|
+
|
428
|
+
gen = @init_data[:general]
|
429
|
+
|
430
|
+
# identifiers
|
431
|
+
@serial_number = gen[:serial_number]
|
432
|
+
@udid = gen[:udid]
|
433
|
+
@asset_tag = gen[:asset_tag]
|
434
|
+
@device_id = gen[:device_id]
|
435
|
+
@device_name = gen[:device_name]
|
436
|
+
@display_name = gen[:display_name]
|
437
|
+
@exchange_activesync_device_identifier = gen[:exchange_activesync_device_identifier]
|
438
|
+
|
439
|
+
# settings
|
440
|
+
@managed = gen[:managed]
|
441
|
+
@supervised = gen[:supervised]
|
442
|
+
@device_ownership_level = gen[:device_ownership_level]
|
443
|
+
@tethered = gen[:tethered]
|
444
|
+
@shared = gen[:shared]
|
445
|
+
@ble_capable = gen[:ble_capable]
|
446
|
+
|
447
|
+
@airplay_password = gen[:airplay_password]
|
448
|
+
@languages = gen[:languages]
|
449
|
+
@locales = gen[:locales]
|
450
|
+
|
451
|
+
# software
|
452
|
+
@os_type = gen[:os_type]
|
453
|
+
@os_build = gen[:os_build]
|
454
|
+
@os_version = gen[:os_version]
|
455
|
+
@modem_firmware = gen[:modem_firmware]
|
456
|
+
|
457
|
+
# hardware
|
458
|
+
@model = gen[:model]
|
459
|
+
@model_number = gen[:model_number]
|
460
|
+
@model_identifier = gen[:model_identifier]
|
461
|
+
@model_display = gen[:model_display]
|
462
|
+
|
463
|
+
# usage
|
464
|
+
@capacity_mb = gen[:capacity_mb]
|
465
|
+
@available_mb = gen[:available_mb]
|
466
|
+
@percentage_used = gen[:percentage_used]
|
467
|
+
@battery_level = gen[:battery_level]
|
468
|
+
|
469
|
+
# network
|
470
|
+
@bluetooth_mac_address = gen[:bluetooth_mac_address]
|
471
|
+
@wifi_mac_address = gen[:wifi_mac_address]
|
472
|
+
@sim_phone_number = gen[:phone_number]
|
473
|
+
@ip_address = gen[:ip_address]
|
474
|
+
|
475
|
+
# timestamps
|
476
|
+
@initial_entry_date = JSS.epoch_to_time gen[:initial_entry_date_epoch]
|
477
|
+
@last_backup_time = JSS.epoch_to_time gen[:last_backup_time_epoch]
|
478
|
+
@last_cloud_backup_date = JSS.epoch_to_time gen[:last_cloud_backup_date_epoch]
|
479
|
+
@last_inventory_update = JSS.epoch_to_time gen[:last_inventory_update_epoch]
|
480
|
+
@last_enrollment = JSS.epoch_to_time gen[:last_enrollment_epoch]
|
481
|
+
|
482
|
+
# subsets
|
483
|
+
@mobile_device_groups = @init_data[:mobile_device_groups]
|
484
|
+
@network = @init_data[:network]
|
485
|
+
@extension_attributes = @init_data[:extension_attributes]
|
486
|
+
@certificates = @init_data[:certificates]
|
487
|
+
@configuration_profiles = @init_data[:configuration_profiles]
|
488
|
+
@provisioning_profiles = @init_data[:provisioning_profiles]
|
489
|
+
@security = @init_data[:security]
|
490
|
+
@applications = @init_data[:applications]
|
843
491
|
else
|
844
|
-
|
492
|
+
@udid = args[:udid]
|
493
|
+
@serial_number = args[:serial_number]
|
494
|
+
@asset_tag = args[:asset_tag]
|
845
495
|
end
|
846
|
-
end
|
496
|
+
end # initialize
|
847
497
|
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
#
|
852
|
-
def pending_managed_apps
|
853
|
-
managed_app_history[:pending]
|
498
|
+
def name=(new_name)
|
499
|
+
super
|
500
|
+
@needs_mdm_name_change = true if managed? && supervised?
|
854
501
|
end
|
855
502
|
|
856
|
-
# An array of data about failed managed app installs
|
857
|
-
#
|
858
|
-
# @return [Array<Hash>] The name: and version: of each failed app install.
|
859
503
|
#
|
860
|
-
def
|
861
|
-
|
504
|
+
def serial_number=(new_val)
|
505
|
+
return nil if new_val == @serial_number
|
506
|
+
@serial_number = new_val.empty? ? new_val : JSS::Validate.unique_identifier(self.class, :serial_number, new_val, api: api)
|
507
|
+
@need_to_update = true
|
862
508
|
end
|
863
509
|
|
864
|
-
# The audits subset of the full history
|
865
|
-
# The history of 'auditable' events.
|
866
510
|
#
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
511
|
+
def udid=(new_val)
|
512
|
+
return nil if new_val == @udid
|
513
|
+
@udid = new_val.empty? ? new_val : JSS::Validate.unique_identifier(self.class, :udid, new_val, api: api)
|
514
|
+
@need_to_update = true
|
871
515
|
end
|
872
516
|
|
873
|
-
# The ebooks subset of the full history
|
874
|
-
#
|
875
|
-
# @return [Hash] Keys are :installed, :pending, and :failed
|
876
|
-
# See #installed_managed_ebooks, #pending_managed_ebooks and
|
877
|
-
# #failed_managed_ebooks
|
878
517
|
#
|
879
|
-
def
|
880
|
-
|
518
|
+
def asset_tag=(new_val)
|
519
|
+
return nil if @asset_tag == new_val
|
520
|
+
new_val.strip!
|
521
|
+
@asset_tag = new_val
|
522
|
+
@need_to_update = true
|
881
523
|
end
|
882
524
|
|
883
|
-
# The ebooks that have been installed via MDM
|
884
|
-
#
|
885
|
-
# @param from[Symbol] :in_house, :ibookstore, or :all.
|
886
|
-
# Defaults to :all
|
887
|
-
#
|
888
|
-
# @return [Hash{Array<Hash>}] When from = :all, all three sources.
|
889
525
|
#
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
case from
|
896
|
-
when :all
|
897
|
-
all
|
898
|
-
when :in_house
|
899
|
-
all[:inhouse]
|
900
|
-
when :ibookstore
|
901
|
-
all[:ibookstore]
|
902
|
-
else
|
903
|
-
raise JSS::InvalidDataError, "Unknown ebook source: '#{from}'"
|
904
|
-
end
|
905
|
-
end
|
906
|
-
|
907
|
-
# Mananged ebooks pending installation
|
908
|
-
#
|
909
|
-
# @return [Array<Hash>] The pending ebooks
|
910
|
-
#
|
911
|
-
def pending_managed_ebooks
|
912
|
-
managed_ebook_history[:pending]
|
913
|
-
end
|
914
|
-
|
915
|
-
# Mananged ebooks tha failed installation
|
916
|
-
#
|
917
|
-
# @return [Array<Hash>] The failed ebook installs
|
918
|
-
#
|
919
|
-
def failed_managed_ebooks
|
920
|
-
managed_ebook_history[:failed]
|
526
|
+
def update
|
527
|
+
super
|
528
|
+
return unless @needs_mdm_name_change
|
529
|
+
set_device_mame @name if managed? && supervised?
|
530
|
+
@needs_mdm_name_change = false
|
921
531
|
end
|
922
532
|
|
923
|
-
|
924
|
-
# Aliases
|
925
|
-
alias battery_percent battery_level
|
926
|
-
alias managed? managed
|
927
|
-
alias sn serial_number
|
928
|
-
alias serialnumber serial_number
|
929
|
-
|
930
|
-
alias noop blank_push
|
931
|
-
alias send_blank_push blank_push
|
932
|
-
alias recon update_inventory
|
933
|
-
alias lock device_lock
|
934
|
-
alias lock_device device_lock
|
935
|
-
alias erase erase_device
|
936
|
-
alias wipe erase_device
|
937
|
-
alias unmanage unmanage_device
|
938
|
-
alias make_unmanaged unmanage_device
|
939
|
-
|
940
533
|
# private methods
|
941
534
|
##############################
|
942
535
|
|
@@ -945,12 +538,16 @@ module JSS
|
|
945
538
|
def rest_xml
|
946
539
|
doc = REXML::Document.new APIConnection::XML_HEADER
|
947
540
|
md = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
|
541
|
+
general = md.add_element('general')
|
542
|
+
general.add_element('name').text = @name
|
543
|
+
general.add_element('udid').text = @udid
|
544
|
+
general.add_element('serial_number').text = @serial_number
|
545
|
+
general.add_element('asset_tag').text = @asset_tag
|
948
546
|
|
949
|
-
md << ext_attr_xml if
|
950
|
-
|
547
|
+
md << ext_attr_xml if unsaved_eas?
|
951
548
|
md << location_xml if has_location?
|
952
549
|
md << purchasing_xml if has_purchasing?
|
953
|
-
|
550
|
+
add_site_to_xml doc
|
954
551
|
doc.to_s
|
955
552
|
end
|
956
553
|
|