Class: Katello::Resources::Candlepin::Environment

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, get, 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

.add_content(env_id, content_ids) ⇒ Object



474
475
476
477
478
# File 'app/lib/katello/resources/candlepin.rb', line 474

def add_content(env_id, content_ids)
  path = self.path(env_id) + "/content"
  params = content_ids.map { |content_id| {:contentId => content_id} }
  JSON.parse(self.post(path, params.to_json, self.default_headers).body).with_indifferent_access
end

.allObject



455
456
457
# File 'app/lib/katello/resources/candlepin.rb', line 455

def all
  JSON.parse(self.get(path, self.default_headers).body).collect { |a| a.with_indifferent_access }
end

.create(owner_id, id, name, description) ⇒ Object



459
460
461
462
463
464
# File 'app/lib/katello/resources/candlepin.rb', line 459

def create(owner_id, id, name, description)
  attrs = {:id => id, :name => name, :description => description}
  path = "/candlepin/owners/#{owner_id}/environments"
  environment_json = self.post(path, attrs.to_json, self.default_headers).body
  JSON.parse(environment_json).with_indifferent_access
end

.delete_content(env_id, content_ids) ⇒ Object



480
481
482
483
484
# File 'app/lib/katello/resources/candlepin.rb', line 480

def delete_content(env_id, content_ids)
  path = self.path(env_id) + "/content"
  params = content_ids.map { |content_id| {:content => content_id}.to_param }.join("&")
  self.delete("#{path}?#{params}", self.default_headers).code.to_i
end

.destroy(id) ⇒ Object



466
467
468
# File 'app/lib/katello/resources/candlepin.rb', line 466

def destroy(id)
  self.delete(path(id), User.cp_oauth_header).code.to_i
end

.find(id) ⇒ Object



451
452
453
# File 'app/lib/katello/resources/candlepin.rb', line 451

def find(id)
  JSON.parse(self.get(path(id), self.default_headers).body).with_indifferent_access
end

.path(id = '') ⇒ Object



470
471
472
# File 'app/lib/katello/resources/candlepin.rb', line 470

def path(id = '')
  "/candlepin/environments/#{id}"
end