Project

General

Profile

« Previous | Next » 

Revision acd8589a

Added by Martin Bacovsky almost 12 years ago

  • ID acd8589abbb2283afa638d1d4b84099576acc452

api v1 - architectures controler and tests

View differences:

app/controllers/api/v1/architectures_controller.rb
include Foreman::Controller::AutoCompleteSearch
before_filter :find_by_name, :only => %w{show update destroy}
api :GET, "/architectures/", "List all architectures."
def index
@architectures = Architecture.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page], :include => :operatingsystems)
end
api :GET, "/architectures/:id/", "Show an architecture."
def show
end
api :POST, "/architectures/", "Create an architecture."
param :architecture, Hash, :required => true do
param :name, String, :required => true
end
def create
respond_with Architecture.new(params[:architecture])
@architecture = Architecture.new(params[:architecture])
process_response @architecture.save
end
api :PUT, "/architectures/:id/", "Update an architecture."
param :architecture, Hash, :required => true do
param :name, String
end
def update
respond_with @architecture.update_attributes(params[:architecture])
process_response @architecture.update_attributes(params[:architecture])
end
api :DELETE, "/architecturess/:id/", "Delete an architecture."
def destroy
respond_with @architecture.destroy
process_response @architecture.destroy
end
end
end

Also available in: Unified diff