azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
758 lines (420 loc) • 47.4 kB
JavaScript
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var __ = require("underscore");
var path = require("path");
var fs = require("fs");
var util = require("util");
var utils = require("../../../util/utils");
var $ = utils.getLocaleString;
var constants = require("./constants");
var VNetUtil = require("../../../util/vnet.util");
function AppGateway(cli, networkManagementClient) {
this.networkManagementClient = networkManagementClient;
this.vnetUtil = new VNetUtil();
this.output = cli.output;
this.interaction = cli.interaction;};
__.extend(AppGateway.prototype, {
create: function create__1(appGatewayName, options, _) { var self, appGateway, progress, __this = this; var __frame = { name: "create__1", line: 33 }; return __func(_, this, arguments, create__1, 2, __frame, function __$create__1() { self = __this;
return self.get(appGatewayName, __cb(_, __frame, 3, 26, function ___(__0, __1) { appGateway = __1;
if (appGateway) {
return _(new Error(util.format($("Application Gateway with name \"%s\" already exists"), appGatewayName))); } ;
appGateway = { };
self._parseAppGateway(appGatewayName, appGateway, options, true);
progress = self.interaction.progress(util.format($("Creating an Application Gateway \"%s\""), appGatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$create__1() {
return self.networkManagementClient.applicationGateways.create(appGateway, __cb(_, __frame, 13, 55, function __$create__1() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$create__1() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$create__1() { _(); }); }); }, true)); }); },
set: function set__2(appGatewayName, options, _) { var self, appGateway, progress, __this = this; var __frame = { name: "set__2", line: 52 }; return __func(_, this, arguments, set__2, 2, __frame, function __$set__2() { self = __this;
return self.get(appGatewayName, __cb(_, __frame, 3, 26, function ___(__0, __1) { appGateway = __1;
if (!appGateway) {
return _(new Error(util.format($("Application Gateway with name \"%s\" not found"), appGatewayName))); } ;
self._parseAppGateway(appGatewayName, appGateway, options, false);
progress = self.interaction.progress(util.format($("Updating an Application Gateway \"%s\""), appGatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$set__2() {
return self.networkManagementClient.applicationGateways.update(appGatewayName, appGateway, __cb(_, __frame, 12, 55, function __$set__2() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$set__2() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$set__2() { _(); }); }); }, true)); }); },
get: function get__3(appGatewayName, _) { var self, progress, appGateway, __this = this; var __frame = { name: "get__3", line: 70 }; return __func(_, this, arguments, get__3, 1, __frame, function __$get__3() { self = __this;
progress = self.interaction.progress(util.format($("Looking up an Application Gateway \"%s\""), appGatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$get__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$get__3() {
return self.networkManagementClient.applicationGateways.get(appGatewayName, __cb(_, __frame, 4, 72, function ___(__0, __1) { appGateway = __1;
return _(null, appGateway); }, true)); }); })(function ___(e, __result) { __catch(function __$get__3() { if (e) {
if ((e.statusCode === 404)) {
return _(null, null); } ;
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$get__3() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$get__3() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$get__3() { _(); }); }); }); },
show: function show__4(appGatewayName, options, _) { var self, appGateway, __this = this; var __frame = { name: "show__4", line: 86 }; return __func(_, this, arguments, show__4, 2, __frame, function __$show__4() { self = __this;
return self.get(appGatewayName, __cb(_, __frame, 2, 26, function ___(__0, __1) { appGateway = __1;
self.interaction.formatOutput(appGateway, function(appGateway) {
if ((appGateway === null)) {
self.output.warn(util.format($("An Application Gateway with name \"%s\" not found"), appGatewayName)); }
else {
self.output.nameValue($("Name"), appGateway.name);
self.output.nameValue($("State"), appGateway.state);
self.output.nameValue($("Description"), appGateway.description);
self.output.nameValue($("Instance count"), appGateway.instanceCount);
self.output.nameValue($("Gateway size"), appGateway.gatewaySize);
self.output.nameValue($("Virtual network name"), appGateway.vnetName);
self.output.header($("Subnets"));
appGateway.subnets.forEach(function(subnet) {
self.output.nameValue($("Name"), subnet, 2); });
if ((appGateway.virtualIPs.length > 0)) {
self.output.header($("Virtual IP's"));
appGateway.virtualIPs.forEach(function(ip) {
self.output.nameValue($("Name"), ip, 2); }); } ; } ; }); _(); }, true)); }); },
list: function list__5(options, _) { var self, progress, appGateways, __this = this; var __frame = { name: "list__5", line: 116 }; return __func(_, this, arguments, list__5, 1, __frame, function __$list__5() { self = __this;
progress = self.interaction.progress($("Looking up Application Gateways")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$list__5() {
return self.networkManagementClient.applicationGateways.list(__cb(_, __frame, 6, 69, function ___(__0, __1) { appGateways = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$list__5() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$list__5() {
self.interaction.formatOutput(appGateways.applicationGateways, function(data) {
if ((data.length === 0)) {
self.output.warn($("No Application Gateways found")); }
else {
self.output.table(data, function(row, gateway) {
row.cell($("Name"), gateway.name);
row.cell($("State"), gateway.state);
row.cell($("Virtual network name"), gateway.vnetName);
row.cell($("Gateway size"), gateway.gatewaySize);
row.cell($("Instance count"), gateway.instanceCount);
row.cell($("Virtual IP's count"), gateway.virtualIPs.length);
row.cell($("Subnets count"), gateway.subnets.length); }); } ; }); _(); }); }); }); },
delete: function delete__6(appGatewayName, options, _) { var self, progress, __this = this; var __frame = { name: "delete__6", line: 144 }; return __func(_, this, arguments, delete__6, 2, __frame, function __$delete__6() { self = __this; return (function __$delete__6(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete Application Gateway \"%s\"? [y/n] "), appGatewayName), __cb(_, __frame, 2, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -143, 17, function ___(__0, __2) { return (function __$delete__6(__then) { if (__2) { return _(null); } else { __then(); } ; })(function __$delete__6() {
progress = self.interaction.progress(util.format($("Deleting an Application Gateway \"%s\""), appGatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$delete__6() {
return self.networkManagementClient.applicationGateways.deleteMethod(appGatewayName, __cb(_, __frame, 8, 55, function __$delete__6() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$delete__6() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$delete__6() { _(); }); }); }); }, true)); }); },
start: function start__7(appGatewayName, options, _) { var self, progress, __this = this; var __frame = { name: "start__7", line: 158 }; return __func(_, this, arguments, start__7, 2, __frame, function __$start__7() { self = __this;
options.operationType = "start";
progress = self.interaction.progress(util.format($("Starting an Application Gateway \"%s\""), appGatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$start__7() {
return self.networkManagementClient.applicationGateways.executeOperation(appGatewayName, options, __cb(_, __frame, 5, 55, function __$start__7() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$start__7() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$start__7() { _(); }); }); }); },
stop: function stop__8(appGatewayName, options, _) { var self, progress, __this = this; var __frame = { name: "stop__8", line: 169 }; return __func(_, this, arguments, stop__8, 2, __frame, function __$stop__8() { self = __this;
options.operationType = "stop";
progress = self.interaction.progress(util.format($("Stopping an Application Gateway \"%s\""), appGatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$stop__8() {
return self.networkManagementClient.applicationGateways.executeOperation(appGatewayName, options, __cb(_, __frame, 5, 55, function __$stop__8() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$stop__8() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$stop__8() { _(); }); }); }); },
showConfig: function showConfig__9(appGatewayName, options, _) { var self, config, __this = this; var __frame = { name: "showConfig__9", line: 180 }; return __func(_, this, arguments, showConfig__9, 2, __frame, function __$showConfig__9() { self = __this;
return self.getConfig(appGatewayName, __cb(_, __frame, 2, 22, function ___(__0, __1) { config = __1;
self.interaction.formatOutput(config, function(config) {
if ((config === null)) {
self.output.warn(util.format($("Application Gateway \"%s\" not found"), appGatewayName)); }
else {
self.output.header($("Frontend IP configurations"));
config.frontendIPConfigurations.forEach(function(fip) {
self.output.nameValue($("Name"), fip.name, 2);
self.output.nameValue($("Type"), fip.type, 2);
self.output.nameValue($("Static IP address"), fip.staticIPAddress, 2);
self.output.data(""); });
self.output.header($("Backend address pools"));
config.backendAddressPools.forEach(function(pool) {
self.output.nameValue($("Name"), pool.name, 2);
self.output.header($("Backend servers"), 2);
pool.backendServers.forEach(function(server) {
self.output.nameValue($("IP address"), server.iPAddress, 4); });
self.output.data(""); });
self.output.header($("Http settings"));
config.backendHttpSettingsList.forEach(function(settings) {
self.output.nameValue($("Name"), settings.name, 2);
self.output.nameValue($("Port"), settings.port, 2);
self.output.nameValue($("Protocol"), settings.protocol, 2);
self.output.nameValue($("Cookie based affinity"), settings.cookieBasedAffinity, 2);
self.output.data(""); });
self.output.header($("Frontend ports"));
config.frontendPorts.forEach(function(frontendPort) {
self.output.nameValue($("Name"), frontendPort.name, 2);
self.output.nameValue($("Port"), frontendPort.port, 2);
self.output.data(""); });
self.output.header($("Http listeners"));
config.httpListeners.forEach(function(listener) {
self.output.nameValue($("Name"), listener.name, 2);
self.output.nameValue($("Frontend port"), listener.frontendPort, 2);
self.output.nameValue($("Protocol"), listener.protocol, 2);
self.output.nameValue($("Frontend IP"), listener.frontendIP, 2);
self.output.data(""); });
self.output.header($("Load balancing rules"));
config.httpLoadBalancingRules.forEach(function(rule) {
self.output.nameValue($("Name"), rule.name, 2);
self.output.nameValue($("Type"), rule.type, 2);
self.output.nameValue($("Http settings"), rule.backendHttpSettings, 2);
self.output.nameValue($("Listener"), rule.listener, 2);
self.output.nameValue($("Backend address pool"), rule.backendAddressPool, 2);
self.output.data(""); }); } ; }); _(); }, true)); }); },
exportConfig: function exportConfig__10(appGatewayName, filePath, options, _) { var self, gateway, config, __this = this; var __frame = { name: "exportConfig__10", line: 245 }; return __func(_, this, arguments, exportConfig__10, 3, __frame, function __$exportConfig__10() { self = __this;
return self.get(appGatewayName, __cb(_, __frame, 2, 23, function ___(__0, __1) { gateway = __1;
if (!gateway) {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ;
return self.getConfig(appGatewayName, __cb(_, __frame, 7, 22, function ___(__0, __2) { config = __2;
if (config) {
fs.writeFileSync(filePath, JSON.stringify(config, null, 2));
self.output.verbose(util.format($("Application Gateway configuration exported to %s"), filePath)); }
else {
self.output.warn(util.format($("Application Gateway \"%s\" not found"), appGatewayName)); } ; _(); }, true)); }, true)); }); },
importConfig: function importConfig__11(appGatewayName, filePath, options, _) { var self, appGateway, configAsString, config, __this = this; var __frame = { name: "importConfig__11", line: 261 }; return __func(_, this, arguments, importConfig__11, 3, __frame, function __$importConfig__11() { self = __this;
return self.get(appGatewayName, __cb(_, __frame, 2, 26, function ___(__0, __1) { appGateway = __1;
if (!appGateway) {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ;
self.output.verbose(util.format($("Loading Application Gateway configuration file: %s"), filePath));
configAsString = fs.readFileSync(filePath, "utf8");
config = JSON.parse(configAsString);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 11, 9, function __$importConfig__11() { _(); }, true)); }, true)); }); },
getConfig: function getConfig__12(appGatewayName, _) { var self, progress, config, __this = this; var __frame = { name: "getConfig__12", line: 275 }; return __func(_, this, arguments, getConfig__12, 1, __frame, function __$getConfig__12() { self = __this;
progress = self.interaction.progress(util.format($("Getting configuration for an Application Gateway \"%s\""), appGatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getConfig__12() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getConfig__12() {
return self.networkManagementClient.applicationGateways.getConfig(appGatewayName, __cb(_, __frame, 5, 64, function ___(__0, __1) { config = __1;
delete config.statusCode;
delete config.requestId; __then(); }, true)); }); })(function ___(error, __result) { __catch(function __$getConfig__12() { if (error) {
if (((error.code === "ResourceNotFound") || (error.code === "NotFound"))) {
config = null; } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$getConfig__12() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getConfig__12() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getConfig__12() {
return _(null, config); }); }); }); },
setConfig: function setConfig__13(appGatewayName, config, _) { var self, progress, __this = this; var __frame = { name: "setConfig__13", line: 293 }; return __func(_, this, arguments, setConfig__13, 2, __frame, function __$setConfig__13() { self = __this;
progress = self.interaction.progress(util.format($("Setting configuration for an Application Gateway \"%s\""), appGatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$setConfig__13() {
return self.networkManagementClient.applicationGateways.setConfig(appGatewayName, config, __cb(_, __frame, 4, 55, function __$setConfig__13() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$setConfig__13() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$setConfig__13() { _(); }); }); }); },
addBackendAddressPool: function addBackendAddressPool__14(appGatewayName, poolName, options, _) { var self, dnsServers, config, pool, addressPool, __this = this; var __frame = { name: "addBackendAddressPool__14", line: 304 }; return __func(_, this, arguments, addBackendAddressPool__14, 3, __frame, function __$addBackendAddressPool__14() { self = __this;
dnsServers = self._parseDnsServers(options);
return self.getConfig(appGatewayName, __cb(_, __frame, 3, 22, function ___(__0, __1) { config = __1; return (function __$addBackendAddressPool__14(__then) {
if (config) {
pool = utils.findFirstCaseIgnore(config.backendAddressPools, { name: poolName }); return (function __$addBackendAddressPool__14(__then) {
if (pool) {
return _(new Error(util.format($("A backend address pool with name \"%s\" already exists for an Application Gateway \"%s\""), poolName, appGatewayName))); } else {
addressPool = {
name: poolName,
backendServers: dnsServers };
config.backendAddressPools.push(addressPool);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 15, 13, __then, true)); } ; })(__then); } else {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ; })(_); }, true)); }); },
removeBackendAddressPool: function removeBackendAddressPool__15(appGatewayName, poolName, options, _) { var self, config, index, __this = this; var __frame = { name: "removeBackendAddressPool__15", line: 326 }; return __func(_, this, arguments, removeBackendAddressPool__15, 3, __frame, function __$removeBackendAddressPool__15() { self = __this;
return self.getConfig(appGatewayName, __cb(_, __frame, 2, 22, function ___(__0, __2) { config = __2; return (function __$removeBackendAddressPool__15(__then) {
if (config) {
index = utils.indexOfCaseIgnore(config.backendAddressPools, { name: poolName }); return (function __$removeBackendAddressPool__15(__then) {
if ((index !== -1)) { return (function __$removeBackendAddressPool__15(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete a backend address pool \"%s?\" [y/n] "), poolName), __cb(_, __frame, 6, 48, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -325, 17, function ___(__0, __3) { return (function __$removeBackendAddressPool__15(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$removeBackendAddressPool__15() {
config.backendAddressPools.splice(index, 1);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 10, 13, __then, true)); }); }, true)); } else {
return _(new Error(util.format($("A backend address pool with name \"%s\" not found for an Application Gateway \"%s\""), poolName, appGatewayName))); } ; })(__then); } else {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ; })(_); }, true)); }); },
addHttpSettings: function addHttpSettings__16(appGatewayName, httpSettingsName, options, _) { var self, httpSettings, config, settings, __this = this; var __frame = { name: "addHttpSettings__16", line: 345 }; return __func(_, this, arguments, addHttpSettings__16, 3, __frame, function __$addHttpSettings__16() { self = __this;
httpSettings = self._parseHttpSettings(httpSettingsName, options, true);
return self.getConfig(appGatewayName, __cb(_, __frame, 3, 22, function ___(__0, __1) { config = __1; return (function __$addHttpSettings__16(__then) {
if (config) {
settings = utils.findFirstCaseIgnore(config.backendHttpSettingsList, { name: httpSettingsName }); return (function __$addHttpSettings__16(__then) {
if (settings) {
return _(new Error(util.format($("A http settings with name \"%s\" already exists for an Application Gateway \"%s\""), httpSettingsName, appGatewayName))); } else {
config.backendHttpSettingsList.push(httpSettings);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 10, 13, __then, true)); } ; })(__then); } else {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ; })(_); }, true)); }); },
removeHttpSettings: function removeHttpSettings__17(appGatewayName, httpSettingsName, options, _) { var self, config, index, __this = this; var __frame = { name: "removeHttpSettings__17", line: 362 }; return __func(_, this, arguments, removeHttpSettings__17, 3, __frame, function __$removeHttpSettings__17() { self = __this;
return self.getConfig(appGatewayName, __cb(_, __frame, 2, 22, function ___(__0, __2) { config = __2; return (function __$removeHttpSettings__17(__then) {
if (config) {
index = utils.indexOfCaseIgnore(config.backendHttpSettingsList, { name: httpSettingsName }); return (function __$removeHttpSettings__17(__then) {
if ((index !== -1)) { return (function __$removeHttpSettings__17(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete a http settings \"%s?\" [y/n] "), httpSettingsName), __cb(_, __frame, 6, 48, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -361, 17, function ___(__0, __3) { return (function __$removeHttpSettings__17(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$removeHttpSettings__17() {
config.backendHttpSettingsList.splice(index, 1);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 10, 13, __then, true)); }); }, true)); } else {
return _(new Error(util.format($("A http settings with name \"%s\" not found for an Application Gateway \"%s"), httpSettingsName, appGatewayName))); } ; })(__then); } else {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ; })(_); }, true)); }); },
addFrontendIp: function addFrontendIp__18(appGatewayName, frontendIpName, options, _) { var self, frontendIp, config, ip, __this = this; var __frame = { name: "addFrontendIp__18", line: 381 }; return __func(_, this, arguments, addFrontendIp__18, 3, __frame, function __$addFrontendIp__18() { self = __this;
frontendIp = self._parseFrontendIp(frontendIpName, options, true);
return self.getConfig(appGatewayName, __cb(_, __frame, 3, 22, function ___(__0, __1) { config = __1; return (function __$addFrontendIp__18(__then) {
if (config) {
ip = utils.findFirstCaseIgnore(config.frontendIPConfigurations, { name: frontendIpName }); return (function __$addFrontendIp__18(__then) {
if (ip) {
return _(new Error(util.format($("A frontend ip with name \"%s\" already exists for an Application Gateway \"%s\""), frontendIpName, appGatewayName))); } else {
config.frontendIPConfigurations.push(frontendIp);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 10, 13, __then, true)); } ; })(__then); } else {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ; })(_); }, true)); }); },
removeFrontendIp: function removeFrontendIp__19(appGatewayName, frontendIpName, options, _) { var self, config, index, __this = this; var __frame = { name: "removeFrontendIp__19", line: 398 }; return __func(_, this, arguments, removeFrontendIp__19, 3, __frame, function __$removeFrontendIp__19() { self = __this;
return self.getConfig(appGatewayName, __cb(_, __frame, 2, 22, function ___(__0, __2) { config = __2;
if (!config) {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ;
index = utils.indexOfCaseIgnore(config.frontendIPConfigurations, { name: frontendIpName });
if ((index === -1)) {
return _(new Error(util.format($("A frontend ip with name \"%s\" not found for an Application Gateway \"%s"), frontendIpName, appGatewayName))); } ; return (function __$removeFrontendIp__19(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete a frontend ip \"%s?\" [y/n] "), frontendIpName), __cb(_, __frame, 12, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -397, 17, function ___(__0, __3) { return (function __$removeFrontendIp__19(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$removeFrontendIp__19() {
config.backendHttpSettingsList.splice(index, 1);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 17, 9, function __$removeFrontendIp__19() { _(); }, true)); }); }, true)); }, true)); }); },
addFrontendPort: function addFrontendPort__20(appGatewayName, frontendPortName, port, options, _) { var self, config, frontendPort, __this = this; var __frame = { name: "addFrontendPort__20", line: 418 }; return __func(_, this, arguments, addFrontendPort__20, 4, __frame, function __$addFrontendPort__20() { self = __this;
return self.getConfig(appGatewayName, __cb(_, __frame, 2, 22, function ___(__0, __1) { config = __1;
if (!config) {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ;
frontendPort = utils.findFirstCaseIgnore(config.frontendPorts, { name: frontendPortName });
if (frontendPort) {
return _(new Error(util.format($("A frontend port with name \"%s\" already exists for an Application Gateway \"%s\""), frontendPortName, appGatewayName))); } ;
frontendPort = {
name: frontendPortName,
port: port };
config.frontendPorts.push(frontendPort);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 16, 9, function __$addFrontendPort__20() {
return self.show(appGatewayName, options, __cb(_, __frame, 17, 9, function __$addFrontendPort__20() { _(); }, true)); }, true)); }, true)); }); },
removeFrontendPort: function removeFrontendPort__21(appGatewayName, frontendPortName, options, _) { var self, config, index, __this = this; var __frame = { name: "removeFrontendPort__21", line: 438 }; return __func(_, this, arguments, removeFrontendPort__21, 3, __frame, function __$removeFrontendPort__21() { self = __this;
return self.getConfig(appGatewayName, __cb(_, __frame, 2, 22, function ___(__0, __2) { config = __2;
if (!config) {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ;
index = utils.indexOfCaseIgnore(config.frontendPorts, { name: frontendPortName });
if ((index === -1)) {
return _(new Error(util.format($("Frontend port with name \"%s\" not found for an Application Gateway \"%s"), frontendPortName, appGatewayName))); } ; return (function __$removeFrontendPort__21(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete a frontend port \"%s?\" [y/n] "), frontendPortName), __cb(_, __frame, 12, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -437, 17, function ___(__0, __3) { return (function __$removeFrontendPort__21(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$removeFrontendPort__21() {
config.frontendPorts.splice(index, 1);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 17, 9, function __$removeFrontendPort__21() { _(); }, true)); }); }, true)); }, true)); }); },
addHttpListener: function addHttpListener__22(appGatewayName, httpListenerName, frontendPortName, options, _) { var self, config, httpListener, protocol, __this = this; var __frame = { name: "addHttpListener__22", line: 458 }; return __func(_, this, arguments, addHttpListener__22, 4, __frame, function __$addHttpListener__22() { self = __this;
return self.getConfig(appGatewayName, __cb(_, __frame, 2, 22, function ___(__0, __1) { config = __1;
if (!config) {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ;
if ((!config.httpListeners || !config.httpListeners.length)) {
config.httpListeners = []; } ;
if (utils.findFirstCaseIgnore(config.httpListeners, { name: httpListenerName })) {
return _(new Error(util.format($("An http listener with name \"%s\" already exists for an Application Gateway \"%s\""), httpListenerName, appGatewayName))); } ;
if (!utils.findFirstCaseIgnore(config.frontendPorts, { name: frontendPortName })) {
return _(new Error(util.format($("Frontend port with name \"%s\" not found for an Application Gateway \"%s"), frontendPortName, appGatewayName))); } ;
httpListener = {
name: httpListenerName,
protocol: "Http",
frontendPort: frontendPortName };
if (options.frontendIpName) {
if (!utils.findFirstCaseIgnore(config.frontendIPConfigurations, { name: options.frontendIpName })) {
return _(new Error(util.format($("Frontend ip with name \"%s\" not found for an Application Gateway \"%s"), options.frontendIpName, appGatewayName))); } ;
httpListener.frontendIP = options.frontendIpName; } ;
if (options.protocol) {
if (((options.protocol.toLowerCase() === "https") && !options.sslCert)) {
return _(new Error($("--ssl-cert parameter is required when \"--protocol Https\" parameter is specified"))); } ;
protocol = options.protocol.toLowerCase();
httpListener.protocol = utils.capitalizeFirstLetter(protocol); } ;
if (options.sslCert) {
httpListener.sslCert = options.sslCert; } ;
config.httpListeners.push(httpListener);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 45, 9, function __$addHttpListener__22() {
return self.show(appGatewayName, options, __cb(_, __frame, 46, 9, function __$addHttpListener__22() { _(); }, true)); }, true)); }, true)); }); },
removeHttpListener: function removeHttpListener__23(appGatewayName, httpListenerName, options, _) { var self, config, index, __this = this; var __frame = { name: "removeHttpListener__23", line: 507 }; return __func(_, this, arguments, removeHttpListener__23, 3, __frame, function __$removeHttpListener__23() { self = __this;
return self.getConfig(appGatewayName, __cb(_, __frame, 2, 22, function ___(__0, __2) { config = __2;
if (!config) {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ;
index = utils.indexOfCaseIgnore(config.httpListeners, { name: httpListenerName });
if ((index === -1)) {
return _(new Error(util.format($("Http listener with name \"%s\" not found for an Application Gateway \"%s"), httpListenerName, appGatewayName))); } ; return (function __$removeHttpListener__23(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete http listener \"%s?\" [y/n] "), httpListenerName), __cb(_, __frame, 12, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -506, 17, function ___(__0, __3) { return (function __$removeHttpListener__23(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$removeHttpListener__23() {
config.httpListeners.splice(index, 1);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 17, 9, function __$removeHttpListener__23() { _(); }, true)); }); }, true)); }, true)); }); },
addLoadBalancingRule: function addLoadBalancingRule__24(appGatewayName, ruleName, httpSettingsName, httpListenerName, addressPoolName, options, _) { var self, config, lbRule, __this = this; var __frame = { name: "addLoadBalancingRule__24", line: 527 }; return __func(_, this, arguments, addLoadBalancingRule__24, 6, __frame, function __$addLoadBalancingRule__24() { self = __this;
return self.getConfig(appGatewayName, __cb(_, __frame, 2, 22, function ___(__0, __1) { config = __1;
if (!config) {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ;
if ((!config.httpLoadBalancingRules || !config.httpLoadBalancingRules.length)) {
config.httpLoadBalancingRules = []; } ;
if (utils.findFirstCaseIgnore(config.httpLoadBalancingRules, { name: ruleName })) {
return _(new Error(util.format($("An http load balancing rule with name \"%s\" already exists for an Application Gateway \"%s\""), ruleName, appGatewayName))); } ;
if (!utils.findFirstCaseIgnore(config.backendHttpSettingsList, { name: httpSettingsName })) {
return _(new Error(util.format($("Http settings with name \"%s\" not found for an Application Gateway \"%s"), httpSettingsName, appGatewayName))); } ;
if (!utils.findFirstCaseIgnore(config.httpListeners, { name: httpListenerName })) {
return _(new Error(util.format($("Http listener with name \"%s\" not found for an Application Gateway \"%s"), httpListenerName, appGatewayName))); } ;
if (!utils.findFirstCaseIgnore(config.backendAddressPools, { name: addressPoolName })) {
return _(new Error(util.format($("Address pool with name \"%s\" not found for an Application Gateway \"%s"), addressPoolName, appGatewayName))); } ;
lbRule = {
name: ruleName,
type: "Basic",
backendHttpSettings: httpSettingsName,
listener: httpListenerName,
backendAddressPool: addressPoolName };
if (options.type) {
lbRule.type = options.type; } ;
config.httpLoadBalancingRules.push(lbRule);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 40, 9, function __$addLoadBalancingRule__24() {
return self.show(appGatewayName, options, __cb(_, __frame, 41, 9, function __$addLoadBalancingRule__24() { _(); }, true)); }, true)); }, true)); }); },
removeLoadBalancingRule: function removeLoadBalancingRule__25(appGatewayName, ruleName, options, _) { var self, config, index, __this = this; var __frame = { name: "removeLoadBalancingRule__25", line: 571 }; return __func(_, this, arguments, removeLoadBalancingRule__25, 3, __frame, function __$removeLoadBalancingRule__25() { self = __this;
return self.getConfig(appGatewayName, __cb(_, __frame, 2, 22, function ___(__0, __2) { config = __2;
if (!config) {
return _(new Error(util.format($("Application Gateway \"%s\" not found"), appGatewayName))); } ;
index = utils.indexOfCaseIgnore(config.httpLoadBalancingRules, { name: ruleName });
if ((index === -1)) {
return _(new Error(util.format($("An http load balancing rule with name \"%s\" not found for an Application Gateway \"%s"), ruleName, appGatewayName))); } ; return (function __$removeLoadBalancingRule__25(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Delete http listener \"%s?\" [y/n] "), ruleName), __cb(_, __frame, 12, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -570, 17, function ___(__0, __3) { return (function __$removeLoadBalancingRule__25(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$removeLoadBalancingRule__25() {
config.httpLoadBalancingRules.splice(index, 1);
return self.setConfig(appGatewayName, config, __cb(_, __frame, 17, 9, function __$removeLoadBalancingRule__25() { _(); }, true)); }); }, true)); }, true)); }); },
addSsl: function addSsl__26(appGatewayName, certName, options, _) { var self, certificateObject, certFormat, data, progress, __this = this; var __frame = { name: "addSsl__26", line: 591 }; return __func(_, this, arguments, addSsl__26, 3, __frame, function __$addSsl__26() { self = __this;
if (utils.stringIsNullOrEmpty(options.certFile)) {
return _(new Error($("--cert-file parameter must not be empty"))); } ;
if (utils.stringIsNullOrEmpty(options.password)) {
return _(new Error($("--password parameter must not be empty"))); } ;
certificateObject = { password: options.password };
certFormat = path.extname(options.certFile).split(".")[1];
certificateObject.certificateFormat = certFormat;
data = fs.readFileSync(options.certFile);
certificateObject.data = data.toString("base64");
progress = self.interaction.progress(util.format($("Adding SSL certificate \"%s\" to Application Gateway \"%s\""), certName, appGatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$addSsl__26() {
return self.networkManagementClient.applicationGateways.addCertificate(appGatewayName, certName, certificateObject, __cb(_, __frame, 20, 55, function __$addSsl__26() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$addSsl__26() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$addSsl__26() { _(); }); }); }); },
removeSsl: function removeSsl__27(appGatewayName, certName, options, _) { var self, progress, __this = this; var __frame = { name: "removeSsl__27", line: 617 }; return __func(_, this, arguments, removeSsl__27, 3, __frame, function __$removeSsl__27() { self = __this; return (function __$removeSsl__27(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return self.interaction.confirm(util.format($("Remove certificate \"%s\" from Application Gateway \"%s\"? [y/n] "), certName, appGatewayName), __cb(_, __frame, 2, 44, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -616, 17, function ___(__0, __2) { return (function __$removeSsl__27(__then) { if (__2) { return _(null); } else { __then(); } ; })(function __$removeSsl__27() {
progress = self.interaction.progress(util.format($("Removing SSL certificate \"%s\" to Application Gateway \"%s\""), certName, appGatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$removeSsl__27() {
return self.networkManagementClient.applicationGateways.deleteCertificate(appGatewayName, certName, __cb(_, __frame, 8, 55, function __$removeSsl__27() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$removeSsl__27() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$removeSsl__27() { _(); }); }); }); }, true)); }); },
_parseAppGateway: function(appGatewayName, appGateway, options, useDefaults) {
var self = this;
appGateway.name = appGatewayName;
appGateway.vnetName = options.vnetName;
if (options.subnetName) {
appGateway.subnets = [options.subnetName,]; }
else if (useDefaults) {
throw new Error($("--subnet-name parameter is required")); } ;
if (options.instanceCount) {
var instanceCount = utils.parseInt(options.instanceCount);
if ((isNaN(instanceCount) || ((instanceCount < 0)))) {
throw new Error($("--instance-count value must be positive integer")); } ;
appGateway.instanceCount = instanceCount; }
else if (useDefaults) {
self.output.warn(("--instance-count parameter is not specified, using default - " + constants.appGateway.defaultInstanceCount));
appGateway.instanceCount = constants.appGateway.defaultInstanceCount; } ;
if (options.gatewaySize) {
self._validateGatewaySize(options.gatewaySize);
appGateway.gatewaySize = options.gatewaySize; }
else if (useDefaults) {
self.output.warn(("--gateway-size parameter is not specified, using default - " + constants.appGateway.sizes[0]));
appGateway.gatewaySize = constants.appGateway.sizes[0]; } ; },
_validateGatewaySize: function(gatewaySize) {
if (!utils.verifyParamExistsInCollection(constants.appGateway.sizes, gatewaySize, "--gateway-size")) {
throw new Error(util.format($("--gateway-size must be one of the followings [%s]"), constants.appGateway.sizes)); } ; },
_parseDnsServers: function(options) {
var self = this;
var ipAddresses = options.servers.split(",");
var dnsServers = [];
ipAddresses.forEach(function(address) {
var ipValidationResult = self.vnetUtil.parseIPv4(address);
if (ipValidationResult.error) {
var dnsValidationResult = self.vnetUtil.isValidDns(address);
if ((dnsValidationResult === false)) {
throw new Error(util.format($("Address \"%s\" is not valid IPv4 or DNS name"), address)); } ; } ;
var dns = { iPAddress: address };
dnsServers.push(dns); });
return dnsServers; },
_parseHttpSettings: function(httpSettingsName, options, useDefaults) {
var self = this;
var httpSettings = {
name: httpSettingsName };
if (options.protocol) {
var protocol = utils.verifyParamExistsInCollection(constants.appGateway.settings.protocol, options.protocol, "protocol");
httpSettings.protocol = utils.capitalizeFirstLetter(protocol); }
else if (useDefaults) {
self.output.warn(util.format($("Using default protocol: %s"), constants.appGateway.settings.protocol[0]));
httpSettings.protocol = constants.appGateway.settings.protocol[0]; } ;
if (options.port) {
var portAsInt = utils.parseInt(options.port);
if (((isNaN(portAsInt) || (portAsInt < constants.appGateway.settings.port[0])) || (portAsInt > constants.appGateway.settings.port[1]))) {
throw new Error(util.format($("port parameter must be an integer in range %s"), utils.toRange(constants.appGateway.settings.port))); } ;
httpSettings.port = portAsInt; } ;
if (options.cookieBasedAffinity) {
var cookieBasedAffinity = utils.verifyParamExistsInCollection(constants.appGateway.settings.affinity, options.cookieBasedAffinity, "cookie based affinity");
httpSettings.cookieBasedAffinity = utils.capitalizeFirstLetter(cookieBasedAffinity); }
else if (useDefaults) {
self.output.warn(util.format($("Using default cookie based affinity: %s"), constants.appGateway.settings.affinity[0]));
httpSettings.cookieBasedAffinity = constants.appGateway.settings.affinity[0]; } ;
return httpSettings; },
_parseFrontendIp: function(frontendIpName, options, useDefaults) {
var self = this;
var frontendIp = {
name: frontendIpName };
if (options.type) {
var type = utils.verifyParamExistsInCollection(constants.appGateway.ip.type, options.type, "type");
frontendIp.type = utils.capitalizeFirstLetter(type); }
else if (useDefaults) {
self.output.warn(util.format($("Using default type: %s"), constants.appGateway.ip.type[0]));
frontendIp.type = constants.appGateway.ip.type[0]; } ;
if (options.staticIpAddress) {
var ipValidationResult = self.vnetUtil.parseIPv4(options.staticIpAddress);
if (ipValidationResult.error) {
throw new Error(util.format($("IPv4 %s static ip address is not valid"), options.staticIpAddress)); } ;
frontendIp.staticIPAddress = options.staticIpAddress; } ;
return frontendIp; }});
module.exports = AppGateway;