Class: Katello::Api::V2::FlatpakRemotesController

Inherits:
ApiController
  • Object
show all
Includes:
Foreman::Controller::FilterParameters, Concerns::FilteredAutoCompleteSearch
Defined in:
app/controllers/katello/api/v2/flatpak_remotes_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

#empty_search_query?, #full_result_response, #resource_class, #scoped_search, #skip_session

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

#createObject



52
53
54
55
56
# File 'app/controllers/katello/api/v2/flatpak_remotes_controller.rb', line 52

def create
  flatpak_remote = FlatpakRemote.new(flatpak_remote_params)
  flatpak_remote.save!
  respond_for_create(resource: flatpak_remote)
end

#default_sortObject



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

def default_sort
  %w(name asc)
end

#destroyObject



70
71
72
# File 'app/controllers/katello/api/v2/flatpak_remotes_controller.rb', line 70

def destroy
  @flatpak_remote.destroy!
end

#flatpak_remote_paramsObject



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

def flatpak_remote_params
  params.require(:flatpak_remote).permit(:name, :url, :description, :organization_id, :username, :token)
end

#indexObject



27
28
29
# File 'app/controllers/katello/api/v2/flatpak_remotes_controller.rb', line 27

def index
  respond(:collection => scoped_search(index_relation, :name, :asc))
end

#index_relationObject



31
32
33
34
35
36
37
# File 'app/controllers/katello/api/v2/flatpak_remotes_controller.rb', line 31

def index_relation
  remotes = FlatpakRemote.readable
  remotes = remotes.where(organization_id: @organization.id) if @organization
  remotes = remotes.where(name: params[:name]) if params[:name]
  remotes = remotes.where(label: params[:label]) if params[:label]
  remotes
end

#rejected_autocomplete_itemsObject



89
90
91
# File 'app/controllers/katello/api/v2/flatpak_remotes_controller.rb', line 89

def rejected_autocomplete_items
  ['organization_id']
end

#scanObject



76
77
78
79
# File 'app/controllers/katello/api/v2/flatpak_remotes_controller.rb', line 76

def scan
  task = async_task(::Actions::Katello::Flatpak::ScanRemote, @flatpak_remote)
  respond_for_async :resource => task
end

#showObject



43
44
45
# File 'app/controllers/katello/api/v2/flatpak_remotes_controller.rb', line 43

def show
  respond :resource => @flatpak_remote
end

#updateObject



63
64
65
66
# File 'app/controllers/katello/api/v2/flatpak_remotes_controller.rb', line 63

def update
  @flatpak_remote.update!(flatpak_remote_params)
  respond_for_show(:resource => @flatpak_remote)
end