UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

273 lines (121 loc) 18.7 kB
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var generatorUtils = require("../../../util/generatorUtils"); var tagUtils = require("../tag/tagUtils"); var util = require("util"); var validation = require("../../../util/validation"); var profile = require("../../../util/profile"); var utils = require("../../../util/utils"); var $ = utils.getLocaleString; exports.init = function(cli) { var network = cli.category("network").description($("Commands to manage network resources")); var loadBalancers = network.category("lb").description($("Commands to manage load balancers")); loadBalancers.command("create [resource-group] [name] [location]").description($("Create a load balancer")).usage("[options] <resource-group> <name> <location>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-n, --name <name>", $("the name of the load balancer")).option("-l, --location <location>", $("the location")).option("-k, --sku-name [sku-name]", $("name of a load balancer SKU")).option("-t, --tags [tags]", $("the list of tags.\n Can be multiple. In the format of \"name=value\".\n Name is required and value is optional.\n For example, -t \"tag1=value1;tag2\"")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __1(resourceGroup, name, location, options, _) { var subscription, networkManagementClient, loadBalancer, progress, parameters; var __frame = { name: "__1", line: 48 }; return __func(_, this, arguments, __1, 4, __frame, function __$__1() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 2, 29, function ___(__0, __2) { name = __2; return cli.interaction.promptIfNotGiven($("location : "), location, __cb(_, __frame, 3, 41, function ___(__0, __3) { options.location = __3; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the load balancer \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.loadBalancers.get(resourceGroup, name, null, __cb(_, __frame, 11, 61, function ___(__0, __4) { loadBalancer = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) { if ((e.statusCode === 404)) { loadBalancer = null; } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__1() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__1() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__1() { if (loadBalancer) { return _(new Error(util.format($("load balancer with name \"%s\" already exists in the resource group \"%s\""), name, resourceGroup))); } ; parameters = { }; if (options.location) { parameters.location = options.location; } ; if (!parameters.sku) { parameters.sku = { }; } ; if (options.skuName) { parameters.sku.name = validation.isIn(options.skuName, ["Basic","Standard",], "--sku-name"); } ; if ((options.tags && utils.argHasValue(options.tags))) { tagUtils.appendTags(parameters, options); } ; generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Creating load balancer \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.loadBalancers.createOrUpdate(resourceGroup, name, parameters, __cb(_, __frame, 45, 61, function ___(__0, __5) { loadBalancer = __5; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__1() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__1() { cli.interaction.formatOutput(loadBalancer, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }); }); loadBalancers.command("set [resource-group] [name]").description($("Update a load balancer")).usage("[options] <resource-group> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-n, --name <name>", $("the name of the load balancer")).option("-k, --sku-name [sku-name]", $("name of a load balancer SKU")).option("-t, --tags [tags]", $("the list of tags.\n Can be multiple. In the format of \"name=value\".\n Name is required and value is optional.\n For example, -t \"tag1=value1;tag2\"")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __2(resourceGroup, name, options, _) { var subscription, networkManagementClient, loadBalancer, progress, parameters; var __frame = { name: "__2", line: 109 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 2, 29, function ___(__0, __2) { name = __2; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the load balancer \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.loadBalancers.get(resourceGroup, name, null, __cb(_, __frame, 10, 61, function ___(__0, __3) { loadBalancer = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) { if ((e.statusCode === 404)) { loadBalancer = null; } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__2() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__2() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__2() { if (!loadBalancer) { return _(new Error(util.format($("load balancer with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; parameters = loadBalancer; if (!parameters.sku) { parameters.sku = { }; } ; if (options.skuName) { parameters.sku.name = validation.isIn(options.skuName, ["Basic","Standard",], "--sku-name"); } ; if ((options.tags && utils.argHasValue(options.tags))) { tagUtils.appendTags(parameters, options); } ; generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Updating load balancer \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.loadBalancers.createOrUpdate(resourceGroup, name, parameters, __cb(_, __frame, 40, 61, function ___(__0, __4) { loadBalancer = __4; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__2() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__2() { cli.interaction.formatOutput(loadBalancer, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }); }); loadBalancers.command("delete [resource-group] [name]").description($("Delete a load balancer")).usage("[options] <resource-group> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-n, --name <name>", $("the name of the load balancer")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __3(resourceGroup, name, options, _) { var subscription, networkManagementClient, loadBalancer, progress; var __frame = { name: "__3", line: 164 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __2) { resourceGroup = __2; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 2, 29, function ___(__0, __3) { name = __3; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the load balancer \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.loadBalancers.get(resourceGroup, name, null, __cb(_, __frame, 10, 61, function ___(__0, __4) { loadBalancer = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) { if ((e.statusCode === 404)) { loadBalancer = null; } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__3() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__3() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__3() { if (!loadBalancer) { return _(new Error(util.format($("load balancer with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; return (function __$__3(_) { var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete load balancer \"%s\"? [y/n] "), name), __cb(_, __frame, 25, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -163, 17, function ___(__0, __5) { return (function __$__3(__then) { if (__5) { cli.output.info(util.format($("load balancer \"%s\" was not deleted and still exists in the resource group \"%s\""), name, resourceGroup)); return _(null); } else { __then(); } ; })(function __$__3() { progress = cli.interaction.progress(util.format($("Deleting load balancer \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.loadBalancers.deleteMethod(resourceGroup, name, __cb(_, __frame, 32, 61, function ___(__0, __6) { loadBalancer = __6; cli.output.info(util.format($("load balancer \"%s\" was successfully deleted from resource group \"%s\""), name, resourceGroup)); _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__3() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__3() { _(); }); }); }); }, true)); }); }); }, true)); }, true)); }); }); loadBalancers.command("show [resource-group] [name]").description($("Show a load balancer")).usage("[options] <resource-group> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-n, --name <name>", $("the name of the load balancer")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, name, options, _) { var subscription, networkManagementClient, loadBalancer, progress; var __frame = { name: "__4", line: 209 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 2, 29, function ___(__0, __2) { name = __2; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the load balancer \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return networkManagementClient.loadBalancers.get(resourceGroup, name, null, __cb(_, __frame, 10, 61, function ___(__0, __3) { loadBalancer = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) { if ((e.statusCode === 404)) { loadBalancer = null; } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__4() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__4() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__4() { if (!loadBalancer) { cli.output.warn(util.format($("load balancer with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup)); } ; cli.interaction.formatOutput(loadBalancer, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }); }); loadBalancers.command("list [resource-group]").description($("List load balancers")).usage("[options] <resource-group>").option("-g, --resource-group [resource-group]", $("the name of the resource group")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __5(resourceGroup, options, _) { var subscription, networkManagementClient, loadBalancer, progress; var __frame = { name: "__5", line: 242 }; return __func(_, this, arguments, __5, 2, __frame, function __$__5() { options.resourceGroup = resourceGroup; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); loadBalancer = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return (function __$__5(__then) { if ((typeof networkManagementClient.loadBalancers.listAll != "function")) { return cli.interaction.promptIfNotGiven($("resource-group : "), resourceGroup, __cb(_, __frame, 9, 42, function ___(__0, __1) { resourceGroup = __1; progress = cli.interaction.progress($("Getting the load balancers")); return networkManagementClient.loadBalancers.list(resourceGroup, __cb(_, __frame, 11, 63, function ___(__0, __2) { loadBalancer = __2; __then(); }, true)); }, true)); } else { return (function __$__5(__then) { if (options.resourceGroup) { progress = cli.interaction.progress($("Getting the load balancers")); return networkManagementClient.loadBalancers.list(resourceGroup, __cb(_, __frame, 15, 65, function ___(__0, __3) { loadBalancer = __3; __then(); }, true)); } else { progress = cli.interaction.progress($("Getting the load balancers")); return networkManagementClient.loadBalancers.listAll(__cb(_, __frame, 18, 65, function ___(__0, __4) { loadBalancer = __4; __then(); }, true)); } ; })(__then); } ; })(function __$__5() { _(null, null, true); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__5() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__5() { cli.interaction.formatOutput(loadBalancer, function(loadBalancer) { if ((!loadBalancer || (loadBalancer.length === 0))) { cli.output.warn($("No load balancers found")); } else { cli.output.table(loadBalancer, function(row, item) { generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); });};