Method: Jamf::APIObject.get_raw
- Defined in:
- lib/jamf/api/classic/base_classes/api_object.rb
.get_raw(id, format: :json, as_string: false, api: nil, cnx: Jamf.cnx) ⇒ Hash, ...
Fetch the mostly- or fully-raw JSON or XML data for an object of this subclass.
By default, returns the JSON data parsed into a Hash.
When format: is anything but :json, returns the XML data parsed into a REXML::Document
When as_string: is truthy, returns an unparsed JSON String (or XML String if format: is not :json) as it comes directly from the API.
When fetching raw JSON, the returned Hash will have its keys symbolized.
This can be substantialy faster than instantiating, especially when you don’t need all the ruby goodness of a full instance, but just want a few values for an object that aren’t available in the all data
This is really just a wrapper around Connection.c_get that automatically fills in the RSRC::BASE value for you.
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 |
# File 'lib/jamf/api/classic/base_classes/api_object.rb', line 1050 def self.get_raw(id, format: :json, as_string: false, api: nil, cnx: Jamf.cnx) cnx = api if api (self) rsrc = "#{self::RSRC_BASE}/id/#{id}" data = cnx.c_get rsrc, format, raw_json: as_string return data if format == :json || as_string REXML::Document.new(**data) end |