class Jamf::Category
@see Jamf::APIObject
Constants
- DEFAULT_CATEGORY
The Default category
- DEFAULT_PRIORITY
The Default Priority
- NO_CATEGORY_ID
- NO_CATEGORY_NAME
When no category has been assigned, this is the ‘name’ and id used
- OBJECT_HISTORY_OBJECT_TYPE
the object type for this object in the object history table. See {APIObject#add_object_history_entry}
- POSSIBLE_PRIORITIES
The range of possible priorities
- 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
Attributes
@return [Integer] the SelfService priority for this category
Public Class Methods
Class Methods
# File lib/jamf/api/classic/api_objects/category.rb 53 def self.category_id_from_name(name, api: nil, cnx: Jamf.cnx) 54 cnx = api if api 55 return nil if name.nil? 56 return nil if name.casecmp(Jamf::Category::NO_CATEGORY_NAME).zero? 57 58 Jamf::Category.map_all_ids_to(:name, cnx: cnx).invert[name] 59 end
See Jamf::APIObject#initialize
Jamf::APIObject::new
# File lib/jamf/api/classic/api_objects/category.rb 103 def initialize(**args) 104 super 105 @priority = @init_data[:priority] || DEFAULT_PRIORITY 106 end
Public Instance Methods
Change the Priority
@param new_val the new priority, must be in the range POSSIBLE_PRIORITIES
@return [void]
# File lib/jamf/api/classic/api_objects/category.rb 117 def priority=(new_val = @priority) 118 return nil if new_val == @priority 119 raise Jamf::InvalidDataError, "priority must be an integer between #{POSSIBLE_PRIORITIES.first} and #{POSSIBLE_PRIORITIES.last} (inclusive)" unless POSSIBLE_PRIORITIES.include? new_val 120 @priority = new_val 121 @need_to_update = true 122 end
Private Instance Methods
Return a String
with the XML Resource for submitting creation or changes to the JSS
via the API via the Creatable
or Updatable
modules
Most classes will redefine this method.
# File lib/jamf/api/classic/api_objects/category.rb 134 def rest_xml 135 doc = REXML::Document.new Jamf::Connection::XML_HEADER 136 tmpl = doc.add_element self.class::RSRC_OBJECT_KEY.to_s 137 tmpl.add_element('name').text = @name 138 tmpl.add_element('priority').text = @priority 139 doc.to_s 140 end