Class: Katello::Resources::Candlepin::Proxy
- Inherits:
-
Object
- Object
- Katello::Resources::Candlepin::Proxy
- Defined in:
- app/lib/katello/resources/candlepin.rb
Class Method Summary collapse
- .delete(path, body = nil) ⇒ Object
- .get(path) ⇒ Object
- .logger ⇒ Object
- .path_with_cp_prefix(path) ⇒ Object
- .post(path, body) ⇒ Object
- .put(path, body) ⇒ Object
Class Method Details
.delete(path, body = nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/lib/katello/resources/candlepin.rb', line 19 def self.delete(path, body = nil) logger.debug "Sending DELETE request to Candlepin: #{path}" client = CandlepinResource.rest_client(Net::HTTP::Delete, :delete, path_with_cp_prefix(path)) # Some candlepin calls will set the body in DELETE requests. client.[:payload] = body unless body.nil? client.delete({:accept => :json, :content_type => :json}.merge(User.cp_oauth_header)) end |
.get(path) ⇒ Object
27 28 29 30 31 |
# File 'app/lib/katello/resources/candlepin.rb', line 27 def self.get(path) logger.debug "Sending GET request to Candlepin: #{path}" client = CandlepinResource.rest_client(Net::HTTP::Get, :get, path_with_cp_prefix(path)) client.get({:accept => :json}.merge(User.cp_oauth_header)) end |
.logger ⇒ Object
9 10 11 |
# File 'app/lib/katello/resources/candlepin.rb', line 9 def self.logger ::Foreman::Logging.logger('katello/cp_proxy') end |
.path_with_cp_prefix(path) ⇒ Object
39 40 41 |
# File 'app/lib/katello/resources/candlepin.rb', line 39 def self.path_with_cp_prefix(path) CandlepinResource.prefix + path end |
.post(path, body) ⇒ Object
13 14 15 16 17 |
# File 'app/lib/katello/resources/candlepin.rb', line 13 def self.post(path, body) logger.debug "Sending POST request to Candlepin: #{path}" client = CandlepinResource.rest_client(Net::HTTP::Post, :post, path_with_cp_prefix(path)) client.post body, {:accept => :json, :content_type => :json}.merge(User.cp_oauth_header) end |
.put(path, body) ⇒ Object
33 34 35 36 37 |
# File 'app/lib/katello/resources/candlepin.rb', line 33 def self.put(path, body) logger.debug "Sending PUT request to Candlepin: #{path}" client = CandlepinResource.rest_client(Net::HTTP::Put, :put, path_with_cp_prefix(path)) client.put body, {:accept => :json, :content_type => :json}.merge(User.cp_oauth_header) end |