Class: JSS::PatchPolicy
- Includes:
- Creatable, Scopable, SelfServable, Updatable
- Defined in:
- lib/jss/api_object/patch_policy.rb,
lib/jss.rb
Overview
A Patch Policy in the JSS
When making new Patch Polices :patch_title and :target_version must be provided as well as :name.
:patch_title is the name or id of a currently active patch title
:target_version is the string identfier of an available version of the title. The target version MUST have a package assigned to it.
See PatchTitle and JSS::PatchSource.available_titles for methods to acquire such info.
Constant Summary collapse
- RSRC_BASE =
'patchpolicies'.freeze
- RSRC_LIST_KEY =
:patch_policies
- RSRC_OBJECT_KEY =
:patch_policy
- RSRC_BY_PATCH_TITLE =
'patchpolicies/softwaretitleconfig/id/'.freeze
- RSRC_BY_PATCH_TITLE_LIST_KEY =
TODO: complain to jamf about this - should be the same as RSRC_LIST_KEY
:"patch policies"
- SCOPE_TARGET_KEY =
:computers
- AUTO_INSTALL_GRACE_PERIOD_MESSAGE =
'$APP_NAMES will quit in $DELAY_MINUTES minutes so that $SOFTWARE_TITLE can be updated. Save anything you are working on and quit the app(s).'.freeze
- DFT_ENABLED =
false
- DFT_DISTRIBUTION =
the default dist method - not in ssvc
'prompt'.freeze
- NO_DEADLINE =
the value of #deadline when there is no deadline
:none
- DFT_DEADLINE =
7
- DFT_GRACE_PERIOD =
The valud of #grace_period when not defined
15
- DFT_GRACE_PERIOD_SUBJECT =
'Important'.freeze
- DFT_GRACE_PERIOD_MESSAGE =
'$APP_NAMES will quit in $DELAY_MINUTES minutes so that $SOFTWARE_TITLE can be updated. Save anything you are working on and quit the app(s).'.freeze
- USE_XML_WORKAROUND =
See XMLWorkaround
{ patch_policy: { general: { id: -1, name: JSS::BLANK, enabled: nil, target_version: JSS::BLANK, release_date: 0, incremental_update: nil, reboot: nil, minimum_os: JSS::BLANK, kill_apps: [ { kill_app_name: JSS::BLANK, kill_app_bundle_id: JSS::BLANK } ], distribution_method: JSS::BLANK, allow_downgrade: nil, patch_unknown: nil }, scope: { all_computers: nil, computers: [ { id: -1, name: JSS::BLANK, udid: JSS::BLANK } ], computer_groups: [ { id: -1, name: JSS::BLANK } ], users: [ { id: -1, username: JSS::BLANK } ], user_groups: [ { id: -1, name: JSS::BLANK } ], buildings: [ { id: -1, name: JSS::BLANK } ], departments: [ { id: -1, name: JSS::BLANK } ], limitations: { network_segments: [ { id: -1, name: JSS::BLANK } ], ibeacons: [ { id: -1, name: JSS::BLANK } ] }, exclusions: { computers: [ { id: -1, name: JSS::BLANK, udid: JSS::BLANK } ], computer_groups: [ { id: -1, name: JSS::BLANK } ], users: [ { id: -1, username: JSS::BLANK } ], user_groups: [ { id: -1, name: JSS::BLANK } ], buildings: [ { id: -1, name: JSS::BLANK } ], departments: [ { id: -1, name: JSS::BLANK } ], network_segments: [ { id: -1, name: JSS::BLANK } ], ibeacons: [ { id: -1, name: JSS::BLANK } ] } }, user_interaction: { install_button_text: JSS::BLANK, self_service_description: JSS::BLANK, self_service_icon: { id: -1, filename: JSS::BLANK, uri: JSS::BLANK }, notifications: { notification_enabled: nil, notification_type: JSS::BLANK, notification_subject: JSS::BLANK, notification_message: JSS::BLANK, reminders: { notification_reminders_enabled: nil, notification_reminder_frequency: 1 } }, deadlines: { deadline_enabled: nil, deadline_period: 7 }, grace_period: { grace_period_duration: 15, notification_center_subject: 'Important', message: AUTO_INSTALL_GRACE_PERIOD_MESSAGE } }, software_title_configuration_id: 2 } }.freeze
Instance Attribute Summary collapse
-
#allow_downgrade ⇒ Boolean
(also: #allow_downgrade?, #downgradable?)
Can this title be downgraded to this version?.
-
#deadline ⇒ Integer, Symnol
How many days is the install deadline?.
-
#enabled ⇒ Boolean
(also: #enabled?)
readonly
Is this patch policy enabled?.
-
#grace_period ⇒ Integer
(also: #grace_period_duration)
How many minutes does the user have to quit the killapps?.
-
#grace_period_message ⇒ String
The message displayed asking the user to quit the killapps within @grace_period minutes.
-
#grace_period_subject ⇒ String
(also: #grace_period_notification_center_subject)
The Subject of the message displayed asking the user to quit the killapps within @grace_period minutes.
-
#icon ⇒ JSS::Icon?
(also: #self_service_icon)
included
from SelfServable
The icon used in self-service.
-
#in_self_service ⇒ Boolean
(also: #in_self_service?)
included
from SelfServable
readonly
Is this thing available in Self Service?.
-
#incremental_update ⇒ Boolean
(also: #incremental_update?)
readonly
Must this patch be installed only over the prev.
-
#kill_apps ⇒ Array<Hash>
readonly
The apps that cannot be running when this is installed.
-
#minimum_os ⇒ String
readonly
The min.
-
#need_to_update ⇒ Boolean
included
from Updatable
readonly
Do we have unsaved changes?.
-
#patch_title_id ⇒ Integer
(also: #software_title_id, #software_title_configuration_id)
readonly
The id of the JSS::PatchTitle for this policy.
-
#patch_unknown ⇒ Boolean
(also: #patch_unknown?)
Can this policy run when we don't know the prev.
-
#reboot ⇒ Boolean
(also: #reboot_required, #reboot?, #reboot_required?)
readonly
Does this patch require a reboot after installation?.
-
#release_date ⇒ Time
readonly
When the target_version was released.
-
#scope ⇒ Object
included
from Scopable
Attribtues.
-
#self_service_categories ⇒ Array<Hash>
included
from SelfServable
readonly
Each Hash has these keys about the category - :id => [Integer] the JSS id of the category - :name => [String] the name of the category.
-
#self_service_description ⇒ String
included
from SelfServable
The verbage that appears in SelfSvc for this item.
-
#self_service_display_name ⇒ String
(also: #self_service_dislay_name)
included
from SelfServable
The name to display in macOS Self Service.
-
#self_service_feature_on_main_page ⇒ Boolean
included
from SelfServable
Only applicable to macOS targets.
-
#self_service_force_users_to_view_description ⇒ Boolean
included
from SelfServable
Should an extra window appear before the user can install the item? (OSX SSvc only).
-
#self_service_install_button_text ⇒ String
included
from SelfServable
defaults to 'Install'.
-
#self_service_notification_message ⇒ String
included
from SelfServable
The message text of the notification.
-
#self_service_notification_subject ⇒ String
included
from SelfServable
object name.
-
#self_service_notification_type ⇒ Symbol
included
from SelfServable
How should notifications be sent either :ssvc_only or :ssvc_and_nctr.
-
#self_service_notifications_enabled ⇒ Boolean
(also: #self_service_notifications_enabled?)
included
from SelfServable
Should jamf send notifications to self service?.
-
#self_service_reinstall_button_text ⇒ String
included
from SelfServable
defaults to 'Reinstall'.
-
#self_service_reminder_frequency ⇒ Integer
included
from SelfServable
How often (in days) should reminders be given.
-
#self_service_reminders_enabled ⇒ Boolean
(also: #self_service_reminders_enabled?)
included
from SelfServable
Should self service give reminders by displaying the notification repeatedly?.
-
#self_service_removal_password ⇒ String
included
from SelfServable
readonly
The password needed for removal, in plain text.
-
#self_service_user_removable ⇒ Symbol
included
from SelfServable
One of the keys in PROFILE_REMOVAL_BY_USER.
-
#target_version ⇒ String
(also: #version)
When setting, the version must exist in the policy's PatchTitle, and have a package assigned to it.
Class Method Summary collapse
-
.all_for_title(title, api: JSS.api) ⇒ Array<Hash>
Fetch name and id of all PatchPolicies tied to a given PatchTitle.
-
.fetch(searchterm = nil, **args) ⇒ Object
Override APIObject.fetch, since there's no …/patchpolicies/name/…
Instance Method Summary collapse
-
#add_self_service_category(new_cat, display_in: true, feature_in: false) ⇒ void
(also: #set_self_service_category, #change_self_service_category)
included
from SelfServable
Add or change one of the categories for this item in self service.
-
#add_to_self_service ⇒ void
included
from SelfServable
Add this object to self service if not already there.
-
#clone(new_name, api: nil) ⇒ APIObject
included
from Creatable
make a clone of this API object, with a new name.
-
#create ⇒ Integer
Create a new PatchPolicy in the JSS.
-
#disable ⇒ void
disable this policy.
-
#enable ⇒ void
enable this policy.
-
#initialize(data = {}) ⇒ PatchPolicy
constructor
When making new Patch Polices :patch_title is required and is a JSS::PatchTitle or the name or id of one.
-
#name=(newname) ⇒ void
included
from Updatable
Change the name of this item Remember to #update to push changes to the server.
-
#parse_scope ⇒ void
included
from Scopable
private
Call this during initialization of objects that have a scope and the scope instance will be created from @init_data.
-
#patch_title(refresh = false) ⇒ JSS::PatchTitle?
The JSS::PatchTitle to for this PatchPolicy.
-
#patch_title_name ⇒ String
The name of the PatchTitle for this patch policy.
-
#remove_from_self_service ⇒ void
included
from SelfServable
Remove this object from self service if it's there.
-
#remove_self_service_category(cat) ⇒ void
included
from SelfServable
Remove a category from those for this item in SSvc.
-
#self_service_execute_url ⇒ String
included
from SelfServable
The url to view this thing in Self Service.
-
#self_service_payload ⇒ Symbol
included
from SelfServable
What does this object deploy to the device via self service?.
-
#self_service_targets ⇒ Array<Symbol>
included
from SelfServable
What devices types can get this thing in Self Service.
-
#self_service_view_url ⇒ String
included
from SelfServable
The url to view this thing in Self Service.
-
#should_update ⇒ void
included
from Scopable
When the scope changes, it calls this to tell us that an update is needed.
-
#update ⇒ Integer
Update an existing PatchPolicy with changes from ruby.
-
#upload(type, local_file, force_ipa_upload: false) ⇒ Boolean
included
from Uploadable
instance method wrapper for class method.
-
#user_removable? ⇒ Boolean?
included
from SelfServable
Can this thing be removed by the user?.
Constructor Details
#initialize(data = {}) ⇒ PatchPolicy
When making new Patch Polices :patch_title is required and is a JSS::PatchTitle or the name or id of one
If target_version: is provided, it must exist in the PatchTitle, and must have a package assigned to it.
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
# File 'lib/jss/api_object/patch_policy.rb', line 363 def initialize(data = {}) super # creation... unless in_jss @init_data[:general] ||= {} @init_data[:software_title_configuration_id] = validate_patch_title @init_data[:patch_title] # were we given target_version in the make params? validate_target_version @init_data[:target_version] if @init_data[:target_version] @init_data[:general][:target_version] = @init_data[:target_version] # other defaults @init_data[:general][:enabled] = false @init_data[:general][:allow_downgrade] = false @init_data[:general][:patch_unknown] = false @init_data[:general][:distribution_method] = DFT_DISTRIBUTION end @patch_title_id = @init_data[:software_title_configuration_id] gen = @init_data[:general] @enabled = gen[:enabled] @target_version = gen[:target_version] @allow_downgrade = gen[:allow_downgrade] @patch_unknown = gen[:patch_unknown] @init_data[:user_interaction] ||= {} deadlines = @init_data[:user_interaction][:deadlines] deadlines ||= {} deadlines[:deadline_period] = DFT_DEADLINE if deadlines[:deadline_period].to_s.empty? @deadline = deadlines[:deadline_enabled] ? deadlines[:deadline_period] : NO_DEADLINE grace = @init_data[:user_interaction][:grace_period] grace ||= {} @grace_period = grace[:grace_period_duration] @grace_period = DFT_GRACE_PERIOD if @grace_period.to_s.empty? @grace_period_subject = grace[:notification_center_subject] @grace_period_subject = DFT_GRACE_PERIOD_SUBJECT if @grace_period_subject.to_s.empty? @grace_period_message = grace[:message] @grace_period_message = DFT_GRACE_PERIOD_MESSAGE if @grace_period_message.to_s.empty? # read-only values, they come from the version. @release_date = JSS.epoch_to_time gen[:release_date] @incremental_update = gen[:incremental_update] @reboot = gen[:reboot] @minimum_os = gen[:minimum_os] @kill_apps = gen[:kill_apps] end |
Instance Attribute Details
#allow_downgrade ⇒ Boolean Also known as: allow_downgrade?, downgradable?
Can this title be downgraded to this version?
313 314 315 |
# File 'lib/jss/api_object/patch_policy.rb', line 313 def allow_downgrade @allow_downgrade end |
#deadline ⇒ Integer, Symnol
How many days is the install deadline?
328 329 330 |
# File 'lib/jss/api_object/patch_policy.rb', line 328 def deadline @deadline end |
#enabled ⇒ Boolean (readonly) Also known as: enabled?
Returns is this patch policy enabled?.
277 278 279 |
# File 'lib/jss/api_object/patch_policy.rb', line 277 def enabled @enabled end |
#grace_period ⇒ Integer Also known as: grace_period_duration
Returns How many minutes does the user have to quit the killapps?.
334 335 336 |
# File 'lib/jss/api_object/patch_policy.rb', line 334 def grace_period @grace_period end |
#grace_period_message ⇒ String
Returns The message displayed asking the user to quit the killapps within @grace_period minutes.
348 349 350 |
# File 'lib/jss/api_object/patch_policy.rb', line 348 def @grace_period_message end |
#grace_period_subject ⇒ String Also known as: grace_period_notification_center_subject
Returns The Subject of the message displayed asking the user to quit the killapps within @grace_period minutes.
341 342 343 |
# File 'lib/jss/api_object/patch_policy.rb', line 341 def grace_period_subject @grace_period_subject end |
#icon ⇒ JSS::Icon? Also known as: self_service_icon Originally defined in module SelfServable
Returns The icon used in self-service.
#in_self_service ⇒ Boolean (readonly) Also known as: in_self_service? Originally defined in module SelfServable
Returns Is this thing available in Self Service?.
#incremental_update ⇒ Boolean (readonly) Also known as: incremental_update?
Returns must this patch be installed only over the prev. version?.
294 295 296 |
# File 'lib/jss/api_object/patch_policy.rb', line 294 def incremental_update @incremental_update end |
#kill_apps ⇒ Array<Hash> (readonly)
Returns The apps that cannot be running when this is installed. each Hash contains :kill_app_name and :kill_app_bundle_id, both Strings.
308 309 310 |
# File 'lib/jss/api_object/patch_policy.rb', line 308 def kill_apps @kill_apps end |
#minimum_os ⇒ String (readonly)
Returns The min. OS version require to install this patch.
304 305 306 |
# File 'lib/jss/api_object/patch_policy.rb', line 304 def minimum_os @minimum_os end |
#need_to_update ⇒ Boolean (readonly) Originally defined in module Updatable
Returns do we have unsaved changes?.
#patch_title_id ⇒ Integer (readonly) Also known as: software_title_id, software_title_configuration_id
Returns the id of the JSS::PatchTitle for this policy. Can be set with the patch_title: param of .make, but is read-only after that.
353 354 355 |
# File 'lib/jss/api_object/patch_policy.rb', line 353 def patch_title_id @patch_title_id end |
#patch_unknown ⇒ Boolean Also known as: patch_unknown?
Can this policy run when we don't know the prev. version?
320 321 322 |
# File 'lib/jss/api_object/patch_policy.rb', line 320 def patch_unknown @patch_unknown end |
#reboot ⇒ Boolean (readonly) Also known as: reboot_required, reboot?, reboot_required?
Returns does this patch require a reboot after installation?.
298 299 300 |
# File 'lib/jss/api_object/patch_policy.rb', line 298 def reboot @reboot end |
#release_date ⇒ Time (readonly)
Returns when the target_version was released.
291 292 293 |
# File 'lib/jss/api_object/patch_policy.rb', line 291 def release_date @release_date end |
#self_service_categories ⇒ Array<Hash> (readonly) Originally defined in module SelfServable
Each Hash has these keys about the category
-
:id => [Integer] the JSS id of the category
-
:name => [String] the name of the category
Most objects also include one or both of these keys:
-
:display_in => [Boolean] should the item be displayed in this category in SSvc? (not MobDevConfProfiles)
-
:feature_in => [Boolean] should the item be featured in this category in SSVC? (macOS targets only)
#self_service_description ⇒ String Originally defined in module SelfServable
Returns The verbage that appears in SelfSvc for this item.
#self_service_display_name ⇒ String Also known as: self_service_dislay_name Originally defined in module SelfServable
Returns The name to display in macOS Self Service.
#self_service_feature_on_main_page ⇒ Boolean Originally defined in module SelfServable
Only applicable to macOS targets
#self_service_force_users_to_view_description ⇒ Boolean Originally defined in module SelfServable
Returns Should an extra window appear before the user can install the item? (OSX SSvc only).
#self_service_install_button_text ⇒ String Originally defined in module SelfServable
defaults to 'Install'
#self_service_notification_message ⇒ String Originally defined in module SelfServable
Returns The message text of the notification.
#self_service_notification_subject ⇒ String Originally defined in module SelfServable
object name.
#self_service_notification_type ⇒ Symbol Originally defined in module SelfServable
Returns How should notifications be sent either :ssvc_only or :ssvc_and_nctr.
#self_service_notifications_enabled ⇒ Boolean Also known as: self_service_notifications_enabled? Originally defined in module SelfServable
Returns Should jamf send notifications to self service?.
#self_service_reinstall_button_text ⇒ String Originally defined in module SelfServable
defaults to 'Reinstall'
#self_service_reminder_frequency ⇒ Integer Originally defined in module SelfServable
Returns How often (in days) should reminders be given.
#self_service_reminders_enabled ⇒ Boolean Also known as: self_service_reminders_enabled? Originally defined in module SelfServable
Returns Should self service give reminders by displaying the notification repeatedly?.
#self_service_removal_password ⇒ String (readonly) Originally defined in module SelfServable
Returns The password needed for removal, in plain text.
#self_service_user_removable ⇒ Symbol Originally defined in module SelfServable
Returns one of the keys in PROFILE_REMOVAL_BY_USER.
#target_version ⇒ String Also known as: version
When setting, the version must exist in the policy's PatchTitle, and have a package assigned to it.
287 288 289 |
# File 'lib/jss/api_object/patch_policy.rb', line 287 def target_version @target_version end |
Class Method Details
.all_for_title(title, api: JSS.api) ⇒ Array<Hash>
Fetch name and id of all PatchPolicies tied to a given PatchTitle
252 253 254 255 256 257 |
# File 'lib/jss/api_object/patch_policy.rb', line 252 def self.all_for_title(title, api: JSS.api) title_id = JSS::PatchTitle.valid_id title raise JSS::NoSuchItemError, "No PatchTitle matching '#{title}'" unless title_id api.get_rsrc("#{RSRC_BY_PATCH_TITLE}#{title_id}")[RSRC_BY_PATCH_TITLE_LIST_KEY] end |
.fetch(searchterm = nil, **args) ⇒ Object
Override APIObject.fetch, since there's no …/patchpolicies/name/… endpoint
262 263 264 265 266 267 268 269 270 271 |
# File 'lib/jss/api_object/patch_policy.rb', line 262 def self.fetch(searchterm = nil, **args) name_search = args.delete :name if name_search id = valid_id name_search raise JSS::NoSuchItemError, "No #{self::RSRC_OBJECT_KEY} found #{err_detail}" unless id args[:id] = id end super end |
Instance Method Details
#add_self_service_category(new_cat, display_in: true, feature_in: false) ⇒ void Also known as: set_self_service_category, change_self_service_category Originally defined in module SelfServable
This method returns an undefined value.
Add or change one of the categories for this item in self service
#add_to_self_service ⇒ void Originally defined in module SelfServable
This method returns an undefined value.
Add this object to self service if not already there.
#clone(new_name, api: nil) ⇒ APIObject Originally defined in module Creatable
make a clone of this API object, with a new name. The class must be creatable
#create ⇒ Integer
Create a new PatchPolicy in the JSS
523 524 525 526 527 528 529 530 531 532 533 |
# File 'lib/jss/api_object/patch_policy.rb', line 523 def create validate_for_saving # TODO: prepare for more cases where the POST rsrc is # different from the PUT/GET/DELETE. orig_rsrc = @rest_rsrc @rest_rsrc = "#{RSRC_BY_PATCH_TITLE}#{CGI.escape patch_title_id.to_s}" super @rest_rsrc = orig_rsrc refetch_version_info id end |
#disable ⇒ void
This method returns an undefined value.
disable this policy
459 460 461 462 463 |
# File 'lib/jss/api_object/patch_policy.rb', line 459 def disable return unless enabled @enabled = false @need_to_update = true end |
#enable ⇒ void
This method returns an undefined value.
enable this policy
449 450 451 452 453 |
# File 'lib/jss/api_object/patch_policy.rb', line 449 def enable return if enabled @enabled = true @need_to_update = true end |
#name=(newname) ⇒ void Originally defined in module Updatable
This method returns an undefined value.
Change the name of this item Remember to #update to push changes to the server.
#parse_scope ⇒ void Originally defined in module Scopable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Call this during initialization of objects that have a scope and the scope instance will be created from @init_data
#patch_title(refresh = false) ⇒ JSS::PatchTitle?
The JSS::PatchTitle to for this PatchPolicy
424 425 426 427 |
# File 'lib/jss/api_object/patch_policy.rb', line 424 def patch_title(refresh = false) @patch_title = nil if refresh @patch_title ||= JSS::PatchTitle.fetch id: patch_title_id end |
#patch_title_name ⇒ String
Returns the name of the PatchTitle for this patch policy.
431 432 433 434 |
# File 'lib/jss/api_object/patch_policy.rb', line 431 def patch_title_name return @patch_title.name if @patch_title JSS::PatchTitle.map_all_ids_to(:name)[software_title_configuration_id] end |
#remove_from_self_service ⇒ void Originally defined in module SelfServable
This method returns an undefined value.
Remove this object from self service if it's there.
#remove_self_service_category(cat) ⇒ void Originally defined in module SelfServable
This method returns an undefined value.
Remove a category from those for this item in SSvc
#self_service_execute_url ⇒ String Originally defined in module SelfServable
Returns The url to view this thing in Self Service.
#self_service_payload ⇒ Symbol Originally defined in module SelfServable
What does this object deploy to the device via self service?
#self_service_targets ⇒ Array<Symbol> Originally defined in module SelfServable
What devices types can get this thing in Self Service
#self_service_view_url ⇒ String Originally defined in module SelfServable
Returns The url to view this thing in Self Service.
#should_update ⇒ void Originally defined in module Scopable
This method returns an undefined value.
When the scope changes, it calls this to tell us that an update is needed.
#update ⇒ Integer
Update an existing PatchPolicy with changes from ruby
539 540 541 542 543 544 545 |
# File 'lib/jss/api_object/patch_policy.rb', line 539 def update validate_for_saving super refetch_version_info if @refetch_for_new_version @refetch_for_new_version = false id end |
#upload(type, local_file, force_ipa_upload: false) ⇒ Boolean Originally defined in module Uploadable
instance method wrapper for class method
Upload a file to the JSS to be stored with this instance of the class mixing in the Uploadable module
#user_removable? ⇒ Boolean? Originally defined in module SelfServable
Can this thing be removed by the user?