Class: Katello::Resources::Candlepin::UpstreamConsumer
Constant Summary
Constants inherited
from HttpResource
HttpResource::REQUEST_MAP
Instance Attribute Summary
Attributes inherited from HttpResource
#json
Class Method Summary
collapse
-
.bind_entitlement(**pool) ⇒ Object
-
.content_access ⇒ Object
-
.get(params) ⇒ Object
Overrides the HttpResource get method to check if the upstream consumer exists.
-
.path(id = upstream_consumer_id) ⇒ Object
-
.ping ⇒ Object
-
.regenerate_upstream_identity(url, client_cert, client_key, ca_file) ⇒ Object
-
.remove_entitlement(entitlement_id) ⇒ Object
-
.start_upstream_export(url, client_cert, client_key, ca_file) ⇒ Object
(also: retrieve_upstream_export)
-
.update(url, client_cert, client_key, ca_file, attributes) ⇒ Object
path
client_cert, client_key, default_headers, json_resource, resource, rest_client, site, upstream_api_uri, upstream_consumer, upstream_consumer_id, upstream_id_cert, upstream_owner_id
#proxy, #proxy_host, #proxy_port, #proxy_scheme, #proxy_uri
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
.bind_entitlement(**pool) ⇒ Object
70
71
72
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 70
def bind_entitlement(**pool)
JSON.parse(self['entitlements'].post(nil, params: pool))
end
|
.content_access ⇒ Object
29
30
31
32
33
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 29
def content_access
JSON.parse(self['content_access'].get).with_indifferent_access
rescue RestClient::NotFound
{}
end
|
.get(params) ⇒ Object
Overrides the HttpResource get method to check if the upstream consumer exists.
22
23
24
25
26
27
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 22
def get(params)
includes = params.key?(:include_only) ? "&" + included_list(params.delete(:include_only)) : ""
JSON.parse(super(path + hash_to_query(params) + includes, self.).body)
rescue RestClient::Gone
raise ::Katello::Errors::UpstreamConsumerGone
end
|
.path(id = upstream_consumer_id) ⇒ Object
8
9
10
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 8
def path(id = upstream_consumer_id)
super(id)
end
|
.regenerate_upstream_identity(url, client_cert, client_key, ca_file) ⇒ Object
65
66
67
68
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 65
def regenerate_upstream_identity(url, client_cert, client_key, ca_file)
logger.debug "Sending POST request to upstream Candlepin: #{url}"
resource(url: url, client_cert: client_cert, client_key: client_key, ca_file: ca_file).post(nil)
end
|
.remove_entitlement(entitlement_id) ⇒ Object
35
36
37
38
39
40
41
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 35
def remove_entitlement(entitlement_id)
fail ArgumentError, "No entitlement ID given to remove." if entitlement_id.blank?
self["entitlements/#{entitlement_id}"].delete
rescue RestClient::NotFound
raise ::Katello::Errors::UpstreamEntitlementGone
end
|
.start_upstream_export(url, client_cert, client_key, ca_file) ⇒ Object
Also known as:
retrieve_upstream_export
43
44
45
46
47
48
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 43
def start_upstream_export(url, client_cert, client_key, ca_file)
logger.debug "Sending GET request to upstream Candlepin: #{url}"
resource(url: url, client_cert: client_cert, client_key: client_key, ca_file: ca_file).get
rescue RestClient::Exception => e
raise e
end
|
.update(url, client_cert, client_key, ca_file, attributes) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 52
def update(url, client_cert, client_key, ca_file, attributes)
logger.debug "Sending PUT request to upstream Candlepin: #{url} #{attributes.to_json}"
resource(
url: url,
client_cert: client_cert,
client_key: client_key,
ca_file: ca_file).put(
attributes.to_json,
'accept' => 'application/json',
'accept-language' => I18n.locale,
'content-type' => 'application/json')
end
|