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
path
client_cert, client_key, 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
58
59
60
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 58
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
|
.get_export(url, client_cert, client_key, ca_file) ⇒ Object
43
44
45
46
47
48
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 43
def get_export(url, client_cert, client_key, ca_file)
logger.debug "Sending GET request to upstream Candlepin: #{url}"
return resource(url: url, client_cert: client_cert, client_key: client_key, ca_file: ca_file).get
rescue RestClient::Exception => e
raise e
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
|
.ping ⇒ Object
12
13
14
15
16
17
18
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 12
def ping
resource.head
rescue RestClient::Unauthorized, RestClient::Gone
raise ::Katello::Errors::UpstreamConsumerGone
rescue RestClient::NotFound
raise ::Katello::Errors::UpstreamConsumerNotFound
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
|
.update(url, client_cert, client_key, ca_file, attributes) ⇒ Object
50
51
52
53
54
55
56
|
# File 'app/lib/katello/resources/candlepin/upstream_consumer.rb', line 50
def update(url, client_cert, client_key, ca_file, attributes)
logger.debug "Sending PUT request to upstream Candlepin: #{url} #{attributes.to_json}"
return 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
|