/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var __ = require("underscore");

















var fs = require("fs");
var util = require("util");
var moment = require("moment");
var batchUtil = require("./batch.util");
var batchShowUtil = require("./batch.showUtil");
var utils = require("../../util/utils");
var startProgress = batchUtil.startProgress;
var endProgress = batchUtil.endProgress;

var $ = utils.getLocaleString;




exports.init = function(cli) {


  batchUtil.init(cli);




  var batch = cli.category("batch").description($("Commands to manage your Batch objects"));


  var logger = cli.output;

  var interaction = cli.interaction;

  var pool = batch.category("pool").description($("Commands to manage your Batch pools"));


  var autoscale = pool.category("autoscale").description($("Commands to manage autoscale of your Batch pools"));


  var allStats = pool.category("all-stats").description($("Commands to manage all the pools under your Batch account"));


  var usageMetrics = pool.category("usage-metrics").description($("Commands to manage usage metrics of your Batch pools"));


  var nodeAgentSkus = pool.category("node-agent-skus").description($("Commands to manage node agent skus of IaaS pools"));


  pool.command("create [json-file]").description($("Create a Batch pool")).option("-f, --json-file <json-file>", $("the file containing the pool object to create in JSON format, if this parameter is specified, all other pool parameters are ignored")).option("-i, --id <pool-id>", $("the Batch pool id")).option("-S, --vm-size <vm-size>", $("the size of virtual machines in the pool, ex: small, Standard_D14")).option("-t, --target-dedicated <target-dedicated>", $("the desired number of compute nodes in the pool")).option("-F, --autoscale-formula <autoscale-formula>", $("the formula for the desired number of compute nodes in the pool, see https://azure.microsoft.com/en-us/documentation/articles/batch-automatic-scaling/ for more detail")).option("-o, --os-family <os-family>", $("the Azure Guest OS family to be installed on the virtual machines in the pool, this parameter cannot be used with the --image-publisher, --image-offer, --image-sku and --node-agent-id parameters")).option("-p, --image-publisher <image-publisher>", $("the publisher of the Azure Virtual Machines Marketplace image, ex: Canonical or MicrosoftWindowsServer")).option("-O, --image-offer <image-offer>", $("the offer type of the Azure Virtual Machines Marketplace image, ex: UbuntuServer or WindowsServer")).option("-K, --image-sku <image-sku>", $("the SKU of the Azure Virtual Machines Marketplace image, ex: 14.04.0-LTS or 2012-R2-Datacenter")).option("-n, --node-agent-id <node-agent-id>", $("the SKU of Batch Node Agent to be provisioned on the compute node")).option("--resize-timeout <resize-timeout>", $("the timeout for allocation of compute nodes to the pool, in ISO 8601 duration formation")).option("-c, --start-task-cmd <start-task-cmd>", $("the command line of the start task")).option("--certificate-ref <certificate-ref>", $("the semicolon separated list of thumbprints specifying the certificates to be installed on each compute node in the pool")).option("--app-package-ref <app-package-ref>", $("the semicolon separated list of ids specifying the application packages to be installed on each compute node in the pool")).option("--metadata <metadata>", $("the semicolon separated list of name-value pairs associated with the pool as metadata, ex: name1=value1;name2=value")).appendBatchAccountOption().execute(createPool);



















  pool.command("list").description($("List Batch pools")).appendODataFilterOption(true, true, true).appendBatchAccountOption().execute(listPool);





  usageMetrics.command("list").description($("List Batch pool usage metrics")).option("-s, --start-time <start-time>", $("the earliest time from which to include metrics")).option("-e, --end-time <end-time>", $("the latest time from which to include metrics")).appendODataFilterOption(false, true, false).appendBatchAccountOption().execute(listUsageMetrics);







  pool.command("show [pool-id]").description($("Show information about the specified Batch pool")).option("-i, --id <pool-id>", $("the Batch pool id")).appendODataFilterOption(true, false, true).appendCommonHeaderFilterOption(true, true).appendBatchAccountOption().execute(showPool);







  allStats.command("show").description($("Show lifetime summary statistics for all of the pools")).appendBatchAccountOption().execute(showAllPoolsStats);




  pool.command("delete [pool-id]").description($("Delete the specified Batch pool")).option("-i, --id <pool-Id>", $("the Batch pool id")).option("-q, --quiet", $("remove the specified Batch pool without confirmation")).appendCommonHeaderFilterOption(true, true).appendBatchAccountOption().execute(deletePool);







  pool.command("set [pool-id] [json-file]").description($("Patch/Update the properties of the specified Batch pool")).option("-i, --id <pool-id>", $("the Batch pool id")).option("-f, --json-file <json-file>", $("the file containing the patch/update pool properties to apply in JSON format, if this parameter is specified, all other pool property parameters are ignored")).option("-c, --start-task-cmd <start-task-cmd>", $("the command line of the start task")).option("--certificate-ref <certificate-ref>", $("the semicolon separated list of thumbprints specifying the certificates to be installed on each compute node in the pool")).option("--app-package-ref <app-package-ref>", $("the semicolon separated list of ids specifying the application packages to be installed on each compute node in the pool")).option("--metadata <metadata>", $("the semicolon separated list of name-value pairs associated with the pool as metadata, ex: name1=value1;name2=value")).option("-r, --replace", $("uses update instead of patch")).appendCommonHeaderFilterOption(true, true).appendBatchAccountOption().execute(updatePool);












  nodeAgentSkus.command("list").description($("Lists the node agent SKUs supported by the Azure Batch service")).appendODataFilterOption(false, true, false).appendBatchAccountOption().execute(listNodeAgentSkus);





  autoscale.command("disable [pool-id]").description($("Disable autoscale at the Batch pool")).option("-i, --id <pool-id>", $("the Batch pool id")).appendBatchAccountOption().execute(disablePoolAutoscale);





  autoscale.command("enable [pool-id]").description($("Enable autoscale at the Batch pool")).option("-i, --id <pool-id>", $("the Batch pool id")).option("-f, --autoscale-formula <autoscale-formula>", $("the autoscale formula, see https://azure.microsoft.com/en-us/documentation/articles/batch-automatic-scaling/ for more detail")).option("--autoscale-evaluation-interval <autoscale-evaluation-interval>", $("the time interval for the desired autoscale evaluation period, in ISO 8601 duration formation")).appendCommonHeaderFilterOption(true, true).appendBatchAccountOption().execute(enablePoolAutoscale);








  autoscale.command("evaluate [pool-id] [autoscale-formula]").description($("Evaluate autoscale at the Batch pool")).option("-i, --id <pool-id>", $("the Batch pool id")).option("-f, --autoscale-formula <autoscale-formula>", $("the autoscale formula, see https://azure.microsoft.com/en-us/documentation/articles/batch-automatic-scaling/ for more detail")).appendBatchAccountOption().execute(evaluatePoolAutoscale);






  pool.command("resize [pool-id] [target-dedicated]").description($("Resize (or stop resizing) the Batch pool")).option("-i, --id <pool-id>", $("the Batch pool id")).option("--abort", $("stop resizing")).option("-t, --target-dedicated <target-dedicated>", $("the dedicated VM count to resize")).option("--resize-timeout <resize-timeout>", $("the timeout for allocation of compute nodes to the pool or removal of compute nodes from the pool, in ISO 8601 duration formation")).option("-o, --deallocate-option <deallocate-option>", $("sets when nodes may be removed from the pool, if the pool size is decreasing")).appendCommonHeaderFilterOption(true, true).appendBatchAccountOption().execute(resizePool);










  var node = batch.category("node").description($("Commands to manage your Batch compute nodes"));


  node.command("delete [pool-id] [node-list]").description($("Remove nodes from the Batch pool")).option("-i, --id <pool-id>", $("the Batch pool id")).option("-l, --node-list <node-list>", $("the list of node ids")).option("-q, --quiet", $("remove nodes from the specified Batch pool without confirmation")).option("--resize-timeout <resize-timeout>", $("the timeout for removal of compute nodes from the pool, in ISO 8601 duration format")).option("-o, --deallocate-option <deallocate-option>", $("sets when nodes may be removed from the pool")).appendCommonHeaderFilterOption(true, true).appendBatchAccountOption().execute(removePoolNodes);




















  function createPool(jsonFile, options, _) { var parsedJson, vmSize, osFamily, ref, objJson, client, addPool, resultMapper, tips, batchOptions; var __frame = { name: "createPool", line: 194 }; return __func(_, this, arguments, createPool, 2, __frame, function __$createPool() {
      if (!jsonFile) {
        jsonFile = options.jsonFile; } ;


      parsedJson = { }; return (function __$createPool(__then) {

        if (!jsonFile) { return (function __$createPool(__then) {
            if (!options.id) {
              return interaction.promptIfNotGiven($("JSON file name: "), jsonFile, __cb(_, __frame, 9, 31, function ___(__0, __1) { jsonFile = __1; __then(); }, true)); } else {

              parsedJson = { id: options.id };
              vmSize = options.vmSize; return (function __$createPool(__then) {
                if (!vmSize) {
                  return cli.interaction.promptIfNotGiven($("VM Size: "), vmSize, __cb(_, __frame, 14, 35, function ___(__0, __2) { vmSize = __2; __then(); }, true)); } else { __then(); } ; })(function __$createPool() {

                __.extend(parsedJson, { vmSize: vmSize });
                if ((((!options.targetDedicated && !options.autoscaleFormula)) || ((options.targetDedicated && options.autoscaleFormula)))) {
                  return _(new Error($("You must specify either --target-dedicated or --autoscale-formula, but not both."))); } ;

                if (options.targetDedicated) {
                  __.extend(parsedJson, { targetDedicated: Number(options.targetDedicated), enableAutoScale: false }); } ;

                if (options.autoscaleFormula) {
                  __.extend(parsedJson, { autoScaleFormula: options.autoscaleFormula, enableAutoScale: true }); } ; return (function __$createPool(__then) {


                  if (!((((options.imagePublisher && options.imageOffer) && options.imageSku) && options.nodeAgentId))) { return (function __$createPool(__then) {
                      if ((((options.imagePublisher || options.imageOffer) || options.imageSku) || options.nodeAgentId)) {
                        return _(new Error($("You must either specify --os-family or all of the folowing: --image-publisher, --image-offer, --image-sku and --node-agent-id."))); } else {

                        osFamily = options.osFamily; return (function __$createPool(__then) {
                          if (!osFamily) {
                            return cli.interaction.promptIfNotGiven($("OS Family: "), osFamily, __cb(_, __frame, 33, 41, function ___(__0, __3) { osFamily = __3; __then(); }, true)); } else { __then(); } ; })(function __$createPool() {

                          __.extend(parsedJson, { cloudServiceConfiguration: { osFamily: osFamily } }); __then(); }); } ; })(__then); } else {

                    if (!options.osFamily) {
                      __.extend(parsedJson, {
                        virtualMachineConfiguration: {
                          imageReference: {
                            publisher: options.imagePublisher,
                            offer: options.imageOffer,
                            sku: options.imageSku,
                            version: "latest" },
                          nodeAgentSKUId: options.nodeAgentId } }); }
                     else {
                      return _(new Error($("You must either specify --os-family or all of the folowing: --image-publisher, --image-offer, --image-sku and --node-agent-id."))); } ; __then(); } ; })(function __$createPool() {


                  if (options.startTaskCmd) {
                    __.extend(parsedJson, { startTask: { commandLine: options.startTaskCmd } }); } ;


                  if (options.resizeTimeout) {
                    __.extend(parsedJson, { resizeTimeout: options.resizeTimeout }); } ;



                  if (options.certificateRef) {
                    ref = [];
                    options.certificateRef.split(";").forEach(function(entry) {
                      ref.push({ thumbprint: entry, thumbprintAlgorithm: "sha1" }); });

                    __.extend(parsedJson, { certificateReferences: ref }); } ;

                  if (options.appPacakgeRef) {
                    ref = [];
                    options.appPacakgeRef.split(";").forEach(function(entry) {
                      ref.push({ applicationId: entry }); });

                    __.extend(parsedJson, { applicationPackageReferences: ref }); } ;

                  if (options.metadata) {
                    ref = [];
                    options.metadata.split(";").forEach(function(entry) {
                      var item = entry.split("=");
                      ref.push({ name: item[0], value: item[1] }); });

                    __.extend(parsedJson, { metadata: ref }); } ; __then(); }); }); } ; })(__then); } else { __then(); } ; })(function __$createPool() {




        if (jsonFile) {
          objJson = fs.readFileSync(jsonFile).toString();
          parsedJson = JSON.parse(objJson); } ;


        client = batchUtil.createBatchServiceClient(options);

        addPool = null;
        if (((parsedJson !== null) && (parsedJson !== undefined))) {
          resultMapper = new client.models["PoolAddParameter"]().mapper();
          addPool = client.deserialize(resultMapper, parsedJson, "result"); } ;


        tips = $("Creating Batch pool");
        batchOptions = { };
        batchOptions.poolAddOptions = batchUtil.getBatchOperationDefaultOption();

        startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$createPool() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$createPool() {

                    return client.pool.add(addPool, batchOptions, __cb(_, __frame, 103, 18, __then, true)); }); })(function ___(err, __result) { __catch(function __$createPool() { if (err) {

                      if (err.message) {
                        if ((typeof err.message === "object")) {
                          err.message = err.message.value; } ; } ;



                      return _(err); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$createPool() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$createPool() {


                endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$createPool() {


            logger.verbose(util.format($("Pool %s has been created successfully"), addPool.id));
            return showPool(addPool.id, options, __cb(_, __frame, 118, 4, function __$createPool() { _(); }, true)); }); }); }); }); };








  function showPool(poolId, options, _) { var client, tips, batchOptions, pool; var __frame = { name: "showPool", line: 321 }; return __func(_, this, arguments, showPool, 2, __frame, function __$showPool() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.id; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 25, function ___(__0, __1) { poolId = __1;
        tips = $("Getting Batch pool information");
        batchOptions = { };
        batchOptions.poolGetOptions = batchUtil.getBatchOperationDefaultOption();

        if (options.selectClause) {
          batchOptions.poolGetOptions.select = options.selectClause; } ;

        if (options.expandClause) {
          batchOptions.poolGetOptions.expand = options.expandClause; } ;


        if (options.ifMatch) {
          batchOptions.poolGetOptions.ifMatch = options.ifMatch; } ;

        if (options.ifNoneMatch) {
          batchOptions.poolGetOptions.ifNoneMatch = options.ifNoneMatch; } ;

        if (options.ifModifiedSince) {
          batchOptions.poolGetOptions.ifModifiedSince = options.ifModifiedSince; } ;

        if (options.ifUnmodifiedSince) {
          batchOptions.poolGetOptions.ifUnmodifiedSince = options.ifUnmodifiedSince; } ;


        pool = null;
        startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showPool() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showPool() {


                    return client.pool.get(poolId, batchOptions, __cb(_, __frame, 34, 25, function ___(__0, __2) { pool = __2; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$showPool() { if (err) {

                      if (batchUtil.isNotFoundException(err)) {
                        return _(new Error(util.format($("Pool %s doesn't exist"), poolId))); }
                       else {
                        if (err.message) {
                          if ((typeof err.message === "object")) {
                            err.message = err.message.value; } ; } ;



                        return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$showPool() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$showPool() {


                endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$showPool() {


            batchShowUtil.showCloudPool(pool, cli.output); _(); }); }); }, true)); }); };







  function showAllPoolsStats(options, _) { var client, tips, batchOptions, stats; var __frame = { name: "showAllPoolsStats", line: 380 }; return __func(_, this, arguments, showAllPoolsStats, 1, __frame, function __$showAllPoolsStats() {
      client = batchUtil.createBatchServiceClient(options);
      tips = $("Getting lifetime summary statistics");
      batchOptions = { };
      batchOptions.poolGetAllPoolsLifetimeStatisticsOptions = batchUtil.getBatchOperationDefaultOption();


      startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showAllPoolsStats() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showAllPoolsStats() {

                  return client.pool.getAllPoolsLifetimeStatistics(batchOptions, __cb(_, __frame, 9, 25, function ___(__0, __1) { stats = __1; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$showAllPoolsStats() { if (e) {

                    if (e.message) {
                      if ((typeof e.message === "object")) {
                        e.message = e.message.value; } ; } ;



                    return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$showAllPoolsStats() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$showAllPoolsStats() {

              endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$showAllPoolsStats() {


          batchShowUtil.showPoolStats(stats, cli.output); _(); }); }); }); };







  function listPool(options, _) { var client, tips, batchOptions, pools, result, nextLink; var __frame = { name: "listPool", line: 410 }; return __func(_, this, arguments, listPool, 1, __frame, function __$listPool() {
      client = batchUtil.createBatchServiceClient(options);
      tips = $("Listing Batch pools");
      batchOptions = { };
      batchOptions.poolListOptions = batchUtil.getBatchOperationDefaultOption();

      if (options.selectClause) {
        batchOptions.poolListOptions.select = options.selectClause; } ;

      if (options.expandClause) {
        batchOptions.poolListOptions.expand = options.expandClause; } ;

      if (options.filterClause) {
        batchOptions.poolListOptions.filter = options.filterClause; } ;


      pools = [];
      startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listPool() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listPool() {


                  return client.pool.list(batchOptions, __cb(_, __frame, 20, 31, function ___(__0, __1) { result = __1;
                    result.forEach(function(pool) {
                      pools.push(pool); });

                    nextLink = result.odatanextLink; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$listPool() { __more = false;

                        var __4 = nextLink; if (__4) {
                          batchOptions.poolListOptions = batchUtil.getBatchOperationDefaultOption();
                          return client.pool.listNext(nextLink, batchOptions, __cb(_, __frame, 28, 29, function ___(__0, __2) { result = __2;
                            result.forEach(function(pool) {
                              pools.push(pool); });

                            nextLink = result.odatanextLink; while (__more) { __loop(); }; __more = true; }, true)); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(__then); }, true)); }); })(function ___(err, __result) { __catch(function __$listPool() { if (err) {


                    if (err.message) {
                      if ((typeof err.message === "object")) {
                        err.message = err.message.value; } ; } ;



                    return _(err); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$listPool() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$listPool() {

              endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$listPool() {


          cli.interaction.formatOutput(pools, function(outputData) {
            if ((outputData.length === 0)) {
              logger.info($("No pool found")); }
             else {
              logger.table(outputData, function(row, item) {
                row.cell($("Id"), item.id);
                row.cell($("State"), item.state);
                row.cell($("VM Size"), item.vmSize);
                row.cell($("VM Count"), item.currentDedicated); }); } ; }); _(); }); }); }); };










  function listUsageMetrics(options, _) { var client, tips, batchOptions, metrics, result, nextLink; var __frame = { name: "listUsageMetrics", line: 475 }; return __func(_, this, arguments, listUsageMetrics, 1, __frame, function __$listUsageMetrics() {
      client = batchUtil.createBatchServiceClient(options);
      tips = $("Listing Batch pool usage metrics");
      batchOptions = { };
      batchOptions.poolListPoolUsageMetricsOptions = batchUtil.getBatchOperationDefaultOption();

      if (options.startTime) {
        batchOptions.poolListPoolUsageMetricsOptions.startTime = new Date(options.startTime); } ;

      if (options.endTime) {
        batchOptions.poolListPoolUsageMetricsOptions.endTime = new Date(options.endTime); } ;

      if (options.filterClause) {
        batchOptions.poolListPoolUsageMetricsOptions.filter = options.filterClause; } ;


      metrics = [];
      startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listUsageMetrics() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listUsageMetrics() {


                  return client.pool.listPoolUsageMetrics(batchOptions, __cb(_, __frame, 20, 30, function ___(__0, __1) { result = __1;
                    result.forEach(function(pool) {
                      metrics.push(pool); });

                    nextLink = result.odatanextLink; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$listUsageMetrics() { __more = false;

                        var __4 = nextLink; if (__4) {
                          batchOptions.poolListPoolUsageMetricsOptions = batchUtil.getBatchOperationDefaultOption();
                          return client.pool.listPoolUsageMetricsNext(nextLink, batchOptions, __cb(_, __frame, 28, 28, function ___(__0, __2) { result = __2;
                            result.forEach(function(pool) {
                              metrics.push(pool); });

                            nextLink = result.odatanextLink; while (__more) { __loop(); }; __more = true; }, true)); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(__then); }, true)); }); })(function ___(err, __result) { __catch(function __$listUsageMetrics() { if (err) {


                    if (err.message) {
                      if ((typeof err.message === "object")) {
                        err.message = err.message.value; } ; } ;



                    return _(err); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$listUsageMetrics() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$listUsageMetrics() {

              endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$listUsageMetrics() {


          cli.interaction.formatOutput(metrics, function(outputData) {
            var UTCFormat = "YYYY-MM-DDTHH:MI:SSZ";
            if ((outputData.length === 0)) {
              logger.info($("No Usage Metric found")); }
             else {
              logger.table(outputData, function(row, item) {
                row.cell($("Id"), item.id);
                if (item.startTime) {
                  row.cell($("Start Time"), item.startTime.toUTCFormat(UTCFormat)); } ;

                if (item.endTime) {
                  row.cell($("End Time"), item.endTime.toUTCFormat(UTCFormat)); } ;

                row.cell($("VM Size"), item.vmSize);
                row.cell($("Total Core Hours"), item.totalCoreHours); }); } ; }); _(); }); }); }); };











  function deletePool(poolId, options, _) { var client, tips, batchOptions; var __frame = { name: "deletePool", line: 547 }; return __func(_, this, arguments, deletePool, 2, __frame, function __$deletePool() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.id; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 25, function ___(__0, __1) { poolId = __1;
        tips = util.format($("Deleting pool %s"), poolId);
        batchOptions = { };
        batchOptions.poolDeleteMethodOptions = batchUtil.getBatchOperationDefaultOption();

        if (options.ifMatch) {
          batchOptions.poolDeleteMethodOptions.ifMatch = options.ifMatch; } ;

        if (options.ifNoneMatch) {
          batchOptions.poolDeleteMethodOptions.ifNoneMatch = options.ifNoneMatch; } ;

        if (options.ifModifiedSince) {
          batchOptions.poolDeleteMethodOptions.ifModifiedSince = options.ifModifiedSince; } ;

        if (options.ifUnmodifiedSince) {
          batchOptions.poolDeleteMethodOptions.ifUnmodifiedSince = options.ifUnmodifiedSince; } ; return (function __$deletePool(__then) {


          if (!options.quiet) {
            return interaction.confirm(util.format($("Do you want to delete pool %s? [y/n] "), poolId), __cb(_, __frame, 24, 23, function ___(__0, __3) { var __2 = !__3; return (function __$deletePool(__then) { if (__2) { return _(null); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$deletePool() {




          startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deletePool() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deletePool() {


                      return client.pool.deleteMethod(poolId, batchOptions, __cb(_, __frame, 32, 18, __then, true)); }); })(function ___(err, __result) { __catch(function __$deletePool() { if (err) {

                        if (batchUtil.isNotFoundException(err)) {
                          return _(new Error(util.format($("Pool %s doesn't exist"), poolId))); }
                         else {
                          if (err.message) {
                            if ((typeof err.message === "object")) {
                              err.message = err.message.value; } ; } ;



                          return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$deletePool() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$deletePool() {


                  endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$deletePool() {


              logger.info(util.format($("Pool %s has been deleted successfully"), poolId)); _(); }); }); }); }, true)); }); };









  function updatePool(poolId, jsonFile, options, _) { var parsedJson, ref, objJson, client, tips, resultMapper, batchOptions, opOptions, updatePoolParam; var __frame = { name: "updatePool", line: 606 }; return __func(_, this, arguments, updatePool, 3, __frame, function __$updatePool() {
      if (!poolId) {
        poolId = options.id; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 4, 25, function ___(__0, __1) { poolId = __1;
        if (!jsonFile) {
          jsonFile = options.jsonFile; } ;


        parsedJson = { }; return (function __$updatePool(__then) {

          if (!jsonFile) { return (function __$updatePool(__then) {
              if ((((!options.startTaskCmd && !options.certificateRef) && !options.appPackageRef) && !options.metadata)) {
                return interaction.promptIfNotGiven($("JSON file name: "), jsonFile, __cb(_, __frame, 13, 31, function ___(__0, __2) { jsonFile = __2; __then(); }, true)); } else {

                if (options.startTaskCmd) {
                  __.extend(parsedJson, { startTask: { commandLine: options.startTaskCmd } }); } ;


                if (options.certificateRef) {
                  ref = [];
                  options.certificateRef.split(";").forEach(function(entry) {
                    ref.push({ thumbprint: entry, thumbprintAlgorithm: "sha1" }); });

                  __.extend(parsedJson, { certificateReferences: ref }); } ;

                if (options.appPacakgeRef) {
                  ref = [];
                  options.appPacakgeRef.split(";").forEach(function(entry) {
                    ref.push({ applicationId: entry }); });

                  __.extend(parsedJson, { applicationPackageReferences: ref }); } ;

                if (options.metadata) {
                  ref = [];
                  options.metadata.split(";").forEach(function(entry) {
                    var item = entry.split("=");
                    ref.push({ name: item[0], value: item[1] }); });

                  __.extend(parsedJson, { metadata: ref }); } ; __then(); } ; })(__then); } else { __then(); } ; })(function __$updatePool() {




          if (jsonFile) {
            objJson = fs.readFileSync(jsonFile).toString();
            parsedJson = JSON.parse(objJson); } ;


          client = batchUtil.createBatchServiceClient(options);



          batchOptions = { };

          opOptions = { };
          opOptions = batchUtil.getBatchOperationDefaultOption();

          if (options.ifMatch) {
            opOptions.ifMatch = options.ifMatch; } ;

          if (options.ifNoneMatch) {
            opOptions.ifNoneMatch = options.ifNoneMatch; } ;

          if (options.ifModifiedSince) {
            opOptions.ifModifiedSince = options.ifModifiedSince; } ;

          if (options.ifUnmodifiedSince) {
            opOptions.ifUnmodifiedSince = options.ifUnmodifiedSince; } ;


          updatePoolParam = null; return (function __$updatePool(__then) {

            if (options.replace) {
              if (((parsedJson !== null) && (parsedJson !== undefined))) {
                resultMapper = new client.models["PoolUpdatePropertiesParameter"]().mapper();
                updatePoolParam = client.deserialize(resultMapper, parsedJson, "result"); } ;


              if (!updatePoolParam.certificateReferences) {
                updatePoolParam.certificateReferences = []; } ;

              if (!updatePoolParam.applicationPackageReferences) {
                updatePoolParam.applicationPackageReferences = []; } ;

              if (!updatePoolParam.metadata) {
                updatePoolParam.metadata = []; } ;


              tips = util.format($("Updating pool %s"), poolId);

              batchOptions.poolUpdatePropertiesOptions = opOptions;

              startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$updatePool() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$updatePool() {


                          return client.pool.updateProperties(poolId, updatePoolParam, batchOptions, __cb(_, __frame, 96, 20, __then, true)); }); })(function ___(err, __result) { __catch(function __$updatePool() { if (err) {

                            if (batchUtil.isNotFoundException(err)) {
                              return _(new Error(util.format($("Pool %s doesn't exist"), poolId))); }
                             else {
                              if (err.message) {
                                if ((typeof err.message === "object")) {
                                  err.message = err.message.value; } ; } ;



                              return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$updatePool() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$updatePool() {


                      endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, __then); }); } else {


              if (((parsedJson !== null) && (parsedJson !== undefined))) {
                resultMapper = new client.models["PoolPatchParameter"]().mapper();
                updatePoolParam = client.deserialize(resultMapper, parsedJson, "result"); } ;


              tips = util.format($("Patching pool %s"), poolId);
              batchOptions.poolPatchOptions = opOptions;

              startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$updatePool() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$updatePool() {


                          return client.pool.patch(poolId, updatePoolParam, batchOptions, __cb(_, __frame, 124, 20, __then, true)); }); })(function ___(err, __result) { __catch(function __$updatePool() { if (err) {

                            if (batchUtil.isNotFoundException(err)) {
                              return _(new Error(util.format($("Pool %s doesn't exist"), poolId))); }
                             else {
                              if (err.message) {
                                if ((typeof err.message === "object")) {
                                  err.message = err.message.value; } ; } ;



                              return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$updatePool() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$updatePool() {


                      endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, __then); }); } ; })(function __$updatePool() {



            logger.verbose(util.format($("Pool %s has been updated/patched successfully"), poolId));
            return showPool(poolId, options, __cb(_, __frame, 143, 4, function __$updatePool() { _(); }, true)); }); }); }, true)); }); };








  function disablePoolAutoscale(poolId, options, _) { var client, tips, batchOptions; var __frame = { name: "disablePoolAutoscale", line: 758 }; return __func(_, this, arguments, disablePoolAutoscale, 2, __frame, function __$disablePoolAutoscale() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.id; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 24, function ___(__0, __1) { poolId = __1;
        tips = util.format($("Disabling autoscale on pool %s"), poolId);
        batchOptions = { };
        batchOptions.poolDisableAutoScaleOptions = batchUtil.getBatchOperationDefaultOption();

        startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$disablePoolAutoscale() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$disablePoolAutoscale() {


                    return client.pool.disableAutoScale(poolId, batchOptions, __cb(_, __frame, 13, 17, __then, true)); }); })(function ___(err, __result) { __catch(function __$disablePoolAutoscale() { if (err) {

                      if (batchUtil.isNotFoundException(err)) {
                        return _(new Error(util.format($("Pool %s doesn't exist"), poolId))); }
                       else {
                        if (err.message) {
                          if ((typeof err.message === "object")) {
                            err.message = err.message.value; } ; } ;



                        return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$disablePoolAutoscale() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$disablePoolAutoscale() {


                endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$disablePoolAutoscale() {


            logger.info(util.format($("Autoscale has been successfully disabled on pool %s"), poolId)); _(); }); }); }, true)); }); };








  function enablePoolAutoscale(poolId, options, _) { var client, tips, batchOptions, param; var __frame = { name: "enablePoolAutoscale", line: 797 }; return __func(_, this, arguments, enablePoolAutoscale, 2, __frame, function __$enablePoolAutoscale() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.id; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 24, function ___(__0, __1) { poolId = __1;
        tips = util.format($("Enabling autoscale on pool %s"), poolId);
        batchOptions = { };
        batchOptions.poolEnableAutoScaleOptions = batchUtil.getBatchOperationDefaultOption();

        param = { };
        if (options.autoscaleFormula) {
          param.autoScaleFormula = options.autoscaleFormula; } ;

        if (options.autoscaleEvaluationInterval) {
          param.autoScaleEvaluationInterval = moment.duration(options.autoscaleEvaluationInterval); } ;


        startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$enablePoolAutoscale() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$enablePoolAutoscale() {


                    return client.pool.enableAutoScale(poolId, param, batchOptions, __cb(_, __frame, 21, 17, __then, true)); }); })(function ___(err, __result) { __catch(function __$enablePoolAutoscale() { if (err) {

                      if (batchUtil.isNotFoundException(err)) {
                        return _(new Error(util.format($("Pool %s doesn't exist"), poolId))); }
                       else {
                        if (err.message) {
                          if ((typeof err.message === "object")) {
                            err.message = err.message.value; } ; } ;



                        return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$enablePoolAutoscale() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$enablePoolAutoscale() {


                endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$enablePoolAutoscale() {


            logger.info(util.format($("Autoscale has been successfully enabled for Pool %s"), poolId)); _(); }); }); }, true)); }); };








  function evaluatePoolAutoscale(poolId, autoscaleFormula, options, _) { var client, tips, batchOptions, run; var __frame = { name: "evaluatePoolAutoscale", line: 844 }; return __func(_, this, arguments, evaluatePoolAutoscale, 3, __frame, function __$evaluatePoolAutoscale() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.id; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 24, function ___(__0, __1) { poolId = __1;
        if (!autoscaleFormula) {
          autoscaleFormula = options.autoscaleFormula; } ;

        return interaction.promptIfNotGiven($("AutoScale formula: "), autoscaleFormula, __cb(_, __frame, 9, 34, function ___(__0, __2) { autoscaleFormula = __2;
          tips = util.format($("Evaluating autoscale on pool %s"), poolId);
          batchOptions = { };
          batchOptions.poolEvaluateAutoScaleOptions = batchUtil.getBatchOperationDefaultOption();

          startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$evaluatePoolAutoscale() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$evaluatePoolAutoscale() {



                      return client.pool.evaluateAutoScale(poolId, autoscaleFormula, batchOptions, __cb(_, __frame, 18, 23, function ___(__0, __3) { run = __3; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$evaluatePoolAutoscale() { if (err) {

                        if (batchUtil.isNotFoundException(err)) {
                          return _(new Error(util.format($("Pool %s doesn't exist"), poolId))); }
                         else {
                          if (err.message) {
                            if ((typeof err.message === "object")) {
                              err.message = err.message.value; } ; } ;



                          return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$evaluatePoolAutoscale() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$evaluatePoolAutoscale() {


                  endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$evaluatePoolAutoscale() {


              batchShowUtil.showAutoScaleRun(run, cli.output); _(); }); }); }, true)); }, true)); }); };








  function resizePool(poolId, targetDedicated, options, _) { var client, tips, batchOptions, param; var __frame = { name: "resizePool", line: 888 }; return __func(_, this, arguments, resizePool, 3, __frame, function __$resizePool() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.id; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 24, function ___(__0, __1) { poolId = __1;


        batchOptions = { }; return (function __$resizePool(__then) {

          if (options.abort) {
            tips = util.format($("Stopping pool %s from resizing"), poolId);
            batchOptions.poolStopResizeOptions = batchUtil.getBatchOperationDefaultOption();

            startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$resizePool() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$resizePool() {


                        return client.pool.stopResize(poolId, batchOptions, __cb(_, __frame, 17, 19, __then, true)); }); })(function ___(err, __result) { __catch(function __$resizePool() { if (err) {

                          if (batchUtil.isNotFoundException(err)) {
                            return _(new Error(util.format($("Pool %s doesn't exist"), poolId))); }
                           else {
                            if (err.message) {
                              if ((typeof err.message === "object")) {
                                err.message = err.message.value; } ; } ;



                            return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$resizePool() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$resizePool() {


                    endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$resizePool() {


                logger.info(util.format($("The resizing of pool %s has been stopped successfully"), poolId)); __then(); }); }); } else {

            if (!targetDedicated) {
              targetDedicated = options.targetDedicated; } ;

            return interaction.promptIfNotGiven($("Target Dedicated VM Count: "), targetDedicated, __cb(_, __frame, 39, 35, function ___(__0, __2) { targetDedicated = __2;
              param = { };
              param.targetDedicated = Number(targetDedicated);
              if (options.resizeTimeout) {
                param.resizeTimeout = moment.duration(options.resizeTimeout); } ;

              if (options.deallocateOption) {
                param.nodeDeallocationOption = options.deallocateOption; } ;


              tips = util.format($("Resizing pool %s"), poolId);
              batchOptions.poolResizeOptions = batchUtil.getBatchOperationDefaultOption();
              if (options.ifMatch) {
                batchOptions.poolDeleteMethodOptions.ifMatch = options.ifMatch; } ;

              if (options.ifNoneMatch) {
                batchOptions.poolDeleteMethodOptions.ifNoneMatch = options.ifNoneMatch; } ;

              if (options.ifModifiedSince) {
                batchOptions.poolDeleteMethodOptions.ifModifiedSince = options.ifModifiedSince; } ;

              if (options.ifUnmodifiedSince) {
                batchOptions.poolDeleteMethodOptions.ifUnmodifiedSince = options.ifUnmodifiedSince; } ;


              startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$resizePool() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$resizePool() {


                          return client.pool.resize(poolId, param, batchOptions, __cb(_, __frame, 67, 19, __then, true)); }); })(function ___(err, __result) { __catch(function __$resizePool() { if (err) {

                            if (batchUtil.isNotFoundException(err)) {
                              return _(new Error(util.format($("Pool %s doesn't exist"), poolId))); }
                             else {
                              if (err.message) {
                                if ((typeof err.message === "object")) {
                                  err.message = err.message.value; } ; } ;



                              return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$resizePool() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$resizePool() {


                      endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$resizePool() {


                  logger.info(util.format($("Pool %s has been resized successfully"), poolId)); __then(); }); }); }, true)); } ; })(_); }, true)); }); };







  function listNodeAgentSkus(options, _) { var client, tips, batchOptions, skus, result, nextLink; var __frame = { name: "listNodeAgentSkus", line: 980 }; return __func(_, this, arguments, listNodeAgentSkus, 1, __frame, function __$listNodeAgentSkus() {
      client = batchUtil.createBatchServiceClient(options);
      tips = $("Listing Batch node agent SKUs");
      batchOptions = { };
      batchOptions.accountListNodeAgentSkusOptions = batchUtil.getBatchOperationDefaultOption();

      if (options.filterClause) {
        batchOptions.accountListNodeAgentSkusOptions.filter = options.filterClause; } ;


      skus = [];
      startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listNodeAgentSkus() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listNodeAgentSkus() {


                  return client.account.listNodeAgentSkus(batchOptions, __cb(_, __frame, 14, 34, function ___(__0, __1) { result = __1;
                    result.forEach(function(sku) {
                      skus.push(sku); });

                    nextLink = result.odatanextLink; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$listNodeAgentSkus() { __more = false;

                        var __4 = nextLink; if (__4) {
                          batchOptions.accountListNodeAgentSkusNextOptions = batchUtil.getBatchOperationDefaultOption();
                          return client.account.listNodeAgentSkusNext(nextLink, batchOptions, __cb(_, __frame, 22, 32, function ___(__0, __2) { result = __2;
                            result.forEach(function(sku) {
                              skus.push(sku); });

                            nextLink = result.odatanextLink; while (__more) { __loop(); }; __more = true; }, true)); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(__then); }, true)); }); })(function ___(err, __result) { __catch(function __$listNodeAgentSkus() { if (err) {


                    if (err.message) {
                      if ((typeof err.message === "object")) {
                        err.message = err.message.value; } ; } ;



                    return _(err); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$listNodeAgentSkus() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$listNodeAgentSkus() {

              endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$listNodeAgentSkus() {


          cli.interaction.formatOutput(skus, function(outputData) {
            if ((outputData.length === 0)) {
              logger.info($("No SKUs found")); }
             else {
              var images = [];
              outputData.forEach(function(agent) {
                agent.verifiedImageReferences.forEach(function(ref) {
                  images.push({ id: agent.id, publisher: ref.publisher, offer: ref.offer, sku: ref.sku, osType: agent.osType }); }); });


              logger.table(images, function(row, item) {
                row.cell($("Agent Id"), item.id);
                row.cell($("Publisher"), item.publisher);
                row.cell($("Offer"), item.offer);
                row.cell($("Sku"), item.sku); }); } ; }); _(); }); }); }); };












  function removePoolNodes(poolId, nodeList, options, _) { var client, tips, batchOptions, param, resultMapper; var __frame = { name: "removePoolNodes", line: 1047 }; return __func(_, this, arguments, removePoolNodes, 3, __frame, function __$removePoolNodes() {
      client = batchUtil.createBatchServiceClient(options);
      if (!poolId) {
        poolId = options.id; } ;

      return interaction.promptIfNotGiven($("Pool id: "), poolId, __cb(_, __frame, 5, 25, function ___(__0, __1) { poolId = __1;
        if (!nodeList) {
          nodeList = options.nodeList; } ;

        return interaction.promptIfNotGiven($("Nodes list: "), nodeList, __cb(_, __frame, 9, 27, function ___(__0, __2) { nodeList = __2;

          tips = util.format($("Removing nodes from pool %s"), poolId);
          batchOptions = { };
          batchOptions.poolRemoveNodesOptions = batchUtil.getBatchOperationDefaultOption();

          param = { };
          param.nodeList = nodeList.split(",");
          if (options.resizeTimeout) {
            param.resizeTimeout = options.resizeTimeout; } ;

          if (options.deallocateOption) {
            param.nodeDeallocationOption = options.deallocateOption; } ;

          resultMapper = new client.models["NodeRemoveParameter"]().mapper();
          param = client.deserialize(resultMapper, param, "result"); return (function __$removePoolNodes(__then) {

            if (!options.quiet) {
              return interaction.confirm(util.format($("Do you want to remove nodes from pool %s? [y/n] "), poolId), __cb(_, __frame, 27, 23, function ___(__0, __4) { var __3 = !__4; return (function __$removePoolNodes(__then) { if (__3) { return _(null); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$removePoolNodes() {




            startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$removePoolNodes() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$removePoolNodes() {


                        return client.pool.removeNodes(poolId, param, batchOptions, __cb(_, __frame, 35, 18, __then, true)); }); })(function ___(err, __result) { __catch(function __$removePoolNodes() { if (err) {

                          if (batchUtil.isNotFoundException(err)) {
                            return _(new Error(util.format($("Pool %s doesn't exist"), poolId))); }
                           else {
                            if (err.message) {
                              if ((typeof err.message === "object")) {
                                err.message = err.message.value; } ; } ;



                            return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$removePoolNodes() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$removePoolNodes() {


                    endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$removePoolNodes() {


                logger.info(util.format($("Nodes have been removed from pool %s successfully"), poolId)); _(); }); }); }); }, true)); }, true)); }); };};
