class Jamf::ConfigurationProfile

The parent class of OSXConfigurationProfile and MobileDeviceConfigurationProfile

Note that the profile payloads and the profile UUID cannot be edited or updated with this via this class. Use the web UI.

@see Jamf::APIObject

Constants

CATEGORY_DATA_TYPE

How is the category stored in the API data?

CATEGORY_SUBSET

Where is the Category in the API JSON?

DISTRIBUTION_METHODS

The possible values for the distribution_method/deployment_method

REDEPLOY_ALL
REDEPLOY_NEWLY_ASSIGNED

when a change is made, which in-scope machines should get the changed profile?

SELF_SERVICE_DIST_METHOD

which DISTRIBUTION_METHODS means we’re in self service?

SELF_SERVICE_PAYLOAD

Our SelfService deploys profiles

SITE_SUBSET

Where is the Site data in the API JSON?

Attributes

description[R]

@return [String] the description of this profile

payloads[R]

@return [String] the plist containing the payloads for this profile. NOT Updatable

redeploy_on_update[R]

@return [String] When a change is made to the profile, which scoped machines

should get the changes? This will always contain REDEPLOY_NEWLY_ASSIGNED
when fetched, but can be set to REDEPLOY_ALL via the redeploy_to_all:
parameter to #update & #save. After the update is complete, it reverts
to REDEPLOY_NEWLY_ASSIGNED
uuid[R]

@return [String] the uuid of this profile. NOT Updatable

Public Class Methods

new(**args) click to toggle source

See Jamf::APIObject#initialize

Calls superclass method Jamf::APIObject::new
    # File lib/jamf/api/classic/base_classes/configuration_profile.rb
 99 def initialize(**args)
100   super
101   @description = @main_subset[:description]
102   @uuid = @main_subset[:uuid]
103   @redeploy_on_update = @main_subset[:redeploy_on_update]
104   @payloads = @main_subset[:payloads]
105 end

Public Instance Methods

description=(new_val) click to toggle source

@param new_val the new discription

@return [void]

    # File lib/jamf/api/classic/base_classes/configuration_profile.rb
114 def description=(new_val)
115   new_val = new_val.strip
116   return nil if @self_service_description == new_val
117 
118   @description = new_val
119   @need_to_update = true
120 end
parsed_payloads() click to toggle source

The @payloads Plist, parsed into a Ruby object

@return [Hash] the parsed payloads plist.

    # File lib/jamf/api/classic/base_classes/configuration_profile.rb
125 def parsed_payloads
126   JSS.parse_plist @payloads
127 end
payload_content() click to toggle source

@return [Array<Hash>] the individual payloads from the payload Plist

    # File lib/jamf/api/classic/base_classes/configuration_profile.rb
131 def payload_content
132   parsed_payloads['PayloadContent']
133 end
payload_content=(new_content) click to toggle source

@param new_content [Array<Hash>] replace the payload content entirely.

The 'payload' of a config profile is an XML Plist. The top-level key
of that plist 'PayloadContent' contains an Array of Dicts, each one being
a part of the payload for the profile.

When replacing the PayloadContent Array, using this method, provide a
*ruby* Array full of *ruby* hashes, and they will be converted to a
Plist and embedded into the API XML appropriately.

WARNING: This can be dangerous! Editing the Plist Payload of a Config
profile may break the profile. Make sure you test on a fake profile
before using this method in production.

@return [void]

    # File lib/jamf/api/classic/base_classes/configuration_profile.rb
151 def payload_content=(new_content)
152   payload_plist_data = parsed_payloads
153   payload_plist_data['PayloadContent'] = new_content
154   @payloads = Jamf.xml_plist_from payload_plist_data
155   @need_to_update = true
156   @update_payloads = true
157 end
payload_types() click to toggle source

@return [Array<String>] the PayloadType of each payload (e.g. com.apple.caldav.account)

    # File lib/jamf/api/classic/base_classes/configuration_profile.rb
161 def payload_types
162   payload_content.map { |p| p['PayloadType'] }
163 end
save(redeploy_to_all: false) click to toggle source

wrapper with param

    # File lib/jamf/api/classic/base_classes/configuration_profile.rb
175 def save(redeploy_to_all: false)
176   if @in_jss
177     raise Jamf::UnsupportedError, 'Updating this object in the JSS is currently not supported by ruby-jss' unless updatable?
178 
179     update redeploy_to_all: redeploy_to_all
180   else
181     raise Jamf::UnsupportedError, 'Creating this object in the JSS is currently not supported by ruby-jss' unless creatable?
182 
183     create
184   end
185 end
update(redeploy_to_all: false) click to toggle source

clear flag after updating

Calls superclass method Jamf::SelfServable#update
    # File lib/jamf/api/classic/base_classes/configuration_profile.rb
166 def update(redeploy_to_all: false)
167   @redeploy_on_update = redeploy_to_all ? REDEPLOY_ALL : REDEPLOY_NEWLY_ASSIGNED
168   super()
169   # always reset to newly assigned
170   @redeploy_on_update = REDEPLOY_NEWLY_ASSIGNED
171   @update_payloads = nil
172 end

Private Instance Methods

rest_xml() click to toggle source

Private Instance Methods

    # File lib/jamf/api/classic/base_classes/configuration_profile.rb
191 def rest_xml
192   doc = REXML::Document.new
193 
194   obj = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
195   gen = obj.add_element('general')
196   gen.add_element('description').text = @description
197   gen.add_element('redeploy_on_update').text = @redeploy_on_update
198   if @update_payloads
199     payloads_plist_xml = JSS.escape_xml(@payloads.gsub(/^\t*/, '').gsub(">\n", '>'))
200     gen.add_element('payloads').text = payloads_plist_xml
201   end
202   obj << @scope.scope_xml
203   add_self_service_xml doc
204   add_category_to_xml doc
205   add_site_to_xml doc
206   doc
207 end