_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3 values | text stringlengths 66 10.5k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q15800 | JSS.WebHook.event= | train | def event=(new_val)
return nil if new_val == @event
raise JSS::InvalidDataError, 'Unknown webhook event' unless EVENTS.include? new_val
@event = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15801 | JSS.WebHook.rest_xml | train | def rest_xml
validate_before_save
doc = REXML::Document.new APIConnection::XML_HEADER
webhook = doc.add_element 'webhook'
webhook.add_element('name').text = @name
webhook.add_element('enabled').text = @enabled
webhook.add_element('url').text = @url
webhook.add_element('content_type').text = CONTENT_TYPES[@content_type]
webhook.add_element('event').text = @event
doc.to_s
end | ruby | {
"resource": ""
} |
q15802 | JSS.ComputerInvitation.create | train | def create
new_invitation_id = super
jss_me = ComputerInvitation.fetch(id: new_invitation_id, name: 'set_by_request')
@name = jss_me.name
@invitation_type = jss_me.invitation_type
@create_account_if_does_not_exist = jss_me.create_account_if_does_not_exist
@expiration_date_epoch = jss_me.expiration_date_epoch
@ssh_username = jss_me.ssh_username
@hide_account = jss_me.hide_account
@invitation_status = jss_me.invitation_status
@multiple_uses_allowed = jss_me.multiple_uses_allowed
end | ruby | {
"resource": ""
} |
q15803 | JSS.ComputerInvitation.rest_xml | train | def rest_xml
doc = REXML::Document.new APIConnection::XML_HEADER
obj = doc.add_element RSRC_OBJECT_KEY.to_s
obj.add_element('invitation_type').text = invitation_type
obj.add_element('create_account_if_does_not_exist').text = create_account_if_does_not_exist
if expiration_date_epoch
obj.add_element('expiration_date_epoch').text = expiration_date_epoch
end
obj.add_element('ssh_username').text = ssh_username
obj.add_element('hide_account').text = hide_account
obj.add_element('invitation_status').text = invitation_status
obj.add_element('multiple_uses_allowed').text = multiple_uses_allowed
add_site_to_xml(doc)
doc.to_s
end | ruby | {
"resource": ""
} |
q15804 | JSS.Icon.save | train | def save(path, overwrite = false)
path = Pathname.new path
path = path + @name if path.directory? && @name
raise JSS::AlreadyExistsError, "The file #{path} already exists" if path.exist? unless overwrite
path.delete if path.exist?
path.jss_save @data
end | ruby | {
"resource": ""
} |
q15805 | JSS.Categorizable.category= | train | def category=(new_cat)
return nil unless updatable? || creatable?
# unset the category? Use nil or an empty string
if NON_CATEGORIES.include? new_cat
unset_category
return
end
new_name, new_id = evaluate_new_category(new_cat)
# no change, go home.
return nil if new_name == @category_name
raise JSS::NoSuchItemError, "Category '#{new_cat}' is not known to the JSS" unless JSS::Category.all_names(:ref, api: @api).include? new_name
@category_name = new_name
@category_id = new_id
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15806 | JSS.Categorizable.parse_category | train | def parse_category
cat =
if self.class::CATEGORY_SUBSET == :top
@init_data[:category]
else
@init_data[self.class::CATEGORY_SUBSET][:category]
end
if cat.is_a? String
@category_name = cat
@category_id = JSS::Category.category_id_from_name @category_name
else
@category_name = cat[:name]
@category_id = cat[:id]
end
clean_raw_categories
end | ruby | {
"resource": ""
} |
q15807 | JSS.Categorizable.add_category_to_xml | train | def add_category_to_xml(xmldoc)
return if category_name.to_s.empty?
cat_elem = REXML::Element.new('category')
if self.class::CATEGORY_DATA_TYPE == String
cat_elem.text = @category_name.to_s
elsif self.class::CATEGORY_DATA_TYPE == Hash
cat_elem.add_element('name').text = @category_name.to_s
else
raise JSS::InvalidDataError, "Uknown CATEGORY_DATA_TYPE for class #{self.class}"
end
root = xmldoc.root
if self.class::CATEGORY_SUBSET == :top
root.add_element cat_elem
return
end
parent = root.elements[self.class::CATEGORY_SUBSET.to_s]
parent ||= root.add_element self.class::CATEGORY_SUBSET.to_s
parent.add_element cat_elem
end | ruby | {
"resource": ""
} |
q15808 | JSS.Scopable.scope= | train | def scope= (new_scope)
raise JSS::InvalidDataError, "JSS::Scopable::Scope instance required" unless new_criteria.kind_of?(JSS::Scopable::Scope)
raise JSS::InvalidDataError, "Scope object must have target_key of :#{self.class::SCOPE_TARGET_KEY}" unless self.class::SCOPE_TARGET_KEY == new_scope.target_key
@scope = new_scope
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15809 | JSS.MDM.erase_device | train | def erase_device(passcode = '', preserve_data_plan: false)
self.class.erase_device @id, passcode: passcode, preserve_data_plan: preserve_data_plan, api: @api
end | ruby | {
"resource": ""
} |
q15810 | JSS.MDM.wallpaper | train | def wallpaper(wallpaper_setting: nil, wallpaper_content: nil, wallpaper_id: nil)
self.class.wallpaper(
@id,
wallpaper_setting: wallpaper_setting,
wallpaper_content: wallpaper_content,
wallpaper_id: wallpaper_id,
api: @api
)
end | ruby | {
"resource": ""
} |
q15811 | JSS.MDM.enable_lost_mode | train | def enable_lost_mode(
message: nil,
phone_number: nil,
footnote: nil,
enforce_lost_mode: true,
play_sound: false
)
self.class.enable_lost_mode(
@id,
message: message,
phone_number: phone_number,
footnote: footnote,
play_sound: play_sound,
enforce_lost_mode: enforce_lost_mode,
api: @api
)
end | ruby | {
"resource": ""
} |
q15812 | JSS.Policy.frequency= | train | def frequency=(freq)
raise JSS::InvalidDataError, "New frequency must be one of :#{FREQUENCIES.keys.join ', :'}" unless FREQUENCIES.key?(freq)
@frequency = FREQUENCIES[freq]
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15813 | JSS.Policy.target_drive= | train | def target_drive=(path_to_drive)
raise JSS::InvalidDataError, 'Path to target drive must be absolute' unless path_to_drive.to_s.start_with? '/'
@target_drive = path_to_drive.to_s
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15814 | JSS.Policy.offline= | train | def offline=(new_val)
raise JSS::InvalidDataError, 'New value must be boolean true or false' unless JSS::TRUE_FALSE.include? new_val
@offline = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15815 | JSS.Policy.set_trigger_event | train | def set_trigger_event(type, new_val)
raise JSS::InvalidDataError, "Trigger type must be one of #{TRIGGER_EVENTS.keys.join(', ')}" unless TRIGGER_EVENTS.key?(type)
if type == :custom
raise JSS::InvalidDataError, 'Custom triggers must be Strings' unless new_val.is_a? String
else
raise JSS::InvalidDataError, 'Non-custom triggers must be true or false' unless JSS::TRUE_FALSE.include? new_val
end
@trigger_events[TRIGGER_EVENTS[type]] = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15816 | JSS.Policy.server_side_activation= | train | def server_side_activation=(activation)
raise JSS::InvalidDataError, 'Activation must be a Time' unless activation.is_a? Time
@server_side_limitations[:activation] = activation
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15817 | JSS.Policy.server_side_expiration= | train | def server_side_expiration=(expiration)
raise JSS::InvalidDataError, 'Expiration must be a Time' unless expiration.is_a? Time
@server_side_limitations[:expiration] = expiration
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15818 | JSS.Policy.user_logged_in= | train | def user_logged_in=(logged_in_option)
raise JSS::InvalidDataError, "user_logged_in options: #{USER_LOGGED_IN.join(', ')}" unless USER_LOGGED_IN.include? logged_in_option
@reboot_options[:user_logged_in] = logged_in_option
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15819 | JSS.Policy.reboot_message= | train | def reboot_message=(message)
raise JSS::InvalidDataError, 'Reboot message must be a String' unless message.is_a? String
@reboot_options[:message] = message
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15820 | JSS.Policy.startup_disk= | train | def startup_disk=(startup_disk_option)
raise JSS::InvalidDataError, "#{startup_disk_option} is not a valid Startup Disk" unless startup_disk_option.is_a? String
@reboot_options[:startup_disk] = 'Specify Local Startup Disk'
self.specify_startup = startup_disk_option
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15821 | JSS.Policy.specify_startup= | train | def specify_startup=(startup_volume)
raise JSS::InvalidDataError, "#{startup_volume} is not a valid Startup Disk" unless startup_volume.is_a? String
@reboot_options[:specify_startup] = startup_volume
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15822 | JSS.Policy.minutes_until_reboot= | train | def minutes_until_reboot=(minutes)
raise JSS::InvalidDataError, 'Minutes until reboot must be an Integer' unless minutes.is_a? Integer
@reboot_options[:minutes_until_reboot] = minutes
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15823 | JSS.Policy.run_command= | train | def run_command=(command)
raise JSS::InvalidDataError, 'Command to run must be a String' unless command.is_a? String
@files_processes[:run_command] = command
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15824 | JSS.Policy.set_search_for_process | train | def set_search_for_process(process, kill = false)
@files_processes[:search_for_process] = process.to_s
@files_processes[:kill_process] = kill ? true : false
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15825 | JSS.Policy.set_search_by_path | train | def set_search_by_path(path, delete = false)
raise JSS::InvalidDataError, 'Path to search for must be a String or a Pathname' unless path.is_a?(String) || path.is_a?(Pathname)
@files_processes[:search_by_path] = path.to_s
@files_processes[:delete_file] = delete ? true : false
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15826 | JSS.Policy.spotlight_search= | train | def spotlight_search=(term)
raise JSS::InvalidDataError, 'Spotlight search term must be a String' unless term.is_a? String
@files_processes[:spotlight_search] = term
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15827 | JSS.Policy.locate_file= | train | def locate_file=(term)
raise JSS::InvalidDataError, 'Term to locate must be a String' unless term.is_a? String
@files_processes[:locate_file] = term
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15828 | JSS.Policy.add_package | train | def add_package(identifier, **opts)
id = validate_package_opts(identifier, opts)
return nil if @packages.map { |p| p[:id] }.include? id
name = JSS::Package.map_all_ids_to(:name, api: @api)[id]
pkg_data = {
id: id,
name: name,
action: PACKAGE_ACTIONS[opts[:action]],
feu: opts[:feu],
fut: opts[:feu],
update_autorun: opts[:update_autorun]
}
@packages.insert opts[:position], pkg_data
@need_to_update = true
@packages
end | ruby | {
"resource": ""
} |
q15829 | JSS.Policy.remove_package | train | def remove_package(identifier)
removed = @packages.delete_if { |p| p[:id] == identifier || p[:name] == identifier }
@need_to_update = true if removed
removed
end | ruby | {
"resource": ""
} |
q15830 | JSS.Policy.add_script | train | def add_script(identifier, **opts)
id = validate_script_opts(identifier, opts)
return nil if @scripts.map { |s| s[:id] }.include? id
name = JSS::Script.map_all_ids_to(:name, api: @api)[id]
script_data = {
id: id,
name: name,
priority: SCRIPT_PRIORITIES[opts[:priority]],
parameter4: opts[:parameter4],
parameter5: opts[:parameter5],
parameter6: opts[:parameter6],
parameter7: opts[:parameter7],
parameter8: opts[:parameter8],
parameter9: opts[:parameter9],
parameter10: opts[:parameter10],
parameter11: opts[:parameter11]
}
@scripts.insert opts[:position], script_data
@need_to_update = true
@scripts
end | ruby | {
"resource": ""
} |
q15831 | JSS.Policy.remove_script | train | def remove_script(identifier)
removed = @scripts.delete_if { |s| s[:id] == identifier || s[:name] == identifier }
@need_to_update = true if removed
removed
end | ruby | {
"resource": ""
} |
q15832 | JSS.Policy.run | train | def run(show_output = false)
return nil unless enabled?
output = JSS::Client.run_jamf('policy', "-id #{id}", show_output)
return nil if output.include? 'No policies were found for the ID'
$CHILD_STATUS.exitstatus.zero? ? true : false
end | ruby | {
"resource": ""
} |
q15833 | JSS.Policy.flush_logs | train | def flush_logs(older_than: 0, period: :days)
raise JSS::NoSuchItemError, "Policy doesn't exist in the JSS. Use #create first." unless @in_jss
unless LOG_FLUSH_INTERVAL_INTEGERS.key?(older_than)
raise JSS::InvalidDataError, "older_than must be one of these integers: #{LOG_FLUSH_INTERVAL_INTEGERS.keys.join ', '}"
end
unless LOG_FLUSH_INTERVAL_PERIODS.key?(period)
raise JSS::InvalidDataError, "period must be one of these symbols: :#{LOG_FLUSH_INTERVAL_PERIODS.keys.join ', :'}"
end
interval = "#{LOG_FLUSH_INTERVAL_INTEGERS[older_than]}+#{LOG_FLUSH_INTERVAL_PERIODS[period]}"
@api.delete_rsrc "#{LOG_FLUSH_RSRC}/policy/id/#{@id}/interval/#{interval}"
end | ruby | {
"resource": ""
} |
q15834 | JSS.Policy.validate_package_opts | train | def validate_package_opts(identifier, opts)
opts[:position] ||= -1
opts[:action] ||= :install
opts[:feu] ||= false
opts[:fut] ||= false
opts[:update_autorun] ||= false
opts[:position] =
case opts[:position]
when :start then 0
when :end then -1
else JSS::Validate.integer(opts[:position])
end
# if the given position is past the end, set it to -1 (the end)
opts[:position] = -1 if opts[:position] > @packages.size
id = JSS::Package.valid_id identifier, api: @api
raise JSS::NoSuchItemError, "No package matches '#{identifier}'" unless id
raise JSS::InvalidDataError, "action must be one of: :#{PACKAGE_ACTIONS.keys.join ', :'}" unless \
PACKAGE_ACTIONS.include? opts[:action]
opts[:feu] = JSS::Validate.boolean opts[:feu]
opts[:fut] = JSS::Validate.boolean opts[:fut]
opts[:update_autorun] = JSS::Validate.boolean opts[:update_autorun]
id
end | ruby | {
"resource": ""
} |
q15835 | JSS.Policy.validate_script_opts | train | def validate_script_opts(identifier, opts)
opts[:position] ||= -1
opts[:priority] ||= :after
raise JSS::InvalidDataError, "priority must be one of: :#{SCRIPT_PRIORITIES.keys.join ', :'}" unless \
SCRIPT_PRIORITIES.include? opts[:priority]
opts[:position] =
case opts[:position]
when :start then 0
when :end then -1
else JSS::Validate.integer(opts[:position])
end
# if the given position is past the end, set it to -1 (the end)
opts[:position] = -1 if opts[:position] > @packages.size
id = JSS::Script.valid_id identifier, api: @api
raise JSS::NoSuchItemError, "No script matches '#{identifier}'" unless id
id
end | ruby | {
"resource": ""
} |
q15836 | JSS.ExtensionAttribute.web_display= | train | def web_display=(new_val)
return nil if @web_display == new_val
raise JSS::InvalidDataError, "inventory_display must be a string, one of: #{INVENTORY_DISPLAY_CHOICES.join(', ')}" unless WEB_DISPLAY_CHOICES.include? new_val
@web_display = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15837 | JSS.ExtensionAttribute.input_type= | train | def input_type=(new_val)
return nil if @input_type == new_val
raise JSS::InvalidDataError, "input_type must be a string, one of: #{INPUT_TYPES.join(', ')}" unless INPUT_TYPES.include? new_val
@input_type = new_val
@popup_choices = nil if @input_type == 'Text Field'
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15838 | JSS.ExtensionAttribute.popup_choices= | train | def popup_choices=(new_val)
return nil if @popup_choices == new_val
raise JSS::InvalidDataError, 'popup_choices must be an Array' unless new_val.is_a?(Array)
# convert each one to a String,
# and check that it matches the @data_type
new_val.map! do |v|
v = v.to_s.strip
case @data_type
when 'Date'
raise JSS::InvalidDataError, "data_type is Date, but '#{v}' is not formatted 'YYYY-MM-DD hh:mm:ss'" unless v =~ /^\d{4}(-\d\d){2} (\d\d:){2}\d\d$/
when 'Integer'
raise JSS::InvalidDataError, "data_type is Integer, but '#{v}' is not one" unless v =~ /^\d+$/
end
v
end
self.input_type = 'Pop-up Menu'
@popup_choices = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15839 | JSS.ExtensionAttribute.all_with_result | train | def all_with_result(search_type, desired_value)
raise JSS::NoSuchItemError, "EA Not In JSS! Use #create to create this #{self.class::RSRC_OBJECT_KEY}." unless @in_jss
raise JSS::InvalidDataError, 'Invalid search_type, see JSS::Criteriable::Criterion::SEARCH_TYPES' unless JSS::Criteriable::Criterion::SEARCH_TYPES.include? search_type.to_s
begin
search_class = self.class::TARGET_CLASS::SEARCH_CLASS
acs = search_class.make api: @api, name: "ruby-jss-EA-result-search-#{Time.now.to_jss_epoch}"
acs.display_fields = [@name]
crit_list = [JSS::Criteriable::Criterion.new(and_or: 'and', name: @name, search_type: search_type.to_s, value: desired_value)]
acs.criteria = JSS::Criteriable::Criteria.new crit_list
acs.create :get_results
results = []
acs.search_results.each do |i|
value = case @data_type
when 'Date' then JSS.parse_datetime i[@symbolized_name]
when 'Integer' then i[@symbolized_name].to_i
else i[@symbolized_name]
end # case
results << { id: i[:id], name: i[:name], value: value }
end
ensure
acs.delete if acs.is_a? self.class::TARGET_CLASS::SEARCH_CLASS
end
results
end | ruby | {
"resource": ""
} |
q15840 | JSS.ExtensionAttribute.rest_rexml | train | def rest_rexml
ea = REXML::Element.new self.class::RSRC_OBJECT_KEY.to_s
ea.add_element('name').text = @name
ea.add_element('description').text = @description
ea.add_element('data_type').text = @data_type
ea.add_element('inventory_display').text = @web_display
it = ea.add_element('input_type')
it.add_element('type').text = @input_type
if @input_type == 'Pop-up Menu'
pcs = it.add_element('popup_choices')
@popup_choices.each { |pc| pcs.add_element('choice').text = pc }
end
ea
end | ruby | {
"resource": ""
} |
q15841 | JSS.ComputerExtensionAttribute.recon_display= | train | def recon_display= (new_val)
return nil if @recon_display == new_val
raise JSS::InvalidDataError, "recon_display must be a string, one of: #{RECON_DISPLAY_CHOICES.join(", ")}" unless RECON_DISPLAY_CHOICES.include? new_val
@recon_display = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15842 | JSS.PatchExternalSource.validate_host_port | train | def validate_host_port(action)
raise JSS::UnsupportedError, "Cannot #{action} without first setting a host_name and port" if host_name.to_s.empty? || port.to_s.empty?
end | ruby | {
"resource": ""
} |
q15843 | JSS.DBConnection.valid_server? | train | def valid_server?(server, port = DFT_PORT)
mysql = Mysql.init
mysql.options Mysql::OPT_CONNECT_TIMEOUT, 5
begin
# this connection should get an access denied error if there is
# a mysql server there. I'm assuming no one will use this username
# and pw for anything real
mysql.connect server, 'notArealUser', "definatelyNotA#{$PROCESS_ID}password", 'not_a_db', port
rescue Mysql::ServerError::AccessDeniedError
return true
rescue
return false
end
false
end | ruby | {
"resource": ""
} |
q15844 | JSS.SelfServable.add_self_service_category | train | def add_self_service_category(new_cat, display_in: true, feature_in: false)
new_cat = JSS::Category.map_all_ids_to(:name, api: @api)[new_cat] if new_cat.is_a? Integer
feature_in = false if display_in == false
raise JSS::NoSuchItemError, "No category '#{new_cat}' in the JSS" unless JSS::Category.all_names(:refresh, api: @api).include? new_cat
raise JSS::InvalidDataError, 'display_in must be true or false' unless display_in.jss_boolean?
raise JSS::InvalidDataError, 'feature_in must be true or false' unless feature_in.jss_boolean?
new_data = { name: new_cat }
new_data[:display_in] = display_in if @self_service_data_config[:can_display_in_categories]
new_data[:feature_in] = feature_in if @self_service_data_config[:can_feature_in_categories]
# see if this category is already among our categories.
idx = @self_service_categories.index { |c| c[:name] == new_cat }
if idx
@self_service_categories[idx] = new_data
else
@self_service_categories << new_data
end
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15845 | JSS.SelfServable.self_service_user_removable= | train | def self_service_user_removable=(new_val, pw = @self_service_removal_password)
new_val, pw = *new_val if new_val.is_a? Array
pw = nil unless new_val == :with_auth
return if new_val == self_service_user_removable && pw == self_service_removal_password
validate_user_removable new_val
@self_service_user_removable = new_val
@self_service_removal_password = pw
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15846 | JSS.SelfServable.self_service_notification_type= | train | def self_service_notification_type=(type)
validate_notifications_supported
# HACK: Until jamf fixes bugs, you can only set notifications
# :off or :ssvc_only. If you want :ssvc_and_nctr, you must
# check the checkbox in the web-UI.
if @self_service_data_config[:notifications_supported] == :ssvc_only && type != :ssvc_only
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"
end
raise JSS::InvalidDataError, "type must be one of: :#{NOTIFICATION_TYPES.keys.join ', :'}" unless NOTIFICATION_TYPES.key? type
@self_service_notification_type = type
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15847 | JSS.SelfServable.self_service_reminder_frequency= | train | def self_service_reminder_frequency=(days)
return if days == self_service_reminder_frequency
validate_notification_reminders_supported
JSS::Validate.integer days
@self_service_reminder_frequency = days
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15848 | JSS.SelfServable.icon= | train | def icon=(new_icon)
if new_icon.is_a? Integer
return if @icon && new_icon == @icon.id
validate_icon new_icon
@new_icon_id = new_icon
@need_to_update = true
else
unless uploadable? && defined?(self.class::UPLOAD_TYPES) && self.class::UPLOAD_TYPES.key?(:icon)
raise JSS::UnsupportedError, "Class #{self.class} does not support icon uploads."
end
new_icon = Pathname.new new_icon
upload(:icon, new_icon)
refresh_icon
end # new_icon.is_a? Integer
new_icon
end | ruby | {
"resource": ""
} |
q15849 | JSS.SelfServable.parse_self_service_notifications | train | def parse_self_service_notifications(ss_data)
return unless @self_service_data_config[:notifications_supported]
# oldstyle/broken, we need the XML to know if notifications are turned on
if @self_service_data_config[:notifications_supported] == :ssvc_only && @in_jss
ssrsrc = "#{rest_rsrc}/subset/selfservice"
raw_xml = api.get_rsrc(ssrsrc, :xml)
@self_service_notifications_enabled = raw_xml.include? '<notification>true</notification>'
@self_service_notification_type = NOTIFICATION_TYPES.invert[ss_data[:notification]]
@self_service_notification_subject = ss_data[:notification_subject]
@self_service_notification_message = ss_data[:notification_message]
return
end
# newstyle, 'notifications' subset
notif_data = ss_data[:notifications]
notif_data ||= {}
@self_service_notifications_enabled = notif_data[:notification_enabled]
@self_service_notification_type = NOTIFICATION_TYPES.invert[notif_data[:notification_type]]
@self_service_notification_type ||= DFT_NOTIFICATION_TYPE
@self_service_notification_subject = notif_data[:notification_subject]
@self_service_notification_message = notif_data[:notification_message]
reminders = notif_data[:reminders]
reminders ||= {}
@self_service_reminders_enabled = reminders[:notification_reminders_enabled]
@self_service_reminder_frequency = reminders[:notification_reminder_frequency]
end | ruby | {
"resource": ""
} |
q15850 | JSS.SelfServable.add_self_service_xml | train | def add_self_service_xml(xdoc)
doc_root = xdoc.root
# whether or not we're in self service is usually not in the
# ssvc subset...
add_in_self_service_xml doc_root
subset_key = @self_service_data_config[:self_service_subset] ? @self_service_data_config[:self_service_subset] : :self_service
ssvc = doc_root.add_element subset_key.to_s
ssvc.add_element('self_service_description').text = @self_service_description if @self_service_description
ssvc.add_element('feature_on_main_page').text = @self_service_feature_on_main_page
if @new_icon_id
icon = ssvc.add_element('self_service_icon')
icon.add_element('id').text = @new_icon_id
end
add_self_service_category_xml ssvc
add_self_service_profile_xml ssvc, doc_root
add_self_service_macos_xml ssvc
add_self_service_notification_xml ssvc
end | ruby | {
"resource": ""
} |
q15851 | JSS.SelfServable.add_in_self_service_xml | train | def add_in_self_service_xml(doc_root)
return unless @self_service_data_config[:in_self_service_data_path]
in_ss_section, in_ss_elem = @self_service_data_config[:in_self_service_data_path]
in_ss_value = @in_self_service ? @self_service_data_config[:in_self_service] : @self_service_data_config[:not_in_self_service]
in_ss_section_xml = doc_root.elements[in_ss_section.to_s]
in_ss_section_xml ||= doc_root.add_element(in_ss_section.to_s)
in_ss_section_xml.add_element(in_ss_elem.to_s).text = in_ss_value.to_s
end | ruby | {
"resource": ""
} |
q15852 | JSS.SelfServable.add_self_service_profile_xml | train | def add_self_service_profile_xml(ssvc, doc_root)
return unless self_service_payload == :profile
if self_service_targets.include? :ios
sec = ssvc.add_element('security')
sec.add_element('removal_disallowed').text = PROFILE_REMOVAL_BY_USER[@self_service_user_removable]
sec.add_element('password').text = @self_service_removal_password.to_s
return
end
gen = doc_root.elements['general']
gen.add_element('user_removable').text = (@self_service_user_removable == :always).to_s
end | ruby | {
"resource": ""
} |
q15853 | JSS.SelfServable.add_self_service_category_xml | train | def add_self_service_category_xml(ssvc)
cats = ssvc.add_element('self_service_categories')
return if self_service_categories.empty?
self_service_categories.each do |cat|
catelem = cats.add_element('category')
catelem.add_element('name').text = cat[:name]
catelem.add_element('display_in').text = cat[:display_in] if @self_service_data_config[:can_display_in_categories]
catelem.add_element('feature_in').text = cat[:feature_in] if @self_service_data_config[:can_feature_in_categories]
end
end | ruby | {
"resource": ""
} |
q15854 | JSS.SelfServable.add_self_service_macos_xml | train | def add_self_service_macos_xml(ssvc)
return unless self_service_targets.include? :macos
ssvc.add_element('self_service_display_name').text = self_service_display_name if self_service_display_name
ssvc.add_element('install_button_text').text = self_service_install_button_text if self_service_install_button_text
ssvc.add_element('reinstall_button_text').text = self_service_reinstall_button_text if self_service_reinstall_button_text
ssvc.add_element('force_users_to_view_description').text = self_service_force_users_to_view_description.to_s
end | ruby | {
"resource": ""
} |
q15855 | JSS.SelfServable.add_self_service_notification_xml | train | def add_self_service_notification_xml(ssvc)
return unless @self_service_data_config[:notifications_supported]
# oldstyle/broken, only sscv notifs
if @self_service_data_config[:notifications_supported] == :ssvc_only
ssvc.add_element('notification').text = self_service_notifications_enabled.to_s
ssvc.add_element('notification_subject').text = self_service_notification_subject if self_service_notification_subject
ssvc.add_element('notification_message').text = self_service_notification_message if self_service_notification_message
return
end
# newstyle, 'notifications' subset
notif = ssvc.add_element('notifications')
notif.add_element('notifications_enabled').text = self_service_notifications_enabled.to_s
notif.add_element('notification_type').text = NOTIFICATION_TYPES[self_service_notification_type] if self_service_notification_type
notif.add_element('notification_subject').text = self_service_notification_subject if self_service_notification_subject
notif.add_element('notification_message').text = self_service_notification_message if self_service_notification_message
return unless @self_service_data_config[:notification_reminders]
reminds = notif.add_element('reminders')
reminds.add_element('notification_reminders_enabled').text = self_service_reminders_enabled.to_s
reminds.add_element('notification_reminder_frequency').text = self_service_reminder_frequency.to_s if self_service_reminder_frequency
end | ruby | {
"resource": ""
} |
q15856 | JSS.SelfServable.validate_user_removable | train | def validate_user_removable(new_val)
raise JSS::UnsupportedError, 'User removal settings not applicable to this class' unless self_service_payload == :profile
raise JSS::UnsupportedError, 'Removal :with_auth not applicable to this class' if new_val == :with_auth && !self_service_targets.include?(:ios)
raise JSS::InvalidDataError, "Value must be one of: :#{PROFILE_REMOVAL_BY_USER.keys.join(', :')}" unless PROFILE_REMOVAL_BY_USER.key?(new_val)
end | ruby | {
"resource": ""
} |
q15857 | JSS.SelfServable.validate_icon | train | def validate_icon(id)
return nil unless JSS::DB_CNX.connected?
raise JSS::NoSuchItemError, "No icon with id #{id}" unless JSS::Icon.all_ids.include? id
end | ruby | {
"resource": ""
} |
q15858 | JSS.AdvancedSearch.update | train | def update(get_results = false)
orig_timeout = @api.cnx.options[:timeout]
@api.timeout = 1800
super()
requery_search_results if get_results
@api.timeout = orig_timeout
@id # remember to return the id
end | ruby | {
"resource": ""
} |
q15859 | JSS.AdvancedSearch.requery_search_results | train | def requery_search_results
orig_open_timeout = @api.cnx.options[:open_timeout]
orig_timeout = @api.cnx.options[:timeout]
@api.timeout = 1800
@api.open_timeout = 1800
begin
requery = self.class.fetch(id: @id)
@search_results = requery.search_results
@result_display_keys = requery.result_display_keys
ensure
@api.timeout = orig_timeout
@api.open_timeout = orig_open_timeout
end
end | ruby | {
"resource": ""
} |
q15860 | JSS.AdvancedSearch.display_fields= | train | def display_fields=(new_val)
raise JSS::InvalidDataError, 'display_fields must be an Array.' unless new_val.is_a? Array
return if new_val.sort == @display_fields.sort
@display_fields = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15861 | JSS.AdvancedSearch.export | train | def export(output_file, format = :csv, overwrite = false)
raise JSS::InvalidDataError, "Export format must be one of: :#{EXPORT_FORMATS.join ', :'}" unless EXPORT_FORMATS.include? format
out = Pathname.new output_file
unless overwrite
raise JSS::AlreadyExistsError, "The output file already exists: #{out}" if out.exist?
end
case format
when :csv
require 'csv'
CSV.open(out.to_s, 'wb') do |csv|
csv << @result_display_keys
@search_results.each do |row|
csv << @result_display_keys.map { |key| row[key] }
end # each do row
end # CSV.open
when :tab
tabbed = @result_display_keys.join("\t") + "\n"
@search_results.each do |row|
tabbed << @result_display_keys.map { |key| row[key] }.join("\t") + "\n"
end # each do row
out.jss_save tabbed.chomp
else # :xml
doc = REXML::Document.new '<?xml version="1.0" encoding="ISO-8859-1"?>'
members = doc.add_element self.class::RESULT_CLASS::RSRC_LIST_KEY.to_s
@search_results.each do |row|
member = members.add_element self.class::RESULT_CLASS::RSRC_OBJECT_KEY.to_s
@result_display_keys.each do |field|
member.add_element(field.to_s.tr(' ', '_')).text = row[field].empty? ? nil : row[field]
end # ech do field
end # each do row
out.jss_save doc.to_s.gsub('><', ">\n<")
end # case
out
end | ruby | {
"resource": ""
} |
q15862 | JSS.AdvancedSearch.rest_xml | train | def rest_xml
doc = REXML::Document.new APIConnection::XML_HEADER
acs = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
acs.add_element('name').text = @name
acs.add_element('sort_1').text = @sort_1 if @sort_1
acs.add_element('sort_2').text = @sort_2 if @sort_2
acs.add_element('sort_3').text = @sort_3 if @sort_3
acs << @criteria.rest_xml
df = acs.add_element('display_fields')
@display_fields.each { |f| df.add_element('display_field').add_element('name').text = f }
add_site_to_xml(doc)
doc.to_s
end | ruby | {
"resource": ""
} |
q15863 | JSS.MobileDeviceApplication.deploy_as_managed_app= | train | def deploy_as_managed_app=(new_val)
return nil if new_val == @deploy_as_managed_app
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@deploy_as_managed_app = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15864 | JSS.MobileDeviceApplication.remove_app_when_mdm_profile_is_removed= | train | def remove_app_when_mdm_profile_is_removed=(new_val)
return nil if new_val == @remove_app_when_mdm_profile_is_removed
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@remove_app_when_mdm_profile_is_removed = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15865 | JSS.MobileDeviceApplication.prevent_backup_of_app_data= | train | def prevent_backup_of_app_data=(new_val)
return nil if new_val == @prevent_backup_of_app_data
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@prevent_backup_of_app_data = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15866 | JSS.MobileDeviceApplication.keep_description_and_icon_up_to_date= | train | def keep_description_and_icon_up_to_date=(new_val)
return nil if new_val == @keep_description_and_icon_up_to_date
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@keep_description_and_icon_up_to_date = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15867 | JSS.MobileDeviceApplication.free= | train | def free=(new_val)
return nil if new_val == @free
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@free = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15868 | JSS.MobileDeviceApplication.take_over_management= | train | def take_over_management=(new_val)
return nil if new_val == @take_over_management
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@take_over_management = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15869 | JSS.MobileDeviceApplication.host_externally= | train | def host_externally=(new_val)
return nil if new_val == @host_externally
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@host_externally = new_val
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15870 | JSS.MobileDeviceApplication.save_ipa | train | 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 | ruby | {
"resource": ""
} |
q15871 | JSS.Computer.management_data | train | def management_data(subset: nil, only: nil)
raise JSS::NoSuchItemError, 'Computer not yet saved in the JSS' unless @in_jss
JSS::Computer.management_data @id, subset: subset, only: only, api: @api
end | ruby | {
"resource": ""
} |
q15872 | JSS.Computer.set_management_to | train | def set_management_to(name, password)
password = nil unless name
@management_username = name
@management_password = password
@managed = name ? true : false
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15873 | JSS.Computer.rest_xml | train | def rest_xml
doc = REXML::Document.new APIConnection::XML_HEADER
computer = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
general = computer.add_element('general')
general.add_element('name').text = @name
general.add_element('alt_mac_address').text = @alt_mac_address
general.add_element('asset_tag').text = @asset_tag
general.add_element('barcode_1').text = @barcode1
general.add_element('barcode_2').text = @barcode2
general.add_element('ip_address').text = @ip_address
general.add_element('mac_address').text = @mac_address
general.add_element('udid').text = @udid
general.add_element('serial_number').text = @serial_number
rmgmt = general.add_element('remote_management')
rmgmt.add_element('managed').text = @managed
rmgmt.add_element('management_username').text = @management_username
rmgmt.add_element('management_password').text = @management_password if @management_password
computer << ext_attr_xml if unsaved_eas?
computer << location_xml if has_location?
computer << purchasing_xml if has_purchasing?
add_site_to_xml(doc)
doc.to_s
end | ruby | {
"resource": ""
} |
q15874 | JSS.APIConnection.get_rsrc | train | def get_rsrc(rsrc, format = :json)
# puts object_id
validate_connected
raise JSS::InvalidDataError, 'format must be :json or :xml' unless %i[json xml].include? format
# TODO: fix what rubocop is complaining about in the line below.
# (I doubt we want to CGI.escape the whole resource)
rsrc = URI.encode rsrc
begin
@last_http_response = @cnx[rsrc].get(accept: format)
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end
# TODO: make sure we're returning the String version of the
# response (i.e. its body) here and in POST, PUT, DELETE.
format == :json ? JSON.parse(@last_http_response, symbolize_names: true) : @last_http_response
end | ruby | {
"resource": ""
} |
q15875 | JSS.APIConnection.put_rsrc | train | def put_rsrc(rsrc, xml)
validate_connected
# convert CRs & to
xml.gsub!(/\r/, ' ')
# send the data
@last_http_response = @cnx[rsrc].put(xml, content_type: 'text/xml')
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end | ruby | {
"resource": ""
} |
q15876 | JSS.APIConnection.post_rsrc | train | def post_rsrc(rsrc, xml = '')
validate_connected
# convert CRs & to
xml.gsub!(/\r/, ' ') if xml
# send the data
@last_http_response = @cnx[rsrc].post xml, content_type: 'text/xml', accept: :json
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end | ruby | {
"resource": ""
} |
q15877 | JSS.APIConnection.delete_rsrc | train | def delete_rsrc(rsrc, xml = nil)
validate_connected
raise MissingDataError, 'Missing :rsrc' if rsrc.nil?
# payload?
return delete_with_payload rsrc, xml if xml
# delete the resource
@last_http_response = @cnx[rsrc].delete
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end | ruby | {
"resource": ""
} |
q15878 | JSS.APIConnection.master_distribution_point | train | def master_distribution_point(refresh = false)
@master_distribution_point = nil if refresh
return @master_distribution_point if @master_distribution_point
all_dps = JSS::DistributionPoint.all refresh, api: self
@master_distribution_point =
case all_dps.size
when 0
raise JSS::NoSuchItemError, 'No distribution points defined'
when 1
JSS::DistributionPoint.fetch id: all_dps.first[:id], api: self
else
JSS::DistributionPoint.fetch id: :master, api: self
end
end | ruby | {
"resource": ""
} |
q15879 | JSS.APIConnection.my_distribution_point | train | def my_distribution_point(refresh = false)
@my_distribution_point = nil if refresh
return @my_distribution_point if @my_distribution_point
my_net_seg = my_network_segments[0]
@my_distribution_point = JSS::NetworkSegment.fetch(id: my_net_seg, api: self).distribution_point if my_net_seg
@my_distribution_point ||= master_distribution_point refresh
@my_distribution_point
end | ruby | {
"resource": ""
} |
q15880 | JSS.APIConnection.network_segments_for_ip | train | def network_segments_for_ip(ip)
ok_ip = IPAddr.new(ip)
matches = []
network_ranges.each { |id, subnet| matches << id if subnet.include?(ok_ip) }
matches
end | ruby | {
"resource": ""
} |
q15881 | JSS.APIConnection.send_mobiledevice_mdm_command | train | def send_mobiledevice_mdm_command(targets, command, data = {})
JSS::MobileDevice.send_mdm_command(targets, command, opts: data, api: self)
end | ruby | {
"resource": ""
} |
q15882 | JSS.APIConnection.verify_basic_args | train | def verify_basic_args(args)
# must have server, user, and pw
raise JSS::MissingDataError, 'No JSS :server specified, or in configuration.' unless args[:server]
raise JSS::MissingDataError, 'No JSS :user specified, or in configuration.' unless args[:user]
raise JSS::MissingDataError, "Missing :pw for user '#{args[:user]}'" unless args[:pw]
end | ruby | {
"resource": ""
} |
q15883 | JSS.APIConnection.verify_server_version | train | def verify_server_version
@connected = true
# the jssuser resource is readable by anyone with a JSS acct
# regardless of their permissions.
# However, it's marked as 'deprecated'. Hopefully jamf will
# keep this basic level of info available for basic authentication
# and JSS version checking.
begin
@server = JSS::Server.new get_rsrc('jssuser')[:user], self
rescue RestClient::Unauthorized
raise JSS::AuthenticationError, "Incorrect JSS username or password for '#{@user}@#{@server_host}:#{@port}'."
end
min_vers = JSS.parse_jss_version(JSS::MINIMUM_SERVER_VERSION)[:version]
return if @server.version >= min_vers # we're good...
err_msg = "JSS version #{@server.raw_version} to low. Must be >= #{min_vers}"
@connected = false
raise JSS::UnsupportedError, err_msg
end | ruby | {
"resource": ""
} |
q15884 | JSS.APIConnection.build_rest_url | train | def build_rest_url(args)
@server_host = args[:server]
@port = args[:port].to_i
if args[:server_path]
# remove leading & trailing slashes in serverpath if any
@server_path = args[:server_path].sub %r{^/*(.*?)/*$}, Regexp.last_match(1)
# re-add single trailing slash
@server_path << '/'
end
# we're using ssl if:
# 1) args[:use_ssl] is anything but false
# or
# 2) the port is a known ssl port.
args[:use_ssl] = args[:use_ssl] != false || SSL_PORTS.include?(@port)
@protocol = 'http'
@protocol << 's' if args[:use_ssl]
# and here's the URL
"#{@protocol}://#{@server_host}:#{@port}/#{@server_path}#{RSRC_BASE}"
end | ruby | {
"resource": ""
} |
q15885 | JSS.Sitable.site= | train | def site=(new_site)
return nil unless updatable? || creatable?
# unset the site? Use nil or an empty string
if NON_SITES.include? new_site
unset_site
return
end
new_id = JSS::Site.valid_id new_site, api: @api
new_name = JSS::Site.map_all_ids_to(:name, api: @api)[new_id]
# no change, go home.
return nil if new_name == @site_name
raise JSS::NoSuchItemError, "Site '#{new_site}' is not known to the JSS" unless new_id
@site_name = new_name
@site_id = new_id
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15886 | JSS.Sitable.parse_site | train | def parse_site
site_data =
if self.class::SITE_SUBSET == :top
@init_data[:site]
elsif @init_data[self.class::SITE_SUBSET]
@init_data[self.class::SITE_SUBSET][:site]
end
site_data ||= { name: NO_SITE_NAME, id: NO_SITE_ID }
@site_name = site_data[:name]
@site_id = site_data[:id]
end | ruby | {
"resource": ""
} |
q15887 | JSS.Sitable.add_site_to_xml | train | def add_site_to_xml(xmldoc)
root = xmldoc.root
site_elem =
if self.class::SITE_SUBSET == :top
root.add_element 'site'
else
parent_elem = root.elements[self.class::SITE_SUBSET.to_s]
parent_elem ||= root.add_element(self.class::SITE_SUBSET.to_s)
parent_elem.add_element 'site'
end
site_elem.add_element('name').text = site_name.to_s
end | ruby | {
"resource": ""
} |
q15888 | JSS.Peripheral.associate | train | def associate(computer)
if computer =~ /^d+$/
raise JSS::NoSuchItemError, "No computer in the JSS with id #{computer}" unless JSS::Computer.all_ids(api: @api).include? computer
@computer_id = computer
else
raise JSS::NoSuchItemError, "No computer in the JSS with name #{computer}" unless JSS::Computer.all_names(api: @api).include? computer
@computer_id = JSS::Computer.map_all_ids_to(:name, api: @api).invert[computer]
end
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15889 | JSS.Peripheral.check_field | train | def check_field(field, value)
### get the field defs for this PeriphType, omitting the leading nil
@field_defs ||= JSS::PeripheralType.fetch(:name => @type, api: @api).fields.compact
### we must have the right number of fields, and they must have the same names
### as the definition
required_fields = @field_defs.map{|f| f[:name]}
raise JSS::InvalidDataError, "Peripherals of type '#{@type}' doesn't have a field '#{field}', they only have: #{required_fields.join(', ')}" unless required_fields.include? field
### any menu fields can only have values as defined by the type.
menu_flds = @field_defs.select{|f| f[:type] == "menu" }
menu_flds.each do |mf|
next unless mf[:name] == field
raise JSS::InvalidDataError, "The value for field '#{field}' must be one of: #{mf[:choices].join(', ')}" unless mf[:choices].include? value
end #if menu_flds.include? field
end | ruby | {
"resource": ""
} |
q15890 | JSS.PatchPolicy.validate_patch_title | train | def validate_patch_title(a_title)
if a_title.is_a? JSS::PatchTitle
@patch_title = a_title
return a_title.id
end
raise JSS::MissingDataError, ':patch_title is required' unless a_title
title_id = JSS::PatchTitle.valid_id a_title
return title_id if title_id
raise JSS::NoSuchItemError, "No Patch Title matches '#{a_title}'"
end | ruby | {
"resource": ""
} |
q15891 | JSS.PatchPolicy.validate_target_version | train | def validate_target_version(tgt_vers)
raise JSS::MissingDataError, "target_version can't be nil" unless tgt_vers
JSS::Validate.non_empty_string tgt_vers
unless patch_title(:refresh).versions.key? tgt_vers
errmsg = "Version '#{tgt_vers}' does not exist for title: #{patch_title_name}."
raise JSS::NoSuchItemError, errmsg
end
return tgt_vers if patch_title.versions_with_packages.key? tgt_vers
errmsg = "Version '#{tgt_vers}' cannot be used in Patch Policies until a package is assigned to it."
raise JSS::UnsupportedError, errmsg
end | ruby | {
"resource": ""
} |
q15892 | JSS.PatchPolicy.refetch_version_info | train | def refetch_version_info
tmp = self.class.fetch id: id
@release_date = tmp.release_date
@incremental_update = tmp.incremental_update
@reboot = tmp.reboot
@minimum_os = tmp.minimum_os
@kill_apps = tmp.kill_apps
end | ruby | {
"resource": ""
} |
q15893 | JSS.User.add_site | train | def add_site (site)
return nil if @sites.map{|s| s[:name]}.include? site
raise JSS::InvalidDataError, "No site in the JSS named #{site}" unless JSS::Site.all_names(api: @api).include? site
@sites << {:name => site}
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15894 | JSS.User.remove_site | train | def remove_site (site)
return nil unless @sites.map{|s| s[:name]}.include? site
@sites.reject!{|s| s[:name] == site}
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15895 | JSS.NetworkSegment.overlap? | train | def overlap?(other_segment)
raise TypeError, 'Argument must be a JSS::NetworkSegment' unless \
other_segment.is_a? JSS::NetworkSegment
other_range = other_segment.range
range.include?(other_range.begin) || range.include?(other_range.end)
end | ruby | {
"resource": ""
} |
q15896 | JSS.NetworkSegment.include? | train | def include?(thing)
if thing.is_a? JSS::NetworkSegment
@starting_address <= thing.range.begin && @ending_address >= thing.range.end
else
thing = IPAddr.new thing.to_s
range.include? thing
end
end | ruby | {
"resource": ""
} |
q15897 | JSS.NetworkSegment.building= | train | def building=(newval)
new = JSS::Building.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No building matching '#{newval}'" unless new
@building = new[:name]
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15898 | JSS.NetworkSegment.override_buildings= | train | def override_buildings=(newval)
raise JSS::InvalidDataError, 'New value must be boolean true or false' unless JSS::TRUE_FALSE.include? newval
@override_buildings = newval
@need_to_update = true
end | ruby | {
"resource": ""
} |
q15899 | JSS.NetworkSegment.department= | train | def department=(newval)
new = JSS::Department.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No department matching '#{newval}' in the JSS" unless new
@department = new[:name]
@need_to_update = true
end | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.