UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

335 lines (149 loc) 22.5 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 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 localNetworkGateways = network.category("local-gateway").description($("Commands to manage local network gateways")); localNetworkGateways.command("create [resource-group] [name] [location] [ip-address]").description($("Create a local network gateway")).usage("[options] <resource-group> <name> <location> <ip-address>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-n, --name <name>", $("the name of the local network gateway")).option("-l, --location <location>", $("the location")).option("-a, --address-space [address-space]", $(("a list of address blocks reserved for" + "\n this virtual network in CIDR notation"))).option("-i, --ip-address <ip-address>", $("ip address of local network gateway")).option("-j, --asn [asn]", $("the BGP speaker's ASN")).option("-b, --bgp-peering-address [bgp-peering-address]", $(("the BGP peering address and BGP" + "\n identifier of this BGP speaker"))).option("-w, --peer-weight [peer-weight]", $(("the weight added to routes learned from" + "\n this BGP speaker"))).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, ipAddress, options, _) { var subscription, networkManagementClient, localNetworkGateway, progress, parameters; var __frame = { name: "__1", line: 54 }; return __func(_, this, arguments, __1, 5, __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; return cli.interaction.promptIfNotGiven($("ip address : "), ipAddress, __cb(_, __frame, 4, 42, function ___(__0, __4) { options.ipAddress = __4; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the local network gateway \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.localNetworkGateways.get(resourceGroup, name, null, __cb(_, __frame, 12, 75, function ___(__0, __5) { localNetworkGateway = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) { if ((e.statusCode === 404)) { localNetworkGateway = 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 (localNetworkGateway) { return _(new Error(util.format($("local network gateway with name \"%s\" already exists in the resource group \"%s\""), name, resourceGroup))); } ; parameters = { }; if (options.location) { parameters.location = options.location; } ; if (!parameters.localNetworkAddressSpace) { parameters.localNetworkAddressSpace = { }; } ; if (options.addressSpace) { parameters.localNetworkAddressSpace.addressPrefixes = []; parameters.localNetworkAddressSpace.addressPrefixes = parameters.localNetworkAddressSpace.addressPrefixes.concat(generatorUtils.splitStringByCharacter(options.addressSpace, ",")); } ; if (options.ipAddress) { parameters.gatewayIpAddress = options.ipAddress; } ; if (!parameters.bgpSettings) { parameters.bgpSettings = { }; } ; if (options.asn) { parameters.bgpSettings.asn = parseInt(options.asn, 10); } ; if (options.bgpPeeringAddress) { parameters.bgpSettings.bgpPeeringAddress = options.bgpPeeringAddress; } ; if (options.peerWeight) { parameters.bgpSettings.peerWeight = parseInt(options.peerWeight, 10); } ; if ((options.tags && utils.argHasValue(options.tags))) { tagUtils.appendTags(parameters, options); } ; generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Creating local network gateway \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.localNetworkGateways.createOrUpdate(resourceGroup, name, parameters, __cb(_, __frame, 66, 75, function ___(__0, __6) { localNetworkGateway = __6; _(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(localNetworkGateway, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }, true)); }); }); localNetworkGateways.command("set [resource-group] [name]").description($("Update a local network gateway")).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 local network gateway")).option("-a, --address-space [address-space]", $(("a list of address blocks reserved for" + "\n this virtual network in CIDR notation"))).option("-i, --ip-address [ip-address]", $("ip address of local network gateway")).option("-j, --asn [asn]", $("the BGP speaker's ASN")).option("-b, --bgp-peering-address [bgp-peering-address]", $(("the BGP peering address and BGP" + "\n identifier of this BGP speaker"))).option("-w, --peer-weight [peer-weight]", $(("the weight added to routes learned from" + "\n this BGP speaker"))).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, localNetworkGateway, progress, parameters; var __frame = { name: "__2", line: 143 }; 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 local network gateway \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.localNetworkGateways.get(resourceGroup, name, null, __cb(_, __frame, 10, 75, function ___(__0, __3) { localNetworkGateway = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) { if ((e.statusCode === 404)) { localNetworkGateway = 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 (!localNetworkGateway) { return _(new Error(util.format($("local network gateway with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; parameters = localNetworkGateway; if (!parameters.localNetworkAddressSpace) { parameters.localNetworkAddressSpace = { }; } ; if (options.addressSpace) { if (!utils.argHasValue(options.addressSpace)) { delete parameters.localNetworkAddressSpace.addressPrefixes; } else { if (((localNetworkGateway && localNetworkGateway.localNetworkAddressSpace) && localNetworkGateway.localNetworkAddressSpace.addressPrefixes)) { parameters.localNetworkAddressSpace.addressPrefixes = localNetworkGateway.localNetworkAddressSpace.addressPrefixes; } else { parameters.localNetworkAddressSpace.addressPrefixes = []; } ; parameters.localNetworkAddressSpace.addressPrefixes = parameters.localNetworkAddressSpace.addressPrefixes.concat(generatorUtils.splitStringByCharacter(options.addressSpace, ",")); } ; } ; if (options.ipAddress) { parameters.gatewayIpAddress = options.ipAddress; } ; if (!parameters.bgpSettings) { parameters.bgpSettings = { }; } ; if (options.asn) { parameters.bgpSettings.asn = parseInt(options.asn, 10); } ; if (options.bgpPeeringAddress) { parameters.bgpSettings.bgpPeeringAddress = options.bgpPeeringAddress; } ; if (options.peerWeight) { parameters.bgpSettings.peerWeight = parseInt(options.peerWeight, 10); } ; if ((options.tags && utils.argHasValue(options.tags))) { tagUtils.appendTags(parameters, options); } ; generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Updating local network gateway \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.localNetworkGateways.createOrUpdate(resourceGroup, name, parameters, __cb(_, __frame, 68, 75, function ___(__0, __4) { localNetworkGateway = __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(localNetworkGateway, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }); }); localNetworkGateways.command("delete [resource-group] [name]").description($("Delete a local network gateway")).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 local network gateway")).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, localNetworkGateway, 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 local network gateway \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.localNetworkGateways.get(resourceGroup, name, null, __cb(_, __frame, 10, 75, function ___(__0, __4) { localNetworkGateway = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) { if ((e.statusCode === 404)) { localNetworkGateway = 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 (!localNetworkGateway) { return _(new Error(util.format($("local network gateway 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 local network gateway \"%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($("local network gateway \"%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 local network gateway \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.localNetworkGateways.deleteMethod(resourceGroup, name, __cb(_, __frame, 32, 75, function ___(__0, __6) { localNetworkGateway = __6; cli.output.info(util.format($("local network gateway \"%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)); }); }); localNetworkGateways.command("show [resource-group] [name]").description($("Show a local network gateway")).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 local network gateway")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, name, options, _) { var subscription, networkManagementClient, localNetworkGateway, 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 local network gateway \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return networkManagementClient.localNetworkGateways.get(resourceGroup, name, null, __cb(_, __frame, 10, 75, function ___(__0, __3) { localNetworkGateway = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) { if ((e.statusCode === 404)) { localNetworkGateway = 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 (!localNetworkGateway) { cli.output.warn(util.format($("local network gateway with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup)); } ; cli.interaction.formatOutput(localNetworkGateway, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }); }); localNetworkGateways.command("list [resource-group]").description($("List local network gateways")).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, localNetworkGateway, 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); localNetworkGateway = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return (function __$__5(__then) { if ((typeof networkManagementClient.localNetworkGateways.listAll != "function")) { return cli.interaction.promptIfNotGiven($("resource-group : "), resourceGroup, __cb(_, __frame, 9, 42, function ___(__0, __1) { resourceGroup = __1; progress = cli.interaction.progress($("Getting the local network gateways")); return networkManagementClient.localNetworkGateways.list(resourceGroup, __cb(_, __frame, 11, 77, function ___(__0, __2) { localNetworkGateway = __2; __then(); }, true)); }, true)); } else { return (function __$__5(__then) { if (options.resourceGroup) { progress = cli.interaction.progress($("Getting the local network gateways")); return networkManagementClient.localNetworkGateways.list(resourceGroup, __cb(_, __frame, 15, 79, function ___(__0, __3) { localNetworkGateway = __3; __then(); }, true)); } else { progress = cli.interaction.progress($("Getting the local network gateways")); return networkManagementClient.localNetworkGateways.listAll(__cb(_, __frame, 18, 79, function ___(__0, __4) { localNetworkGateway = __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(localNetworkGateway, function(localNetworkGateway) { if ((!localNetworkGateway || (localNetworkGateway.length === 0))) { cli.output.warn($("No local network gateways found")); } else { cli.output.table(localNetworkGateway, function(row, item) { generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); });};