lib/jamf/api/classic/api_objects/patch_policy.rb in ruby-jss-4.1.0 vs lib/jamf/api/classic/api_objects/patch_policy.rb in ruby-jss-4.1.1b1
- old
+ new
@@ -260,13 +260,16 @@
# Override APIObject.fetch, since there's no .../patchpolicies/name/... endpoint
# @see APIObject#fetch
#
def self.fetch(searchterm = nil, **args)
+ cnx = args[:cnx]
+ cnx ||= Jamf.cnx
+
name_search = args.delete :name
if name_search
- id = valid_id name_search
+ id = valid_id name_search, cnx: cnx
raise Jamf::NoSuchItemError, "No #{self::RSRC_OBJECT_KEY} found #{err_detail}" unless id
args[:id] = id
end
super
@@ -367,10 +370,12 @@
# creation...
unless in_jss
@init_data[:general] ||= {}
@init_data[:software_title_configuration_id] = validate_patch_title @init_data[:patch_title]
+ # need this set here for the validations below
+ @patch_title_id = @init_data[:software_title_configuration_id]
# 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]
@@ -422,11 +427,11 @@
#
# @return [Jamf::PatchTitle, nil]
#
def patch_title(refresh = false)
@patch_title = nil if refresh
- @patch_title ||= Jamf::PatchTitle.fetch id: patch_title_id
+ @patch_title ||= Jamf::PatchTitle.fetch id: patch_title_id, cnx: @cnx
end
# @return [String] the name of the PatchTitle for this patch policy
#
def patch_title_name
@@ -571,11 +576,11 @@
@patch_title = a_title
return a_title.id
end
raise Jamf::MissingDataError, ':patch_title is required' unless a_title
- title_id = Jamf::PatchTitle.valid_id a_title
+ title_id = Jamf::PatchTitle.valid_id a_title, cnx: @cnx
return title_id if title_id
raise Jamf::NoSuchItemError, "No Patch Title matches '#{a_title}'"
end
@@ -603,10 +608,10 @@
end
# Update our local version data after the target_version is changed
#
def refetch_version_info
- tmp = self.class.fetch id: id
+ tmp = self.class.fetch id: id, cnx: @cnx
@release_date = tmp.release_date
@incremental_update = tmp.incremental_update
@reboot = tmp.reboot
@minimum_os = tmp.minimum_os
@kill_apps = tmp.kill_apps