Class: Jamf::MobileDevice
- Inherits:
-
CollectionResource
- Object
- JSONObject
- Resource
- CollectionResource
- Jamf::MobileDevice
- Extended by:
- UnCreatable, UnDeletable
- Includes:
- Extendable, Locatable, Referable
- Defined in:
- lib/jamf/api/resources/collection_resources/mobile_device.rb
Overview
A mobile device in the JSS
Constant Summary collapse
- IOS =
Class Constants
'ios'.freeze
- APPLETV =
'appleTv'.freeze
- ANDROID =
'android'.freeze
- UNKNOWN =
'unknown'.freeze
- IPHONE =
'iPhone'.freeze
- IPOD =
'iPod'.freeze
- IPAD =
'iPad'.freeze
- TYPES =
The enum for the ‘type’ attribute
[ IOS, APPLETV, ANDROID, UNKNOWN ].freeze
- APPLE_TYPES =
[IOS, APPLETV].freeze
- RSRC_PATH =
'/inventory/obj/mobileDevice'.freeze
- UPDATE_RESOURCE =
{ method: :post, path_suffix: 'update' }.freeze
- OBJECT_MODEL =
{ # @!attribute [r] id # @return [Integer] id: { class: :integer, identifier: :primary, readonly: true }, # @!attribute name # @param [String] # @return [String] name: { class: :string }, # @!attribute [r] serialNumber # @return [String] serialNumber: { class: :string, identifier: true, readonly: true }, # @!attribute [r] wifiMacAddress # @return [String] wifiMacAddress: { class: :string, identifier: true, readonly: true }, # @!attribute [r] udid # @return [String] udid: { class: :string, identifier: true, readonly: true }, # @!attribute [r] phoneNumber # @return [String] phoneNumber: { class: :string, identifier: true, readonly: true }, # @!attribute [r] model # @return [String] model: { class: :string, readonly: true }, # @!attribute [r] modelIdentifier # @return [String] modelIdentifier: { class: :string, readonly: true }, # @!attribute username # Has custom setter, is part of Location in Details # @param [String] # @return [String] username: { class: :string, readonly: true }, # TODO: Will jamf give us isManaged or isSupervised? # in the non-detail data? # @!attribute [r] isManaged # @return [Boolean] # isManaged: { # class: :boolean, # readonly: true # }, # @!attribute [r] type # @return [Symbol] type: { class: :string, readonly: true, enum: Jamf::MobileDevice::TYPES } }.freeze
Instance Attribute Summary collapse
- #id ⇒ Integer readonly
- #isManaged ⇒ Boolean readonly
- #model ⇒ String readonly
- #modelIdentifier ⇒ String readonly
- #name ⇒ String
- #phoneNumber ⇒ String readonly
- #serialNumber ⇒ String readonly
- #type ⇒ Symbol readonly
- #udid ⇒ String readonly
-
#username ⇒ String
Has custom setter, is part of Location in Details.
- #wifiMacAddress ⇒ String readonly
Class Method Summary collapse
-
.all_androids(refresh: false, cnx: Jamf.cnx) ⇒ Array<Hash>
The list of all Androids.
-
.all_appleTvs(refresh: false, cnx: Jamf.cnx) ⇒ Array<Hash>
The list of all AppleTVs.
-
.all_ipads(refresh: false, cnx: Jamf.cnx) ⇒ Array<Hash>
The list of all iPads.
-
.all_iphones(refresh: false, cnx: Jamf.cnx) ⇒ Array<Hash>
The list of all iPhones.
-
.all_ipods(refresh: false, cnx: Jamf.cnx) ⇒ Array<Hash>
The list of all iPods.
- .creatable? ⇒ Boolean extended from UnCreatable
- .deletable? ⇒ Boolean extended from UnDeletable
Instance Method Summary collapse
-
#clear_unsaved_changes ⇒ Object
clear changes for details as well as top.
-
#details ⇒ Object
Fetch the details as needed.
- #ext_attr_names ⇒ Object included from Extendable
-
#ext_attrs ⇒ Object
included
from Extendable
The Array of extensionAttributes converted to a Hash of ‘Name’ => value.
- #ext_attrs_clear_unsaved_changes ⇒ Object included from Extendable
- #ext_attrs_to_jamf ⇒ Object included from Extendable
- #ext_attrs_to_update ⇒ Object included from Extendable
- #ext_attrs_unsaved_changes ⇒ Object included from Extendable
- #ext_attrs_unsaved_changes? ⇒ Boolean included from Extendable
- #location=(_loc) ⇒ Object included from Locatable
-
#method_missing(meth, *args, &block) ⇒ Object
catches the attributes in the details.
-
#reference ⇒ self.class::GenericReference
included
from Referable
A reference to this object.
-
#respond_to_missing?(meth) ⇒ Boolean
provides respond_to? for the attributes in the details.
- #set_ext_attr(ea_name, new_val) ⇒ Object included from Extendable
-
#to_jamf ⇒ Object
This custom method outputs a ‘UpdateMobileDevice’ object model as defined in the API docs.
-
#type_details ⇒ Object
Return the correct part of the details for the device type.
-
#unsaved_changes ⇒ Object
TODO - needed? Clean up? merge top-level and details changes and type-specific changes.
- #user ⇒ Object included from Locatable
Constructor Details
This class inherits a constructor from Jamf::JSONObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
catches the attributes in the details
292 293 294 295 296 297 298 299 300 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 292 def method_missing(meth, *args, &block) if details.respond_to? meth details.send meth, *args, &block elsif type_details.respond_to? meth type_details.send meth, *args, &block else super end end |
Instance Attribute Details
#id ⇒ Integer (readonly)
|
|
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 78
|
#isManaged ⇒ Boolean (readonly)
|
|
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 148
|
#model ⇒ String (readonly)
|
|
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 125
|
#modelIdentifier ⇒ String (readonly)
|
|
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 132
|
#phoneNumber ⇒ String (readonly)
|
|
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 117
|
#serialNumber ⇒ String (readonly)
|
|
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 93
|
#type ⇒ Symbol (readonly)
|
|
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 157
|
#udid ⇒ String (readonly)
|
|
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 109
|
#username ⇒ String
Has custom setter, is part of Location in Details
|
|
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 139
|
#wifiMacAddress ⇒ String (readonly)
|
|
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 101
|
Class Method Details
.all_androids(refresh: false, cnx: Jamf.cnx) ⇒ Array<Hash>
Returns the list of all Androids.
216 217 218 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 216 def self.all_androids(refresh: false, cnx: Jamf.cnx) all(refresh, cnx: cnx).select { |d| d[:type] == ANDROID } end |
.all_appleTvs(refresh: false, cnx: Jamf.cnx) ⇒ Array<Hash>
Returns the list of all AppleTVs.
211 212 213 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 211 def self.all_appleTvs(refresh: false, cnx: Jamf.cnx) all(refresh, cnx: cnx).select { |d| d[:type] == APPLETV } end |
.all_ipads(refresh: false, cnx: Jamf.cnx) ⇒ Array<Hash>
Returns the list of all iPads.
206 207 208 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 206 def self.all_ipads(refresh: false, cnx: Jamf.cnx) all(refresh, cnx: cnx).select { |d| d[:model].start_with? IPAD } end |
.all_iphones(refresh: false, cnx: Jamf.cnx) ⇒ Array<Hash>
Returns the list of all iPhones.
196 197 198 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 196 def self.all_iphones(refresh: false, cnx: Jamf.cnx) all(refresh, cnx: cnx).select { |d| d[:model].start_with? IPHONE } end |
.all_ipods(refresh: false, cnx: Jamf.cnx) ⇒ Array<Hash>
Returns the list of all iPods.
201 202 203 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 201 def self.all_ipods(refresh: false, cnx: Jamf.cnx) all(refresh, cnx: cnx).select { |d| d[:model].start_with? IPOD } end |
.creatable? ⇒ Boolean Originally defined in module UnCreatable
.deletable? ⇒ Boolean Originally defined in module UnDeletable
Instance Method Details
#clear_unsaved_changes ⇒ Object
clear changes for details as well as top
270 271 272 273 274 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 270 def clear_unsaved_changes @details.clear_unsaved_changes if @details ext_attrs_clear_unsaved_changes @unsaved_changes = {} end |
#details ⇒ Object
Fetch the details as needed
277 278 279 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 277 def details @details ||= MobileDeviceDetails.fetch @id, @cnx end |
#ext_attr_names ⇒ Object Originally defined in module Extendable
#ext_attrs ⇒ Object Originally defined in module Extendable
The Array of extensionAttributes converted to a Hash of ‘Name’ => value
#ext_attrs_clear_unsaved_changes ⇒ Object Originally defined in module Extendable
#ext_attrs_to_jamf ⇒ Object Originally defined in module Extendable
#ext_attrs_to_update ⇒ Object Originally defined in module Extendable
#ext_attrs_unsaved_changes ⇒ Object Originally defined in module Extendable
#ext_attrs_unsaved_changes? ⇒ Boolean Originally defined in module Extendable
#reference ⇒ self.class::GenericReference Originally defined in module Referable
Returns A reference to this object.
#respond_to_missing?(meth) ⇒ Boolean
provides respond_to? for the attributes in the details
303 304 305 306 307 308 309 310 311 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 303 def respond_to_missing?(meth, *) if details.respond_to? meth true elsif type_details.respond_to? meth true else super end end |
#set_ext_attr(ea_name, new_val) ⇒ Object Originally defined in module Extendable
#to_jamf ⇒ Object
This custom method outputs a ‘UpdateMobileDevice’ object model as defined in the API docs
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 232 def to_jamf changes = unsaved_changes data_to_send = {} data_to_send[:name] = changes[:name][:new] if changes[:name] data_to_send[:assetTag] = changes[:assetTag][:new] if changes[:assetTag] data_to_send[:siteId] = changes[:site][:new].id if changes[:site] data_to_send[:location] = details.location.to_jamf if changes[:location] data_to_send[:updatedExtensionAttributes] = ext_attrs_to_jamf if ext_attrs_unsaved_changes? return data_to_send unless APPLE_TYPES.include? @type data_to_send[@type] = { purchasing: details.type_details.purchasing.to_jamf } if changes[:type_changes][:purchasing] data_to_send[APPLETV][:airplayPassword] = changes[:type_changes][:airplayPassword][:new] if @type == APPLETV && changes[:type_changes][:airplayPassword] data_to_send end |
#type_details ⇒ Object
Return the correct part of the details for the device type
283 284 285 286 287 288 289 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 283 def type_details case @type when :ios then details.ios when :appleTv then details.appleTv when :android then details.android end end |
#unsaved_changes ⇒ Object
TODO - needed? Clean up? merge top-level and details changes and type-specific changes
254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/jamf/api/resources/collection_resources/mobile_device.rb', line 254 def unsaved_changes @unsaved_changes ||= {} # name is the only thing at the top-level that isn't readonly if @details changes = details.unsaved_changes changes[:name] = @unsaved_changes[:name] if @unsaved_changes[:name] changes[:ext_attrs] = ext_attrs_unsaved_changes if ext_attrs_unsaved_changes? type_changes = type_details.unsaved_changes changes[:type_changes] = type_changes unless type_changes.empty? else changes = @unsaved_changes end changes end |