Method: Jamf::PatchSource.fetch

Defined in:
lib/jamf/api/classic/base_classes/patch_source.rb

.fetch(searchterm = nil, **args) ⇒ Object

Fetch either an internal or external patch source

BUG: there’s an API bug when fetching a non-existent patch source which is why we rescue 500 internal server errors and report them as ‘no matching patch source’

See Also:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/jamf/api/classic/base_classes/patch_source.rb', line 119

def self.fetch(searchterm = nil, **args)
  if self == Jamf::PatchSource
    begin
      fetched = Jamf::PatchInternalSource.fetch searchterm, **args
    rescue
      fetched = nil
    end
    unless fetched
      begin
        fetched = Jamf::PatchExternalSource.fetch searchterm, **args
      rescue
        raise Jamf::NoSuchItemError, 'No matching PatchSource found'
      end
    end
    return fetched
  end # if self == Jamf::PatchSource

  begin
    super searchterm, **args
  rescue Jamf::NoSuchItemError
    raise Jamf::NoSuchItemError, "No matching #{self::RSRC_OBJECT_KEY} found"
  end
end