Method: JSS::PatchSource.fetch

Defined in:
lib/jss/api_object/patch_source.rb

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

Fetch either an internal or external patch source

BUG: there’s an API bug: fetching a non-existent which is why we rescue internal server errors.

See Also:



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/jss/api_object/patch_source.rb', line 128

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

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