Class: Katello::Resources::Candlepin::Content

Inherits:
CandlepinResource show all
Defined in:
app/lib/katello/resources/candlepin.rb

Instance Attribute Summary

Attributes inherited from HttpResource

#json

Class Method Summary collapse

Methods inherited from CandlepinResource

default_headers, logger, name_to_key

Methods inherited from HttpResource

#[], #[]=, create_thing, delete, hash_to_query, #initialize, join_path, logger, post, print_debug_info, process_response, put, raise_rest_client_exception, rest_client, url_encode

Constructor Details

This class inherits a constructor from Katello::HttpResource

Class Method Details

.allObject



538
539
540
541
# File 'app/lib/katello/resources/candlepin.rb', line 538

def all
  content_json = Candlepin::CandlepinResource.get(path, self.default_headers).body
  JSON.parse(content_json)
end

.create(attrs) ⇒ Object



529
530
531
# File 'app/lib/katello/resources/candlepin.rb', line 529

def create(attrs)
  JSON.parse(self.post(path, JSON.generate(attrs), self.default_headers).body).with_indifferent_access
end

.destroy(id) ⇒ Object



543
544
545
546
# File 'app/lib/katello/resources/candlepin.rb', line 543

def destroy(id)
  fail ArgumentError, "content id has to be specified" unless id
  self.delete(path(id), self.default_headers).code.to_i
end

.get(id) ⇒ Object



533
534
535
536
# File 'app/lib/katello/resources/candlepin.rb', line 533

def get(id)
  content_json = super(path(id), self.default_headers).body
  JSON.parse(content_json).with_indifferent_access
end

.path(id = nil) ⇒ Object



552
553
554
# File 'app/lib/katello/resources/candlepin.rb', line 552

def path(id = nil)
  "/candlepin/content/#{id}"
end

.update(attrs) ⇒ Object



548
549
550
# File 'app/lib/katello/resources/candlepin.rb', line 548

def update(attrs)
  JSON.parse(self.put(path(attrs[:id] || attrs['id']), JSON.generate(attrs), self.default_headers).body).with_indifferent_access
end