idx
int64
0
24.9k
question
stringlengths
68
4.14k
target
stringlengths
9
749
5,500
def []= ( key , value ) raise ArgumentError , "key must be string" unless key . instance_of? ( String ) raise ArgumentError , "value must be string" unless value . instance_of? ( String ) @root_node = update_and_delete_storage ( @root_node , NibbleKey . from_string ( key ) , value ) update_root_hash end
Set value of key .
5,501
def delete ( key ) raise ArgumentError , "key must be string" unless key . instance_of? ( String ) raise ArgumentError , "max key size is 32" if key . size > 32 @root_node = delete_and_delete_storage ( @root_node , NibbleKey . from_string ( key ) ) update_root_hash end
Delete value at key .
5,502
def to_h h = { } to_hash ( @root_node ) . each do | k , v | key = k . terminate ( false ) . to_string h [ key ] = v end h end
Convert to hash .
5,503
def find ( node , nbk ) node_type = get_node_type node case node_type when :blank BLANK_NODE when :branch return node . last if nbk . empty? sub_node = decode_to_node node [ nbk [ 0 ] ] find sub_node , nbk [ 1 .. - 1 ] when :leaf node_key = NibbleKey . decode ( node [ 0 ] ) . terminate ( false ) nbk == node_key ? node ...
Get value inside a node .
5,504
def update_node ( node , key , value ) node_type = get_node_type node case node_type when :blank [ key . terminate ( true ) . encode , value ] when :branch if key . empty? node . last = value else new_node = update_and_delete_storage ( decode_to_node ( node [ key [ 0 ] ] ) , key [ 1 .. - 1 ] , value ) node [ key [ 0 ] ...
Update item inside a node .
5,505
def delete_node ( node , key ) case get_node_type ( node ) when :blank BLANK_NODE when :branch delete_branch_node ( node , key ) else delete_kv_node ( node , key ) end end
Delete item inside node .
5,506
def delete_node_storage ( node ) return if node == BLANK_NODE raise ArgumentError , "node must be Array or BLANK_NODE" unless node . instance_of? ( Array ) encoded = encode_node node return if encoded . size < 32 end
Delete node storage .
5,507
def get_node_type ( node ) return :blank if node == BLANK_NODE case node . size when KV_WIDTH NibbleKey . decode ( node [ 0 ] ) . terminate? ? :leaf : :extension when BRANCH_WIDTH :branch else raise InvalidNode , "node size must be #{KV_WIDTH} or #{BRANCH_WIDTH}" end end
get node type and content
5,508
def preprocess_code ( code ) code = Utils . bytes_to_int_array code ops = [ ] i = 0 while i < code . size o = Opcodes :: TABLE . fetch ( code [ i ] , [ :INVALID , 0 , 0 , 0 ] ) + [ code [ i ] , 0 ] ops . push o if o [ 0 ] [ 0 , Opcodes :: PREFIX_PUSH . size ] == Opcodes :: PREFIX_PUSH n = o [ 0 ] [ Opcodes :: PREFIX_PU...
Preprocesses code and determines which locations are in the middle of pushdata and thus invalid
5,509
def check_pow ( nonce = nil ) logger . debug "checking pow" , block : full_hash_hex [ 0 , 8 ] Miner . check_pow ( number , mining_hash , mixhash , nonce || self . nonce , difficulty ) end
Check if the proof - of - work of the block is valid .
5,510
def to_h h = { } %i( prevhash uncles_hash extra_data nonce mixhash ) . each do | field | h [ field ] = "0x#{Utils.encode_hex(send field)}" end %i( state_root tx_list_root receipts_root coinbase ) . each do | field | h [ field ] = Utils . encode_hex send ( field ) end %i( number difficulty gas_limit gas_used timestamp )...
Serialize the header to a readable hash .
5,511
def get_brothers ( block ) o = [ ] i = 0 while block . has_parent? && i < @env . config [ :max_uncle_depth ] parent = block . get_parent children = get_children ( parent ) . select { | c | c != block } o . concat children block = parent i += 1 end o end
Return the uncles of the hypothetical child of block .
5,512
def add_block ( block , forward_pending_transaction = true ) unless block . has_parent? || block . genesis? logger . debug "missing parent" , block_hash : block return false end unless block . validate_uncles logger . debug "invalid uncles" , block_hash : block return false end unless block . header . check_pow || bloc...
Returns true if block was added successfully .
5,513
def add_transaction ( transaction ) raise AssertError , "head candiate cannot be nil" unless @head_candidate hc = @head_candidate logger . debug "add tx" , num_txs : transaction_count , tx : transaction , on : hc if @head_candidate . include_transaction? ( transaction . full_hash ) logger . debug "known tx" return end ...
Add a transaction to the head_candidate block .
5,514
def get_chain ( start : '' , count : 10 ) logger . debug "get_chain" , start : Utils . encode_hex ( start ) , count : count if start . true? return [ ] unless @index . db . include? ( start ) block = get start return [ ] unless in_main_branch? ( block ) else block = head end blocks = [ ] count . times do | i | blocks ....
Return count of blocks starting from head or start .
5,515
def update_head_candidate ( forward_pending_transaction = true ) logger . debug "updating head candidate" , head : head blk = head uncles = get_brothers ( blk ) . map ( & :header ) . uniq ( @env . config [ :max_uncle_depth ] + 2 ) . times do | i | blk . uncles . each { | u | uncles . delete u } blk = blk . get_parent i...
after new head is set
5,516
def update_blocknumbers ( blk ) loop do if blk . number > 0 @db . put_temporarily block_by_number_key ( blk . number ) , blk . full_hash else @db . put block_by_number_key ( blk . number ) , blk . full_hash end @db . commit_refcount_changes blk . number break if blk . number == 0 blk = blk . get_parent ( ) break if has...
start from head and update until the existing indices match the block
5,517
def install_if_reported_available = ( new_val ) return nil if new_val == @install_if_reported_available new_val = false if new_val . to_s . empty? raise JSS :: InvalidDataError , 'install_if_reported_available must be boolean true or false' unless JSS :: TRUE_FALSE . include? new_val @install_if_reported_available = ne...
Change the if_in_swupdate field in the JSS
5,518
def priority = ( new_val ) return nil if new_val == @priority new_val = DEFAULT_PRIORITY if new_val . to_s . empty? raise JSS :: InvalidDataError , ':priority must be an integer from 1-20' unless PRIORITIES . include? new_val @priority = new_val @need_to_update = true end
Change the priority field in the JSS
5,519
def required_processor = ( new_val ) return nil if new_val == @required_processor new_val = DEFAULT_PROCESSOR if new_val . to_s . empty? raise JSS :: InvalidDataError , "Required_processor must be one of: #{CPU_TYPES.join ', '}" unless CPU_TYPES . include? new_val @required_processor = new_val @need_to_update = true en...
Change the required processor field in the JSS
5,520
def calculate_checksum ( type : nil , local_file : nil , rw_pw : nil , ro_pw : nil , unmount : true ) type ||= DEFAULT_CHECKSUM_HASH_TYPE mdp = JSS :: DistributionPoint . master_distribution_point api : @api if local_file file_to_calc = local_file else if rw_pw dppw = rw_pw mnt = :rw elsif ro_pw dppw = ro_pw mnt = :ro ...
Caclulate and return the checksum hash for a given local file or the file on the master dist point if no local file is given .
5,521
def checksum_valid? ( local_file : nil , rw_pw : nil , ro_pw : nil , unmount : true ) return false unless @checksum new_checksum = calculate_checksum ( type : @checksum_type , local_file : local_file , rw_pw : rw_pw , ro_pw : ro_pw , unmount : unmount ) new_checksum == @checksum end
Is the checksum for this pkg is valid?
5,522
def update_master_filename ( old_file_name , new_file_name , rw_pw , unmount = true ) raise JSS :: NoSuchItemError , "#{old_file_name} does not exist in the jss." unless @in_jss mdp = JSS :: DistributionPoint . master_distribution_point api : @api pkgs_dir = mdp . mount ( rw_pw , :rw ) + DIST_POINT_PKGS_FOLDER . to_s o...
Change the name of a package file on the master distribution point .
5,523
def delete ( delete_file : false , rw_pw : nil , unmount : true ) super ( ) delete_master_file ( rw_pw , unmount ) if delete_file end
delete master file Delete this package from the JSS optionally deleting the master dist point file also .
5,524
def uninstall ( args = { } ) unless removable? raise JSS :: UnsupportedError , 'This package cannot be uninstalled. Please use CasperAdmin to index it and allow uninstalls' end raise JSS :: UnsupportedError , 'You must have root privileges to uninstall packages' unless JSS . superuser? args [ :target ] ||= '/' do_feu =...
Uninstall this pkg via the jamf command .
5,525
def rest_xml doc = REXML :: Document . new dp = doc . add_element "distribution_point" dp . add_element ( :name . to_s ) . text = @name dp . add_element ( :ip_address . to_s ) . text = @ip_address dp . add_element ( :local_path . to_s ) . text = @local_path dp . add_element ( :enable_load_balancing . to_s ) . text = @e...
Unused - until I get around to making DP s updatable
5,526
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
Set the event handled by this webhook Must be a member of the EVENTS Array
5,527
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' ) ....
Return the REST XML for this webhook with the current values for saving or updating
5,528
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_...
Public Instance Methods
5,529
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_ele...
Sets invitation expiration 4 hours after request .
5,530
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
Save the icon to a file .
5,531
def category = ( new_cat ) return nil unless updatable? || creatable? if NON_CATEGORIES . include? new_cat unset_category return end new_name , new_id = evaluate_new_category ( new_cat ) return nil if new_name == @category_name raise JSS :: NoSuchItemError , "Category '#{new_cat}' is not known to the JSS" unless JSS ::...
Change the category of this object . Any of the NON_CATEGORIES values will unset the category
5,532
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 ] @categor...
Parse the category data from any incoming API data
5,533
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 ....
Add the category to the XML for POSTing or PUTting to the API .
5,534
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 . ta...
Change the scope
5,535
def erase_device ( passcode = '' , preserve_data_plan : false ) self . class . erase_device @id , passcode : passcode , preserve_data_plan : preserve_data_plan , api : @api end
Send an erase device command to this object
5,536
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
Send a wallpaper command to this object
5,537
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
Send a enable_lost_mode command to one or more targets
5,538
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
Set a new frequency for this policy .
5,539
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
Set a new target drive for this policy .
5,540
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
Set whether this policy is available offline .
5,541
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 :: InvalidDataE...
Change a trigger event
5,542
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
Set Server Side Activation
5,543
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
Set Server Side Expiration
5,544
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
What to do at reboot when there is a User Logged In
5,545
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
Set Reboot Message
5,546
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
Set Startup Disk Only Supports Specify Local Startup Disk at the moment
5,547
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
Specify Startup Volume Only Supports Specify Local Startup Disk
5,548
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
Reboot Options Minutes Until Reboot
5,549
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
Set the unix shell command to be run on the client
5,550
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
Set the process name to search for and if it should be killed if found .
5,551
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 = ...
Set the path to search for a String or Pathname and whether or not to delete it if found .
5,552
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
Set the term to seach for using spotlight
5,553
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
Set the term to seach for using the locate command
5,554
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 [...
Add a package to the list of pkgs handled by this policy . If the pkg already exists in the policy nil is returned and no changes are made .
5,555
def remove_package ( identifier ) removed = @packages . delete_if { | p | p [ :id ] == identifier || p [ :name ] == identifier } @need_to_update = true if removed removed end
Remove a package from this policy by name or id
5,556
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 ] ] , paramet...
Add a script to the list of SCRIPT_PRIORITIESipts run by this policy . If the script already exists in the policy nil is returned and no changes are made .
5,557
def remove_script ( identifier ) removed = @scripts . delete_if { | s | s [ :id ] == identifier || s [ :name ] == identifier } @need_to_update = true if removed removed end
Remove a script from this policy by name or id
5,558
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
Actions Try to execute this policy on this machine .
5,559
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.jo...
Flush all policy logs for this policy older than some number of days weeks months or years .
5,560
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...
raise an error if a package being added isn t valid
5,561
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 ...
raise an error if a script being added isn t valid
5,562
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
Change the inventory_display of this EA
5,563
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
Change the input type of this EA
5,564
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 ) 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 formatt...
Change the Popup Choices of this EA New value must be an Array the items will be converted to Strings .
5,565
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 :: SEA...
Get an Array of Hashes for all inventory objects with a desired result in their latest report for this EA .
5,566
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 ...
Return a REXML object for this ext attr with the current values . Subclasses should augment this in their rest_xml methods then return it . to_s for saving or updating
5,567
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
Change the recon_display of this EA
5,568
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
raise an exeption if needed when trying to do something that needs a host and port set
5,569
def valid_server? ( server , port = DFT_PORT ) mysql = Mysql . init mysql . options Mysql :: OPT_CONNECT_TIMEOUT , 5 begin mysql . connect server , 'notArealUser' , "definatelyNotA#{$PROCESS_ID}password" , 'not_a_db' , port rescue Mysql :: ServerError :: AccessDeniedError return true rescue return false end false end
disconnect Test that a given hostname is a MySQL server
5,570
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 :: Categor...
Add or change one of the categories for this item in self service
5,571
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...
Set the value for user - removability of profiles optionally providing a password for removal on iOS targets .
5,572
def self_service_notification_type = ( type ) validate_notifications_supported 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 N...
How should self service notifications be displayed
5,573
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
set reminder notification frequency
5,574
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...
Set a new Self Service icon for this object .
5,575
def parse_self_service_notifications ( ss_data ) return unless @self_service_data_config [ :notifications_supported ] 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_enabl...
parse incoming ssvc notification settings
5,576
def add_self_service_xml ( xdoc ) doc_root = xdoc . root 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' )...
refresh icon Add approriate XML for self service data to the XML document for this item .
5,577
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...
add_self_service_xml add the correct XML indicating whether or not we re even in SSvc
5,578
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' ...
add the xml specific to profiles
5,579
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'...
add the xml for self - service categories
5,580
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_b...
set macOS settings in ssvc xml
5,581
def add_self_service_notification_xml ( ssvc ) return unless @self_service_data_config [ :notifications_supported ] 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'...
set ssvc notification settings in xml
5,582
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 ) ra...
Raise an error if user_removable settings are wrong
5,583
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
Raise an error if an icon id is not valid
5,584
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 end
Save any changes
5,585
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_dis...
Requery the API for the search results .
5,586
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
Set the list of fields to be retrieved with the search results .
5,587
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}...
Export the display fields of the search results to a file .
5,588
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 ( 'sor...
Clean up the inconsistent Display Field keys in the search results .
5,589
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
Set whether or not this app should be deployed as managed
5,590
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
Set whether or not this app should be removed when the device is unmanaged
5,591
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
Set whether or not the device should back up this app s data
5,592
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
Set whether or not the jss should update info about this app from the app store
5,593
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
Set whether or not this is a free app
5,594
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
Set whether or not Jamf should manage this app even if the user installed it on their own .
5,595
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
Set whether or not this app s . ipa is hosted outside the Jamf server
5,596
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 Bas...
Save the application to a file .
5,597
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
app usage The computer management data for this computer
5,598
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
Set or unset management acct and password for this computer
5,599
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_el...
Return a String with the XML Resource for submitting changes to the JSS via the API