class Jamf::MobileDeviceApplication

A Mobile Device Application in the JSS

Constants

CATEGORY_DATA_TYPE

How is the category stored in the API data?

CATEGORY_SUBSET

Where is the Category in the API JSON?

OBJECT_HISTORY_OBJECT_TYPE

the object type for this object in the object history table. See {APIObject#add_object_history_entry}

OS_TYPES

possible values for os_type

OTHER_LOOKUP_KEYS

see Jamf::APIObject

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

SCOPE_TARGET_KEY

See Jamf::Scopable

SITE_SUBSET

Where is the Site data in the API JSON?

UPLOAD_TYPES

see Jamf::Uploadable

Attributes

auto_update?[R]

@return [Boolean] Should this app auto-update on devices?

bundle_id[R]

@return [String] e.g. com.company.appname

configuration_prefs[R]

@return [String] Pre-configuration data for installing the app.

Currently there's only one key in the :configuration hash, :preferences,
which contains a plist <dict> element with config data.
deploy_as_managed_app[R]

@return [Boolean] Should this app be mananged?

description[R]

@return [String]

display_name[R]

@return [String] The user-facing name (i.e. in self service)

external_url[R]

@return [String] If :host_externally is true, the URL for the app

free[R]

@return [Boolean] is this a free app?

free?[R]

@return [Boolean] is this a free app?

host_externally[R]

@return [Boolean] Does the app itself come from outside the JSS?

internal_app[R]

@return [Boolean]

ipa[R]

@return [Hash] The .ipa file info

itunes_country_region[R]

@return [String] The app’s country/region code in the iTunes store

itunes_store_url[R]

@return [String] The URL of this item in the iTunes store, if applicable

itunes_sync_time[R]

@return [Integer] The last time the app and data was synced from iTunes (I think)

keep_app_updated_on_devices[R]

@return [Boolean] Should this app auto-update on devices?

keep_description_and_icon_up_to_date[R]

@return [Boolean] should the JSS update the icon and description from the app

source?
make_available_after_install[R]

@return [Boolean] Will this still appear in SelfSvc after installation (I think)

os_type[R]

@return [String] Is this an iOS or tvOS app?

prevent_backup_of_app_data[R]

@return [Boolean] Should this app be able to backup its data when the device

does its backups (to icloud or itunes)?
provisioning_profile[R]

@return [Hash] The provisioning profile info for this app

remove_app_when_mdm_profile_is_removed[R]

@return [Boolean] Should the app be removed when the device is unmanaged?

self_service_make_available_after_install[R]

@return [Boolean] Will this still appear in SelfSvc after installation (I think)

take_over_management[R]

@return [Boolean] If the user installs this app on their own, should Jamf

take over managing it?
url[R]

@return [String] The URL for downloading this app

version[R]

@return [String]

Public Class Methods

new(**args) click to toggle source

See Jamf::APIObject#initialize

Calls superclass method Jamf::APIObject::new
    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
197 def initialize(**args)
198   super
199   general = @init_data[:general]
200   @display_name = general[:display_name]
201   @description = general[:description]
202   @bundle_id = general[:bundle_id]
203   @version = general[:version]
204   @ipa = general[:ipa]
205   @os_type = general[:os_type]
206   @provisioning_profile = general[:provisioning_profile]
207   @url = general[:url]
208   @itunes_store_url = general[:itunes_store_url]
209   @make_available_after_install = general[:make_available_after_install]
210   @itunes_country_region = general[:itunes_country_region]
211   @itunes_sync_time = general[:itunes_sync_time]
212   @deploy_as_managed_app = general[:deploy_as_managed_app]
213   @keep_app_updated_on_devices = general[:keep_app_updated_on_devices]
214   @remove_app_when_mdm_profile_is_removed = general[:remove_app_when_mdm_profile_is_removed]
215   @prevent_backup_of_app_data = general[:prevent_backup_of_app_data]
216   @keep_description_and_icon_up_to_date = general[:keep_description_and_icon_up_to_date]
217   @free = general[:free]
218   @take_over_management = general[:take_over_management]
219   @host_externally = general[:host_externally]
220   @external_url = general[:external_url]
221   @configuration_prefs = @init_data[:app_configuration][:preferences]
222 end

Public Instance Methods

auto_update=(new_val)
bundle_id=(new_val) click to toggle source

Sets the bundle_id (only usable if you are hosting the .ipa externally)

@param new_val the bundle id

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
426 def bundle_id=(new_val)
427   unless @host_externally
428     raise 'Bundle IDs are set automatically from the .ipa file when hosted on your own Jamf-defined distribution point (i.e. #host_externally is false)'
429   end
430 
431   return if new_val == @bundle_id
432 
433   @bundle_id = new_val
434   @need_to_update = true
435 end
configuration_prefs=(new_val) click to toggle source

Set the configuration prefs for this app. The value must be a <dict> element from a plist

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
472 def configuration_prefs=(new_val)
473   return nil if new_val == @configuration_prefs
474 
475   @configuration_prefs = new_val
476   @need_to_update = true
477 end
deploy_as_managed_app=(new_val) click to toggle source

Set whether or not this app should be deployed as managed

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
308 def deploy_as_managed_app=(new_val)
309   return nil if new_val == @deploy_as_managed_app
310   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
311 
312   @deploy_as_managed_app = new_val
313   @need_to_update = true
314 end
description=(new_val) click to toggle source

Set the description

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
249 def description=(new_val)
250   return nil if new_val.to_s == @description
251 
252   @description = new_val.to_s
253   @need_to_update = true
254 end
display_name=(new_val) click to toggle source

Set the display_name

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
236 def display_name=(new_val)
237   return nil if new_val.to_s == @display_name
238 
239   @display_name = new_val.to_s
240   @need_to_update = true
241 end
external_url=(new_val) click to toggle source

Set the url to use for the app if host_externally is true

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
458 def external_url=(new_val)
459   return nil if new_val == @external_url
460 
461   @external_url = new_val
462   @need_to_update = true
463 end
free=(new_val) click to toggle source

Set whether or not this is a free app

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
380 def free=(new_val)
381   return nil if new_val == @free
382   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
383 
384   @free = new_val
385   @need_to_update = true
386 end
host_externally=(new_val) click to toggle source

Set whether or not this app’s .ipa is hosted outside the Jamf server

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
443 def host_externally=(new_val)
444   return if new_val == @host_externally
445 
446   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
447 
448   @host_externally = new_val
449   @need_to_update = true
450 end
keep_app_updated_on_devices=(new_val) click to toggle source

Set whether or not this app should be auto-updated on devices

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
322 def keep_app_updated_on_devices=(new_val)
323   return nil if new_val == @keep_app_updated_on_devices
324   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
325 
326   @keep_app_updated_on_devices = new_val
327   @need_to_update = true
328 end
Also aliased as: auto_update=
keep_description_and_icon_up_to_date=(new_val) click to toggle source

Set whether or not the jss should update info about this app from the app store

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
366 def keep_description_and_icon_up_to_date=(new_val)
367   return nil if new_val == @keep_description_and_icon_up_to_date
368   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
369 
370   @keep_description_and_icon_up_to_date = new_val
371   @need_to_update = true
372 end
make_available_after_install=(new_val) click to toggle source

Set whether or not this app should be available in Self Service after being installed. (e.g. for removal)

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
293 def make_available_after_install=(new_val)
294   return nil if new_val == @make_available_after_install
295   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
296 
297   @make_available_after_install = new_val
298   @need_to_update = true
299 end
os_type=(new_val) click to toggle source

Set the os type

@param new_val[Symbol, String] a key or value from OS_TYPES

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
262 def os_type=(new_val)
263   new_val = OS_TYPES[new_val] if new_val.is_a? Symbol
264 
265   raise Jamf::InvalidDataError, "Unknown os_type, must be one of #{OS_TYPES.keys.join ', '}" unless OS_TYPES.values.include?(new_val)
266 
267   return if new_val == @os_type
268 
269   @os_type = new_val
270   @need_to_update = true
271 end
pretty_print_instance_variables() click to toggle source

Remove the various cached data from the instance_variables used to create pretty-print (pp) output.

@return [Array] the desired instance_variables

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
522 def pretty_print_instance_variables
523   vars = super
524   vars.delete :@ipa
525   vars
526 end
prevent_backup_of_app_data=(new_val) click to toggle source

Set whether or not the device should back up this app’s data

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
352 def prevent_backup_of_app_data=(new_val)
353   return nil if new_val == @prevent_backup_of_app_data
354   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
355 
356   @prevent_backup_of_app_data = new_val
357   @need_to_update = true
358 end
remove_app_when_mdm_profile_is_removed=(new_val) click to toggle source

Set whether or not this app should be removed when the device is unmanaged

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
338 def remove_app_when_mdm_profile_is_removed=(new_val)
339   return nil if new_val == @remove_app_when_mdm_profile_is_removed
340   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
341 
342   @remove_app_when_mdm_profile_is_removed = new_val
343   @need_to_update = true
344 end
save_ipa(path, overwrite = false) click to toggle source

Save the application to a file.

@param path[Pathname, String] The path to which the file should be saved. If the path given is an existing directory, the ipa’s current filename will be used, if known.

@param overwrite Overwrite the file if it exists? Defaults to false

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
489 def save_ipa(path, overwrite = false)
490   return nil unless @ipa[:data]
491 
492   path = Pathname.new path
493   path += @ipa[:name] if path.directory? && @ipa[:name]
494 
495   raise Jamf::AlreadyExistsError, "The file #{path} already exists" if path.exist? && !overwrite
496 
497   path.delete if path.exist?
498   path.jss_save Base64.decode64(@ipa[:data])
499 end
self_service_make_available_after_install=(new_val)
take_over_management=(new_val) click to toggle source

Set whether or not Jamf should manage this app even if the user installed it on their own.

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
395 def take_over_management=(new_val)
396   return nil if new_val == @take_over_management
397   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
398 
399   @take_over_management = new_val
400   @need_to_update = true
401 end
upload_ipa(path, force_ipa_upload: false) click to toggle source

Upload a new app .ipa file

@param path[String, Pathname] The path to the .ipa file to upload

@param force_ipa_upload Should the server upload the .ipa file to

JCDS or AWS if such are confgured for use?

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
510 def upload_ipa(path, force_ipa_upload: false)
511   new_ipa = Pathname.new path
512   upload(:app, new_ipa, force_ipa_upload: force_ipa_upload)
513   refresh_ipa
514 end
url=(new_val) click to toggle source

Set the url

@param new_val The new value

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
279 def url=(new_val)
280   return nil if new_val == @url
281 
282   @url = new_val
283   @need_to_update = true
284 end
version=(new_val) click to toggle source

Sets the version (only usable if you are hosting the .ipa externally)

@param new_val the version

@return [void]

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
409 def version=(new_val)
410   unless @host_externally
411     raise 'Versions are set automatically from the .ipa file when hosted on your own Jamf-defined distribution point (i.e. #host_externally is false)'
412   end
413 
414   return if new_val == @version
415 
416   @version = new_val
417   @need_to_update = true
418 end

Private Instance Methods

refresh_ipa() click to toggle source

Re-read the ipa data from the API.

@return [Type] description_of_returned_object

    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
536 def refresh_ipa
537   return nil unless @in_jss
538 
539   fresh_data = @cnx.c_get(@rest_rsrc)[self.class::RSRC_OBJECT_KEY]
540   @ipa = fresh_data[:general][:ipa]
541 end
rest_xml() click to toggle source
    # File lib/jamf/api/classic/api_objects/mobile_device_application.rb
543 def rest_xml
544   doc = REXML::Document.new Jamf::Connection::XML_HEADER
545   obj = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
546   gen = obj.add_element 'general'
547   gen.add_element('name').text = @display_name
548   gen.add_element('display_name').text = @display_name
549   gen.add_element('description').text = @description
550   gen.add_element('os_type').text = @os_type
551   gen.add_element('url').text = @url
552   gen.add_element('make_available_after_install').text = @make_available_after_install
553   gen.add_element('deploy_as_managed_app').text = @deploy_as_managed_app
554   gen.add_element('remove_app_when_mdm_profile_is_removed').text = @remove_app_when_mdm_profile_is_removed
555   gen.add_element('prevent_backup_of_app_data').text = @prevent_backup_of_app_data
556   gen.add_element('keep_app_updated_on_devices').text = @keep_app_updated_on_devices
557   gen.add_element('keep_description_and_icon_up_to_date').text = @keep_description_and_icon_up_to_date
558   gen.add_element('free').text = @free
559   gen.add_element('take_over_management').text = @take_over_management
560   gen.add_element('host_externally').text = @host_externally
561   gen.add_element('bundle_id').text = @bundle_id if @host_externally
562   gen.add_element('version').text = @version if @host_externally
563   gen.add_element('external_url').text = @external_url
564   config = gen.add_element('configuration')
565   config.add_element('preferences').text = @configuration_prefs
566   obj << @scope.scope_xml
567   add_category_to_xml doc
568   add_self_service_xml doc
569   add_site_to_xml doc
570   add_vpp_xml doc
571   doc.to_s
572 end