lib/jamf/api/connection/jamf_pro_api.rb in ruby-jss-2.1.0b5 vs lib/jamf/api/connection/jamf_pro_api.rb in ruby-jss-2.1.0
- old
+ new
@@ -51,15 +51,16 @@
end
end
# @param rsrc[String] the resource to get
# (the part of the API url after the '/api/' )
-
+
# @return [Hash] the result of the get
#######################################################
def jp_get(rsrc)
validate_connected @jp_cnx
+ rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
resp = @jp_cnx.get(rsrc) do |req|
# Modify the request here if needed.
# puts "JPAPI Cookie is: #{req.headers['Cookie']}"
end
@last_http_response = resp
@@ -80,10 +81,11 @@
#
# @return [String] the response body
#######################################################
def jp_post(rsrc, data)
validate_connected @jp_cnx
+ rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
resp = @jp_cnx.post(rsrc) do |req|
req.body = data
end
@last_http_response = resp
return resp.body if resp.success?
@@ -102,10 +104,11 @@
# @return [String] the response from the server.
#
#######################################################
def jp_put(rsrc, data)
validate_connected @jp_cnx
+ rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
resp = @jp_cnx.put(rsrc) do |req|
req.body = data
end
@last_http_response = resp
return resp.body if resp.success?
@@ -124,10 +127,11 @@
# @return [String] the response from the server.
#
#######################################################
def jp_patch(rsrc, data)
validate_connected @jp_cnx
+ rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
resp = @jp_cnx.patch(rsrc) do |req|
req.body = data
end
@last_http_response = resp
return resp.body if resp.success?
@@ -144,10 +148,11 @@
# @return [String] the response from the server.
#
#######################################################
def jp_delete(rsrc)
validate_connected @jp_cnx
+ rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
resp = @jp_cnx.delete rsrc
@last_http_response = resp
return resp.body if resp.success?
raise Jamf::Connection::JamfProAPIError, resp
@@ -157,9 +162,10 @@
# GET a rsrc without doing any JSON parsing, using
# a temporary Faraday connection object
#######################################################
def jp_download(rsrc)
+ rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
temp_cnx = create_jp_connection(parse_json: false)
resp = temp_cnx.get rsrc
@last_http_response = resp
return resp.body if resp.success?