Class: Katello::Api::V2::GpgKeysController
Constant Summary
Concerns::FilteredAutoCompleteSearch::PAGE_SIZE
Instance Method Summary
collapse
#auto_complete_search
#full_result_response, #resource_class, #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
#api_version
Instance Method Details
#content ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
|
# File 'app/controllers/katello/api/v2/gpg_keys_controller.rb', line 77
def content
filepath = params.try(:[], :content).try(:path)
if filepath
content = File.open(filepath, "rb") { |file| file.read }
@gpg_key.update_attributes!(:content => content)
render :json => {:status => "success"}
else
fail HttpErrors::BadRequest, _("No file uploaded")
end
end
|
#create ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/katello/api/v2/gpg_keys_controller.rb', line 39
def create
filepath = params.try(:[], :file_path).try(:path)
content = nil
if filepath
content = File.open(filepath, "rb") { |file| file.read }
else
content = params[:content]
end
gpg_key = @organization.gpg_keys.create!(gpg_key_params.merge(:content => content))
respond_for_show(:resource => gpg_key)
end
|
#destroy ⇒ Object
69
70
71
72
|
# File 'app/controllers/katello/api/v2/gpg_keys_controller.rb', line 69
def destroy
@gpg_key.destroy
respond_for_destroy
end
|
#index ⇒ Object
26
27
28
|
# File 'app/controllers/katello/api/v2/gpg_keys_controller.rb', line 26
def index
respond(:collection => scoped_search(index_relation.uniq, :name, :desc))
end
|
#index_relation ⇒ Object
30
31
32
33
34
|
# File 'app/controllers/katello/api/v2/gpg_keys_controller.rb', line 30
def index_relation
query = GpgKey.readable.where(:organization_id => @organization.id)
query = query.where(:name => params[:name]) if params[:name]
query
end
|
#show ⇒ Object
55
56
57
|
# File 'app/controllers/katello/api/v2/gpg_keys_controller.rb', line 55
def show
respond_for_show(:resource => @gpg_key)
end
|
#update ⇒ Object
62
63
64
65
|
# File 'app/controllers/katello/api/v2/gpg_keys_controller.rb', line 62
def update
@gpg_key.update_attributes!(gpg_key_params)
respond_for_show(:resource => @gpg_key)
end
|