Class: Katello::Api::V2::HostPackagesController

Inherits:
ApiController
  • Object
show all
Includes:
Concerns::FilteredAutoCompleteSearch
Defined in:
app/controllers/katello/api/v2/host_packages_controller.rb

Constant Summary

Constants included from Concerns::FilteredAutoCompleteSearch

Concerns::FilteredAutoCompleteSearch::PAGE_SIZE

Instance Method Summary collapse

Methods included from Concerns::FilteredAutoCompleteSearch

#auto_complete_search

Methods inherited from ApiController

#full_result_response, #scoped_search

Methods included from Rendering

#respond_for_async, #respond_for_bulk_async, #respond_for_create, #respond_for_destroy, #respond_for_index, #respond_for_show, #respond_for_status, #respond_for_update, #respond_with_template, #respond_with_template_collection, #respond_with_template_resource, #try_specific_collection_template, #try_specific_resource_template

Methods included from Katello::Api::Version2

#api_version

Instance Method Details

#indexObject



22
23
24
25
# File 'app/controllers/katello/api/v2/host_packages_controller.rb', line 22

def index
  collection = scoped_search(index_relation.uniq, :name, :asc, :resource_class => ::Katello::InstalledPackage)
  respond_for_index(:collection => collection)
end

#index_relationObject



81
82
83
# File 'app/controllers/katello/api/v2/host_packages_controller.rb', line 81

def index_relation
  @host.installed_packages
end

#installObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/katello/api/v2/host_packages_controller.rb', line 30

def install
  if params[:packages]
    packages = validate_package_list_format(params[:packages])
    task     = async_task(::Actions::Katello::Host::Package::Install, @host, packages)
    respond_for_async :resource => task
    return
  end

  if params[:groups]
    groups = extract_group_names(params[:groups])
    task   = async_task(::Actions::Katello::Host::PackageGroup::Install, @host, groups)
    respond_for_async :resource => task
  end
end

#removeObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'app/controllers/katello/api/v2/host_packages_controller.rb', line 66

def remove
  if params[:packages]
    packages = validate_package_list_format(params[:packages])
    task     = async_task(::Actions::Katello::Host::Package::Remove, @host, packages)
    respond_for_async :resource => task
    return
  end

  if params[:groups]
    groups = extract_group_names(params[:groups])
    task   = async_task(::Actions::Katello::Host::PackageGroup::Remove, @host, groups)
    respond_for_async :resource => task
  end
end

#resource_classObject



85
86
87
# File 'app/controllers/katello/api/v2/host_packages_controller.rb', line 85

def resource_class
  Katello::InstalledPackage
end

#upgradeObject



48
49
50
51
52
53
54
# File 'app/controllers/katello/api/v2/host_packages_controller.rb', line 48

def upgrade
  if params[:packages]
    packages = validate_package_list_format(params[:packages])
    task     = async_task(::Actions::Katello::Host::Package::Update, @host, packages)
    respond_for_async :resource => task
  end
end

#upgrade_allObject



58
59
60
61
# File 'app/controllers/katello/api/v2/host_packages_controller.rb', line 58

def upgrade_all
  task     = async_task(::Actions::Katello::Host::Package::Update, @host, [])
  respond_for_async :resource => task
end