foreman/app/controllers/api/v2/environments_controller.rb @ acfbc458
e1a1fa81 | Joseph Mitchell Magen | module Api
|
|
module V2
|
|||
dc38aad3 | Joseph Magen | class EnvironmentsController < V2::BaseController
|
|
e1a1fa81 | Joseph Mitchell Magen | ||
include Api::Version2
|
|||
include Api::TaxonomyScope
|
|||
dc38aad3 | Joseph Magen | include Api::ImportPuppetclassesCommonController
|
|
before_filter :find_resource, :only => %w{show update destroy}
|
|||
api :GET, "/environments/", "List all environments."
|
|||
param :search, String, :desc => "Filter results"
|
|||
param :order, String, :desc => "Sort results"
|
|||
param :page, String, :desc => "paginate results"
|
|||
param :per_page, String, :desc => "number of entries per request"
|
|||
e1a1fa81 | Joseph Mitchell Magen | ||
def index
|
|||
acfbc458 | Marek Hulan | @environments = Environment.
|
|
authorized(:view_environments).
|
|||
search_for(*search_options).paginate(paginate_options)
|
|||
e1a1fa81 | Joseph Mitchell Magen | end
|
|
dc38aad3 | Joseph Magen | api :GET, "/environments/:id/", "Show an environment."
|
|
param :id, :identifier, :required => true
|
|||
e1a1fa81 | Joseph Mitchell Magen | def show
|
|
end
|
|||
2be84f3d | Joseph Magen | def_param_group :environment do
|
|
param :environment, Hash, :action_aware => true do
|
|||
param :name, String, :required => true
|
|||
end
|
|||
dc38aad3 | Joseph Magen | end
|
|
2be84f3d | Joseph Magen | api :POST, "/environments/", "Create an environment."
|
|
param_group :environment, :as => :create
|
|||
dc38aad3 | Joseph Magen | def create
|
|
@environment = Environment.new(params[:environment])
|
|||
process_response @environment.save
|
|||
end
|
|||
api :PUT, "/environments/:id/", "Update an environment."
|
|||
param :id, :identifier, :required => true
|
|||
2be84f3d | Joseph Magen | param_group :environment
|
|
dc38aad3 | Joseph Magen | ||
def update
|
|||
process_response @environment.update_attributes(params[:environment])
|
|||
end
|
|||
api :DELETE, "/environments/:id/", "Delete an environment."
|
|||
param :id, :identifier, :required => true
|
|||
def destroy
|
|||
process_response @environment.destroy
|
|||
end
|
|||
e1a1fa81 | Joseph Mitchell Magen | end
|
|
end
|
|||
end
|