Skip to content

Commit

Permalink
Refs #37989 - Pluralize api docs endpoint and other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sjha4 committed Nov 25, 2024
1 parent 74d6613 commit 035a50b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/controllers/katello/api/v2/flatpak_remotes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Api::V2::FlatpakRemotesController < Katello::Api::V2::ApiController
api :GET, "/flatpak_remotes", N_("List flatpak remotes")
param :organization_id, :number, :desc => N_("organization identifier"), :required => false
param :name, String, :desc => N_("Name of the flatpak remote"), :required => false
param :label, String, :desc => N_("Label of the flatpak remote"), :required => false
param_group :search, Api::V2::ApiController
add_scoped_search_description_for(FlatpakRemote)
def index
Expand All @@ -35,15 +34,18 @@ def index_relation
end

api :GET, "/flatpak_remotes/:id", N_("Show a flatpak remote")
api :GET, "/organizations/:organization_id/flatpak_remotes/:id", N_("Show a flatpak remote")
param :id, :number, :desc => N_("Flatpak remote numeric identifier"), :required => true
param :organization_id, :number, :desc => N_("organization identifier")
def show
respond :resource => @flatpak_remote
end

api :POST, "/flatpak_remote", N_("Create a flatpak remote")
api :POST, "/flatpak_remotes", N_("Create a flatpak remote")
param :name, String, :desc => N_("name"), :required => true
param :url, String, :desc => N_("url"), :required => true
param :organization_id, :number, :desc => N_("organization identifier"), :required => true
param :registry_url, String, :desc => N_("Optional Registry url. Will be updated when remote is scanned.")
param_group :flatpak_remote
def create
flatpak_remote = FlatpakRemote.new(flatpak_remote_params)
Expand All @@ -67,7 +69,7 @@ def destroy
@flatpak_remote.destroy
end

api :POST, "/flatpak_remote/:id/scan", N_("Scan a flatpak remote")
api :POST, "/flatpak_remotes/:id/scan", N_("Scan a flatpak remote")
param :id, :number, :desc => N_("Flatpak remote numeric identifier"), :required => true
def scan
task = async_task(::Actions::Katello::Flatpak::ScanRemote, @flatpak_remote)
Expand All @@ -79,7 +81,7 @@ def default_sort
end

def flatpak_remote_params
params.require(:flatpak_remote).permit(:name, :url, :organization_id, :description, :username, :token)
params.require(:flatpak_remote).permit(:name, :url, :description, :username, :token)
end
end
end
1 change: 1 addition & 0 deletions app/models/katello/flatpak_remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class FlatpakRemote < Katello::Model
validates :name, presence: true
validates :url, presence: true
validates :organization_id, presence: true
validates :name, :uniqueness => {:scope => :organization_id}

scope :seeded, -> { where(:seeded => true) }

Expand Down
2 changes: 2 additions & 0 deletions config/routes/api/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ class ActionDispatch::Routing::Mapper
get :manifest_history
end
end
api_resources :flatpak_remotes, :only => [:index, :show]
api_resources :flatpak_remote_repositories, :only => [:index, :show]
end

match "/packages/thindex" => "packages#thindex", :via => :get
Expand Down

0 comments on commit 035a50b

Please sign in to comment.