Class: Katello::Resources::Candlepin::Environment
Constant Summary
Constants inherited
from HttpResource
HttpResource::REQUEST_MAP
Instance Attribute Summary
Attributes inherited from HttpResource
#json
Class Method Summary
collapse
default_headers, fetch_paged, included_list, logger, name_to_key, process_response, raise_rest_client_exception
#[], #[]=, hash_to_query, #initialize, issue_request, join_path, logger, process_response, raise_rest_client_exception, rest_client
#filter_sensitive_data
Class Method Details
.add_content(env_id, content_ids) ⇒ Object
31
32
33
34
35
|
# File 'app/lib/katello/resources/candlepin/environment.rb', line 31
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.).body).with_indifferent_access
end
|
.all ⇒ Object
10
11
12
|
# File 'app/lib/katello/resources/candlepin/environment.rb', line 10
def all
JSON.parse(self.get(path, self.).body).collect { |a| a.with_indifferent_access }
end
|
.create(owner_id, id, name, description) ⇒ Object
14
15
16
17
18
19
|
# File 'app/lib/katello/resources/candlepin/environment.rb', line 14
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.).body
JSON.parse(environment_json).with_indifferent_access
end
|
.delete_content(env_id, content_ids) ⇒ Object
37
38
39
40
41
|
# File 'app/lib/katello/resources/candlepin/environment.rb', line 37
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.).code.to_i
end
|
.destroy(id) ⇒ Object
21
22
23
24
25
|
# File 'app/lib/katello/resources/candlepin/environment.rb', line 21
def destroy(id)
self.delete(path(id), User.).code.to_i
rescue RestClient::NotFound => e
raise ::Katello::Errors::CandlepinEnvironmentGone, e.message
end
|
.find(id) ⇒ Object
6
7
8
|
# File 'app/lib/katello/resources/candlepin/environment.rb', line 6
def find(id)
JSON.parse(self.get(path(id), self.).body).with_indifferent_access
end
|
.path(id = '') ⇒ Object
27
28
29
|
# File 'app/lib/katello/resources/candlepin/environment.rb', line 27
def path(id = '')
"/candlepin/environments/#{id}"
end
|