Class: Runcible::Extensions::Unit
- Inherits:
-
Resources::Unit
- Object
- Base
- Resources::Unit
- Runcible::Extensions::Unit
- Defined in:
- lib/runcible/extensions/unit.rb
Direct Known Subclasses
Distribution, DockerImage, DockerManifest, DockerManifestList, DockerTag, Errata, File, OstreeBranch, PackageCategory, PackageGroup, PuppetModule, PythonPackage, Rpm, YumRepoMetadataFile
Class Method Summary collapse
-
.content_type ⇒ Object
The content type (e.g. rpm, errata).
Instance Method Summary collapse
-
#all ⇒ RestClient::Response
Retrieves all content of a certain @@type.
- #content_type ⇒ Object
-
#copy(source_repo_id, destination_repo_id, optional = {}) ⇒ RestClient::Response
copy contents from source repo to the destination repo.
-
#find(id, optional = {}) ⇒ RestClient::Response
Retrieves a single content by it’s content ID.
-
#find_all(ids, optional = {}) ⇒ RestClient::Response
Retrieves a set of content by the contents IDs.
-
#find_all_by_unit_ids(ids, fields = [], optional = {}) ⇒ RestClient::Response
Retrieves a set of content by the Pulp unit IDs.
-
#find_by_unit_id(id, optional = {}) ⇒ RestClient::Response
Retrieves a single content by it’s unit ID.
-
#unassociate_from_repo(repo_id, filters) ⇒ RestClient::Response
unassociates content units from a repository.
-
#unassociate_ids_from_repo(repo_id, ids) ⇒ RestClient::Response
unassociates content units from a repository.
-
#unassociate_unit_ids_from_repo(repo_id, ids) ⇒ RestClient::Response
unassociates content units from a repository.
Methods inherited from Resources::Unit
Methods inherited from Base
#add_http_auth_header, #add_oauth_header, #call, #combine_get_params, #config, #format_payload_json, #generate_log_message, #generate_payload, #get_response, #initialize, #lazy_config=, #log_debug, #log_exception, #log_info, #logger, #path, #process_response, #required_params
Constructor Details
This class inherits a constructor from Runcible::Base
Class Method Details
.content_type ⇒ Object
The content type (e.g. rpm, errata)
5 6 7 |
# File 'lib/runcible/extensions/unit.rb', line 5 def self.content_type fail 'Content type not defined' end |
Instance Method Details
#all ⇒ RestClient::Response
Retrieves all content of a certain @@type
16 17 18 |
# File 'lib/runcible/extensions/unit.rb', line 16 def all search(content_type, {}) end |
#content_type ⇒ Object
9 10 11 |
# File 'lib/runcible/extensions/unit.rb', line 9 def content_type self.class.content_type end |
#copy(source_repo_id, destination_repo_id, optional = {}) ⇒ RestClient::Response
copy contents from source repo to the destination repo
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/runcible/extensions/unit.rb', line 98 def copy(source_repo_id, destination_repo_id, optional = {}) criteria = {:type_ids => [content_type], :filters => {}} criteria[:filters]['association'] = {'unit_id' => {'$in' => optional[:ids]}} if optional[:ids] criteria[:filters] = optional[:filters] if optional[:filters] criteria[:fields] = {:unit => optional[:fields]} if optional[:fields] payload = {:criteria => criteria} payload[:override_config] = optional[:override_config] if optional.key?(:override_config) if optional[:copy_children] payload[:override_config] ||= {} payload[:override_config][:recursive] = true end Runcible::Extensions::Repository.new(self.config).unit_copy(destination_repo_id, source_repo_id, payload) end |
#find(id, optional = {}) ⇒ RestClient::Response
Retrieves a single content by it’s content ID
24 25 26 |
# File 'lib/runcible/extensions/unit.rb', line 24 def find(id, optional = {}) find_all([id], optional).first end |
#find_all(ids, optional = {}) ⇒ RestClient::Response
Retrieves a set of content by the contents IDs
32 33 34 35 |
# File 'lib/runcible/extensions/unit.rb', line 32 def find_all(ids, optional = {}) optional[:include_repos] = optional.fetch(:include_repos, true) search(content_type, { :filters => {'id' => {'$in' => ids}} }, optional) end |
#find_all_by_unit_ids(ids, fields = [], optional = {}) ⇒ RestClient::Response
Retrieves a set of content by the Pulp unit IDs
50 51 52 53 54 55 |
# File 'lib/runcible/extensions/unit.rb', line 50 def find_all_by_unit_ids(ids, fields = [], optional = {}) optional[:include_repos] = optional.fetch(:include_repos, true) criteria = { :filters => { :_id => { '$in' => ids } } } criteria[:fields] = fields unless fields.empty? search(content_type, criteria, optional) end |
#find_by_unit_id(id, optional = {}) ⇒ RestClient::Response
Retrieves a single content by it’s unit ID
41 42 43 |
# File 'lib/runcible/extensions/unit.rb', line 41 def find_by_unit_id(id, optional = {}) find_all_by_unit_ids([id], [], optional).first end |
#unassociate_from_repo(repo_id, filters) ⇒ RestClient::Response
unassociates content units from a repository
62 63 64 65 66 |
# File 'lib/runcible/extensions/unit.rb', line 62 def unassociate_from_repo(repo_id, filters) criteria = {:type_ids => [content_type]} criteria[:filters] = filters Runcible::Extensions::Repository.new(self.config).unassociate_units(repo_id, criteria) end |
#unassociate_ids_from_repo(repo_id, ids) ⇒ RestClient::Response
unassociates content units from a repository
76 77 78 |
# File 'lib/runcible/extensions/unit.rb', line 76 def unassociate_ids_from_repo(repo_id, ids) unassociate_from_repo(repo_id, :unit => {'id' => {'$in' => ids}}) end |
#unassociate_unit_ids_from_repo(repo_id, ids) ⇒ RestClient::Response
unassociates content units from a repository
88 89 90 |
# File 'lib/runcible/extensions/unit.rb', line 88 def unassociate_unit_ids_from_repo(repo_id, ids) unassociate_from_repo(repo_id, :association => {'unit_id' => {'$in' => ids}}) end |