azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
186 lines (91 loc) • 9.44 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; var util = require("util");
var profile = require("../../util/profile");
var utils = require("../../util/utils");
var WebsitesClient = require("./websites/websitesclient");
var $ = utils.getLocaleString;
exports.init = function(cli) {
var log = cli.output;
var site = cli.category("site");
var siteConnectionStrings = site.category("connectionstring").description($("Commands to manage your Web Site connection strings"));
siteConnectionStrings.command("list [name]").usage("[options] [name]").description($("Show your site application settings")).option("--slot <slot>", $("the name of the slot")).option("-s, --subscription <id>", $("the subscription id")).execute(function __1(name, options, _) { var parsedSiteName, context, siteConfigurations; var __frame = { name: "__1", line: 36 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
parsedSiteName = WebsitesClient.parseSiteName(name);
context = {
subscription: profile.current.getSubscription(options.subscription).id,
site: {
name: parsedSiteName.name,
slot: (options.slot ? options.slot : parsedSiteName.slot) } };
return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 10, 11, function __$__1() {
return site.doSiteConfigGet(context, __cb(_, __frame, 12, 36, function ___(__0, __1) { siteConfigurations = __1;
cli.interaction.formatOutput(siteConfigurations.connectionStrings, function(data) {
if ((data.length > 0)) {
log.table(data, function(row, item) {
row.cell($("Name"), item.name);
row.cell($("Type"), item.type); }); }
else {
log.info($("No connection strings defined yet")); } ; }); _(); }, true)); }, true)); }); });
siteConnectionStrings.command("add [connectionname] [value] [type] [name]").usage("[options] <connectionname> <value> <type> [name]").description($("Add a connection string to your site")).option("--slot <slot>", $("the name of the slot")).option("-c, --connectionname <connectionname>", $("the connection string name")).option("-v, --value <value>", $("the connection string value")).option("-t, --type <type>", $("the connection string type")).option("-s, --subscription <id>", $("the subscription id")).execute(function __2(connectionname, value, type, name, options, _) { var parsedSiteName, context, siteConfigurations; var __frame = { name: "__2", line: 69 }; return __func(_, this, arguments, __2, 5, __frame, function __$__2() {
return cli.interaction.promptIfNotGiven($("Connection String Name: "), connectionname, __cb(_, __frame, 1, 39, function ___(__0, __1) { connectionname = __1;
return cli.interaction.promptIfNotGiven($("Connection String Value: "), value, __cb(_, __frame, 2, 30, function ___(__0, __2) { value = __2;
return cli.interaction.chooseIfNotGiven($("Connection String Type: "), $("Getting types"), type, function(cb) {
cb(null, ["SQLAzure","SQLServer","Custom","MySql",]); }, __cb(_, __frame, 3, 29, function ___(__0, __3) { type = __3;
if (utils.ignoreCaseEquals(type, "SQLAzure")) {
type = 2; } else {
if (utils.ignoreCaseEquals(type, "SQLServer")) {
type = 1; } else {
if (utils.ignoreCaseEquals(type, "Custom")) {
type = 3; } else {
if (utils.ignoreCaseEquals(type, "MySql")) {
type = 0; }
else {
return _(new Error($("Invalid connection string type. Valid types are: SQLAzure, SQLServer, Custom or MySql"))); } ; } ; } ; } ;
parsedSiteName = WebsitesClient.parseSiteName(name);
context = {
subscription: profile.current.getSubscription(options.subscription).id,
site: {
name: parsedSiteName.name,
slot: (options.slot ? options.slot : parsedSiteName.slot) } };
return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 29, 11, function __$__2() {
return site.doSiteConfigGet(context, __cb(_, __frame, 30, 36, function ___(__0, __4) { siteConfigurations = __4;
siteConfigurations.connectionStrings.push({
connectionString: value,
name: connectionname,
type: type });
return site.doSiteConfigPUT(siteConfigurations, context, __cb(_, __frame, 37, 11, function __$__2() { _(); }, true)); }, true)); }, true)); }, true)); }, true)); }, true)); }); });
siteConnectionStrings.command("delete [connectionname] [name]").usage("[options] <connectionname> [name]").description($("Delete a connection string for your site")).option("--slot <slot>", $("the name of the slot")).option("-c, --connectionname <connectionname>", $("the connection string name")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <id>", $("the subscription id")).execute(function __3(connectionname, name, options, _) { var parsedSiteName, context, siteConfigurations, found, i; var __frame = { name: "__3", line: 116 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() {
return cli.interaction.promptIfNotGiven($("Connection String Name: "), connectionname, __cb(_, __frame, 1, 39, function ___(__0, __2) { connectionname = __2; return (function __$__3(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Deleteconnection string %s? [y/n] "), connectionname), __cb(_, __frame, 3, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -115, 18, function ___(__0, __3) { return (function __$__3(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$__3() {
parsedSiteName = WebsitesClient.parseSiteName(name);
context = {
subscription: profile.current.getSubscription(options.subscription).id,
site: {
name: parsedSiteName.name,
slot: (options.slot ? options.slot : parsedSiteName.slot) } };
return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 16, 11, function __$__3() {
return site.doSiteConfigGet(context, __cb(_, __frame, 17, 36, function ___(__0, __4) { siteConfigurations = __4;
found = false; return (function __$__3(__then) {
if (siteConfigurations.connectionStrings) {
for (i = 0; (i < siteConfigurations.connectionStrings.length); i++) {
if (utils.ignoreCaseEquals(siteConfigurations.connectionStrings[i].name, connectionname)) {
siteConfigurations.connectionStrings.splice(i, 1);
found = true;
i--; } ; }; return (function __$__3(__then) {
if (found) {
return site.doSiteConfigPUT(siteConfigurations, context, __cb(_, __frame, 30, 15, __then, true)); } else { __then(); } ; })(__then); } else { __then(); } ; })(function __$__3() {
if (!found) {
return _(new Error(util.format($("Connection string with name \"%s\" does not exist"), connectionname))); } ; _(); }); }, true)); }, true)); }); }, true)); }, true)); }); });
siteConnectionStrings.command("show [connectionname] [name]").usage("[options] <connectionname> [name]").description($("Show a connection string for your site")).option("--slot <slot>", $("the name of the slot")).option("-c, --connectionname <connectionname>", $("the connection string name")).option("-s, --subscription <id>", $("the subscription id")).execute(function __4(connectionname, name, options, _) { var parsedSiteName, context, siteConfigurations, match; var __frame = { name: "__4", line: 161 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() {
return cli.interaction.promptIfNotGiven($("Connection String Name: "), connectionname, __cb(_, __frame, 1, 39, function ___(__0, __1) { connectionname = __1;
parsedSiteName = WebsitesClient.parseSiteName(name);
context = {
subscription: profile.current.getSubscription(options.subscription).id,
site: {
name: parsedSiteName.name,
slot: (options.slot ? options.slot : parsedSiteName.slot) } };
return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 12, 11, function __$__4() {
return site.doSiteConfigGet(context, __cb(_, __frame, 13, 36, function ___(__0, __2) { siteConfigurations = __2;
match = siteConfigurations.connectionStrings.filter(function(c) { return utils.ignoreCaseEquals(c.name, connectionname); })[0];
if (match) {
cli.interaction.formatOutput(match, function(data) {
cli.interaction.logEachData($("Connection String"), data); }); }
else {
return _(new Error(util.format($("Connection string with name \"%s\" does not exist"), connectionname))); } ; _(); }, true)); }, true)); }, true)); }); });};