Class: Katello::Api::V2::ContentCredentialsController
Constant Summary
Concerns::FilteredAutoCompleteSearch::PAGE_SIZE
Instance Method Summary
collapse
#auto_complete_search
#check_katello_agent_not_disabled, #deprecate_katello_agent, #empty_search_query?, #full_result_response, #katello_agent_removal_release, #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
#api_version
Instance Method Details
#content ⇒ Object
84
85
86
|
# File 'app/controllers/katello/api/v2/content_credentials_controller.rb', line 84
def content
render(:plain => @content_credential.content, :layout => false)
end
|
#create ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/katello/api/v2/content_credentials_controller.rb', line 47
def create
filepath = params.try(:[], :file_path).try(:path)
content = nil
if filepath
content = File.read(filepath, mode: 'rb')
else
content = params[:content]
end
content_credential = @organization.gpg_keys.create!(content_credential_params.merge(:content => content))
respond_for_create(:resource => content_credential)
end
|
#destroy ⇒ Object
77
78
79
80
|
# File 'app/controllers/katello/api/v2/content_credentials_controller.rb', line 77
def destroy
@content_credential.destroy
respond_for_destroy
end
|
#index ⇒ Object
33
34
35
|
# File 'app/controllers/katello/api/v2/content_credentials_controller.rb', line 33
def index
respond(:collection => scoped_search(index_relation.distinct, :name, :asc))
end
|
#index_relation ⇒ Object
37
38
39
40
41
42
|
# File 'app/controllers/katello/api/v2/content_credentials_controller.rb', line 37
def index_relation
query = ContentCredential.readable.where(:organization_id => @organization.id)
query = query.where(:name => params[:name]) if params[:name]
query = query.where(:content_type => params[:content_type]) if params[:content_type]
query
end
|
#resource_class ⇒ Object
8
9
10
|
# File 'app/controllers/katello/api/v2/content_credentials_controller.rb', line 8
def resource_class
Katello::ContentCredential
end
|
#set_content ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
|
# File 'app/controllers/katello/api/v2/content_credentials_controller.rb', line 91
def set_content
filepath = params.try(:[], :content).try(:path)
if filepath
content = File.open(filepath, 'rb') { |file| file.read }
@content_credential.update!(:content => content)
render :json => {:status => 'success'}
else
fail HttpErrors::BadRequest, _('No file uploaded')
end
end
|
#show ⇒ Object
63
64
65
|
# File 'app/controllers/katello/api/v2/content_credentials_controller.rb', line 63
def show
respond_for_show(:resource => @content_credential)
end
|
#update ⇒ Object
70
71
72
73
|
# File 'app/controllers/katello/api/v2/content_credentials_controller.rb', line 70
def update
sync_task(::Actions::Katello::ContentCredential::Update, @content_credential, content_credential_params.to_h)
respond_for_show(:resource => @content_credential)
end
|