UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

335 lines (157 loc) 23 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 expressRoutes = network.category("express-route").description($("Commands to manage express routes")); var expressRouteCircuits = expressRoutes.category("circuit").description($("Commands to manage circuits")); var defaultTier = "Standard"; var defaultFamily = "MeteredData"; var defaultBandwidthInMbps = "100"; expressRouteCircuits.command("create [resource-group] [name] [location] [service-provider-name] [peering-location]").description($("Create an express route circuit")).usage("[options] <resource-group> <name> <location> <service-provider-name> <peering-location>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-n, --name <name>", $("the name of the express route circuit")).option("-l, --location <location>", $("the location")).option("-e, --sku-tier [sku-tier]", $(("the tier of the SKU. Possible values" + "\n are 'Standard' and 'Premium'"))).option("-f, --sku-family [sku-family]", $(("the family of the SKU. Possible values" + "\n are: 'UnlimitedData' and 'MeteredData'"))).option("-p, --service-provider-name <service-provider-name>", $("the serviceProviderName")).option("-i, --peering-location <peering-location>", $("the peering location")).option("-b, --bandwidth-in-mbps [bandwidth-in-mbps]", $("the BandwidthInMbps")).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, serviceProviderName, peeringLocation, options, _) { var useDefaults, subscription, networkManagementClient, expressRouteCircuit, progress, parameters; var __frame = { name: "__1", line: 60 }; return __func(_, this, arguments, __1, 6, __frame, function __$__1() { useDefaults = true; return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 2, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 29, function ___(__0, __2) { name = __2; return cli.interaction.promptIfNotGiven($("location : "), location, __cb(_, __frame, 4, 41, function ___(__0, __3) { options.location = __3; return cli.interaction.promptIfNotGiven($("service provider name : "), serviceProviderName, __cb(_, __frame, 5, 52, function ___(__0, __4) { options.serviceProviderName = __4; return cli.interaction.promptIfNotGiven($("peering location : "), peeringLocation, __cb(_, __frame, 6, 48, function ___(__0, __5) { options.peeringLocation = __5; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the express route circuit \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.expressRouteCircuits.get(resourceGroup, name, null, __cb(_, __frame, 14, 75, function ___(__0, __6) { expressRouteCircuit = __6; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) { if ((e.statusCode === 404)) { expressRouteCircuit = 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 (expressRouteCircuit) { return _(new Error(util.format($("express route circuit 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.skuTier) { parameters.sku.tier = validation.isIn(options.skuTier, ["Standard","Premium",], "--sku-tier"); } else { if (useDefaults) { parameters.sku.tier = defaultTier; } ; } ; if (options.skuFamily) { parameters.sku.family = validation.isIn(options.skuFamily, ["UnlimitedData","MeteredData",], "--sku-family"); } else { if (useDefaults) { parameters.sku.family = defaultFamily; } ; } ; if (!parameters.serviceProviderProperties) { parameters.serviceProviderProperties = { }; } ; if (options.serviceProviderName) { parameters.serviceProviderProperties.serviceProviderName = options.serviceProviderName; } ; if (options.peeringLocation) { parameters.serviceProviderProperties.peeringLocation = options.peeringLocation; } ; if (options.bandwidthInMbps) { parameters.serviceProviderProperties.bandwidthInMbps = parseInt(options.bandwidthInMbps, 10); } else { if (useDefaults) { parameters.serviceProviderProperties.bandwidthInMbps = parseInt(defaultBandwidthInMbps, 10); } ; } ; if ((parameters.sku.tier && parameters.sku.family)) { parameters.sku.name = ((parameters.sku.tier + "_") + parameters.sku.family); } ; if ((options.tags && utils.argHasValue(options.tags))) { tagUtils.appendTags(parameters, options); } ; generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Creating express route circuit \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.expressRouteCircuits.createOrUpdate(resourceGroup, name, parameters, __cb(_, __frame, 76, 75, function ___(__0, __7) { expressRouteCircuit = __7; _(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(expressRouteCircuit, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }, true)); }, true)); }); }); expressRouteCircuits.command("set [resource-group] [name]").description($("Update an express route circuit")).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 express route circuit")).option("-e, --sku-tier [sku-tier]", $(("the tier of the SKU. Possible values" + "\n are 'Standard' and 'Premium'"))).option("-f, --sku-family [sku-family]", $(("the family of the SKU. Possible values" + "\n are: 'UnlimitedData' and 'MeteredData'"))).option("-b, --bandwidth-in-mbps [bandwidth-in-mbps]", $("the BandwidthInMbps")).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 useDefaults, subscription, networkManagementClient, expressRouteCircuit, progress, parameters; var __frame = { name: "__2", line: 156 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() { useDefaults = false; return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 2, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 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 express route circuit \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.expressRouteCircuits.get(resourceGroup, name, null, __cb(_, __frame, 11, 75, function ___(__0, __3) { expressRouteCircuit = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) { if ((e.statusCode === 404)) { expressRouteCircuit = 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 (!expressRouteCircuit) { return _(new Error(util.format($("express route circuit with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; parameters = expressRouteCircuit; if (!parameters.sku) { parameters.sku = { }; } ; if (options.skuTier) { parameters.sku.tier = validation.isIn(options.skuTier, ["Standard","Premium",], "--sku-tier"); } else { if (useDefaults) { parameters.sku.tier = defaultTier; } ; } ; if (options.skuFamily) { parameters.sku.family = validation.isIn(options.skuFamily, ["UnlimitedData","MeteredData",], "--sku-family"); } else { if (useDefaults) { parameters.sku.family = defaultFamily; } ; } ; if (options.bandwidthInMbps) { parameters.serviceProviderProperties.bandwidthInMbps = parseInt(options.bandwidthInMbps, 10); } else { if (useDefaults) { parameters.serviceProviderProperties.bandwidthInMbps = parseInt(defaultBandwidthInMbps, 10); } ; } ; if ((options.tags && utils.argHasValue(options.tags))) { tagUtils.appendTags(parameters, options); } ; generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Updating express route circuit \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.expressRouteCircuits.createOrUpdate(resourceGroup, name, parameters, __cb(_, __frame, 55, 75, function ___(__0, __4) { expressRouteCircuit = __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(expressRouteCircuit, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }); }); expressRouteCircuits.command("delete [resource-group] [name]").description($("Delete an express route circuit")).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 express route circuit")).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, expressRouteCircuit, progress; var __frame = { name: "__3", line: 226 }; 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 express route circuit \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.expressRouteCircuits.get(resourceGroup, name, null, __cb(_, __frame, 10, 75, function ___(__0, __4) { expressRouteCircuit = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) { if ((e.statusCode === 404)) { expressRouteCircuit = 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 (!expressRouteCircuit) { return _(new Error(util.format($("express route circuit 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 express route circuit \"%s\"? [y/n] "), name), __cb(_, __frame, 25, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -225, 17, function ___(__0, __5) { return (function __$__3(__then) { if (__5) { cli.output.info(util.format($("express route circuit \"%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 express route circuit \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.expressRouteCircuits.deleteMethod(resourceGroup, name, __cb(_, __frame, 32, 75, function ___(__0, __6) { expressRouteCircuit = __6; cli.output.info(util.format($("express route circuit \"%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)); }); }); expressRouteCircuits.command("show [resource-group] [name]").description($("Show an express route circuit")).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 express route circuit")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, name, options, _) { var subscription, networkManagementClient, expressRouteCircuit, progress; var __frame = { name: "__4", line: 271 }; 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 express route circuit \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return networkManagementClient.expressRouteCircuits.get(resourceGroup, name, null, __cb(_, __frame, 10, 75, function ___(__0, __3) { expressRouteCircuit = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) { if ((e.statusCode === 404)) { expressRouteCircuit = 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 (!expressRouteCircuit) { cli.output.warn(util.format($("express route circuit with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup)); } ; cli.interaction.formatOutput(expressRouteCircuit, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }); }); expressRouteCircuits.command("list [resource-group]").description($("List express route circuits")).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, expressRouteCircuit, progress; var __frame = { name: "__5", line: 304 }; return __func(_, this, arguments, __5, 2, __frame, function __$__5() { options.resourceGroup = resourceGroup; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); expressRouteCircuit = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return (function __$__5(__then) { if ((typeof networkManagementClient.expressRouteCircuits.listAll != "function")) { return cli.interaction.promptIfNotGiven($("resource-group : "), resourceGroup, __cb(_, __frame, 9, 42, function ___(__0, __1) { resourceGroup = __1; progress = cli.interaction.progress($("Getting the express route circuits")); return networkManagementClient.expressRouteCircuits.list(resourceGroup, __cb(_, __frame, 11, 77, function ___(__0, __2) { expressRouteCircuit = __2; __then(); }, true)); }, true)); } else { return (function __$__5(__then) { if (options.resourceGroup) { progress = cli.interaction.progress($("Getting the express route circuits")); return networkManagementClient.expressRouteCircuits.list(resourceGroup, __cb(_, __frame, 15, 79, function ___(__0, __3) { expressRouteCircuit = __3; __then(); }, true)); } else { progress = cli.interaction.progress($("Getting the express route circuits")); return networkManagementClient.expressRouteCircuits.listAll(__cb(_, __frame, 18, 79, function ___(__0, __4) { expressRouteCircuit = __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(expressRouteCircuit, function(expressRouteCircuit) { if ((!expressRouteCircuit || (expressRouteCircuit.length === 0))) { cli.output.warn($("No express route circuits found")); } else { cli.output.table(expressRouteCircuit, function(row, item) { generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); });};