const awscli = require("./awscli");
const azurecli = require("./azurecli");
const db = require("./mongo");


async function deallocate(provId, isSendEmailAfter ) {
    let provision = await db.provision.getById(provId);
    if ( !provision ) return;

    azurecli.deallocate(provision, isSendEmailAfter);

    if (provision.scenario === 'azqmi-fort'){
        awscli.stop(provision, isSendEmailAfter);
    } else {
        azurecli.deallocate(provision, isSendEmailAfter);
    }

}

async function start(provId){
    
    let provision = await db.provision.getById(provId);
    if ( !provision ) return;

    if (provision.scenario === 'azqmi-fort'){
        awscli.start(provision);
    } else {
        azurecli.start(provision);
    }
}

async function updateVmsTags(provId, tagsEdit) {
    azurecli.updateVmsTags(provId, tagsEdit);
}

module.exports.deallocate = deallocate;
module.exports.start = start;
module.exports.updateVmsTags = updateVmsTags;