lib/jss/api_object/mobile_device.rb in ruby-jss-1.0.4 vs lib/jss/api_object/mobile_device.rb in ruby-jss-1.1.0b1
- old
+ new
@@ -98,22 +98,38 @@
RSRC_OBJECT_KEY = :mobile_device
# Where is the Site data in the API JSON?
SITE_SUBSET = :general
- # these keys, as well as :id and :name, are present in valid API JSON data for this class
- VALID_DATA_KEYS = %i[device_name capacity tethered].freeze
-
- # these keys, as well as :id and :name, can be used to look up objects of this class in the JSS
+ # 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
OTHER_LOOKUP_KEYS = {
- udid: { rsrc_key: :udid, list: :all_udids },
- serialnumber: { rsrc_key: :serialnumber, list: :all_serial_numbers },
- serial_number: { rsrc_key: :serialnumber, list: :all_serial_numbers },
- macaddress: { rsrc_key: :macaddress, list: :all_wifi_mac_addresses },
- mac_address: { rsrc_key: :macaddress, list: :all_wifi_mac_addresses }
+ udid: {
+ aliases: [:uuid, :guid],
+ fetch_rsrc_key: :udid
+ },
+ serial_number: {
+ aliases: [:serialnumber, :sn],
+ fetch_rsrc_key: :serialnumber
+ },
+ wifi_mac_address: {
+ aliases: [
+ :wifi_mac_addresse,
+ :mac_address,
+ :mac_addresse,
+ :macaddress,
+ :macaddresse,
+ :macaddr
+ ],
+ fetch_rsrc_key: :macaddress
+ }
}.freeze
+ NON_UNIQUE_NAMES = true
+
# This class lets us seach for computers
SEARCH_CLASS = JSS::AdvancedMobileDeviceSearch
# This is the class for relevant Extension Attributes
EXT_ATTRIB_CLASS = JSS::MobileDeviceExtensionAttribute
@@ -127,32 +143,12 @@
OBJECT_HISTORY_OBJECT_TYPE = 21
# Class Methods
#####################################
- # @return [Array<String>] all mobiledevice serial_numbers
- def self.all_serial_numbers(refresh = false, api: JSS.api)
- all(refresh, api: api).map { |i| i[:serial_number] }
- end
-
# @return [Array<String>] all mobiledevice phone numbers
def self.all_phone_numbers(refresh = false, api: JSS.api)
all(refresh, api: api).map { |i| i[:phone_number] }.reject(&:empty?)
- end
-
- # @return [Array<String>] all mobiledevice wifi mac addrs
- def self.all_wifi_mac_addresses(refresh = false, api: JSS.api)
- all(refresh, api: api).map { |i| i[:wifi_mac_address] }
- end
-
- # @return [Array<String>] all mobiledevice wifi mac addrs
- def self.all_mac_addresses(refresh = false, api: JSS.api)
- all_wifi_mac_addresses(refresh, api: api)
- end
-
- # @return [Array<String>] all mobiledevice udids
- def self.all_udids(refresh = false, api: JSS.api)
- all(refresh, api: api).map { |i| i[:udid] }
end
# @return [Array<Hash>] the list of all managed mobile devices
def self.all_managed(refresh = false, api: JSS.api)
all(refresh, api: api).select { |d| d[:managed] }