UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

362 lines (170 loc) 26.2 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 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 virtualNetworks = network.category("vnet").description($("Commands to manage virtual networks")); var subnets = virtualNetworks.category("subnet").description($("Commands to manage subnet")); subnets.command("create [resource-group] [vnet-name] [name] [address-prefix]").description($("Create a subnet")).usage("[options] <resource-group> <vnet-name> <name> <address-prefix>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-e, --vnet-name <vnet-name>", $("the vnet name")).option("-n, --name <name>", $("the name of the subnet")).option("-a, --address-prefix <address-prefix>", $("the address prefix for the subnet")).option("-w, --network-security-group-id [network-security-group-id]", $(("sets network security group id. This" + "\n option is mutually exclusive with --network-security-group-name"))).option("-o, --network-security-group-name [network-security-group-name]", $(("sets network security group name. This" + "\n option is mutually exclusive with --network-security-group-id"))).option("-i, --route-table-id [route-table-id]", $(("sets route table id. This option is" + "\n mutually exclusive with --route-table-name"))).option("-r, --route-table-name [route-table-name]", $(("sets route table name. This option is" + "\n mutually exclusive with --route-table-id"))).option("-p, --service-endpoints [service-endpoints]", $("an array of service endpoints")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __1(resourceGroup, vnetName, name, addressPrefix, options, _) { var subscription, networkManagementClient, subnet, progress, parameters, idContainerNetworkSecurityGroup, idContainerRouteTable; var __frame = { name: "__1", line: 56 }; 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($("vnet name : "), vnetName, __cb(_, __frame, 2, 33, function ___(__0, __2) { vnetName = __2; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 29, function ___(__0, __3) { name = __3; return cli.interaction.promptIfNotGiven($("address prefix : "), addressPrefix, __cb(_, __frame, 4, 46, function ___(__0, __4) { options.addressPrefix = __4; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the subnet \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.subnets.get(resourceGroup, vnetName, name, null, __cb(_, __frame, 12, 49, function ___(__0, __5) { subnet = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) { if ((e.statusCode === 404)) { subnet = 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 (subnet) { return _(new Error(util.format($("subnet with name \"%s\" already exists in the resource group \"%s\""), name, resourceGroup))); } ; parameters = { }; if (options.addressPrefix) { parameters.addressPrefix = options.addressPrefix; } ; if (!parameters.networkSecurityGroup) { parameters.networkSecurityGroup = { }; } ; return (function __$__1(__then) { if (options.networkSecurityGroupId) { if (options.networkSecurityGroupName) { cli.output.warn($("--network-security-group-name parameter will be ignored because --network-security-group-id and --network-security-group-name are mutually exclusive")); } ; parameters.networkSecurityGroup.id = options.networkSecurityGroupId; __then(); } else { return (function __$__1(__then) { if (options.networkSecurityGroupName) { return networkManagementClient.networkSecurityGroups.get(resourceGroup, options.networkSecurityGroupName, __cb(_, __frame, 41, 92, function ___(__0, __6) { idContainerNetworkSecurityGroup = __6; parameters.networkSecurityGroup.id = idContainerNetworkSecurityGroup.id; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$__1() { if (!parameters.routeTable) { parameters.routeTable = { }; } ; return (function __$__1(__then) { if (options.routeTableId) { if (options.routeTableName) { cli.output.warn($("--route-table-name parameter will be ignored because --route-table-id and --route-table-name are mutually exclusive")); } ; parameters.routeTable.id = options.routeTableId; __then(); } else { return (function __$__1(__then) { if (options.routeTableName) { return networkManagementClient.routeTables.get(resourceGroup, options.routeTableName, __cb(_, __frame, 54, 72, function ___(__0, __7) { idContainerRouteTable = __7; parameters.routeTable.id = idContainerRouteTable.id; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$__1() { if (options.serviceEndpoints) { parameters.serviceEndpoints = options.serviceEndpoints.split(",").map(function(item) { return { service: item }; }); } ; generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Creating subnet \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.subnets.createOrUpdate(resourceGroup, vnetName, name, parameters, __cb(_, __frame, 65, 49, function ___(__0, __8) { subnet = __8; _(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(subnet, generatorUtils.traverse); _(); }); }); }); }); }); }); }, true)); }, true)); }, true)); }, true)); }); }); subnets.command("set [resource-group] [vnet-name] [name]").description($("Update a subnet")).usage("[options] <resource-group> <vnet-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-e, --vnet-name <vnet-name>", $("the vnet name")).option("-n, --name <name>", $("the name of the subnet")).option("-a, --address-prefix [address-prefix]", $("the address prefix for the subnet")).option("-w, --network-security-group-id [network-security-group-id]", $(("sets network security group id. This" + "\n option is mutually exclusive with --network-security-group-name"))).option("-o, --network-security-group-name [network-security-group-name]", $(("sets network security group name. This" + "\n option is mutually exclusive with --network-security-group-id"))).option("-i, --route-table-id [route-table-id]", $(("sets route table id. This option is" + "\n mutually exclusive with --route-table-name"))).option("-r, --route-table-name [route-table-name]", $(("sets route table name. This option is" + "\n mutually exclusive with --route-table-id"))).option("-p, --service-endpoints [service-endpoints]", $("an array of service endpoints")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __2(resourceGroup, vnetName, name, options, _) { var subscription, networkManagementClient, subnet, progress, parameters, idContainerNetworkSecurityGroup, idContainerRouteTable; var __frame = { name: "__2", line: 146 }; return __func(_, this, arguments, __2, 4, __frame, function __$__2() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("vnet name : "), vnetName, __cb(_, __frame, 2, 33, function ___(__0, __2) { vnetName = __2; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 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 subnet \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.subnets.get(resourceGroup, vnetName, name, null, __cb(_, __frame, 11, 49, function ___(__0, __4) { subnet = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) { if ((e.statusCode === 404)) { subnet = 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 (!subnet) { return _(new Error(util.format($("subnet with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; parameters = subnet; if (options.addressPrefix) { parameters.addressPrefix = options.addressPrefix; } ; if (!parameters.networkSecurityGroup) { parameters.networkSecurityGroup = { }; } ; return (function __$__2(__then) { if (options.networkSecurityGroupId) { if (options.networkSecurityGroupName) { cli.output.warn($("--network-security-group-name parameter will be ignored because --network-security-group-id and --network-security-group-name are mutually exclusive")); } ; if (!utils.argHasValue(options.networkSecurityGroupId)) { delete parameters.networkSecurityGroup; } else { parameters.networkSecurityGroup.id = options.networkSecurityGroupId; } ; __then(); } else { return (function __$__2(__then) { if (options.networkSecurityGroupName) { return (function __$__2(__then) { if (!utils.argHasValue(options.networkSecurityGroupName)) { delete parameters.networkSecurityGroup; __then(); } else { return networkManagementClient.networkSecurityGroups.get(resourceGroup, options.networkSecurityGroupName, __cb(_, __frame, 47, 94, function ___(__0, __5) { idContainerNetworkSecurityGroup = __5; parameters.networkSecurityGroup.id = idContainerNetworkSecurityGroup.id; __then(); }, true)); } ; })(__then); } else { __then(); } ; })(__then); } ; })(function __$__2() { if (!parameters.routeTable) { parameters.routeTable = { }; } ; return (function __$__2(__then) { if (options.routeTableId) { if (options.routeTableName) { cli.output.warn($("--route-table-name parameter will be ignored because --route-table-id and --route-table-name are mutually exclusive")); } ; if (!utils.argHasValue(options.routeTableId)) { delete parameters.routeTable; } else { parameters.routeTable.id = options.routeTableId; } ; __then(); } else { return (function __$__2(__then) { if (options.routeTableName) { return (function __$__2(__then) { if (!utils.argHasValue(options.routeTableName)) { delete parameters.routeTable; __then(); } else { return networkManagementClient.routeTables.get(resourceGroup, options.routeTableName, __cb(_, __frame, 68, 74, function ___(__0, __6) { idContainerRouteTable = __6; parameters.routeTable.id = idContainerRouteTable.id; __then(); }, true)); } ; })(__then); } else { __then(); } ; })(__then); } ; })(function __$__2() { if (options.serviceEndpoints) { if (!utils.argHasValue(options.serviceEndpoints)) { delete parameters.serviceEndpoints; } else { parameters.serviceEndpoints = options.serviceEndpoints.split(",").map(function(item) { return { service: item }; }); } ; } ; generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Updating subnet \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.subnets.createOrUpdate(resourceGroup, vnetName, name, parameters, __cb(_, __frame, 84, 49, function ___(__0, __7) { subnet = __7; _(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(subnet, generatorUtils.traverse); _(); }); }); }); }); }); }); }, true)); }, true)); }, true)); }); }); subnets.command("delete [resource-group] [vnet-name] [name]").description($("Delete a subnet")).usage("[options] <resource-group> <vnet-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-e, --vnet-name <vnet-name>", $("the vnet name")).option("-n, --name <name>", $("the name of the subnet")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __3(resourceGroup, vnetName, name, options, _) { var subscription, networkManagementClient, subnet, progress; var __frame = { name: "__3", line: 246 }; return __func(_, this, arguments, __3, 4, __frame, function __$__3() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __2) { resourceGroup = __2; return cli.interaction.promptIfNotGiven($("vnet name : "), vnetName, __cb(_, __frame, 2, 33, function ___(__0, __3) { vnetName = __3; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 29, function ___(__0, __4) { name = __4; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the subnet \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.subnets.get(resourceGroup, vnetName, name, null, __cb(_, __frame, 11, 49, function ___(__0, __5) { subnet = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) { if ((e.statusCode === 404)) { subnet = 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 (!subnet) { return _(new Error(util.format($("subnet 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 subnet \"%s\"? [y/n] "), name), __cb(_, __frame, 26, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -245, 17, function ___(__0, __6) { return (function __$__3(__then) { if (__6) { cli.output.info(util.format($("subnet \"%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 subnet \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.subnets.deleteMethod(resourceGroup, vnetName, name, __cb(_, __frame, 33, 49, function ___(__0, __7) { subnet = __7; cli.output.info(util.format($("subnet \"%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)); }, true)); }); }); subnets.command("show [resource-group] [vnet-name] [name]").description($("Show a subnet")).usage("[options] <resource-group> <vnet-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-e, --vnet-name <vnet-name>", $("the vnet name")).option("-n, --name <name>", $("the name of the subnet")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, vnetName, name, options, _) { var subscription, networkManagementClient, subnet, progress; var __frame = { name: "__4", line: 293 }; return __func(_, this, arguments, __4, 4, __frame, function __$__4() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("vnet name : "), vnetName, __cb(_, __frame, 2, 33, function ___(__0, __2) { vnetName = __2; return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 3, 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 subnet \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return networkManagementClient.subnets.get(resourceGroup, vnetName, name, null, __cb(_, __frame, 11, 49, function ___(__0, __4) { subnet = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) { if ((e.statusCode === 404)) { subnet = 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 (!subnet) { cli.output.warn(util.format($("subnet with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup)); } ; cli.interaction.formatOutput(subnet, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }, true)); }); }); subnets.command("list [resource-group] [vnet-name]").description($("List subnet")).usage("[options] <resource-group> <vnet-name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-e, --vnet-name <vnet-name>", $("the vnet name")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __5(resourceGroup, vnetName, options, _) { var subscription, networkManagementClient, subnet, progress; var __frame = { name: "__5", line: 328 }; return __func(_, this, arguments, __5, 3, __frame, function __$__5() { options.resourceGroup = resourceGroup; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); subnet = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return (function __$__5(__then) { if ((typeof networkManagementClient.subnets.listAll != "function")) { return cli.interaction.promptIfNotGiven($("resource-group : "), resourceGroup, __cb(_, __frame, 9, 42, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("virtual network : "), vnetName, __cb(_, __frame, 10, 37, function ___(__0, __2) { vnetName = __2; progress = cli.interaction.progress($("Getting the subnet")); return networkManagementClient.subnets.list(resourceGroup, vnetName, __cb(_, __frame, 12, 51, function ___(__0, __3) { subnet = __3; __then(); }, true)); }, true)); }, true)); } else { return (function __$__5(__then) { if (options.resourceGroup) { return cli.interaction.promptIfNotGiven($("virtual network : "), vnetName, __cb(_, __frame, 15, 39, function ___(__0, __4) { vnetName = __4; progress = cli.interaction.progress($("Getting the subnet")); return networkManagementClient.subnets.list(resourceGroup, vnetName, __cb(_, __frame, 17, 53, function ___(__0, __5) { subnet = __5; __then(); }, true)); }, true)); } else { return cli.interaction.promptIfNotGiven($("virtual network : "), vnetName, __cb(_, __frame, 19, 39, function ___(__0, __6) { vnetName = __6; progress = cli.interaction.progress($("Getting the subnet")); return networkManagementClient.subnets.listAll(vnetName, __cb(_, __frame, 21, 53, function ___(__0, __7) { subnet = __7; __then(); }, true)); }, 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(subnet, function(subnet) { if ((!subnet || (subnet.length === 0))) { cli.output.warn($("No subnet found")); } else { cli.output.table(subnet, function(row, item) { generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); });};