Class: Katello::Resources::Candlepin::ActivationKey
Instance Attribute Summary
Attributes inherited from HttpResource
#json
Class Method Summary
collapse
-
.add_pools(id, pool_id, quantity) ⇒ Object
-
.add_product(id, product_id) ⇒ Object
-
.content_overrides(id) ⇒ Object
-
.create(name, owner_key, auto_attach) ⇒ Object
-
.destroy(id) ⇒ Object
-
.get(id = nil, params = '') ⇒ Object
-
.key_pools(id) ⇒ Object
-
.path(id = nil) ⇒ Object
-
.pools(owner_key) ⇒ Object
-
.remove_pools(id, pool_id) ⇒ Object
-
.remove_product(id, product_id) ⇒ Object
-
.update(id, release_version, service_level, auto_attach) ⇒ Object
-
.update_content_override(id, content_label, name, value = nil) ⇒ Object
default_headers, logger, name_to_key
#[], #[]=, create_thing, delete, hash_to_query, #initialize, join_path, logger, post, print_debug_info, process_response, put, raise_rest_client_exception, rest_client, url_encode
Class Method Details
.add_pools(id, pool_id, quantity) ⇒ Object
774
775
776
777
778
779
780
|
# File 'app/lib/katello/resources/candlepin.rb', line 774
def add_pools(id, pool_id, quantity)
cppath = join_path(path(id), "pools/#{pool_id}")
quantity = Integer(quantity) rescue nil
cppath += "?quantity=#{quantity}" if quantity && quantity > 0
pool = self.post(cppath, {}, self.)
JSON.parse(pool).with_indifferent_access
end
|
.add_product(id, product_id) ⇒ Object
763
764
765
766
767
|
# File 'app/lib/katello/resources/candlepin.rb', line 763
def add_product(id, product_id)
cppath = join_path(path(id), "product/#{product_id}")
product = self.post(cppath, {}, self.)
JSON.parse(product).with_indifferent_access
end
|
.content_overrides(id) ⇒ Object
.create(name, owner_key, auto_attach) ⇒ Object
738
739
740
741
|
# File 'app/lib/katello/resources/candlepin.rb', line 738
def create(name, owner_key, auto_attach)
url = "/candlepin/owners/#{owner_key}/activation_keys"
JSON.parse(self.post(url, {:name => name, :autoAttach => auto_attach}.to_json, self.).body).with_indifferent_access
end
|
.destroy(id) ⇒ Object
748
749
750
751
|
# File 'app/lib/katello/resources/candlepin.rb', line 748
def destroy(id)
fail(ArgumentError, "activation key id has to be specified") unless id
self.delete(path(id), self.).code.to_i
end
|
.get(id = nil, params = '') ⇒ Object
731
732
733
734
735
736
|
# File 'app/lib/katello/resources/candlepin.rb', line 731
def get(id = nil, params = '')
akeys_json = super(path(id) + params, self.).body
akeys = JSON.parse(akeys_json)
akeys = [akeys] unless id.nil?
::Katello::Util::Data.array_with_indifferent_access akeys
end
|
.path(id = nil) ⇒ Object
807
808
809
|
# File 'app/lib/katello/resources/candlepin.rb', line 807
def path(id = nil)
"/candlepin/activation_keys/#{id}"
end
|
.pools(owner_key) ⇒ Object
753
754
755
|
# File 'app/lib/katello/resources/candlepin.rb', line 753
def pools(owner_key)
Candlepin::Owner.pools(owner_key)
end
|
.remove_pools(id, pool_id) ⇒ Object
782
783
784
785
|
# File 'app/lib/katello/resources/candlepin.rb', line 782
def remove_pools(id, pool_id)
pool = self.delete(join_path(path(id), "pools/#{pool_id}"), self.)
JSON.parse(pool).with_indifferent_access
end
|
.remove_product(id, product_id) ⇒ Object
769
770
771
772
|
# File 'app/lib/katello/resources/candlepin.rb', line 769
def remove_product(id, product_id)
product = self.delete(join_path(path(id), "product/#{product_id}"), self.)
JSON.parse(product).with_indifferent_access
end
|
.update(id, release_version, service_level, auto_attach) ⇒ Object
743
744
745
746
|
# File 'app/lib/katello/resources/candlepin.rb', line 743
def update(id, release_version, service_level, auto_attach)
attrs = { :releaseVer => release_version, :serviceLevel => service_level, :autoAttach => auto_attach }.delete_if { |_k, v| v.nil? }
JSON.parse(self.put(path(id), attrs.to_json, self.).body).with_indifferent_access
end
|
.update_content_override(id, content_label, name, value = nil) ⇒ Object
792
793
794
795
796
797
798
799
800
801
802
803
804
805
|
# File 'app/lib/katello/resources/candlepin.rb', line 792
def update_content_override(id, content_label, name, value = nil)
attrs = [{ :contentLabel => content_label, :name => name }]
if value
attrs[0][:value] = value
result = Candlepin::CandlepinResource.put(join_path(path(id), 'content_overrides'),
attrs.to_json, self.)
else
client = Candlepin::CandlepinResource.rest_client(Net::HTTP::Delete, :delete,
join_path(path(id), 'content_overrides'))
client.options[:payload] = attrs.to_json
result = client.delete({:accept => :json, :content_type => :json}.merge(User.))
end
::Katello::Util::Data.array_with_indifferent_access(JSON.parse(result))
end
|