Revision c72a2f0f
Added by Tomáš Strachota almost 12 years ago
- ID c72a2f0f078850c23e355d9173157c1ebe574789
app/controllers/api/v1/operatingsystems_controller.rb | ||
---|---|---|
module Api
|
||
module V1
|
||
class OperatingsystemsController < BaseController
|
||
|
||
before_filter :find_by_name, :only => %w{show edit update destroy bootfiles}
|
||
|
||
def index
|
||
@operatingsystems = Operatingsystem.all
|
||
end
|
||
|
||
def show
|
||
end
|
||
|
||
def create
|
||
@operatingsystem = Operatingsystem.new(params[:operatingsystem])
|
||
process_error unless @operatingsystem.save
|
||
end
|
||
|
||
def update
|
||
process_error unless @operatingsystem.update_attributes(params[:operatingsystem])
|
||
end
|
||
|
||
def destroy
|
||
process_error unless @operatingsystem.destroy
|
||
end
|
||
|
||
def bootfiles
|
||
medium = Medium.find_by_name(params[:medium])
|
||
arch = Architecture.find_by_name(params[:architecture])
|
||
render :json => @operatingsystem.pxe_files(medium, arch)
|
||
rescue => e
|
||
render :json => e.to_s, :status => :unprocessable_entity
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/views/api/v1/operatingsystems/create.json.rabl | ||
---|---|---|
object @operatingsystem
|
||
|
||
extends "api/v1/operatingsystems/show"
|
||
|
app/views/api/v1/operatingsystems/index.json.rabl | ||
---|---|---|
collection @operatingsystems
|
||
|
||
extends "api/v1/operatingsystems/show"
|
app/views/api/v1/operatingsystems/show.json.rabl | ||
---|---|---|
object @operatingsystem
|
||
attributes :name, :id
|
||
|
config/routes.rb | ||
---|---|---|
scope :module => :v1, :constraints => ApiConstraints.new(:version => 1, :default => true) do
|
||
resources :bookmarks, :except => [:new, :edit]
|
||
resources :architectures, :except => [:new, :edit]
|
||
resources :operatingsystems, :except => [:new, :edit] do
|
||
member do
|
||
get 'bootfiles'
|
||
end
|
||
end
|
||
|
||
match '/', :to => 'home#index'
|
||
match 'status', :to => 'home#status', :as => "status"
|
||
end
|
Also available in: Unified diff
api v1 - operatingsystems controller