lib/jss/api_object/patch_policy.rb in ruby-jss-1.1.3 vs lib/jss/api_object/patch_policy.rb in ruby-jss-1.2.0b1
- old
+ new
@@ -250,11 +250,26 @@
# @return [Array<Hash>] the :id and :name of each policy for the title
#
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
+
+ # Override APIObject.fetch, since there's no .../patchpolicies/name/... endpoint
+ # @see APIObject#fetch
+ #
+ 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 # fetch
# Attributes
################################
# @return [Boolean] is this patch policy enabled?