UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

342 lines (170 loc) 23.9 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 applicationGateways = network.category("application-gateway").description($("Commands to manage application gateways")); var urlPathMaps = applicationGateways.category("url-path-map").description($("Commands to manage url path maps")); urlPathMaps.command("create [resource-group] [gateway-name] [name]").description($("Create an url path map")).usage("[options] <resource-group> <gateway-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --gateway-name <gateway-name>", $("the gateway name")).option("-n, --name <name>", $("the name of the url path map")).option("-b, --default-redirect-configuration-name [default-redirect-configuration-name]", $(("sets default redirect configuration." + "\n This option is mutually exclusive with --default-redirect-configuration-id"))).option("-c, --default-redirect-configuration-id [default-redirect-configuration-id]", $(("sets default redirect configuration." + "\n This option is mutually exclusive with --default-redirect-configuration-name"))).option("-p, --path [path]", $("path rules of URL path map")).option("-a, --address-pool-name [address-pool-name]", $(("sets backend address pool. This option" + "\n is mutually exclusive with --address-pool-id"))).option("-o, --address-pool-id [address-pool-id]", $(("sets backend address pool. This option" + "\n is mutually exclusive with --address-pool-name"))).option("-i, --http-settings-name [http-settings-name]", $(("sets backend http settings. This option" + "\n is mutually exclusive with --backend-http-setting-id"))).option("-e, --http-settings-id [http-settings-id]", $(("sets backend http settings. This option" + "\n is mutually exclusive with --http-settings-name"))).option("-r, --rule-name [rule-name]", $("sets path rules name")).option("--nowait", $("do not wait for the operation to complete. Returns as soon as the intial request is received by the server")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __1(resourceGroup, gatewayName, name, options, _) { var subscription, networkManagementClient, applicationGateway, progress, parentItem, urlPathMap, index, parameters, referredDefaultRedirectConfiguration, idContainerDefaultRedirectConfiguration, referredBackendAddressPool, idContainerBackendAddressPool, referredBackendHttpSettings, idContainerBackendHttpSettings; var __frame = { name: "__1", line: 61 }; 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($("gateway name : "), gatewayName, __cb(_, __frame, 2, 36, function ___(__0, __2) { gatewayName = __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 application gateway \"%s\""), gatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return networkManagementClient.applicationGateways.get(resourceGroup, gatewayName, null, __cb(_, __frame, 11, 73, function ___(__0, __4) { applicationGateway = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) { if ((e.statusCode === 404)) { applicationGateway = 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() { parentItem = applicationGateway; if (!parentItem) { return _(new Error(util.format($("application gateway with name \"%s\" not found in the resource group \"%s\""), gatewayName, resourceGroup))); } ; urlPathMap = utils.findFirstCaseIgnore(parentItem.urlPathMaps, { name: name }); if (urlPathMap) { return _(new Error(util.format($("url path map with name \"%s\" already exists in application gateway \"%s\""), name, gatewayName))); } ; index = 0; parameters = { }; if (!parameters.defaultRedirectConfiguration) { parameters.defaultRedirectConfiguration = { }; } ; if (options.defaultRedirectConfigurationId) { if (options.defaultRedirectConfigurationName) { cli.output.warn($("--default-redirect-configuration-name parameter will be ignored because --default-redirect-configuration-id and --default-redirect-configuration-name are mutually exclusive")); } ; parameters.defaultRedirectConfiguration.id = options.defaultRedirectConfigurationId; } else { if (options.defaultRedirectConfigurationName) { referredDefaultRedirectConfiguration = utils.findFirstCaseIgnore(applicationGateway.redirectConfigurations, { name: options.defaultRedirectConfigurationName }); if (!referredDefaultRedirectConfiguration) { return _(new Error(util.format($("No default redirect configuration with name \"%s\" found"), options.defaultRedirectConfigurationName))); } ; idContainerDefaultRedirectConfiguration = referredDefaultRedirectConfiguration; parameters.defaultRedirectConfiguration.id = idContainerDefaultRedirectConfiguration.id; } ; } ; if (!parameters.pathRules) { parameters.pathRules = []; } ; if (!parameters.pathRules[index]) { parameters.pathRules[index] = { }; } ; if (options.path) { parameters.pathRules[index].paths = generatorUtils.splitStringByCharacter(options.path, ","); } ; if (!parameters.pathRules[index].backendAddressPool) { parameters.pathRules[index].backendAddressPool = { }; } ; if (options.addressPoolId) { if (options.addressPoolName) { cli.output.warn($("--address-pool-name parameter will be ignored because --address-pool-id and --address-pool-name are mutually exclusive")); } ; parameters.pathRules[index].backendAddressPool.id = options.addressPoolId; if (!parameters.defaultRedirectConfiguration.id) { parameters.defaultBackendAddressPool = { }; parameters.defaultBackendAddressPool.id = options.addressPoolId; } else { cli.output.warn($("--backend-address-pool parameter will be ignored because --default-redirect-configuration and --backend-address-pool are mutually exclusive")); } ; } else { if (options.addressPoolName) { referredBackendAddressPool = utils.findFirstCaseIgnore(applicationGateway.backendAddressPools, { name: options.addressPoolName }); if (!referredBackendAddressPool) { return _(new Error(util.format($("No backend address pool with name \"%s\" found"), options.addressPoolName))); } ; idContainerBackendAddressPool = referredBackendAddressPool; if (!parameters.defaultRedirectConfiguration.id) { parameters.defaultBackendAddressPool = { }; parameters.defaultBackendAddressPool.id = idContainerBackendAddressPool.id; } else { cli.output.warn($("--backend-address-pool parameter will be ignored because --default-redirect-configuration and --backend-address-pool are mutually exclusive")); } ; parameters.pathRules[index].backendAddressPool.id = idContainerBackendAddressPool.id; } ; } ; if (!parameters.pathRules[index].backendHttpSettings) { parameters.pathRules[index].backendHttpSettings = { }; } ; if (options.httpSettingsId) { if (options.httpSettingsName) { cli.output.warn($("--http-settings-name parameter will be ignored because --http-settings-id and --http-settings-name are mutually exclusive")); } ; parameters.pathRules[index].backendHttpSettings.id = options.httpSettingsId; if (!parameters.defaultRedirectConfiguration.id) { parameters.defaultBackendHttpSettings = { }; parameters.defaultBackendHttpSettings.id = options.httpSettingsId; } else { cli.output.warn($("--backend-http-settings parameter will be ignored because --default-redirect-configuration and --backend-http-settings are mutually exclusive")); } ; } else { if (options.httpSettingsName) { referredBackendHttpSettings = utils.findFirstCaseIgnore(applicationGateway.backendHttpSettingsCollection, { name: options.httpSettingsName }); if (!referredBackendHttpSettings) { return _(new Error(util.format($("No backend http settings with name \"%s\" found"), options.httpSettingsName))); } ; idContainerBackendHttpSettings = referredBackendHttpSettings; if (!parameters.defaultRedirectConfiguration.id) { parameters.defaultBackendHttpSettings = { }; parameters.defaultBackendHttpSettings.id = idContainerBackendHttpSettings.id; } else { cli.output.warn($("--backend-http-settings parameter will be ignored because --default-redirect-configuration and --backend-http-settings are mutually exclusive")); } ; parameters.pathRules[index].backendHttpSettings.id = idContainerBackendHttpSettings.id; } ; } ; if (options.ruleName) { parameters.pathRules[index].name = options.ruleName; } ; parameters.name = name; parentItem.urlPathMaps.push(parameters); generatorUtils.removeEmptyObjects(parameters); progress = cli.interaction.progress(util.format($("Creating url path map in application gateway \"%s\""), gatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function __$__1(__then) { if (options.nowait) { return networkManagementClient.applicationGateways.beginCreateOrUpdate(resourceGroup, gatewayName, applicationGateway, __cb(_, __frame, 131, 75, function ___(__0, __5) { applicationGateway = __5; __then(); }, true)); } else { return networkManagementClient.applicationGateways.createOrUpdate(resourceGroup, gatewayName, applicationGateway, __cb(_, __frame, 133, 75, function ___(__0, __6) { applicationGateway = __6; __then(); }, true)); } ; })(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() { cli.interaction.formatOutput(applicationGateway, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }); }); urlPathMaps.command("delete [resource-group] [gateway-name] [name]").description($("Delete an url path map")).usage("[options] <resource-group> <gateway-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --gateway-name <gateway-name>", $("the gateway name")).option("-n, --name <name>", $("the name of the url path map")).option("--nowait", $("do not wait for the operation to complete. Returns as soon as the intial request is received by the server")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __2(resourceGroup, gatewayName, name, options, _) { var subscription, networkManagementClient, applicationGateway, progress, parentItem, index; var __frame = { name: "__2", line: 212 }; return __func(_, this, arguments, __2, 4, __frame, function __$__2() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __2) { resourceGroup = __2; return cli.interaction.promptIfNotGiven($("gateway name : "), gatewayName, __cb(_, __frame, 2, 36, function ___(__0, __3) { gatewayName = __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 application gateway \"%s\""), gatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return networkManagementClient.applicationGateways.get(resourceGroup, gatewayName, null, __cb(_, __frame, 11, 73, function ___(__0, __5) { applicationGateway = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) { if ((e.statusCode === 404)) { applicationGateway = 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() { parentItem = applicationGateway; if (!parentItem) { return _(new Error(util.format($("application gateway with name \"%s\" not found in the resource group \"%s\""), gatewayName, resourceGroup))); } ; index = utils.indexOfCaseIgnore(parentItem.urlPathMaps, { name: name }); if ((index === -1)) { return _(new Error(util.format($("url path map \"%s\" not found in application gateway \"%s\""), name, gatewayName))); } ; return (function __$__2(_) { var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete url path map with name \"%s\" from application gateway \"%s\"? [y/n] "), name, gatewayName), __cb(_, __frame, 32, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -211, 17, function ___(__0, __6) { return (function __$__2(__then) { if (__6) { return _(null); } else { __then(); } ; })(function __$__2() { parentItem.urlPathMaps.splice(index, 1); progress = cli.interaction.progress("Deleting url path map"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function __$__2(__then) { if (options.nowait) { return networkManagementClient.applicationGateways.beginCreateOrUpdate(resourceGroup, gatewayName, applicationGateway, __cb(_, __frame, 41, 75, function ___(__0, __7) { applicationGateway = __7; __then(); }, true)); } else { return networkManagementClient.applicationGateways.createOrUpdate(resourceGroup, gatewayName, applicationGateway, __cb(_, __frame, 44, 75, function ___(__0, __8) { applicationGateway = __8; __then(); }, true)); } ; })(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() { cli.interaction.formatOutput(applicationGateway, generatorUtils.traverse); _(); }); }); }); }, true)); }); }); }, true)); }, true)); }, true)); }); }); urlPathMaps.command("show [resource-group] [gateway-name] [name]").description($("Show an url path map")).usage("[options] <resource-group> <gateway-name> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --gateway-name <gateway-name>", $("the gateway name")).option("-n, --name <name>", $("the name of the url path map")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __3(resourceGroup, gatewayName, name, options, _) { var subscription, networkManagementClient, applicationGateway, progress, parentItem, urlPathMap; var __frame = { name: "__3", line: 272 }; return __func(_, this, arguments, __3, 4, __frame, function __$__3() { return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1; return cli.interaction.promptIfNotGiven($("gateway name : "), gatewayName, __cb(_, __frame, 2, 36, function ___(__0, __2) { gatewayName = __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 application gateway \"%s\""), gatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return networkManagementClient.applicationGateways.get(resourceGroup, gatewayName, null, __cb(_, __frame, 11, 73, function ___(__0, __4) { applicationGateway = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) { if ((e.statusCode === 404)) { applicationGateway = 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() { parentItem = applicationGateway; if (!parentItem) { return _(new Error(util.format($("application gateway with name \"%s\" not found in the resource group \"%s\""), gatewayName, resourceGroup))); } ; urlPathMap = utils.findFirstCaseIgnore(parentItem.urlPathMaps, { name: name }); if (!urlPathMap) { cli.output.warn(util.format($("url path map with name \"%s\" not found in the application gateway \"%s\""), name, gatewayName)); } ; cli.interaction.formatOutput(urlPathMap, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }, true)); }); }); urlPathMaps.command("list [resource-group] [gateway-name]").description($("List url path maps")).usage("[options] <resource-group> <gateway-name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --gateway-name <gateway-name>", $("the gateway name")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, gatewayName, options, _) { var subscription, networkManagementClient, applicationGateway, progress, parentItem; var __frame = { name: "__4", line: 313 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() { subscription = profile.current.getSubscription(options.subscription); networkManagementClient = utils.createNetworkManagementClient(subscription); applicationGateway = null; progress = cli.interaction.progress(util.format($("Looking up the application gateway \"%s\""), gatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return networkManagementClient.applicationGateways.get(resourceGroup, gatewayName, null, __cb(_, __frame, 7, 73, function ___(__0, __1) { applicationGateway = __1; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) { if ((e.statusCode === 404)) { applicationGateway = 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() { parentItem = applicationGateway; if (!parentItem) { return _(new Error(util.format($("application gateway with name \"%s\" not found in the resource group \"%s\""), gatewayName, resourceGroup))); } ; cli.interaction.formatOutput(parentItem.urlPathMaps, function(items) { if ((!items || (items.length === 0))) { cli.output.warn($("No url path maps found")); } else { cli.output.table(items, function(row, item) { generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); });};