azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
256 lines (112 loc) • 19 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 tagUtils = require("../tag/tagUtils");
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 applicationSecurityGroups = network.category("application-security-group").description($("Commands to manage application security groups"));
applicationSecurityGroups.command("create [resource-group] [name] [location]").description($("Create an application security group")).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 application security group")).option("-l, --location <location>", $("the location")).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 subscription, networkManagementClient, applicationSecurityGroup, progress, parameters; var __frame = { name: "__1", line: 46 }; 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($("name : "), name, __cb(_, __frame, 2, 29, function ___(__0, __2) { name = __2;
return cli.interaction.promptIfNotGiven($("location : "), location, __cb(_, __frame, 3, 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 application security group \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return networkManagementClient.applicationSecurityGroups.get(resourceGroup, name, null, __cb(_, __frame, 11, 85, function ___(__0, __4) { applicationSecurityGroup = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) {
if ((e.statusCode === 404)) {
applicationSecurityGroup = 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 (applicationSecurityGroup) {
return _(new Error(util.format($("application security group with name \"%s\" already exists in the resource group \"%s\""), name, resourceGroup))); } ;
parameters = { };
if (options.location) {
parameters.location = options.location; } ;
if ((options.tags && utils.argHasValue(options.tags))) {
tagUtils.appendTags(parameters, options); } ;
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Creating application security group \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return networkManagementClient.applicationSecurityGroups.createOrUpdate(resourceGroup, name, parameters, __cb(_, __frame, 38, 85, function ___(__0, __5) { applicationSecurityGroup = __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(applicationSecurityGroup, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }); });
applicationSecurityGroups.command("set [resource-group] [name]").description($("Update an application security group")).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 application security group")).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 subscription, networkManagementClient, applicationSecurityGroup, progress, parameters; var __frame = { name: "__2", line: 99 }; 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($("name : "), name, __cb(_, __frame, 2, 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 application security group \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return networkManagementClient.applicationSecurityGroups.get(resourceGroup, name, null, __cb(_, __frame, 10, 85, function ___(__0, __3) { applicationSecurityGroup = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) {
if ((e.statusCode === 404)) {
applicationSecurityGroup = 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 (!applicationSecurityGroup) {
return _(new Error(util.format($("application security group with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ;
parameters = applicationSecurityGroup;
if ((options.tags && utils.argHasValue(options.tags))) {
tagUtils.appendTags(parameters, options); } ;
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Updating application security group \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return networkManagementClient.applicationSecurityGroups.createOrUpdate(resourceGroup, name, parameters, __cb(_, __frame, 33, 85, function ___(__0, __4) { applicationSecurityGroup = __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(applicationSecurityGroup, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }); });
applicationSecurityGroups.command("delete [resource-group] [name]").description($("Delete an application security group")).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 application security group")).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, applicationSecurityGroup, progress; var __frame = { name: "__3", line: 147 }; 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 application security group \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return networkManagementClient.applicationSecurityGroups.get(resourceGroup, name, null, __cb(_, __frame, 10, 85, function ___(__0, __4) { applicationSecurityGroup = __4; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) {
if ((e.statusCode === 404)) {
applicationSecurityGroup = 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 (!applicationSecurityGroup) {
return _(new Error(util.format($("application security group 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 application security group \"%s\"? [y/n] "), name), __cb(_, __frame, 25, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -146, 17, function ___(__0, __5) { return (function __$__3(__then) { if (__5) {
cli.output.info(util.format($("application security group \"%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 application security group \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return networkManagementClient.applicationSecurityGroups.deleteMethod(resourceGroup, name, __cb(_, __frame, 32, 85, function ___(__0, __6) { applicationSecurityGroup = __6;
cli.output.info(util.format($("application security group \"%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)); }); });
applicationSecurityGroups.command("show [resource-group] [name]").description($("Show an application security group")).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 application security group")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, name, options, _) { var subscription, networkManagementClient, applicationSecurityGroup, progress; var __frame = { name: "__4", line: 192 }; 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($("name : "), name, __cb(_, __frame, 2, 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 application security group \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() {
return networkManagementClient.applicationSecurityGroups.get(resourceGroup, name, null, __cb(_, __frame, 10, 85, function ___(__0, __3) { applicationSecurityGroup = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) {
if ((e.statusCode === 404)) {
applicationSecurityGroup = null; }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__4() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__4() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__4() {
if (!applicationSecurityGroup) {
cli.output.warn(util.format($("application security group with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup)); } ;
cli.interaction.formatOutput(applicationSecurityGroup, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }); });
applicationSecurityGroups.command("list [resource-group]").description($("List application security groups")).usage("[options] <resource-group>").option("-g, --resource-group [resource-group]", $("the name of the resource group")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __5(resourceGroup, options, _) { var subscription, networkManagementClient, applicationSecurityGroup, progress; var __frame = { name: "__5", line: 225 }; return __func(_, this, arguments, __5, 2, __frame, function __$__5() {
options.resourceGroup = resourceGroup;
subscription = profile.current.getSubscription(options.subscription);
networkManagementClient = utils.createNetworkManagementClient(subscription);
applicationSecurityGroup = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return (function __$__5(__then) {
if ((typeof networkManagementClient.applicationSecurityGroups.listAll != "function")) {
return cli.interaction.promptIfNotGiven($("resource-group : "), resourceGroup, __cb(_, __frame, 9, 42, function ___(__0, __1) { resourceGroup = __1;
progress = cli.interaction.progress($("Getting the application security groups"));
return networkManagementClient.applicationSecurityGroups.list(resourceGroup, __cb(_, __frame, 11, 87, function ___(__0, __2) { applicationSecurityGroup = __2; __then(); }, true)); }, true)); } else { return (function __$__5(__then) {
if (options.resourceGroup) {
progress = cli.interaction.progress($("Getting the application security groups"));
return networkManagementClient.applicationSecurityGroups.list(resourceGroup, __cb(_, __frame, 15, 89, function ___(__0, __3) { applicationSecurityGroup = __3; __then(); }, true)); } else {
progress = cli.interaction.progress($("Getting the application security groups"));
return networkManagementClient.applicationSecurityGroups.listAll(__cb(_, __frame, 18, 89, function ___(__0, __4) { applicationSecurityGroup = __4; __then(); }, true)); } ; })(__then); } ; })(function __$__5() { _(null, null, true); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__5() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__5() {
cli.interaction.formatOutput(applicationSecurityGroup, function(applicationSecurityGroup) {
if ((!applicationSecurityGroup || (applicationSecurityGroup.length === 0))) {
cli.output.warn($("No application security groups found")); }
else {
cli.output.table(applicationSecurityGroup, function(row, item) {
generatorUtils.showTableRow(row, item); }); } ; }); _(); }); }); }); });};