72 lines
2.4 KiB
Ruby
72 lines
2.4 KiB
Ruby
module Devops
|
|
module API2_0
|
|
module Routes
|
|
module StackPresetRoutes
|
|
|
|
def self.registered(app)
|
|
# Get list of available stack_template_presets
|
|
#
|
|
# * *Request*
|
|
# - method : GET
|
|
# - headers :
|
|
# - Accept: application/json
|
|
#
|
|
# * *Returns* : array of hashes
|
|
# [ {id: 'preset id', template_preset_body: 'long body'} ]
|
|
#
|
|
app.get_with_headers "/stack_presets", :headers => [:accept] do
|
|
# check_privileges("stack_template_presets", "r")
|
|
json Devops::API2_0::Handler::StackPreset.new(request, params).presets.map(&:to_hash)
|
|
end
|
|
|
|
# Get information about stack_template_preset
|
|
#
|
|
# * *Request*
|
|
# - method : GET
|
|
# - headers :
|
|
# - Accept: application/json
|
|
#
|
|
# * *Returns* : hash
|
|
# {id: 'preset id', template_preset_body: 'long body'}
|
|
#
|
|
app.get_with_headers "/stack_presets/:id", :headers => [:accept] do |id|
|
|
# check_privileges("stack_template_presets", "r")
|
|
json Devops::API2_0::Handler::StackPreset.new(request, params).preset(id).to_hash
|
|
end
|
|
|
|
# Build stack template from preset
|
|
#
|
|
# * *Request*
|
|
# - method : POST
|
|
# - headers :
|
|
# - Accept: application/json
|
|
# - params :
|
|
# - provider: string
|
|
# - stack_template_id: id of stack template to create
|
|
# - template_attrs: hash with template attributes
|
|
#
|
|
# TODO: not stack template, but stack itself
|
|
#
|
|
# * *Returns* : created stack template model
|
|
# {
|
|
# id: 'template id',
|
|
# provider: 'provider',
|
|
# template_body: 'long body'
|
|
# }
|
|
#
|
|
app.post_with_headers "/stack_presets/:id/apply", :headers => [:accept] do |id|
|
|
# check_privileges("stack_template_presets", "r")
|
|
check_privileges('stack_template', 'w')
|
|
body = create_object_from_json_body
|
|
stack = Devops::API2_0::Handler::StackPreset.new(request, params).apply(id, body)
|
|
create_response 'Created', stack.to_hash, 201
|
|
end
|
|
|
|
puts "Stack template presets routes initialized"
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|