lib/runcible/extensions/repository.rb in runcible-1.7.2 vs lib/runcible/extensions/repository.rb in runcible-1.8.0
- old
+ new
@@ -29,24 +29,22 @@
# @param [Array] distributors an array of hashes representing distributors or
# an array of Distributor objects
# @param [Hash] optional container for all optional parameters
# @return [RestClient::Response] the created repository
def create_with_importer_and_distributors(id, importer, distributors = [], optional = {})
- if importer.is_a?(Runcible::Models::Importer)
+ if importer && importer.is_a?(Runcible::Models::Importer)
optional[:importer_type_id] = importer.id
optional[:importer_config] = importer.config
- else
+ elsif importer
optional[:importer_type_id] = importer.delete('id') || importer.delete(:id)
optional[:importer_config] = importer
- end if importer
+ end
repo_type = if importer.methods.include?(:repo_type)
importer.repo_type
elsif importer.is_a?(Hash) && importer.key?(:repo_type)
importer[:repo_type]
- else
- nil
end
if optional.key?(:importer_type_id) && repo_type
# pulp needs _repo-type in order to determine the type of repo to create.
optional[:notes] = { '_repo-type' => importer.repo_type }
@@ -324,13 +322,33 @@
# @param [String] id the ID of the repository
# @param [Hash] tags for an image in the following format
# the [{:image_id => <image hash>, :tag =>"value"}]
# @return [RestClient::Response]
def update_docker_tags(id, tags)
- update(id, :scratchpad => {:tags => tags})
+ update(id, :scratchpad => {:tags => tags})
end
+ # Retrieves the file IDs for a single repository
+ #
+ # @param [String] id the ID of the repository
+ # @return [RestClient::Response] the set of repository file IDs
+ def file_ids(id)
+ criteria = {:type_ids => [Runcible::Extensions::File.content_type],
+ :fields => {:unit => [], :association => ['unit_id']}}
+
+ unit_search(id, criteria).map { |i| i['unit_id'] }
+ end
+
+ # Retrieves the files for a single repository
+ #
+ # @param [String] id the ID of the repository
+ # @return [RestClient::Response] the set of repository files
+ def files(id)
+ criteria = {:type_ids => [Runcible::Extensions::File.content_type]}
+ unit_search(id, criteria).map { |i| i['metadata'].with_indifferent_access }
+ end
+
# Creates or updates a sync schedule for a repository
#
# @param [String] repo_id the ID of the repository
# @param [String] type the importer type
# @param [String] schedule the time as an iso8601 interval
@@ -385,10 +403,10 @@
# when false run this operation serially and return a list of
# spawned tasks that are to be tracked separately.
# False is the default option.
# @return [RestClient::Response]
def regenerate_applicability_by_ids(ids, parallel = false)
- criteria = {
+ criteria = {
'parallel' => parallel,
'repo_criteria' => { 'filters' => { 'id' => { '$in' => ids } } }
}
regenerate_applicability(criteria)
end