azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
330 lines (146 loc) • 23.7 kB
JavaScript
/*** 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 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 applicationGateways = network.category("application-gateway").description($("Commands to manage application gateways"));
var webApplicationFirewallConfiguration = applicationGateways.category("waf-config").description($("Commands to manage web application firewall configuration"));
webApplicationFirewallConfiguration.command("create [resource-group] [gateway-name] [enable] [waf-mode] [rule-set-type] [rule-set-version]").description($("Create a web application firewall configuration")).usage("[options] <resource-group> <gateway-name> <enable> <waf-mode> <rule-set-type> <rule-set-version>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-w, --gateway-name <gateway-name>", $("the gateway name")).option("-e, --enable <enable>", $(("whether the web application firewall is" + "\n enabled or not"))).option("-m, --waf-mode <waf-mode>", $("web application firewall mode")).option("-y, --rule-set-type <rule-set-type>", $(("the type of the web application" + "\n firewall rule set. Possible values are: 'OWASP'"))).option("-r, --rule-set-version <rule-set-version>", $("the version of the rule set type")).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, enable, wafMode, ruleSetType, ruleSetVersion, options, _) { var subscription, networkManagementClient, applicationGateway, progress, parentItem, webApplicationFirewallConfiguration, parameters; var __frame = { name: "__1", line: 53 }; return __func(_, this, arguments, __1, 7, __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($("enable : "), enable, __cb(_, __frame, 3, 39, function ___(__0, __3) { options.enable = __3;
return cli.interaction.promptIfNotGiven($("waf mode : "), wafMode, __cb(_, __frame, 4, 40, function ___(__0, __4) { options.wafMode = __4;
return cli.interaction.promptIfNotGiven($("rule set type : "), ruleSetType, __cb(_, __frame, 5, 44, function ___(__0, __5) { options.ruleSetType = __5;
return cli.interaction.promptIfNotGiven($("rule set version : "), ruleSetVersion, __cb(_, __frame, 6, 47, function ___(__0, __6) { options.ruleSetVersion = __6;
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, 14, 73, function ___(__0, __7) { applicationGateway = __7; __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))); } ;
webApplicationFirewallConfiguration = parentItem.webApplicationFirewallConfiguration;
if (webApplicationFirewallConfiguration) {
return _(new Error(util.format($("web application firewall configuration already exists in application gateway \"%s\""), gatewayName))); } ;
parameters = { };
if (options.enable) {
parameters.enabled = utils.parseBool(options.enable); } ;
if (options.wafMode) {
parameters.firewallMode = validation.isIn(options.wafMode, ["Detection","Prevention",], "--waf-mode"); } ;
if (options.ruleSetType) {
parameters.ruleSetType = options.ruleSetType; } ;
if (options.ruleSetVersion) {
parameters.ruleSetVersion = options.ruleSetVersion; } ;
parentItem.webApplicationFirewallConfiguration = parameters;
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Creating web application firewall configuration 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, 59, 75, function ___(__0, __8) { applicationGateway = __8; __then(); }, true)); } else {
return networkManagementClient.applicationGateways.createOrUpdate(resourceGroup, gatewayName, applicationGateway, __cb(_, __frame, 61, 75, function ___(__0, __9) { applicationGateway = __9; __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() {
parentItem = applicationGateway;
cli.interaction.formatOutput(parentItem.webApplicationFirewallConfiguration, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }, true)); }, true)); }, true)); }); });
webApplicationFirewallConfiguration.command("set [resource-group] [gateway-name]").description($("Update a web application firewall configuration")).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("-e, --enable [enable]", $(("whether the web application firewall is" + "\n enabled or not"))).option("-m, --waf-mode [waf-mode]", $("web application firewall mode")).option("-y, --rule-set-type [rule-set-type]", $(("the type of the web application" + "\n firewall rule set. Possible values are: 'OWASP'"))).option("-r, --rule-set-version [rule-set-version]", $("the version of the rule set type")).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 __2(resourceGroup, gatewayName, options, _) { var subscription, networkManagementClient, applicationGateway, progress, parentItem, webApplicationFirewallConfiguration, parameters; var __frame = { name: "__2", line: 137 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("gateway name : "), gatewayName, __cb(_, __frame, 2, 36, function ___(__0, __2) { gatewayName = __2;
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, 10, 73, function ___(__0, __3) { applicationGateway = __3; __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))); } ;
webApplicationFirewallConfiguration = parentItem.webApplicationFirewallConfiguration;
if (!webApplicationFirewallConfiguration) {
return _(new Error(util.format($("web application firewall configuration not found in application gateway \"%s\""), gatewayName))); } ;
parameters = webApplicationFirewallConfiguration;
if (options.enable) {
parameters.enabled = utils.parseBool(options.enable); } ;
if (options.wafMode) {
parameters.firewallMode = validation.isIn(options.wafMode, ["Detection","Prevention",], "--waf-mode"); } ;
if (options.ruleSetType) {
parameters.ruleSetType = options.ruleSetType; } ;
if (options.ruleSetVersion) {
parameters.ruleSetVersion = options.ruleSetVersion; } ;
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Updating web application firewall configuration in \"%s\""), gatewayName)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function __$__2(__then) {
if (options.nowait) {
return networkManagementClient.applicationGateways.beginCreateOrUpdate(resourceGroup, gatewayName, applicationGateway, __cb(_, __frame, 53, 75, function ___(__0, __4) { applicationGateway = __4; __then(); }, true)); } else {
return networkManagementClient.applicationGateways.createOrUpdate(resourceGroup, gatewayName, applicationGateway, __cb(_, __frame, 55, 75, function ___(__0, __5) { applicationGateway = __5; __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() {
parentItem = applicationGateway;
cli.interaction.formatOutput(parentItem.webApplicationFirewallConfiguration, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }); });
webApplicationFirewallConfiguration.command("delete [resource-group] [gateway-name]").description($("Delete a web application firewall configuration")).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("--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 __3(resourceGroup, gatewayName, options, _) { var subscription, networkManagementClient, applicationGateway, progress, parentItem; var __frame = { name: "__3", line: 210 }; 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($("gateway name : "), gatewayName, __cb(_, __frame, 2, 36, function ___(__0, __3) { gatewayName = __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, 10, 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))); } ; return (function __$__3(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete web application firewall configuration from application gateway \"%s\"? [y/n] "), gatewayName), __cb(_, __frame, 26, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -209, 17, function ___(__0, __5) { return (function __$__3(__then) { if (__5) { return _(null); } else { __then(); } ; })(function __$__3() {
delete parentItem.webApplicationFirewallConfiguration;
progress = cli.interaction.progress("Deleting web application firewall configuration"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function __$__3(__then) {
if (options.nowait) {
return networkManagementClient.applicationGateways.beginCreateOrUpdate(resourceGroup, gatewayName, applicationGateway, __cb(_, __frame, 35, 75, function ___(__0, __6) { applicationGateway = __6; __then(); }, true)); } else {
return networkManagementClient.applicationGateways.createOrUpdate(resourceGroup, gatewayName, applicationGateway, __cb(_, __frame, 38, 75, function ___(__0, __7) { applicationGateway = __7; __then(); }, true)); } ; })(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() { _(); }); }); }); }, true)); }); }); }, true)); }, true)); }); });
webApplicationFirewallConfiguration.command("show [resource-group] [gateway-name]").description($("Show a web application firewall configuration")).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, webApplicationFirewallConfiguration; var __frame = { name: "__4", line: 261 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("gateway name : "), gatewayName, __cb(_, __frame, 2, 36, function ___(__0, __2) { gatewayName = __2;
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 __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() {
return networkManagementClient.applicationGateways.get(resourceGroup, gatewayName, null, __cb(_, __frame, 10, 73, function ___(__0, __3) { applicationGateway = __3; __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))); } ;
webApplicationFirewallConfiguration = parentItem.webApplicationFirewallConfiguration;
if (!webApplicationFirewallConfiguration) {
cli.output.warn(util.format($("web application firewall configuration not found in the \"%s\""), gatewayName)); } ;
cli.interaction.formatOutput(webApplicationFirewallConfiguration, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }); });
webApplicationFirewallConfiguration.command("list [resource-group] [gateway-name]").description($("List web application firewall configurations")).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 __5(resourceGroup, gatewayName, options, _) { var subscription, networkManagementClient, applicationGateway, progress, parentItem; var __frame = { name: "__5", line: 301 }; return __func(_, this, arguments, __5, 3, __frame, function __$__5() {
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 __$__5() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() {
return networkManagementClient.applicationGateways.get(resourceGroup, gatewayName, null, __cb(_, __frame, 7, 73, function ___(__0, __1) { applicationGateway = __1; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__5() { if (e) {
if ((e.statusCode === 404)) {
applicationGateway = null; }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, 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() {
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.webApplicationFirewallConfiguration, function(items) {
if ((!items || (items.length === 0))) {
cli.output.warn($("No web application firewall configurations found")); }
else {
cli.output.table(items, function(row, item) {
generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); });};