Class: Katello::Pulp3::PackageGroup

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

Instance Attribute Summary

Attributes inherited from PulpContentUnit

#backend_data, #uuid

Class Method Summary collapse

Instance 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, create_content, #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



47
48
49
# File 'app/services/katello/pulp3/package_group.rb', line 47

def self.content_api
  PulpRpmClient::ContentPackagegroupsApi.new(Katello::Pulp3::Api::Yum.new(SmartProxy.pulp_primary!).api_client)
end

.generate_model_row(unit) ⇒ Object



57
58
59
60
61
62
63
# File 'app/services/katello/pulp3/package_group.rb', line 57

def self.generate_model_row(unit)
  custom_json = {}
  custom_json['pulp_id'] = unit['pulp_href']
  custom_json['name'] = unit['name']
  custom_json['description'] = unit['description']
  custom_json
end

.ids_for_repository(repo_id) ⇒ Object



51
52
53
54
55
# File 'app/services/katello/pulp3/package_group.rb', line 51

def self.ids_for_repository(repo_id)
  repo = Katello::Pulp3::Repository::Yum.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

Instance Method Details

#_idObject



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

def _id
  backend_data['pulp_href']
end

#conditional_package_namesObject



30
31
32
# File 'app/services/katello/pulp3/package_group.rb', line 30

def conditional_package_names
  package_names_of_type(2)
end

#default_package_namesObject



22
23
24
# File 'app/services/katello/pulp3/package_group.rb', line 22

def default_package_names
  package_names_of_type(0)
end

#mandatory_package_namesObject



34
35
36
# File 'app/services/katello/pulp3/package_group.rb', line 34

def mandatory_package_names
  package_names_of_type(3)
end

#optional_package_namesObject



26
27
28
# File 'app/services/katello/pulp3/package_group.rb', line 26

def optional_package_names
  package_names_of_type(1)
end

#package_names_of_type(type) ⇒ Object



42
43
44
45
# File 'app/services/katello/pulp3/package_group.rb', line 42

def package_names_of_type(type)
  filtered_packages = backend_data['packages'].select { |package| package['type'] == type }
  filtered_packages.map { |package| package['name'] }
end

#unknown_package_namesObject



38
39
40
# File 'app/services/katello/pulp3/package_group.rb', line 38

def unknown_package_names
  package_names_of_type(4)
end