azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
193 lines (77 loc) • 10.4 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,__tryCatch=__rt.__tryCatch; var util = require("util");
var azureCommon = require("azure-common");
var profile = require("../../util/profile");
var utils = require("../../util/utils");
var $ = utils.getLocaleString;
var namespaceNameIsValid = azureCommon.validate.namespaceNameIsValid;
exports.init = function(cli) {
var log = cli.output;
var sb = cli.category("sb").description($("Commands to manage your Service Bus configuration"));
var sbnamespace = sb.category("namespace").description($("Commands to manage your Service Bus namespaces"));
sbnamespace.command("list").description($("List currently defined service bus namespaces")).option("-s, --subscription <id>", $("the subscription id")).execute(function __1(options, _) { var service, namespaces, progress; var __frame = { name: "__1", line: 40 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
service = createService(options.subscription);
progress = cli.interaction.progress($("Getting namespaces")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return service.namespaces.list(__cb(_, __frame, 7, 40, function ___(__0, __1) { namespaces = __1.namespaces; _(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(namespaces, function(outputData) {
if ((outputData.length === 0)) {
log.info($("No namespaces defined")); }
else {
log.table(outputData, function(row, ns) {
row.cell($("Name"), ns.name);
row.cell($("Region"), ns.region);
row.cell($("Status"), ns.status); }); } ; }); _(); }); }); }); });
sbnamespace.command("show [name]").description($("Get detailed information about a single service bus namespace")).option("-s, --subscription <id>", $("the subscription id")).execute(function __2(name, options, _) { var service, namespace, progress; var __frame = { name: "__2", line: 68 }; return __func(_, this, arguments, __2, 2, __frame, function __$__2() {
return cli.interaction.promptIfNotGiven($("Service Bus namespace: "), name, __cb(_, __frame, 1, 29, function ___(__0, __1) { name = __1;
return namespaceNameIsValid(name, __cb(_, __frame, 2, 6, function __$__2() {
service = createService(options.subscription);
progress = cli.interaction.progress($("Getting namespace")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return service.namespaces.get(name, __cb(_, __frame, 9, 39, function ___(__0, __2) { namespace = __2.namespace; _(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(namespace, function(outputData) {
Object.keys(outputData).forEach(function(key) {
if ((key !== "_")) {
log.data(util.format($("%s: %s"), key, outputData[key])); } ; }); }); _(); }); }); }, true)); }, true)); }); });
sbnamespace.command("check <name>").description($("Check that a service bus namespace is legal and available")).usage("[options] <name>").option("-s, --subscription <id>", $("the subscription id")).execute(function __3(name, options, _) { var service, isAvailable, progress; var __frame = { name: "__3", line: 95 }; return __func(_, this, arguments, __3, 2, __frame, function __$__3() {
return namespaceNameIsValid(name, __cb(_, __frame, 1, 6, function __$__3() {
service = createService(options.subscription);
progress = cli.interaction.progress(util.format($("Checking namespace %s"), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return service.namespaces.checkAvailability(name, __cb(_, __frame, 8, 41, function ___(__0, __1) { isAvailable = __1.isAvailable; _(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() {
cli.interaction.formatOutput({ available: isAvailable }, function(outputData) {
if (outputData.available) {
log.data(util.format($("Namespace %s is available"), name)); }
else {
log.data(util.format($("Namespace %s is not available"), name)); } ; }); _(); }); }); }, true)); }); });
sbnamespace.command("create [namespace] [region]").description($("Create a service bus namespace")).usage("[options] <namespace> <region>").option("-n, --namespace <namespace>", $("the namespace name")).option("-r, --region <region>", $("the region to create the namespace in")).option("-s, --subscription <id>", $("the subscription id")).execute(function __4(namespace, region, options, _) { var service, progress, createdNamespace; var __frame = { name: "__4", line: 123 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() {
service = createService(options.subscription);
return cli.interaction.promptIfNotGiven($("Namespace name: "), namespace, __cb(_, __frame, 3, 34, function ___(__0, __1) { namespace = __1;
return cli.interaction.chooseIfNotGiven($("Region: "), $("Getting regions"), region, function(cb) {
service.getServiceBusRegions(function(err, regions) {
if (err) { return cb(err); } ;
cb(null, regions.regions.map(function(region) { return region.code; })); }); }, __cb(_, __frame, 4, 31, function ___(__0, __2) { region = __2;
progress = cli.interaction.progress(util.format($("Creating namespace %s in region %s"), namespace, region));
return service.namespaces.create(namespace, region, __cb(_, __frame, 12, 48, function ___(__0, __3) { createdNamespace = __3.namespace;
progress.end();
cli.interaction.formatOutput(createdNamespace, function(outputData) {
Object.keys(outputData).forEach(function(key) {
log.data(util.format($("%s: %s"), key, outputData[key])); }); }); _(); }, true)); }, true)); }, true)); }); });
sbnamespace.command("delete [namespace]").description($("Delete a service bus namespace")).option("-n, --namespace <namespace>", $("the namespace name")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <id>", $("the subscription id")).execute(function __5(namespace, options, _) { var service, progress; var __frame = { name: "__5", line: 150 }; return __func(_, this, arguments, __5, 2, __frame, function __$__5() {
return cli.interaction.promptIfNotGiven($("Namespace name: "), namespace, __cb(_, __frame, 1, 34, function ___(__0, __2) { namespace = __2; return (function __$__5(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete namespace %s? [y/n] "), namespace), __cb(_, __frame, 3, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -149, 18, function ___(__0, __3) { return (function __$__5(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$__5() {
service = createService(options.subscription);
progress = cli.interaction.progress(util.format($("Deleting namespace %s"), namespace)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() {
return service.namespaces.deleteMethod(namespace, __cb(_, __frame, 11, 27, function __$__5() { _(null, null, true); }, 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() { _(); }); }); }); }, true)); }, true)); }); });
var location = sbnamespace.category("location").description($("Commands to manage your Service Bus locations"));
location.list = location.command("list").description($("Show list of available service bus locations")).option("-s, --subscription <id>", $("the subscription id")).execute(function __6(options, _) { var service, progress, regions; var __frame = { name: "__6", line: 173 }; return __func(_, this, arguments, __6, 1, __frame, function __$__6() {
service = createService(options.subscription);
progress = cli.interaction.progress($("Getting locations")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() {
return service.getServiceBusRegions(__cb(_, __frame, 5, 26, function ___(__0, __1) { regions = __1.regions; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__6() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__6() {
cli.interaction.formatOutput(regions, function(outputData) {
log.table(outputData, function(row, region) {
row.cell($("Name"), region.fullName);
row.cell($("Code"), region.code); }); }); _(); }); }); }); });
function createService(subscription) {
return utils.createServiceBusClient(profile.current.getSubscription(subscription)); };};