class Jamf::RestrictedSoftware

Restricted Software items in the JSS.

@see Jamf::APIObject

Constants

OBJECT_HISTORY_OBJECT_TYPE

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

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

Our scopes deal with computers

SITE_SUBSET

Where is the Site data in the API JSON?

Attributes

delete_executable[R]

@return [Boolean] whether to delete the executable

delete_executable?[R]

@return [Boolean] whether to delete the executable

display_message[R]

@return [String] message displayed to the user

kill_process[R]

@return [Boolean] whether to kill the running process

kill_process?[R]

@return [Boolean] whether to kill the running process

match_exact_process_name[R]

@return [Boolean] whether to return match exact process name

match_exact_process_name?[R]

@return [Boolean] whether to return match exact process name

process_name[R]

@return [String] the process name

send_notification[R]

@return [Boolean] whether to send a notification

send_notification?[R]

@return [Boolean] whether to send a notification

site[R]

@return [Hash] the :name and :id of the site for this machine

Public Class Methods

new(**args) click to toggle source

Instance Methods

Calls superclass method Jamf::APIObject::new
    # File lib/jamf/api/classic/api_objects/restricted_software.rb
 91 def initialize(**args)
 92   super
 93 
 94   @init_data[:general] ||= {}
 95   @process_name = @init_data[:general][:process_name]
 96   @match_exact_process_name = @init_data[:general][:match_exact_process_name]
 97   @send_notification = @init_data[:general][:send_notification]
 98   @kill_process = @init_data[:general][:kill_process]
 99   @delete_executable = @init_data[:general][:delete_executable]
100   @display_message = @init_data[:general][:display_message]
101   @site = Jamf::APIObject.get_name(@init_data[:general][:site])
102   @site ||= 'None'
103   @scope ||= Jamf::Scopable::Scope.new SCOPE_TARGET_KEY, nil
104 end

Public Instance Methods

create() click to toggle source
Calls superclass method Jamf::APIObject::create
    # File lib/jamf/api/classic/api_objects/restricted_software.rb
152 def create
153   raise Jamf::MissingDataError, 'process_name must be set before creating' if @process_name.to_s.empty?
154   raise Jamf::AlreadyExistsError, "A #{RSRC_OBJECT_KEY} named #{@name} already exists in the JSS" if self.class.all_names(:refresh, cnx: @cnx).include? @name
155   super
156 end
delete_executable=(new_val) click to toggle source
    # File lib/jamf/api/classic/api_objects/restricted_software.rb
129 def delete_executable=(new_val)
130   confirm_boolean(new_val)
131   @delete_executable = new_val
132   @need_to_update = true
133 end
display_message=(new_val) click to toggle source
    # File lib/jamf/api/classic/api_objects/restricted_software.rb
135 def display_message=(new_val)
136   @display_message = new_val.to_s
137   @need_to_update = true
138 end
kill_process=(new_val) click to toggle source
    # File lib/jamf/api/classic/api_objects/restricted_software.rb
123 def kill_process=(new_val)
124   confirm_boolean(new_val)
125   @kill_process = new_val
126   @need_to_update = true
127 end
match_exact_process_name=(new_val) click to toggle source
    # File lib/jamf/api/classic/api_objects/restricted_software.rb
111 def match_exact_process_name=(new_val)
112   confirm_boolean(new_val)
113   @match_exact_process_name = new_val
114   @need_to_update = true
115 end
process_name=(new_val) click to toggle source
    # File lib/jamf/api/classic/api_objects/restricted_software.rb
106 def process_name=(new_val)
107   @process_name = new_val.to_s
108   @need_to_update = true
109 end
send_notification=(new_val) click to toggle source
    # File lib/jamf/api/classic/api_objects/restricted_software.rb
117 def send_notification=(new_val)
118   confirm_boolean(new_val)
119   @send_notification = new_val
120   @need_to_update = true
121 end
site=(new_val) click to toggle source
    # File lib/jamf/api/classic/api_objects/restricted_software.rb
140 def site=(new_val)
141   if new_val.is_a? Integer
142     raise Jamf::NoSuchItemError, "No site found with id #{new_val}" unless Jamf::Site.all_ids(cnx: @cnx).include? new_val
143     new_val = Jamf::Site.map_all_ids_to(:name, cnx: @cnx)[new_val]
144   else
145     new_val = new_val.to_s
146     raise Jamf::NoSuchItemError, "No site found with name #{new_val}" unless Jamf::Site.all_names(cnx: @cnx).include? new_val
147   end
148   @site = new_val
149   @need_to_update = true
150 end
update() click to toggle source
Calls superclass method Jamf::Scopable#update
    # File lib/jamf/api/classic/api_objects/restricted_software.rb
158 def update
159   raise Jamf::MissingDataError, 'process_name must be set before updating' if @process_name.to_s.empty?
160   super
161 end

Private Instance Methods

confirm_boolean(val) click to toggle source

TODO: Move this into a Validators module

    # File lib/jamf/api/classic/api_objects/restricted_software.rb
194 def confirm_boolean(val)
195   raise Jamf::InvalidDataError, 'Value must be boolean true or false' unless Jamf::TRUE_FALSE.include? val
196 end
rest_xml() click to toggle source

Private Instance Methods

    # File lib/jamf/api/classic/api_objects/restricted_software.rb
173 def rest_xml
174   doc = REXML::Document.new Jamf::Connection::XML_HEADER
175   obj = doc.add_element RSRC_OBJECT_KEY.to_s
176 
177   general = obj.add_element 'general'
178   general.add_element('name').text = @name
179   general.add_element('process_name').text = @process_name
180   general.add_element('match_exact_process_name').text = @match_exact_process_name.to_s
181   general.add_element('send_notification').text = @send_notification.to_s
182   general.add_element('kill_process').text = @kill_process.to_s
183   general.add_element('delete_executable').text = @delete_executable.to_s
184   general.add_element('display_message').text = @display_message.to_s
185 
186   site = general.add_element 'site'
187   site.add_element('name').text = @site
188 
189   obj << @scope.scope_xml
190   doc.to_s
191 end