Class: Katello::Resources::Candlepin::CandlepinResource
Direct Known Subclasses
ActivationKey, Admin, CPUser, CandlepinPing, Consumer, Content, Entitlement, Environment, Job, Owner, Pool, Product, Subscription, UpstreamCandlepinResource
Constant Summary
Constants inherited
from HttpResource
HttpResource::REQUEST_MAP
Instance Attribute Summary
Attributes inherited from HttpResource
#json
Class Method Summary
collapse
#[], #[]=, hash_to_query, #initialize, issue_request, join_path, rest_client
#filter_sensitive_data
Class Method Details
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'app/lib/katello/resources/candlepin.rb', line 38
def self.(uuid = nil)
if !uuid.nil? && User.consumer?
= { 'cp-consumer' => uuid }
else
= User.
end
= {'accept' => 'application/json',
'accept-language' => I18n.locale,
'content-type' => 'application/json'}
request_id = ::Logging.mdc['request']
['X-Correlation-ID'] = request_id if request_id
.merge!()
end
|
.fetch_paged(page_size = -1)) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'app/lib/katello/resources/candlepin.rb', line 67
def self.fetch_paged(page_size = -1)
if page_size == -1
page_size = SETTINGS[:katello][:candlepin][:bulk_load_size]
end
page = 0
content = []
loop do
page += 1
data = yield("per_page=#{page_size}&page=#{page}")
content.concat(data)
break if data.size < page_size
end
content
end
|
.included_list(included) ⇒ Object
63
64
65
|
# File 'app/lib/katello/resources/candlepin.rb', line 63
def self.included_list(included)
included.map { |value| "include=#{value}" }.join('&')
end
|
.logger ⇒ Object
34
35
36
|
# File 'app/lib/katello/resources/candlepin.rb', line 34
def self.logger
::Foreman::Logging.logger('katello/cp_rest')
end
|
.name_to_key(a_name) ⇒ Object
59
60
61
|
# File 'app/lib/katello/resources/candlepin.rb', line 59
def self.name_to_key(a_name)
a_name.tr(' ', '_')
end
|
.process_response(response) ⇒ Object
17
18
19
20
21
|
# File 'app/lib/katello/resources/candlepin.rb', line 17
def process_response(response)
debug_level = response.code >= 400 ? :error : :debug
logger.send(debug_level, "Candlepin request #{response.[:x_candlepin_request_uuid]} returned with code #{response.code}")
super
end
|
.raise_rest_client_exception(error, path, http_method) ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'app/lib/katello/resources/candlepin.rb', line 23
def raise_rest_client_exception(error, path, http_method)
unless error&.response&.&.dig(:x_version)
fail ::Katello::Errors::CandlepinNotRunning
end
super
end
|