module Jamf::SelfServable

A mix-in module for handling Self Service data for objects in the JSS.

The JSS objects that have Self Service data return it in a :self_service subset, which have somewhat similar data, i.e. a hash with at least these keys:

Config Profiles in self service have this key:

Additionally, items that apper in macOS Slf Svc have these keys:

See the attribute definitions for details of these values and structures.

Including this module in an {APIObject} subclass will give it matching attributes with ‘self_service_’ appended if needed, e.g. {#self_service_feature_on_main_page}

Classes including this module MUST:

IMPORTANT: Since SelfServable also includes #{Jamf::Uploadable}, for uploading icons, see that module for its requirements.

Constants

AUTO_INSTALL
AUTO_INSTALL_OR_PROMPT
DEFAULT_FORCE_TO_VIEW_DESC
DEFAULT_INSTALL_BUTTON_TEXT
DEFAULT_REINSTALL_BUTTON_TEXT
DFT_NOTIFICATION_TYPE
MAKE_AVAILABLE
NOTIFICATION_TYPES
PATCHPOL_AUTO
PATCHPOL_SELF_SERVICE
PROFILE_REMOVAL_BY_USER
SELF_SERVABLE

Constants

SELF_SERVICE_CLASSES

This hash contains the details about the inconsistencies of how Self Service data is dealt with in the API data of the different self-servable classes.

NOTE: The keys are the string versions of the Classes themselves, so that we don’t cause circular dependencies when loading these classes with zeitwerk

- in_self_service_data_path: Array, In the API data hash (the @init_data)
    where to find the value indicicating that a thing is in self service.
    e.g. [:self_service, :use_for_self_service] means
    @init_data[:self_service][:use_for_self_service]

- in_self_service: Object, In the path defined above, what value means
    the thing IS in self service

- not_in_self_service: Object, In the path defined above, what value means
    the thing IS NOT in self service

- self_service_subset: Symbol.  Which key of the init data hash contains
  the self service data. If not defined, its :self_service, but
  PatchPolcies use :user_interaction

- targets: Array<Symbol>, the array contains either :macos, :ios, or both.

- payload: Symbol, The thing that is deployed by self service, one of:
   :policy, :app, :profile, :patchpolicy (ebooks are considered apps)

- can_display_in_categories: Boolean, when adding 'self service categories'
  can the thing be 'displayed in' those categories?

- can_feature_in_categories: Boolean, when adding 'self service categories'
  can the thing be 'featured in' those categories?

- notifications_supported: either nil (not supported), :ssvc_only, or
  :ssvc_and_nctr  NOTE: when notifications are supported for :ssvc_only,
  its due to a bug in the handling of the XML (two separate values are
  using the same XML element tag <notification>) Items that support both
  have a <notifications> subset inside the <self_service> subset

- notification_reminders: if true, supports notification reminders.
  Only true for items that have a <notifications> subset

- url_entity: the 'entity' value used in user-urls for this SSVc item.

It’s unfortunate that this is needed in order to keep all the self service ruby code in this one module.

USER_URL_BASE
USER_URL_EXEC_ACTION
USER_URL_VIEW_ACTION

Attributes

icon[R]

@return [Jamf::Icon, nil] The icon used in self-service

in_self_service[R]

@return [Boolean] Is this thing available in Self Service?

in_self_service?[R]

@return [Boolean] Is this thing available in Self Service?

self_service_categories[R]

@return [Array<Hash>] The categories in which this item should appear in SSvc

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)

self_service_description[R]

@return [String] The verbage that appears in SelfSvc for this item

self_service_dislay_name[R]

@return [String] The name to display in macOS Self Service.

self_service_display_name[R]

@return [String] The name to display in macOS Self Service.

self_service_feature_on_main_page[R]

@return [Boolean] Should this item feature on the main page of SSvc? Only applicable to macOS targets

self_service_force_users_to_view_description[R]

@return [Boolean] Should an extra window appear before the user can install the item? (OSX SSvc only)

self_service_icon[R]

@return [Jamf::Icon, nil] The icon used in self-service

self_service_install_button_text[R]

@return [String] The text label on the install button in SSvc (OSX SSvc only) defaults to ‘Install’

self_service_notification_message[R]

@return [String] The message text of the notification

self_service_notification_subject[R]

@return [String] The subject text of the notification. Defaults to the object name.

self_service_notification_type[R]

@return [Symbol] How should notifications be sent

either :ssvc_only or :ssvc_and_nctr
self_service_notifications_enabled[R]

@return [Boolean] Should jamf send notifications to self service?

self_service_notifications_enabled?[R]

@return [Boolean] Should jamf send notifications to self service?

self_service_reinstall_button_text[R]

@return [String] The text label on the reinstall button in SSvc (OSX SSvc only) defaults to ‘Reinstall’

self_service_reminder_frequency[R]

@return [Integer] How often (in days) should reminders be given

self_service_reminders_enabled[R]

@return [Boolean] Should self service give reminders by displaying the

notification repeatedly?
self_service_reminders_enabled?[R]

@return [Boolean] Should self service give reminders by displaying the

notification repeatedly?
self_service_removal_password[R]

@return [String] The password needed for removal, in plain text.

self_service_user_removable[R]

@return [Symbol] one of the keys in PROFILE_REMOVAL_BY_USER

Public Instance Methods

add_self_service_category(new_cat, display_in: true, feature_in: false) click to toggle source

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

@param new_cat[String, Integer] the name or id of a category where this

object should appear in SelfSvc

@param display_in should this item appear in the SelfSvc page for

the category? Only meaningful in applicable classes

@param feature_in 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.

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
437 def add_self_service_category(new_cat, display_in: true, feature_in: false)
438   new_cat = Jamf::Category.map_all_ids_to(:name, cnx: @cnx)[new_cat] if new_cat.is_a? Integer
439   feature_in = false if display_in == false
440   raise Jamf::NoSuchItemError, "No category '#{new_cat}' in the JSS" unless Jamf::Category.all_names(:refresh, cnx: @cnx).include? new_cat
441 
442   raise Jamf::InvalidDataError, 'display_in must be true or false' unless display_in.jss_boolean?
443 
444   raise Jamf::InvalidDataError, 'feature_in must be true or false' unless feature_in.jss_boolean?
445 
446   new_data = { name: new_cat }
447   new_data[:display_in] = display_in if @self_service_data_config[:can_display_in_categories]
448   new_data[:feature_in] = feature_in if @self_service_data_config[:can_feature_in_categories]
449 
450   # see if this category is already among our categories.
451   idx = @self_service_categories.index { |c| c[:name] == new_cat }
452 
453   if idx
454     @self_service_categories[idx] = new_data
455   else
456     @self_service_categories << new_data
457   end
458 
459   @need_to_update = true
460 end
add_to_self_service() click to toggle source

Add this object to self service if not already there.

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
623 def add_to_self_service
624   return nil unless @self_service_data_config[:in_self_service_data_path]
625   return nil if in_self_service?
626   @in_self_service = true
627   @need_to_update = true
628 end
assign_icon(new_icon)
Alias for: icon=
change_self_service_category(new_cat, display_in: true, feature_in: false)
create() click to toggle source

HACK: ity hack hack… remove when jamf fixes these bugs

Calls superclass method
    # File lib/jamf/api/classic/api_objects/self_servable.rb
677 def create
678   resp = super
679   force_notifications_on if @need_ss_notification_activation_hack
680   resp
681 end
icon=(new_icon) click to toggle source

Set a new Self Service icon for this object.

Since Jamf::Icon objects are read-only, the icon can only be changed by supplying the id number of an icon already existing in the JSS, or a path to a local file, which will be uploaded to the JSS and added to this instance. Uploads take effect immediately, but if an integer is supplied, the change must be sent to the JSS via {#update} or {#create}

@param new_icon[Integer, String, Pathname] The id or path to the new icon.

@return [false, Integer, Pathname] false means no change was made.

    # File lib/jamf/api/classic/api_objects/self_servable.rb
600 def icon=(new_icon)
601   if new_icon.is_a? Integer
602     return if @icon && new_icon == @icon.id
603     validate_icon new_icon
604     @new_icon_id = new_icon
605     @need_to_update = true
606   else
607     unless uploadable? && defined?(self.class::UPLOAD_TYPES) && self.class::UPLOAD_TYPES.key?(:icon)
608       raise Jamf::UnsupportedError, "Class #{self.class} does not support icon uploads."
609     end
610     new_icon = Pathname.new new_icon
611     upload(:icon, new_icon)
612     refresh_icon
613   end # new_icon.is_a? Integer
614   new_icon
615 end
Also aliased as: self_service_icon=, assign_icon
remove_from_self_service() click to toggle source

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

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
634 def remove_from_self_service
635   return nil unless @self_service_data_config[:in_self_service_data_path]
636   return nil unless in_self_service?
637   @in_self_service = false
638   @need_to_update = true
639 end
remove_self_service_category(cat) click to toggle source

Remove a category from those for this item in SSvc

@param cat [String, Integer] the name or id of the category to remove

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
470 def remove_self_service_category(cat)
471   @self_service_categories.reject! { |c| c[:name] == cat || c[:id] == cat }
472   @need_to_update = true
473 end
self_service_description=(new_val) click to toggle source

@param new_val the new discription

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
352 def self_service_description=(new_val)
353   new_val = new_val.strip
354   return if @self_service_description == new_val
355 
356   @self_service_description = new_val
357   @need_to_update = true
358 end
self_service_display_name=(new_val) click to toggle source

@param new_val The display name of the item in SSvc

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
364 def self_service_display_name=(new_val)
365   new_val = new_val.strip
366   return nil if @self_service_display_name == new_val
367   raise Jamf::InvalidDataError, 'Only macOS Self Service items have display names' unless self_service_targets.include? :macos
368   @self_service_display_name = new_val
369   @need_to_update = true
370 end
self_service_execute_url() click to toggle source

@return [String] The url to view this thing in Self Service

    # File lib/jamf/api/classic/api_objects/self_servable.rb
339 def self_service_execute_url
340   return nil unless @self_service_data_config[:url_entity]
341 
342   "#{USER_URL_BASE}#{@self_service_data_config[:url_entity]}&id=#{id}&action=#{USER_URL_EXEC_ACTION}"
343 end
self_service_feature_on_main_page=(new_val) click to toggle source

@param new_val should this appear on the main SelfSvc page?

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
402 def self_service_feature_on_main_page=(new_val)
403   return nil if @self_service_feature_on_main_page == new_val
404   return nil unless @self_service_data_config[:can_feature_in_categories]
405   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
406   @self_service_feature_on_main_page = new_val
407   @need_to_update = true
408 end
self_service_force_users_to_view_description=(new_val) click to toggle source

@param new_val Should the description be shown to users in a new

window before executing the payload?

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
415 def self_service_force_users_to_view_description=(new_val)
416   return nil if @self_service_force_users_to_view_description == new_val
417   raise Jamf::InvalidDataError, 'Only macOS Self Service Items can force users to view description' unless self_service_targets.include? :macos
418   raise Jamf::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
419   @self_service_force_users_to_view_description = new_val
420   @need_to_update = true
421 end
self_service_icon=(new_icon)
Alias for: icon=
self_service_install_button_text=(new_val) click to toggle source

@param new_val the new install button text

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
378 def self_service_install_button_text=(new_val)
379   new_val = new_val.strip
380   return nil if @self_service_install_button_text == new_val
381   raise Jamf::InvalidDataError, 'Only macOS Self Service Items can have custom button text' unless self_service_targets.include? :macos
382   @self_service_install_button_text = new_val
383   @need_to_update = true
384 end
self_service_notification_message=(msg) click to toggle source

@param msg The message text for the notification

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
550 def self_service_notification_message=(msg)
551   msg = msg.strip
552   return if msg == @self_service_notification_message
553   validate_notifications_supported
554   @self_service_notification_message = msg
555   @need_to_update = true
556 end
self_service_notification_subject=(subj) click to toggle source

@param subj The subject text for the notification

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
538 def self_service_notification_subject=(subj)
539   subj = subj.strip
540   return if subj == @self_service_notification_subject
541   validate_notifications_supported
542   @self_service_notification_subject = subj
543   @need_to_update = true
544 end
self_service_notification_type=(type) click to toggle source

How should self service notifications be displayed

@param type A key from SelfServable::NOTIFICATION_TYPES

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
518 def self_service_notification_type=(type)
519   validate_notifications_supported
520 
521   # HACK: Until jamf fixes bugs, you can only set notifications
522   # :off or :ssvc_only. If you want :ssvc_and_nctr, you must
523   # check the checkbox in the web-UI.
524   if @self_service_data_config[:notifications_supported] == :ssvc_only && type != :ssvc_only
525     raise "JAMF BUG: Until Jamf fixes API bugs in #{self.class}, you can only set Self Service notifications to :ssvc_only. Use the WebUI to activate Notification Center notifications"
526   end
527 
528   raise Jamf::InvalidDataError, "type must be one of: :#{NOTIFICATION_TYPES.keys.join ', :'}" unless NOTIFICATION_TYPES.key? type
529 
530   @self_service_notification_type = type
531   @need_to_update = true
532 end
self_service_notifications_enabled=(new_val) click to toggle source

en/disable notifications

@param new_val [Boolean] should we display notifications?

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
504 def self_service_notifications_enabled=(new_val)
505   return if new_val == self_service_notifications_enabled
506   validate_notifications_supported
507   Jamf::Validate.boolean new_val
508   @self_service_notifications_enabled = new_val
509   @need_to_update = true
510 end
self_service_payload() click to toggle source

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

@return [Symbol] :profile, :app, or :policy

    # File lib/jamf/api/classic/api_objects/self_servable.rb
663 def self_service_payload
664   @self_service_data_config[:payload]
665 end
self_service_reinstall_button_text=(new_val) click to toggle source

@param new_val the new reinstall button text

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
390 def self_service_reinstall_button_text=(new_val)
391   new_val = new_val.strip
392   return nil if @self_service_reinstall_button_text == new_val
393   raise Jamf::InvalidDataError, 'Only macOS Self Service Items can have custom button text' unless self_service_targets.include? :macos
394   @self_service_reinstall_button_text = new_val
395   @need_to_update = true
396 end
self_service_reminder_frequency=(days) click to toggle source

set reminder notification frequency

@param new_val How many days between reminder notifications?

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
578 def self_service_reminder_frequency=(days)
579   return if days == self_service_reminder_frequency
580   validate_notification_reminders_supported
581   Jamf::Validate.integer days
582   @self_service_reminder_frequency = days
583   @need_to_update = true
584 end
self_service_reminders_enabled=(new_val) click to toggle source

en/disable reminder notifications

@param new_val [Boolean] should we display reminder notifications?

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
564 def self_service_reminders_enabled=(new_val)
565   return if new_val == self_service_reminders_enabled
566   validate_notification_reminders_supported
567   Jamf::Validate.boolean new_val
568   @self_service_reminders_enabled = new_val
569   @need_to_update = true
570 end
self_service_targets() click to toggle source

What devices types can get this thing in Self Service

@return [Array<Symbol>] An array of :macos, :ios, or both.

    # File lib/jamf/api/classic/api_objects/self_servable.rb
654 def self_service_targets
655   @self_service_data_config[:targets]
656 end
self_service_user_removable=(new_val, pw = @self_service_removal_password) click to toggle source

Set the value for user-removability of profiles, optionally providing a password for removal, on iOS targets.

@param new_val One of the keys of PROFILE_REMOVAL_BY_USER,

:always, :never, or :with_auth

@param pw A new password to use if removable :with_auth

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
485 def self_service_user_removable=(new_val, pw = @self_service_removal_password)
486   new_val, pw = *new_val if new_val.is_a? Array
487   pw = nil unless new_val == :with_auth
488 
489   return if new_val == self_service_user_removable && pw == self_service_removal_password
490 
491   validate_user_removable new_val
492 
493   @self_service_user_removable = new_val
494   @self_service_removal_password = pw
495   @need_to_update = true
496 end
self_service_view_url() click to toggle source

@return [String] The url to view this thing in Self Service

    # File lib/jamf/api/classic/api_objects/self_servable.rb
331 def self_service_view_url
332   return nil unless @self_service_data_config[:url_entity]
333 
334   "#{USER_URL_BASE}#{@self_service_data_config[:url_entity]}&id=#{id}&action=#{USER_URL_VIEW_ACTION}"
335 end
set_self_service_category(new_cat, display_in: true, feature_in: false)
update() click to toggle source

HACK: ity hack hack… remove when jamf fixes these bugs

Calls superclass method
    # File lib/jamf/api/classic/api_objects/self_servable.rb
669 def update
670   resp = super
671   force_notifications_on if @need_ss_notification_activation_hack
672   resp
673 end
user_removable?() click to toggle source

Can this thing be removed by the user?

@return [Boolean, nil] nil means ‘not applicable’

    # File lib/jamf/api/classic/api_objects/self_servable.rb
645 def user_removable?
646   return nil unless self_service_payload == :profile
647   @self_service_user_removable != :never
648 end

Private Instance Methods

add_in_self_service_xml(doc_root) click to toggle source

add the correct XML indicating whether or not we’re even in SSvc

    # File lib/jamf/api/classic/api_objects/self_servable.rb
849 def add_in_self_service_xml(doc_root)
850   return unless @self_service_data_config[:in_self_service_data_path]
851 
852   in_ss_section, in_ss_elem = @self_service_data_config[:in_self_service_data_path]
853 
854   in_ss_value = @in_self_service ? @self_service_data_config[:in_self_service] : @self_service_data_config[:not_in_self_service]
855 
856   in_ss_section_xml = doc_root.elements[in_ss_section.to_s]
857   in_ss_section_xml ||= doc_root.add_element(in_ss_section.to_s)
858   in_ss_section_xml.add_element(in_ss_elem.to_s).text = in_ss_value.to_s
859 end
add_self_service_category_xml(ssvc) click to toggle source

add the xml for self-service categories

    # File lib/jamf/api/classic/api_objects/self_servable.rb
876 def add_self_service_category_xml(ssvc)
877   cats = ssvc.add_element('self_service_categories')
878   return if self_service_categories.empty?
879 
880   self_service_categories.each do |cat|
881     catelem = cats.add_element('category')
882     catelem.add_element('name').text = cat[:name]
883     catelem.add_element('display_in').text = cat[:display_in] if @self_service_data_config[:can_display_in_categories]
884     catelem.add_element('feature_in').text = cat[:feature_in] if @self_service_data_config[:can_feature_in_categories]
885   end
886 end
add_self_service_macos_xml(ssvc) click to toggle source

set macOS settings in ssvc xml

    # File lib/jamf/api/classic/api_objects/self_servable.rb
889 def add_self_service_macos_xml(ssvc)
890   return unless self_service_targets.include? :macos
891 
892   ssvc.add_element('install_button_text').text = self_service_install_button_text if self_service_install_button_text
893   ssvc.add_element('force_users_to_view_description').text = self_service_force_users_to_view_description.to_s
894 
895   return if self.class == Jamf::MacApplication
896 
897   ssvc.add_element('self_service_display_name').text = self_service_display_name if self_service_display_name
898   ssvc.add_element('reinstall_button_text').text = self_service_reinstall_button_text if self_service_reinstall_button_text
899 end
add_self_service_notification_xml(ssvc) click to toggle source

set ssvc notification settings in xml

    # File lib/jamf/api/classic/api_objects/self_servable.rb
903 def add_self_service_notification_xml(ssvc)
904   return unless @self_service_data_config[:notifications_supported]
905 
906   # oldstyle/broken, only sscv notifs
907   if @self_service_data_config[:notifications_supported] == :ssvc_only
908     ssvc.add_element('notification').text = self_service_notifications_enabled.to_s
909     ssvc.add_element('notification_subject').text = self_service_notification_subject if self_service_notification_subject
910     ssvc.add_element('notification_message').text = self_service_notification_message if self_service_notification_message
911     return
912   end
913 
914   # newstyle, 'notifications' subset
915   notif = ssvc.add_element('notifications')
916   notif.add_element('notifications_enabled').text = self_service_notifications_enabled.to_s
917   notif.add_element('notification_type').text = NOTIFICATION_TYPES[self_service_notification_type] if self_service_notification_type
918   notif.add_element('notification_subject').text = self_service_notification_subject if self_service_notification_subject
919   notif.add_element('notification_message').text = self_service_notification_message if self_service_notification_message
920 
921   return unless @self_service_data_config[:notification_reminders]
922 
923   reminds = notif.add_element('reminders')
924   reminds.add_element('notification_reminders_enabled').text = self_service_reminders_enabled.to_s
925   reminds.add_element('notification_reminder_frequency').text = self_service_reminder_frequency.to_s if self_service_reminder_frequency
926 
927 end
add_self_service_profile_xml(ssvc, doc_root) click to toggle source

add the xml specific to profiles

    # File lib/jamf/api/classic/api_objects/self_servable.rb
862 def add_self_service_profile_xml(ssvc, doc_root)
863   return unless self_service_payload == :profile
864 
865   if self_service_targets.include? :ios
866     sec = ssvc.add_element('security')
867     sec.add_element('removal_disallowed').text = PROFILE_REMOVAL_BY_USER[@self_service_user_removable]
868     sec.add_element('password').text = @self_service_removal_password.to_s
869     return
870   end
871   gen = doc_root.elements['general']
872   gen.add_element('user_removable').text = (@self_service_user_removable == :always).to_s
873 end
add_self_service_xml(xdoc) click to toggle source

Add approriate XML for self service data to the XML document for this item.

@param xdoc The XML Document to which we’re adding Self

Service data

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
820 def add_self_service_xml(xdoc)
821   doc_root = xdoc.root
822 
823   # whether or not we're in self service is usually not in the
824   # ssvc subset...
825   add_in_self_service_xml doc_root
826 
827   subset_key = @self_service_data_config[:self_service_subset] || :self_service
828 
829   ssvc = doc_root.add_element subset_key.to_s
830 
831   ssvc.add_element('self_service_description').text = @self_service_description if @self_service_description
832   ssvc.add_element('feature_on_main_page').text = @self_service_feature_on_main_page
833 
834   if @new_icon_id
835     icon = ssvc.add_element('self_service_icon')
836     icon.add_element('id').text = @new_icon_id
837   end
838 
839   add_self_service_category_xml ssvc
840 
841   add_self_service_profile_xml ssvc, doc_root
842 
843   add_self_service_macos_xml ssvc
844 
845   add_self_service_notification_xml ssvc
846 end
force_notifications_on() click to toggle source

HACK: ity hack hack… remove when jamf fixes these bugs

    # File lib/jamf/api/classic/api_objects/self_servable.rb
689     def force_notifications_on
690       xml = <<-ENDXML
691 <#{self.class::RSRC_OBJECT_KEY}>
692   <self_service>
693     <notification>true</notification>
694   </self_service>
695 </#{self.class::RSRC_OBJECT_KEY}>
696       ENDXML
697       @cnx.c_put rest_rsrc, xml
698       @need_ss_notification_activation_hack = nil
699     end
in_self_service_at_init?() click to toggle source

Figure out if this object is in Self Service, from the API initialization data. Alas, how to do it is far from consistent

@return [Boolean]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
747 def in_self_service_at_init?
748   return nil unless @self_service_data_config[:in_self_service_data_path]
749   subsection, key = @self_service_data_config[:in_self_service_data_path]
750   return false unless @init_data[subsection]
751   @init_data[subsection][key] == @self_service_data_config[:in_self_service]
752 end
parse_self_service() click to toggle source

Call this during initialization of objects that have a self_service subset and the self_service attributes will be populated (as primary attributes) from @init_data

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
708 def parse_self_service
709   @self_service_data_config = SELF_SERVICE_CLASSES[self.class.to_s]
710 
711   subset_key = @self_service_data_config[:self_service_subset] ? @self_service_data_config[:self_service_subset] : :self_service
712 
713   ss_data = @init_data[subset_key]
714   ss_data ||= {}
715 
716   @in_self_service = in_self_service_at_init?
717 
718   @self_service_description = ss_data[:self_service_description]
719 
720   @icon = Jamf::Icon.new(ss_data[:self_service_icon]) if ss_data[:self_service_icon]
721 
722   @self_service_feature_on_main_page = ss_data[:feature_on_main_page]
723 
724   @self_service_categories = ss_data[:self_service_categories]
725   @self_service_categories ||= []
726 
727   parse_self_service_profile ss_data
728 
729   return unless self_service_targets.include? :macos
730 
731   # Computers only...
732   @self_service_display_name = ss_data[:self_service_display_name]
733   @self_service_display_name ||= name
734   @self_service_install_button_text = ss_data[:install_button_text]
735   @self_service_reinstall_button_text = ss_data[:reinstall_button_text]
736   @self_service_force_users_to_view_description = ss_data[:force_users_to_view_description]
737 
738   parse_self_service_notifications ss_data
739 end
parse_self_service_notifications(ss_data) click to toggle source

parse incoming ssvc notification settings

    # File lib/jamf/api/classic/api_objects/self_servable.rb
766 def parse_self_service_notifications(ss_data)
767   return unless @self_service_data_config[:notifications_supported]
768 
769   # oldstyle/broken, we need the XML to know if notifications are turned on
770   if @self_service_data_config[:notifications_supported] == :ssvc_only && @in_jss
771     ssrsrc = "#{rest_rsrc}/subset/selfservice"
772     raw_xml = cnx.c_get(ssrsrc, :xml)
773     @self_service_notifications_enabled = raw_xml.include? '<notification>true</notification>'
774     @self_service_notification_type = NOTIFICATION_TYPES.invert[ss_data[:notification]]
775     @self_service_notification_subject = ss_data[:notification_subject]
776     @self_service_notification_message = ss_data[:notification_message]
777     return
778   end
779 
780   # newstyle, 'notifications' subset
781   notif_data = ss_data[:notifications]
782   notif_data ||= {}
783 
784   @self_service_notifications_enabled = notif_data[:notification_enabled]
785   @self_service_notification_type = NOTIFICATION_TYPES.invert[notif_data[:notification_type]]
786   @self_service_notification_type ||= DFT_NOTIFICATION_TYPE
787   @self_service_notification_subject = notif_data[:notification_subject]
788   @self_service_notification_message = notif_data[:notification_message]
789 
790   reminders = notif_data[:reminders]
791   reminders ||= {}
792   @self_service_reminders_enabled = reminders[:notification_reminders_enabled]
793   @self_service_reminder_frequency = reminders[:notification_reminder_frequency]
794 end
parse_self_service_profile(ss_data) click to toggle source

parse incoming ssvc settings for profiles

    # File lib/jamf/api/classic/api_objects/self_servable.rb
755 def parse_self_service_profile(ss_data)
756   return unless self_service_payload == :profile
757   if self_service_targets.include? :ios
758     @self_service_user_removable = PROFILE_REMOVAL_BY_USER[ss_data[:security][:removal_disallowed]]
759     @self_service_removal_password = ss_data[:security][:password]
760     return
761   end
762   @self_service_user_removable =  @init_data[:general][:user_removable]
763 end
refresh_icon() click to toggle source

Re-read the icon data for this object from the API Generally done after uploading a new icon via {#icon=}

@return [void]

    # File lib/jamf/api/classic/api_objects/self_servable.rb
801 def refresh_icon
802   return nil unless @in_jss
803   fresh_data = @cnx.c_get(@rest_rsrc)[self.class::RSRC_OBJECT_KEY]
804   subset_key = @self_service_data_config[:self_service_subset] ? @self_service_data_config[:self_service_subset] : :self_service
805 
806   ss_data = fresh_data[subset_key]
807 
808   icon_data = ss_data[:self_service_icon]
809   @icon = Jamf::Icon.new icon_data
810 end
validate_icon(id) click to toggle source

Raise an error if an icon id is not valid

    # File lib/jamf/api/classic/api_objects/self_servable.rb
939 def validate_icon(id)
940   return nil unless Jamf::DB_CNX.connected?
941   raise Jamf::NoSuchItemError, "No icon with id #{id}" unless Jamf::Icon.all_ids.include? id
942 end
validate_notification_reminders_supported() click to toggle source

Raise an error if notification reminders aren’t supported

    # File lib/jamf/api/classic/api_objects/self_servable.rb
950 def validate_notification_reminders_supported
951   raise Jamf::UnsupportedError, "#{self.class} doesn't support Self Service notifications" unless @self_service_data_config[:notification_reminders]
952 end
validate_notifications_supported() click to toggle source

Raise an error if notifications aren’t supported

    # File lib/jamf/api/classic/api_objects/self_servable.rb
945 def validate_notifications_supported
946   raise Jamf::UnsupportedError, "#{self.class} doesn't support Self Service notifications" unless @self_service_data_config[:notifications_supported]
947 end
validate_user_removable(new_val) click to toggle source

Raise an error if user_removable settings are wrong

    # File lib/jamf/api/classic/api_objects/self_servable.rb
930 def validate_user_removable(new_val)
931   raise Jamf::UnsupportedError, 'User removal settings not applicable to this class' unless self_service_payload == :profile
932 
933   raise Jamf::UnsupportedError, 'Removal :with_auth not applicable to this class' if new_val == :with_auth && !self_service_targets.include?(:ios)
934 
935   raise Jamf::InvalidDataError, "Value must be one of: :#{PROFILE_REMOVAL_BY_USER.keys.join(', :')}" unless PROFILE_REMOVAL_BY_USER.key?(new_val)
936 end