require "lib/executors/server_executor"
require "app/api3/parsers/stack"
require 'db/mongo/models/stack/stack_factory'
require 'workers/stack_bootstrap_worker'
require_relative "request_handler"

module Devops
  module API3
    module Handler
      class Stack < RequestHandler

        def autoscaling_groups_change(group_id, provider_account)
          provider = ::Provider::ProviderFactory.get('aws', provider_account)
          stack_id = provider.stack_id_of_autoscaling_group(group_id)
          stack = ::Devops::Db.connector.stack_by_id(stack_id)
          jid = Worker.start_async(StackSyncWorker, stack_name: stack.name)
          puts jid
          jid
        end

      end
    end
  end
end
