2015-04-16 17:54:40 +03:00
|
|
|
require 'db/mongo/models/stack_template/stack_template_factory'
|
2015-07-30 15:37:43 +03:00
|
|
|
require "app/api2/parsers/stack_template"
|
2015-07-27 11:14:01 +03:00
|
|
|
require_relative "request_handler"
|
2015-04-16 17:54:40 +03:00
|
|
|
|
|
|
|
|
module Devops
|
2015-07-27 11:14:01 +03:00
|
|
|
module API2_0
|
2015-04-16 17:54:40 +03:00
|
|
|
module Handler
|
2015-07-27 11:14:01 +03:00
|
|
|
class StackTemplate < RequestHandler
|
2015-04-16 17:54:40 +03:00
|
|
|
|
2015-07-30 15:37:43 +03:00
|
|
|
set_parser Devops::API2_0::Parser::StackTemplateParser
|
|
|
|
|
|
2015-07-27 11:14:01 +03:00
|
|
|
def stack_templates
|
|
|
|
|
Devops::Db.connector.stack_templates
|
2015-04-16 17:54:40 +03:00
|
|
|
end
|
|
|
|
|
|
2015-07-27 11:14:01 +03:00
|
|
|
def stack_templates_for_provider provider
|
|
|
|
|
Devops::Db.connector.stack_templates(provider)
|
2015-04-16 17:54:40 +03:00
|
|
|
end
|
|
|
|
|
|
2015-07-30 15:37:43 +03:00
|
|
|
def create_stack_template
|
|
|
|
|
body = parser.create
|
2015-07-27 11:14:01 +03:00
|
|
|
template_model = Model::StackTemplateFactory.create(body['provider'], body)
|
|
|
|
|
Devops::Db.connector.stack_template_insert(template_model)
|
|
|
|
|
template_model
|
2015-04-16 17:54:40 +03:00
|
|
|
end
|
|
|
|
|
|
2015-07-27 11:14:01 +03:00
|
|
|
def get_stack_template id
|
|
|
|
|
Devops::Db.connector.stack_template(id)
|
2015-04-16 17:54:40 +03:00
|
|
|
end
|
|
|
|
|
|
2015-07-27 11:14:01 +03:00
|
|
|
def delete_stack_template id
|
|
|
|
|
Devops::Db.connector.stack_template_delete id
|
2015-04-16 17:54:40 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2015-07-27 11:14:01 +03:00
|
|
|
end
|