Class: Katello::Pulp3::FileUnit

Inherits:
PulpContentUnit show all
Includes:
LazyAccessor
Defined in:
app/services/katello/pulp3/file_unit.rb

Constant Summary collapse

CONTENT_TYPE =
"file".freeze

Instance Attribute Summary

Attributes inherited from PulpContentUnit

#backend_data, #uuid

Class Method Summary collapse

Methods included from LazyAccessor

included

Methods inherited from PulpContentUnit

add_timestamps, backend_unit_identifier, content_api_create, content_type, content_unit_list, #fetch_backend_data, fetch_content_list, find_duplicate_unit, #initialize, model_class, page_options, pulp_data, pulp_units_batch_all, pulp_units_batch_for_repo, pulp_units_for_ids, supports_id_fetch?, unit_identifier

Constructor Details

This class inherits a constructor from Katello::Pulp3::PulpContentUnit

Class Method Details

.content_apiObject



7
8
9
# File 'app/services/katello/pulp3/file_unit.rb', line 7

def self.content_api
  PulpFileClient::ContentFilesApi.new(Katello::Pulp3::Api::File.new(SmartProxy.pulp_primary!).api_client)
end

.create_content(options) ⇒ Object



11
12
13
14
# File 'app/services/katello/pulp3/file_unit.rb', line 11

def self.create_content(options)
  fail _("Artifact Id and relative path are needed to create content") unless options.dig(:file_name) && options.dig(:artifact)
  PulpFileClient::FileContent.new(relative_path: options[:file_name], artifact: options[:artifact])
end

.generate_model_row(unit) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'app/services/katello/pulp3/file_unit.rb', line 22

def self.generate_model_row(unit)
  filename = File.basename(unit['relative_path'].try(:split, '/').try(:[], -1))

  {
    pulp_id: unit[unit_identifier],
    name: filename,
    path: unit['relative_path'],
    checksum: unit['sha256']
  }
end

.ids_for_repository(repo_id) ⇒ Object



16
17
18
19
20
# File 'app/services/katello/pulp3/file_unit.rb', line 16

def self.ids_for_repository(repo_id)
  repo = Katello::Pulp3::Repository::File.new(Katello::Repository.find(repo_id), SmartProxy.pulp_primary)
  repo_content_list = repo.content_list
  repo_content_list.map { |content| content.try(:pulp_href) }
end