Class: JSS::MobileDeviceApplication

Inherits:
APIObject show all
Includes:
Categorizable, Creatable, Scopable, SelfServable, Sitable, Updatable, Uploadable, VPPable
Defined in:
lib/jss/api_object/mobile_device_application.rb,
lib/jss.rb

Overview

A Mobile Device Application in the JSS

Constant Summary collapse

RSRC_BASE =

The base for REST resources of this class

'mobiledeviceapplications'.freeze
RSRC_LIST_KEY =

the hash key used for the JSON list output of all objects in the JSS

:mobile_device_applications
RSRC_OBJECT_KEY =

The hash key used for the JSON object output. It’s also used in various error messages

:mobile_device_application
VALID_DATA_KEYS =

these keys, as well as :id and :name, are present in valid API JSON data for this class

[:internal_app].freeze
SCOPE_TARGET_KEY =

See JSS::Scopable

:mobile_devices
UPLOAD_TYPES =

see JSS::Uploadable

{
  icon: :mobiledeviceapplicationsicon,
  app: :mobiledeviceapplicationsipa,
  attachment: :mobiledeviceapplications
}.freeze
OTHER_LOOKUP_KEYS =

see JSS::APIObject

{
  bundleid: {rsrc_id: :bundleid, list: :all_bundle_ids},
  bundle_id: {rsrc_id: :bundleid, list: :all_bundle_ids}
}.freeze
OBJECT_HISTORY_OBJECT_TYPE =

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

23
SITE_SUBSET =

Where is the Site data in the API JSON?

:general

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ MobileDeviceApplication

See JSS::APIObject#initialize



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/jss/api_object/mobile_device_application.rb', line 189

def initialize(args)
  super
  general = @init_data[:general]
  @display_name = general[:display_name]
  @description = general[:description]
  @bundle_id = general[:bundle_id] # TODO: does this get set automatically when uploading a .ipa?
  @version = general[:version] # TODO: does this get set automatically when uploading a .ipa?
  @ipa = general[:ipa]
  @provisioning_profile = general[:provisioning_profile]
  @url = general[:url]
  @itunes_store_url = general[:itunes_store_url]
  @make_available_after_install = general[:make_available_after_install]
  @itunes_country_region = general[:itunes_country_region]
  @itunes_sync_time = general[:itunes_sync_time]
  @deploy_as_managed_app = general[:deploy_as_managed_app]
  @remove_app_when_mdm_profile_is_removed = general[:remove_app_when_mdm_profile_is_removed]
  @prevent_backup_of_app_data = general[:prevent_backup_of_app_data]
  @keep_description_and_icon_up_to_date = general[:keep_description_and_icon_up_to_date]
  @free = general[:free]
  @take_over_management = general[:take_over_management]
  @host_externally = general[:host_externally]
  @external_url = general[:external_url]
  @configuration_prefs = @init_data[:app_configuration][:preferences]
end

Instance Attribute Details

#assign_vpp_device_based_licensesBoolean Also known as: vpp_device_based? Originally defined in module VPPable

Returns:

  • (Boolean)

#bundle_idString (readonly)

Returns e.g. com.company.appname.

Returns:

  • (String)

    e.g. com.company.appname



119
120
121
# File 'lib/jss/api_object/mobile_device_application.rb', line 119

def bundle_id
  @bundle_id
end

#configuration_prefsString

Returns 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.

Returns:

  • (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.



180
181
182
# File 'lib/jss/api_object/mobile_device_application.rb', line 180

def configuration_prefs
  @configuration_prefs
end

#deploy_as_managed_appBoolean

Returns Should this app be mananged?.

Returns:

  • (Boolean)

    Should this app be mananged?



150
151
152
# File 'lib/jss/api_object/mobile_device_application.rb', line 150

def deploy_as_managed_app
  @deploy_as_managed_app
end

#descriptionString

Returns:



116
117
118
# File 'lib/jss/api_object/mobile_device_application.rb', line 116

def description
  @description
end

#display_nameString

Returns The user-facing name (i.e. in self service).

Returns:

  • (String)

    The user-facing name (i.e. in self service)



113
114
115
# File 'lib/jss/api_object/mobile_device_application.rb', line 113

def display_name
  @display_name
end

#external_urlString

Returns If :host_externally is true, the URL for the app.

Returns:

  • (String)

    If :host_externally is true, the URL for the app



175
176
177
# File 'lib/jss/api_object/mobile_device_application.rb', line 175

def external_url
  @external_url
end

#freeBoolean Also known as: free?

Returns is this a free app?.

Returns:

  • (Boolean)

    is this a free app?



164
165
166
# File 'lib/jss/api_object/mobile_device_application.rb', line 164

def free
  @free
end

#host_externallyBoolean

Returns Does the app itself come from outside the JSS?.

Returns:

  • (Boolean)

    Does the app itself come from outside the JSS?



172
173
174
# File 'lib/jss/api_object/mobile_device_application.rb', line 172

def host_externally
  @host_externally
end

#iconJSS::Icon? Also known as: self_service_icon Originally defined in module SelfServable

Returns The icon used in self-service.

Returns:

  • (JSS::Icon, nil)

    The icon used in self-service

#in_self_serviceBoolean (readonly) Also known as: in_self_service? Originally defined in module SelfServable

Returns Is this thing available in Self Service?.

Returns:

  • (Boolean)

    Is this thing available in Self Service?

#internal_appBoolean (readonly)

Returns:

  • (Boolean)


125
126
127
# File 'lib/jss/api_object/mobile_device_application.rb', line 125

def internal_app
  @internal_app
end

#ipaHash (readonly)

Returns The .ipa file info.

Returns:

  • (Hash)

    The .ipa file info



128
129
130
# File 'lib/jss/api_object/mobile_device_application.rb', line 128

def ipa
  @ipa
end

#itunes_country_regionString (readonly)

Returns The app’s country/region code in the iTunes store.

Returns:

  • (String)

    The app’s country/region code in the iTunes store



144
145
146
# File 'lib/jss/api_object/mobile_device_application.rb', line 144

def itunes_country_region
  @itunes_country_region
end

#itunes_store_urlString (readonly)

Returns The URL of this item in the iTunes store, if applicable.

Returns:

  • (String)

    The URL of this item in the iTunes store, if applicable



137
138
139
# File 'lib/jss/api_object/mobile_device_application.rb', line 137

def itunes_store_url
  @itunes_store_url
end

#itunes_sync_timeInteger (readonly)

Returns The last time the app and data was synced from iTunes (I think).

Returns:

  • (Integer)

    The last time the app and data was synced from iTunes (I think)



147
148
149
# File 'lib/jss/api_object/mobile_device_application.rb', line 147

def itunes_sync_time
  @itunes_sync_time
end

#keep_description_and_icon_up_to_dateBoolean

Returns should the JSS update the icon and description from the app source?.

Returns:

  • (Boolean)

    should the JSS update the icon and description from the app source?



161
162
163
# File 'lib/jss/api_object/mobile_device_application.rb', line 161

def keep_description_and_icon_up_to_date
  @keep_description_and_icon_up_to_date
end

#make_available_after_installBoolean Also known as: self_service_make_available_after_install

Returns Will this still appear in SelfSvc after installation (I think).

Returns:

  • (Boolean)

    Will this still appear in SelfSvc after installation (I think)



140
141
142
# File 'lib/jss/api_object/mobile_device_application.rb', line 140

def make_available_after_install
  @make_available_after_install
end

#need_to_updateBoolean (readonly) Originally defined in module Updatable

Returns do we have unsaved changes?.

Returns:

  • (Boolean)

    do we have unsaved changes?

#prevent_backup_of_app_dataBoolean

Returns Should this app be able to backup its data when the device does its backups (to icloud or itunes)?.

Returns:

  • (Boolean)

    Should this app be able to backup its data when the device does its backups (to icloud or itunes)?



157
158
159
# File 'lib/jss/api_object/mobile_device_application.rb', line 157

def prevent_backup_of_app_data
  @prevent_backup_of_app_data
end

#provisioning_profileHash (readonly)

Returns The provisioning profile info for this app.

Returns:

  • (Hash)

    The provisioning profile info for this app



131
132
133
# File 'lib/jss/api_object/mobile_device_application.rb', line 131

def provisioning_profile
  @provisioning_profile
end

#remaining_vpp_licensesInteger (readonly) Also known as: vpp_licenses_remaining Originally defined in module VPPable

Returns:

  • (Integer)

#remove_app_when_mdm_profile_is_removedBoolean

Returns Should the app be removed when the device is unmanaged?.

Returns:

  • (Boolean)

    Should the app be removed when the device is unmanaged?



153
154
155
# File 'lib/jss/api_object/mobile_device_application.rb', line 153

def remove_app_when_mdm_profile_is_removed
  @remove_app_when_mdm_profile_is_removed
end

#scopeObject Originally defined in module Scopable

Attribtues

#self_service_categoriesArray<Hash> (readonly) Originally defined in module SelfServable

Each Hash has these keys about the category

  • :id => [Integer] the JSS id of the category

  • :name => [String] the name of the category

Most objects also include one or both of these keys:

  • :display_in => [Boolean] should the item be displayed in this category in SSvc? (not MobDevConfProfiles)

  • :feature_in => [Boolean] should the item be featured in this category in SSVC? (macOS targets only)

Returns:

  • (Array<Hash>)

    The categories in which this item should appear in SSvc

#self_service_descriptionString Originally defined in module SelfServable

Returns The verbage that appears in SelfSvc for this item.

Returns:

  • (String)

    The verbage that appears in SelfSvc for this item

#self_service_feature_on_main_pageBoolean Originally defined in module SelfServable

Only applicable to macOS targets

Returns:

  • (Boolean)

    Should this item feature on the main page of SSvc?

#self_service_force_users_to_view_descriptionBoolean Originally defined in module SelfServable

Returns Should an extra window appear before the user can install the item? (OSX SSvc only).

Returns:

  • (Boolean)

    Should an extra window appear before the user can install the item? (OSX SSvc only)

#self_service_install_button_textString Originally defined in module SelfServable

Returns The text label on the install button in SSvc (OSX SSvc only).

Returns:

  • (String)

    The text label on the install button in SSvc (OSX SSvc only)

#self_service_removal_passwordString (readonly) Originally defined in module SelfServable

Returns The password needed for removal, in plain text.

Returns:

  • (String)

    The password needed for removal, in plain text.

#self_service_user_removableSymbol Originally defined in module SelfServable

Returns one of the keys in PROFILE_REMOVAL_BY_USER.

Returns:

  • (Symbol)

    one of the keys in PROFILE_REMOVAL_BY_USER

#take_over_managementBoolean

Returns If the user installs this app on their own, should Jamf take over managing it?.

Returns:

  • (Boolean)

    If the user installs this app on their own, should Jamf take over managing it?



169
170
171
# File 'lib/jss/api_object/mobile_device_application.rb', line 169

def take_over_management
  @take_over_management
end

#total_vpp_licensesInteger (readonly) Also known as: vpp_total_licenses, vpp_license_count Originally defined in module VPPable

Returns:

  • (Integer)

#urlString

Returns The URL for downloading this app.

Returns:

  • (String)

    The URL for downloading this app



134
135
136
# File 'lib/jss/api_object/mobile_device_application.rb', line 134

def url
  @url
end

#used_vpp_licensesInteger (readonly) Also known as: vpp_licenses_used Originally defined in module VPPable

Returns:

  • (Integer)

#versionString (readonly)

Returns:



122
123
124
# File 'lib/jss/api_object/mobile_device_application.rb', line 122

def version
  @version
end

#vpp_admin_account_idInteger (readonly) Originally defined in module VPPable

Returns:

  • (Integer)

#vpp_codesHash (readonly) Originally defined in module VPPable

Returns:

Class Method Details

.all_bundle_ids(refresh = false, api: JSS.api) ⇒ Object

Class Methods



57
58
59
# File 'lib/jss/api_object/mobile_device_application.rb', line 57

def self.all_bundle_ids(refresh = false, api: JSS.api)
  all(refresh, api: api).map { |mda| mda[:bundle_id] }
end

Instance Method Details

#add_self_service_category(new_cat, display_in: true, feature_in: false) ⇒ void Also known as: set_self_service_category, change_self_service_category Originally defined in module SelfServable

This method returns an undefined value.

Add or change one of the categories for this item in self service

Parameters:

  • new_cat (String, Integer)

    the name or id of a category where this object should appear in SelfSvc

  • display_in (Boolean) (defaults to: true)

    should this item appear in the SelfSvc page for the category? Only meaningful in applicable classes

  • feature_in (Boolean) (defaults to: false)

    should this item be featured in the SelfSvc page for the category? Only meaningful in applicable classes. NOTE: this will always be false if display_in is false.

Raises:

#add_to_self_servicevoid Originally defined in module SelfServable

This method returns an undefined value.

Add this object to self service if not already there.

#category=(new_cat) ⇒ void Originally defined in module Categorizable

This method returns an undefined value.

Change the category of this object. Any of the NON_CATEGORIES values will unset the category

Parameters:

  • new_cat (Integer, String)

    The new category

Raises:

#category_assigned?Boolean Also known as: categorized? Originally defined in module Categorizable

Does this object have a category assigned?

Returns:

  • (Boolean)

    Does this object have a category assigned?

#category_idInteger Originally defined in module Categorizable

The id of the category for this object.

Returns:

  • (Integer)

    The id of the category for this object.

#category_nameString Also known as: category Originally defined in module Categorizable

The name of the category for this object. For backward compatibility, this is aliased to just ‘category’

Returns:

  • (String)

    The name of the category for this object.

#category_objectJSS::Category Originally defined in module Categorizable

The JSS::Category instance for this object’s category

Returns:

  • (JSS::Category)

    The JSS::Category instance for this object’s category

#clone(new_name, api: nil) ⇒ APIObject Originally defined in module Creatable

make a clone of this API object, with a new name. The class must be creatable

Parameters:

  • name (String)

    the name for the new object

  • api (JSS::APIConnection) (defaults to: nil)

    the API in which to create the object Defaults to the API used to instantiate this object

Returns:

  • (APIObject)

    An uncreated clone of this APIObject with the given name

Raises:

#create(api: nil) ⇒ Integer Originally defined in module Creatable

Create a new object in the JSS.

Parameters:

  • api (JSS::APIConnection) (defaults to: nil)

    the API in which to create the object Defaults to the API used to instantiate this object

Returns:

  • (Integer)

    the jss ID of the newly created object

Raises:

#evaluate_new_category(new_cat) ⇒ Array<String, Integer> Originally defined in module Categorizable

Given a category name or id, return the name and id TODO: use APIObject.exist? and/or APIObject.valid_id

Parameters:

  • new_cat (String, Integer)

    The name or id of a possible category

Returns:

  • (Array<String, Integer>)

    The matching name and id, which may be nil.

#name=(newname) ⇒ void Originally defined in module Updatable

This method returns an undefined value.

Change the name of this item Remember to #update to push changes to the server.

Parameters:

  • newname (String)

    the new name

Raises:

#parse_scopevoid Originally defined in module Scopable

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Call this during initialization of objects that have a scope and the scope instance will be created from @init_data

#remove_from_self_servicevoid Originally defined in module SelfServable

This method returns an undefined value.

Remove this object from self service if it’s there.

#remove_self_service_category(cat) ⇒ void Originally defined in module SelfServable

This method returns an undefined value.

Remove a category from those for this item in SSvc

Parameters:

  • cat (String, Integer)

    the name or id of the category to remove

#save_ipa(path, overwrite = false) ⇒ void

This method returns an undefined value.

Save the application to a file.

If the path given is an existing directory, the ipa’s current filename will be used, if known.

Parameters:

  • path (Pathname, String)

    The path to which the file should be saved.

  • overwrite (Boolean) (defaults to: false)

    Overwrite the file if it exists? Defaults to false

Raises:



403
404
405
406
407
408
409
410
411
# File 'lib/jss/api_object/mobile_device_application.rb', line 403

def save_ipa(path, overwrite = false)
  return nil unless @ipa[:data]
  path = Pathname.new path
  path = path + @ipa[:name] if path.directory? && @ipa[:name]

  raise JSS::AlreadyExistsError, "The file #{path} already exists" if path.exist? && !overwrite
  path.delete if path.exist?
  path.jss_save Base64.decode64(@ipa[:data])
end

#self_service_payloadSymbol Originally defined in module SelfServable

What does this object deploy to the device via self service?

Returns:

  • (Symbol)

    :profile, :app, or :policy

#self_service_targetsArray<Symbol> Originally defined in module SelfServable

What devices types can get this thing in Self Service

Returns:

  • (Array<Symbol>)

    An array of :macos, :ios, or both.

#should_updatevoid Originally defined in module Scopable

This method returns an undefined value.

When the scope changes, it calls this to tell us that an update is needed.

#site=(new_site) ⇒ void Originally defined in module Sitable

This method returns an undefined value.

Change the site of this object. Any of the NON_SITES values will unset the site

Parameters:

  • new_site (Integer, String)

    The new site

Raises:

#site_assigned?Boolean Originally defined in module Sitable

Does this object have a site assigned?

Returns:

  • (Boolean)

    Does this object have a site assigned?

#site_idInteger Originally defined in module Sitable

The id of the site for this object.

Returns:

  • (Integer)

    The id of the site for this object.

#site_nameString Also known as: site Originally defined in module Sitable

The name of the site for this object. For backward compatibility, this is aliased to just ‘site’

Returns:

  • (String)

    The name of the site for this object.

#site_objectJSS::Site Originally defined in module Sitable

The JSS::Site instance for this object’s site

Returns:

  • (JSS::Site)

    The JSS::Site instance for this object’s site

#unset_categoryvoid Originally defined in module Categorizable

This method returns an undefined value.

Set the category to nothing

#unset_sitevoid Originally defined in module Sitable

This method returns an undefined value.

Set the site to nothing

#updateObject Originally defined in module Scopable

A wrapper around the update method, to try catching RestClient::Conflict 409 errors when we couldn’t verify all ldap users/groups due to lack of ldap connections

#upload(type, local_file) ⇒ String Originally defined in module Uploadable

Upload a file to the JSS via the REST Resource of the object to which this module is mixed in.

Parameters:

  • type (Symbol)

    the type of upload happening. Must be one of the keys defined in the class’s UPLOAD_TYPES Hash.

  • local_file (String, Pathname)

    String or Pathname pointing to the locally-readable file to be uploaded.

Returns:

  • (String)

    The xml response from the server.

Raises:

#upload_ipa(path) ⇒ void

This method returns an undefined value.

Upload a new app .ipa file

Parameters:



419
420
421
422
423
# File 'lib/jss/api_object/mobile_device_application.rb', line 419

def upload_ipa(path)
  new_ipa = Pathname.new path
  upload(:app, new_icon)
  refresh_ipa
end

#user_removable?Boolean? Originally defined in module SelfServable

Can this thing be removed by the user?

Returns:

  • (Boolean, nil)

    nil means ‘not applicable’