foreman/app/controllers/api/v1/operatingsystems_controller.rb @ b2b47290
c72a2f0f | Tomas Strachota | module Api
|
|
module V1
|
|||
b2b47290 | Petr Chalupa | class OperatingsystemsController < V1::BaseController
|
|
86fb12c1 | Ohad Levy | ||
resource_description do
|
|||
name 'Operating systems'
|
|||
end
|
|||
63efbbf5 | Petr Chalupa (Pitr) | before_filter :find_resource, :only => %w{show edit update destroy bootfiles}
|
|
c72a2f0f | Tomas Strachota | ||
86fb12c1 | Ohad Levy | api :GET, "/operatingsystems/", "List all operating systems."
|
|
c72a2f0f | Tomas Strachota | def index
|
|
@operatingsystems = Operatingsystem.all
|
|||
end
|
|||
86fb12c1 | Ohad Levy | api :GET, "/operatingsystems/:id/", "Show an OS."
|
|
c72a2f0f | Tomas Strachota | def show
|
|
end
|
|||
86fb12c1 | Ohad Levy | api :POST, "/operatingsystems/", "Create an OS."
|
|
param :operatingsystem, Hash, :required => true do
|
|||
63efbbf5 | Petr Chalupa (Pitr) | param :name, /\A(\S+)\Z/, :required => true
|
|
param :major, String, :required => true
|
|||
param :minor, String, :required => true
|
|||
86fb12c1 | Ohad Levy | end
|
|
c72a2f0f | Tomas Strachota | def create
|
|
@operatingsystem = Operatingsystem.new(params[:operatingsystem])
|
|||
86fb12c1 | Ohad Levy | process_response @operatingsystem.save
|
|
63efbbf5 | Petr Chalupa (Pitr) | end
|
|
c72a2f0f | Tomas Strachota | ||
86fb12c1 | Ohad Levy | api :PUT, "/operatingsystems/:id/", "Update an OS."
|
|
param :operatingsystem, Hash, :required => true do
|
|||
63efbbf5 | Petr Chalupa (Pitr) | param :name, /\A(\S+)\Z/
|
|
param :major, String
|
|||
param :minor, String
|
|||
86fb12c1 | Ohad Levy | end
|
|
c72a2f0f | Tomas Strachota | def update
|
|
86fb12c1 | Ohad Levy | process_response @operatingsystem.update_attributes(params[:operatingsystem])
|
|
c72a2f0f | Tomas Strachota | end
|
|
86fb12c1 | Ohad Levy | api :DELETE, "/operatingsystems/:id/", "Delete a bookmark."
|
|
c72a2f0f | Tomas Strachota | def destroy
|
|
86fb12c1 | Ohad Levy | process_response @operatingsystem.destroy
|
|
c72a2f0f | Tomas Strachota | end
|
|
86fb12c1 | Ohad Levy | api :GET, "/operatingsystems/:id/bootfiles/", "List boot files an OS."
|
|
param :medium, String
|
|||
param :architecture, String
|
|||
c72a2f0f | Tomas Strachota | def bootfiles
|
|
medium = Medium.find_by_name(params[:medium])
|
|||
63efbbf5 | Petr Chalupa (Pitr) | arch = Architecture.find_by_name(params[:architecture])
|
|
c72a2f0f | Tomas Strachota | render :json => @operatingsystem.pxe_files(medium, arch)
|
|
rescue => e
|
|||
render :json => e.to_s, :status => :unprocessable_entity
|
|||
end
|
|||
end
|
|||
end
|
|||
end
|