UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

302 lines (131 loc) 18.8 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 publicIPAddresses = network.category("public-ip").description($("Commands to manage public ip addresses")); var defaultPublicIPAllocationMethod = "Dynamic"; var defaultPublicIPAddressVersion = "IPv4"; var defaultIdleTimeoutInMinutes = "4"; publicIPAddresses.command("create [resource-group] [name] [location]").description($("Create a public ip address")).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 public ip address")).option("-l, --location <location>", $("the location")).option("-k, --sku-name [sku-name]", $("name of a public IP address SKU")).option("-a, --allocation-method [allocation-method]", $(("the public IP allocation method." + "\n Possible values are: 'Static' and 'Dynamic'"))).option("-e, --ip-version [ip-version]", $(("the public IP address version. Possible" + "\n values are: 'IPv4' and 'IPv6'"))).option("-d, --domain-name-label [domain-name-label]", $((((("sets the Domain name label.The" + "\n concatenation of the domain name label and the regionalized DNS zone make up") + "\n the fully qualified domain name associated with the public IP address. If a") + "\n domain name label is specified, an A DNS record is created for the public IP in") + "\n the Microsoft Azure DNS system"))).option("-f, --reverse-fqdn [reverse-fqdn]", $(((("sets the Reverse FQDN. A user-visible," + "\n fully qualified domain name that resolves to this public IP address. If the") + "\n reverseFqdn is specified, then a PTR DNS record is created pointing from the IP") + "\n address in the in-addr.arpa domain to the reverse FQDN"))).option("-i, --idle-timeout [idle-timeout]", $(("the idle timeout of the public IP" + "\n address"))).option("-z, --zones [zones]", $(("a list of availability zones denoting" + "\n the IP allocated for the resource needs to come from"))).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 useDefaults, subscription, networkManagementClient, publicIPAddress, progress, parameters; var __frame = { name: "__1", line: 69 }; return __func(_, this, arguments, __1, 4, __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; subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); progress = cli.interaction.progress(util.format($("Looking up the public ip address \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.publicIPAddresses.get(resourceGroup, name, null, __cb(_, __frame, 12, 68, function ___(__0, __4) { publicIPAddress = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) { if ((e.statusCode === 404)) { publicIPAddress = 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 (publicIPAddress) { return _(new Error(util.format($("public ip address 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.allocationMethod) { parameters.publicIPAllocationMethod = validation.isIn(options.allocationMethod, ["Static","Dynamic",], "--allocation-method"); } else { if (useDefaults) { parameters.publicIPAllocationMethod = defaultPublicIPAllocationMethod; } ; } ; if (options.ipVersion) { parameters.publicIPAddressVersion = validation.isIn(options.ipVersion, ["IPv4","IPv6",], "--ip-version"); } else { if (useDefaults) { parameters.publicIPAddressVersion = defaultPublicIPAddressVersion; } ; } ; if (!parameters.dnsSettings) { parameters.dnsSettings = { }; } ; if (options.domainNameLabel) { parameters.dnsSettings.domainNameLabel = options.domainNameLabel; } ; if (!parameters.dnsSettings) { parameters.dnsSettings = { }; } ; if (options.reverseFqdn) { parameters.dnsSettings.reverseFqdn = options.reverseFqdn; } ; if (options.idleTimeout) { parameters.idleTimeoutInMinutes = parseInt(options.idleTimeout, 10); } else { if (useDefaults) { parameters.idleTimeoutInMinutes = parseInt(defaultIdleTimeoutInMinutes, 10); } ; } ; if (options.zones) { parameters.zones = generatorUtils.splitStringByCharacter(options.zones, ","); } ; if ((options.tags && utils.argHasValue(options.tags))) { tagUtils.appendTags(parameters, options); } ; generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Creating public ip address \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.publicIPAddresses.createOrUpdate(resourceGroup, name, parameters, __cb(_, __frame, 82, 68, function ___(__0, __5) { publicIPAddress = __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(publicIPAddress, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }); }); publicIPAddresses.command("set [resource-group] [name]").description($("Update a public ip address")).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 public ip address")).option("-k, --sku-name [sku-name]", $("name of a public IP address SKU")).option("-a, --allocation-method [allocation-method]", $(("the public IP allocation method." + "\n Possible values are: 'Static' and 'Dynamic'"))).option("-d, --domain-name-label [domain-name-label]", $((((("sets the Domain name label.The" + "\n concatenation of the domain name label and the regionalized DNS zone make up") + "\n the fully qualified domain name associated with the public IP address. If a") + "\n domain name label is specified, an A DNS record is created for the public IP in") + "\n the Microsoft Azure DNS system"))).option("-f, --reverse-fqdn [reverse-fqdn]", $(((("sets the Reverse FQDN. A user-visible," + "\n fully qualified domain name that resolves to this public IP address. If the") + "\n reverseFqdn is specified, then a PTR DNS record is created pointing from the IP") + "\n address in the in-addr.arpa domain to the reverse FQDN"))).option("-i, --idle-timeout [idle-timeout]", $(("the idle timeout of the public IP" + "\n address"))).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, publicIPAddress, progress, parameters; var __frame = { name: "__2", line: 180 }; 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 public ip address \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.publicIPAddresses.get(resourceGroup, name, null, __cb(_, __frame, 11, 68, function ___(__0, __3) { publicIPAddress = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) { if ((e.statusCode === 404)) { publicIPAddress = 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 (!publicIPAddress) { return _(new Error(util.format($("public ip address with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; parameters = publicIPAddress; if (!parameters.sku) { parameters.sku = { }; } ; if (options.skuName) { parameters.sku.name = validation.isIn(options.skuName, ["Basic","Standard",], "--sku-name"); } ; if (options.allocationMethod) { parameters.publicIPAllocationMethod = validation.isIn(options.allocationMethod, ["Static","Dynamic",], "--allocation-method"); } else { if (useDefaults) { parameters.publicIPAllocationMethod = defaultPublicIPAllocationMethod; } ; } ; if (!parameters.dnsSettings) { parameters.dnsSettings = { }; } ; if (options.domainNameLabel) { if (!utils.argHasValue(options.domainNameLabel)) { delete parameters.dnsSettings; } else { parameters.dnsSettings.domainNameLabel = options.domainNameLabel; } ; } ; if (!parameters.dnsSettings) { parameters.dnsSettings = { }; } ; if (options.reverseFqdn) { parameters.dnsSettings.reverseFqdn = options.reverseFqdn; } ; if (options.idleTimeout) { parameters.idleTimeoutInMinutes = parseInt(options.idleTimeout, 10); } else { if (useDefaults) { parameters.idleTimeoutInMinutes = parseInt(defaultIdleTimeoutInMinutes, 10); } ; } ; if ((options.tags && utils.argHasValue(options.tags))) { tagUtils.appendTags(parameters, options); } ; generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Updating public ip address \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.publicIPAddresses.createOrUpdate(resourceGroup, name, parameters, __cb(_, __frame, 71, 68, function ___(__0, __4) { publicIPAddress = __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(publicIPAddress, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }); }); publicIPAddresses.command("delete [resource-group] [name]").description($("Delete a public ip address")).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 public ip address")).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, publicIPAddress, progress; var __frame = { name: "__3", line: 266 }; 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 public ip address \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.publicIPAddresses.get(resourceGroup, name, null, __cb(_, __frame, 10, 68, function ___(__0, __4) { publicIPAddress = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) { if ((e.statusCode === 404)) { publicIPAddress = 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 (!publicIPAddress) { return _(new Error(util.format($("public ip address 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 public ip address \"%s\"? [y/n] "), name), __cb(_, __frame, 25, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -265, 17, function ___(__0, __5) { return (function __$__3(__then) { if (__5) { cli.output.info(util.format($("public ip address \"%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 public ip address \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.publicIPAddresses.deleteMethod(resourceGroup, name, __cb(_, __frame, 32, 68, function ___(__0, __6) { publicIPAddress = __6; cli.output.info(util.format($("public ip address \"%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)); }); });};