fluke/devops-service/app/api2/routes/stack_template.rb
Tim Lianov 0fe1218731 Revert "Merge branch 'qa' into release"
This reverts commit 49ba7a8b0d, reversing
changes made to eb753df4c9.
2016-01-21 12:10:36 -05:00

47 lines
1.7 KiB
Ruby

module Devops
module API2_0
module Routes
module StackTemplateRoutes
def self.registered(app)
app.get_with_headers '/stack_templates', :headers => [:accept] do
check_privileges('stack_template', 'r')
json Devops::API2_0::Handler::StackTemplate.new(request).stack_templates.map(&:to_hash)
end
app.get_with_headers '/stack_templates/provider/:provider', :headers => [:accept] do |provider|
check_privileges('stack_template', 'r')
check_provider(provider)
json Devops::API2_0::Handler::StackTemplate.new(request).stack_templates_for_provider(provider).map(&:to_hash)
end
app.post_with_headers "/stack_template/:provider", :headers => [:accept] do |provider|
check_privileges('stack_template', 'w')
check_provider(provider)
model = Devops::API2_0::Handler::StackTemplate.new(request).create_stack_template(provider)
create_response 'Created', model.to_hash, 201
end
hash = {}
hash['GET'] = lambda {|stack_template_id|
check_privileges('stack_template', 'r')
json Devops::API2_0::Handler::StackTemplate.new(request).get_stack_template(stack_template_id).to_hash
}
hash['DELETE'] = lambda {|stack_template_id|
check_privileges('stack_template', 'w')
Devops::API2_0::Handler::StackTemplate.new(request).delete_stack_template(stack_template_id)
create_response("Template '#{stack_template_id}' has been removed")
}
app.multi_routes '/stack_template/:stack_template_id', {}, hash
puts "Stack_template routes initialized"
end
end
end
end
end