azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
963 lines (415 loc) • 43.5 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 util = require("util");
var profile = require("../../../util/profile");
var utils = require("../../../util/utils");
var rediscacheUtils = require("./rediscacheUtils");
var resourceUtils = require("../resource/resourceUtils");
var $ = utils.getLocaleString;
var SKU_TYPE = ["Basic","Standard","Premium",];
var VM_SIZE = ["C0","C1","C2","C3","C4","C5","C6","P1","P2","P3","P4",];
var KEY_TYPE = ["Primary","Secondary",];
var DefaultRedisVersion = "3.0";
exports.init = function(cli) {
var log = cli.output;
var rediscache = cli.category("rediscache").description($("Commands to manage your Azure Redis Cache(s)"));
rediscache.command("create [name] [resource-group] [location]").description($("Create a Redis Cache")).usage("[--name <name> --resource-group <resource-group> --location <location> [options]]").option("-n, --name <name>", $("Name of the Redis Cache.")).option("-g, --resource-group <resource-group>", $("Name of the Resource Group")).option("-l, --location <location>", $("Location to create cache.")).option("-z, --size <size>", util.format($("Size of the Redis Cache. Valid values: [%s]"), VM_SIZE.join(", "))).option("-x, --sku <sku>", util.format($("Redis SKU. Should be one of : [%s]"), SKU_TYPE.join(", "))).option("-e, --enable-non-ssl-port", $("EnableNonSslPort property of the Redis Cache. Add this flag if you want to enable the Non SSL Port for your cache")).option("-c, --redis-configuration <redis-configuration>", $("Redis Configuration. Enter a JSON formatted string of configuration keys and values here. Format:\"{\"<key1>\":\"<value1>\",\"<key2>\":\"<value2>\"}\"")).fileRelatedOption("-f, --redis-configuration-file <redisConfigurationFile>", $("Redis Configuration. Enter the path of a file containing configuration keys and values here. Format for the file entry: {\"<key1>\":\"<value1>\",\"<key2>\":\"<value2>\"}")).option("-r, --shard-count <shard-count>", $("Number of Shards to create on a Premium Cluster Cache")).option("-v, --virtual-network <virtual-network>", $("The exact ARM resource ID of the virtual network to deploy the redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1")).option("-t, --subnet <subnet>", $("Required when deploying a redis cache inside an existing Azure Virtual Network")).option("-p, --static-ip <static-ip>", $("Required when deploying a redis cache inside an existing Azure Virtual Network")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __1(name, resourceGroup, location, options, _) { var validatedSkuVM, skuFamily, skuCapacity, subscription, client, checkRedisCacheProgress, redisCacheNameExists, skuProperties, parameters, redisConfigurationHashTable, indexSku, progress, callbackArgs, result, response; var __frame = { name: "__1", line: 64 }; return __func(_, this, arguments, __1, 4, __frame, function __$__1() {
log.verbose(("arguments: " + JSON.stringify({
name: name,
options: options })));
options.name = (options.name || name);
options.resourceGroup = (options.resourceGroup || resourceGroup);
options.location = (options.location || location);
if (!options.name) {
return _(null, cli.missingArgument("name")); } else {
if (!options.resourceGroup) {
return _(null, cli.missingArgument("resource-group")); } else {
if (!options.location) {
return _(null, cli.missingArgument("location")); } ; } ; } ;
if ((options.redisConfiguration && options.redisConfigurationFile)) {
return _(new Error("Only one argument among redis-configuration or redis-configuration-file is allowed. Not both")); } ;
if (options.enableNonSslPort) {
options.enableNonSslPort = true; }
else {
options.enableNonSslPort = false; } ;
validatedSkuVM = rediscacheUtils.parseSkuVM(options.sku, options.size);
options.sku = validatedSkuVM.sku;
options.size = validatedSkuVM.vmSize;
skuFamily = options.size.substring(0, 1);
skuCapacity = parseInt(options.size.substring(1));
subscription = profile.current.getSubscription();
client = utils.createRedisCacheManagementClient(subscription);
checkRedisCacheProgress = cli.interaction.progress(util.format($("")));
redisCacheNameExists = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return client.redis.get(options.resourceGroup, options.name, __cb(_, __frame, 56, 42, function ___(__0, __1) { redisCacheNameExists = __1; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) {
if (((e.statusCode !== 404))) {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__1() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__1() {
checkRedisCacheProgress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__1() {
if (redisCacheNameExists) {
return _(new Error(util.format($("The requested cache name is unavailable: %s"), options.name))); } ;
skuProperties = {
capacity: skuCapacity,
family: skuFamily,
name: options.sku };
parameters = {
location: options.location,
redisVersion: DefaultRedisVersion,
enableNonSslPort: options.enableNonSslPort,
sku: skuProperties };
if ((options.redisConfiguration || options.redisConfigurationFile)) {
redisConfigurationHashTable = rediscacheUtils.getValidRedisConfiguration(options);
parameters.redisConfiguration = redisConfigurationHashTable; } ;
indexSku = SKU_TYPE.indexOf(options.sku);
if (((indexSku < 2) && (((((options.shardCount) || (options.virtualNetwork)) || (options.subnet)) || (options.staticIp))))) {
return _(new Error("ShardCount/VirtualNetwork are features supported only by Premium Sku")); } ;
if ((options.sku == SKU_TYPE[2])) {
if (options.shardCount) { parameters.shardCount = parseInt(options.shardCount); } ;
if (options.virtualNetwork) { parameters.virtualNetwork = options.virtualNetwork; } ;
if (options.subnet) { parameters.subnet = options.subnet; } ;
if (options.staticIp) { parameters.staticIP = options.staticIp; } ; } ;
progress = cli.interaction.progress(util.format($("Attempting to create Redis Cache %s ..."), options.name));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return client.redis.createOrUpdate(options.resourceGroup, options.name, parameters, __cb(_, __frame, 109, 34, function ___(__0, __2) { callbackArgs = __2;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) {
if ((e.code === "NameNotAvailable")) {
return _(new Error(util.format($("The requested cache name is unavailable: %s"), options.name))); }
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() {
cli.interaction.formatOutput(result, function(data) {
if (!data) {
log.info($("No Redis Cache information available")); }
else {
log.data("");
log.data($("Provisioning State :"), result.provisioningState);
log.data("");
log.data($("Cache Name :"), result.name);
log.data($("Resource Group :"), options.resourceGroup);
log.data($("Location :"), result.location);
log.data($("Host Name :"), result.hostName);
log.data($("Port :"), result.port);
log.data($("SSL Port :"), result.sslPort);
log.data($("Non SSL Enabled :"), result.enableNonSslPort.toString());
log.data($("Redis Version :"), result.redisVersion);
log.data($("Sku :"), result.sku.name);
log.data($("Size :"), (result.sku.family + result.sku.capacity.toString()));
log.data($("Id :"), result.id);
log.data($("Redis Configuration:"), result.redisConfiguration);
log.data($("Shard Count :"), result.shardCount);
log.data($("Virtual Network :"), result.virtualNetwork);
log.data($("Subnet :"), result.subnet);
log.data($("Static IP :"), result.staticIp);
log.data(""); } ; });
if ((response.statusCode == 200)) {
log.info((("Redis Cache " + options.name) + " is getting created...")); } ; _(); }); }); }); }); }); });
rediscache.command("delete [name] [resource-group]").description($("Delete an existing Redis Cache")).usage("[--name <name> --resource-group <resource-group> ]").option("-n, --name <name>", $("Name of the Redis Cache.")).option("-g, --resource-group <resource-group>", $("Name of the Resource Group under which the cache exists")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __2(name, resourceGroup, options, _) { var subscription, client, SeeIfCacheExists, progress, callbackArgs, result, response; var __frame = { name: "__2", line: 229 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
log.verbose(("arguments: " + JSON.stringify({
name: name,
options: options })));
options.name = (options.name || name);
options.resourceGroup = (options.resourceGroup || resourceGroup);
if (!options.name) {
return _(null, cli.missingArgument("name")); } else {
if (!options.resourceGroup) {
return _(null, cli.missingArgument("resource-group")); } ; } ;
subscription = profile.current.getSubscription();
client = utils.createRedisCacheManagementClient(subscription);
SeeIfCacheExists = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return client.redis.get(options.resourceGroup, options.name, __cb(_, __frame, 33, 38, function ___(__0, __1) { SeeIfCacheExists = __1; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) {
if ((e.code === "ResourceNotFound")) {
return _(new Error(rediscacheUtils.showNotFoundError(options.resourceGroup, options.name))); }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__2() {
progress = cli.interaction.progress(util.format($("Deleting Redis Cache %s"), options.name));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return client.redis.deleteMethod(options.resourceGroup, options.name, __cb(_, __frame, 52, 34, function ___(__0, __2) { callbackArgs = __2;
result = callbackArgs[0];
response = callbackArgs[2]; _(null, null, true); }, 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() {
if ((response.statusCode == 200)) {
log.info(("Delete command successfully invoked for Redis Cache " + options.name)); } ; _(); }); }); }); }); }); });
rediscache.command("list").description($("List all Redis Caches within your Subscription or Resource Group")).usage("[options]").option("-g, --resource-group <resource-group>", $("Name of the Resource Group")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __3(options, _) { var subscription, client, operation, progress, result, i; var __frame = { name: "__3", line: 300 }; return __func(_, this, arguments, __3, 1, __frame, function __$__3() {
subscription = profile.current.getSubscription();
client = utils.createRedisCacheManagementClient(subscription); return (function __$__3(__then) {
if (options.resourceGroup) {
return client.redis.listByResourceGroup(options.resourceGroup, __cb(_, __frame, 14, 31, function ___(__0, __1) { operation = __1; __then(); }, true)); } else {
return client.redis.list(__cb(_, __frame, 17, 31, function ___(__0, __2) { operation = __2; __then(); }, true)); } ; })(function __$__3() {
progress = cli.interaction.progress(util.format($("Getting Redis Cache(s) "))); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
result = operation;
for (i = 0; (i < result.length); ++i) {
result[i].resourceGroup = resourceUtils.getResourceInformation(result[i].id).resourceGroup; }; _(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 ((result.length === 0)) {
log.info($("No redis caches found.")); }
else {
log.table(result, function(row, item) {
row.cell($("Name"), item.name);
row.cell($("Resource Group"), item.resourceGroup);
row.cell($("Location"), item.location);
row.cell($("Host Name"), item.hostName);
row.cell($("Port"), item.port);
row.cell($("ProvisioningState"), item.provisioningState);
row.cell($("SSL Port"), item.sslPort);
row.cell($("Non SSL Enabled"), item.enableNonSslPort);
row.cell($("Redis Version"), item.redisVersion);
row.cell($("Sku"), item.sku.name);
row.cell($("Size"), (item.sku.family + item.sku.capacity.toString()));
row.cell($("Id"), item.id);
row.cell($("Redis Configuration"), item.redisConfiguration);
row.cell($("Shard Count"), item.shardCount);
row.cell($("Virtual Network"), item.virtualNetwork);
row.cell($("Subnet"), item.subnet);
row.cell($("Static IP"), item.staticIp); }); } ;
log.info("Redis Cache Details"); _(); }); }); }); }); });
rediscache.command("show [name] [resource-group]").description($("Show properties of an existing Redis Cache")).usage("[--name <name> --resource-group <resource-group>]").option("-n, --name <name>", $("Name of the Redis Cache.")).option("-g, --resource-group <resource-group>", $("Name of the Resource Group")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(name, resourceGroup, options, _) { var subscription, client, operation, progress, result, progressRG; var __frame = { name: "__4", line: 366 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() {
log.verbose(("arguments: " + JSON.stringify({
name: name,
options: options })));
options.name = (options.name || name);
options.resourceGroup = (options.resourceGroup || resourceGroup);
if (!options.name) {
return _(null, cli.missingArgument("name")); } else {
if (!options.resourceGroup) {
return _(null, cli.missingArgument("resource-group")); } ; } ;
subscription = profile.current.getSubscription(options.subscription);
client = utils.createRedisCacheManagementClient(subscription);
operation = null;
progress = cli.interaction.progress(util.format($("Getting Redis Cache(s) "))); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() {
return client.redis.get(options.resourceGroup, options.name, __cb(_, __frame, 30, 31, function ___(__0, __1) { operation = __1; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) {
if ((e.code === "ResourceNotFound")) {
return _(new Error(rediscacheUtils.showNotFoundError(options.resourceGroup, options.name))); }
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() {
progressRG = cli.interaction.progress(util.format($("Getting Redis Cache(s) Resource Group "))); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() {
result = operation;
result.resourceGroup = resourceUtils.getResourceInformation(result.id).resourceGroup; _(null, null, true); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__4() {
progressRG.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__4() {
cli.interaction.formatOutput(result, function(data) {
if (!data) {
log.info($("No Redis Cache information available")); }
else {
log.data($("Cache Name :"), result.name);
log.data($("Resource Group :"), result.resourceGroup);
log.data($("Location :"), result.location);
log.data($("Host Name :"), result.hostName);
log.data($("Port :"), result.port);
log.data($("Provisioning State :"), result.provisioningState);
log.data($("SSL Port :"), result.sslPort);
log.data($("Non SSL Enabled :"), result.enableNonSslPort.toString());
log.data($("Redis Version :"), result.redisVersion);
log.data($("Sku :"), result.sku.name);
log.data($("Size :"), (result.sku.family + result.sku.capacity.toString()));
log.data($("Id :"), result.id);
log.data($("Redis Configuration:"), result.redisConfiguration);
log.data($("Shard Count :"), result.shardCount);
log.data($("Virtual Network :"), result.virtualNetwork);
log.data($("Subnet :"), result.subnet);
log.data($("Static IP :"), result.staticIp);
log.data(""); } ; });
log.info("Redis Cache Details"); _(); }); }); }); }); }); });
rediscache.command("set [name] [resource-group]").description($("Change settings of an existing Redis Cache")).usage("[--name <name> --resource-group <resource-group> --redis-configuration <redis-configuration>/--redis-configuration-file <redisConfigurationFile>]").option("-n, --name <name>", $("Name of the Redis Cache.")).option("-g, --resource-group <resource-group>", $("Name of the Resource Group")).option("-c, --redis-configuration <redis-configuration>", $("Redis Configuration. Enter a JSON formatted string of configuration keys and values here.")).fileRelatedOption("-f, --redis-configuration-file <redisConfigurationFile>", $("Redis Configuration. Enter the path of a file containing configuration keys and values here.")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __5(name, resourceGroup, options, _) { var subscription, client, progress, operation, result, redisConfigurationHashTable, parameters, updateProgress, updateResult; var __frame = { name: "__5", line: 460 }; return __func(_, this, arguments, __5, 3, __frame, function __$__5() {
log.verbose(("arguments: " + JSON.stringify({
name: name,
options: options })));
options.name = (options.name || name);
options.resourceGroup = (options.resourceGroup || resourceGroup);
if (!options.name) {
return _(null, cli.missingArgument("name")); } else {
if (!options.resourceGroup) {
return _(null, cli.missingArgument("resource-group")); } else {
if ((!options.redisConfiguration && !options.redisConfigurationFile)) {
return _(null, cli.missingArgument("redis-configuration or redis-configuration-file")); } ; } ; } ;
if ((options.redisConfiguration && options.redisConfigurationFile)) {
return _(new Error("Only one argument among redis-configuration or redis-configuration-file is allowed. Not both")); } ;
subscription = profile.current.getSubscription(options.subscription);
client = utils.createRedisCacheManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Getting Redis Cache(s) ")));
operation = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() {
return client.redis.get(options.resourceGroup, options.name, __cb(_, __frame, 36, 31, function ___(__0, __1) { operation = __1; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__5() { if (e) {
if ((e.code === "ResourceNotFound")) {
return _(new Error(rediscacheUtils.showNotFoundError(options.resourceGroup, options.name))); }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__5() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() {
result = operation;
result.resourceGroup = resourceUtils.getResourceInformation(result.id).resourceGroup; _(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() {
redisConfigurationHashTable = rediscacheUtils.getValidRedisConfiguration(options);
parameters = {
location: result.location,
redisVersion: result.redisVersion,
redisConfiguration: redisConfigurationHashTable,
enableNonSslPort: result.enableNonSslPort,
sku: {
capacity: result.sku.capacity,
family: result.sku.family,
name: result.sku.name } };
updateProgress = cli.interaction.progress(util.format($("Updating Redis Cache %s ..."), options.name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() {
return client.redis.createOrUpdate(options.resourceGroup, options.name, parameters, __cb(_, __frame, 72, 34, function ___(__0, __2) { updateResult = __2; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__5() {
updateProgress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__5() {
cli.interaction.formatOutput(updateResult, function(data) {
if (!data) {
log.info($("No Redis Cache information available")); }
else {
log.data($("Provisioning State :"), updateResult.provisioningState);
log.data("");
log.data($("Cache Name :"), updateResult.name);
log.data($("Resource Group :"), updateResult.resourceGroup);
log.data($("Location :"), updateResult.location);
log.data($("Host Name :"), updateResult.hostName);
log.data($("Port :"), updateResult.port);
log.data($("SSL Port :"), updateResult.sslPort);
log.data($("Non SSL Enabled :"), updateResult.enableNonSslPort.toString());
log.data($("Redis Version :"), updateResult.redisVersion);
log.data($("Sku :"), updateResult.sku.name);
log.data($("Size :"), (updateResult.sku.family + updateResult.sku.capacity.toString()));
log.data($("Id :"), updateResult.id);
log.data($("Redis Configuration:"), result.redisConfiguration);
log.data($("Shard Count :"), result.shardCount);
log.data($("Virtual Network :"), result.virtualNetwork);
log.data($("Subnet :"), result.subnet);
log.data($("Static IP :"), result.staticIp);
log.data(""); } ; });
log.info((("Redis Cache " + options.name) + " is getting updated ")); _(); }); }); }); }); }); }); }); });
rediscache.command("renew-key [name] [resource-group]").description($("Renew the authentication key for an existing Redis Cache")).usage("[--name <name> --resource-group <resource-group> ]").option("-n, --name <name>", $("Name of the Redis Cache.")).option("-g, --resource-group <resource-group>", $("Name of the Resource Group under which cache exists")).option("-t, --key-type <key-type>", $("type of key to renew. Valid values are: 'Primary', 'Secondary'.")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __6(name, resourceGroup, options, _) { var subscription, client, SeeIfCacheExists, progress, callbackArgs, result, response; var __frame = { name: "__6", line: 575 }; return __func(_, this, arguments, __6, 3, __frame, function __$__6() {
log.verbose(("arguments: " + JSON.stringify({
name: name,
options: options })));
options.name = (options.name || name);
options.resourceGroup = (options.resourceGroup || resourceGroup);
if (!options.name) {
return _(null, cli.missingArgument("name")); } else {
if (!options.resourceGroup) {
return _(null, cli.missingArgument("resource-group")); } ; } ;
options.keyType = rediscacheUtils.parseEnumArgument("key-type", options.keyType, KEY_TYPE, KEY_TYPE[0]);
subscription = profile.current.getSubscription();
client = utils.createRedisCacheManagementClient(subscription);
SeeIfCacheExists = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() {
return client.redis.get(options.resourceGroup, options.name, __cb(_, __frame, 36, 38, function ___(__0, __1) { SeeIfCacheExists = __1.resource; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__6() { if (e) {
if ((e.code === "ResourceNotFound")) {
return _(new Error(rediscacheUtils.showNotFoundError(options.resourceGroup, options.name))); }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__6() {
progress = cli.interaction.progress(util.format($("Renewing %s key for Redis Cache %s"), options.keyType.toString(), options.name));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() {
return client.redis.regenerateKey(options.resourceGroup, options.name, options.keyType, __cb(_, __frame, 55, 34, function ___(__0, __2) { callbackArgs = __2;
result = callbackArgs[0];
response = callbackArgs[2]; _(null, null, true); }, 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() {
if ((response.statusCode == 200)) {
cli.interaction.formatOutput(result, function(data) {
if (!data) {
log.info($("No Redis Cache information available")); }
else {
log.data($("Primary Key :"), result.primaryKey);
log.data($("Secondary Key :"), result.secondaryKey);
log.data(""); } ; }); }
else {
log.error(("Could not renew key for Redis Cache " + options.name)); } ;
log.info(((options.keyType + " Key renewed for Redis Cache ") + options.name)); _(); }); }); }); }); }); });
rediscache.command("list-keys [name] [resource-group]").description($("Lists Primary and Secondary key of an existing Redis Cache")).usage("[--name <name> --resource-group <resource-group>]").option("-n, --name <name>", $("Name of the Redis Cache.")).option("-g, --resource-group <resource-group>", $("Name of the Resource Group under which Cache exists")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __7(name, resourceGroup, options, _) { var subscription, client, SeeIfCacheExists, progress, result; var __frame = { name: "__7", line: 662 }; return __func(_, this, arguments, __7, 3, __frame, function __$__7() {
log.verbose(("arguments: " + JSON.stringify({
name: name,
options: options })));
options.name = (options.name || name);
options.resourceGroup = (options.resourceGroup || resourceGroup);
if (!options.name) {
return _(null, cli.missingArgument("name")); } else {
if (!options.resourceGroup) {
return _(null, cli.missingArgument("resource-group")); } ; } ;
subscription = profile.current.getSubscription();
client = utils.createRedisCacheManagementClient(subscription);
SeeIfCacheExists = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__7() {
return client.redis.get(options.resourceGroup, options.name, __cb(_, __frame, 34, 38, function ___(__0, __1) { SeeIfCacheExists = __1.resource; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__7() { if (e) {
if ((e.code === "ResourceNotFound")) {
return _(new Error(rediscacheUtils.showNotFoundError(options.resourceGroup, options.name))); }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__7() {
progress = cli.interaction.progress(util.format($("Getting keys for Redis Cache %s ..."), options.name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__7() {
return client.redis.listKeys(options.resourceGroup, options.name, __cb(_, __frame, 52, 28, function ___(__0, __2) { result = __2; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__7() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__7() {
cli.interaction.formatOutput(result, function(data) {
if (!data) {
log.info($("No Redis Cache information available")); }
else {
log.data($("Primary Key :"), result.primaryKey);
log.data($("Secondary Key :"), result.secondaryKey);
log.data(""); } ; });
log.info((" Keys for Redis Cache " + options.name)); _(); }); }); }); }); }); });
rediscache.command("set-diagnostics [name] [resource-group] [storage-account-name] [storage-account-resource-group]").description($("Sets diagnostics on an existing Redis Cache using the storage account specified")).usage("[--name <name> --resource-group <resource-group> --storage-account-name <storage-account-name> --storage-account-resource-group <storage-account-resource-group>]").option("-n, --name <name>", $("Name of the Redis Cache.")).option("-g, --resource-group <resource-group>", $("Name of the Resource Group under which Cache exists")).option("-x, --storage-account-name <storage-account-name>", $("Name of the Storage Account.")).option("-b, --storage-account-resource-group <storage-account-resource-group>", $("Name of the Resource Group under which the Storage Account exists")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __8(name, resourceGroup, storageAccountName, storageAccountResourceGroup, options, _) { var subscription, client, insightsClient, cacheDetails, redisCacheResourceId, putParameters, getResponse, properties, i, insightsAccountSet, insightsProgress; var __frame = { name: "__8", line: 741 }; return __func(_, this, arguments, __8, 5, __frame, function __$__8() {
log.verbose(("arguments: " + JSON.stringify({
name: name,
options: options })));
options.name = (options.name || name);
options.resourceGroup = (options.resourceGroup || resourceGroup);
options.storageAccountName = (options.storageAccountName || storageAccountName);
options.storageAccountResourceGroup = (options.storageAccountResourceGroup || storageAccountResourceGroup);
if (!options.name) {
return _(null, cli.missingArgument("name")); } else {
if (!options.resourceGroup) {
return _(null, cli.missingArgument("resource-group")); } else {
if (!options.storageAccountName) {
return _(null, cli.missingArgument("storage-account-name")); } else {
if (!options.storageAccountResourceGroup) {
return _(null, cli.missingArgument("storage-account-resource-group")); } ; } ; } ; } ;
subscription = profile.current.getSubscription();
client = utils.createRedisCacheManagementClient(subscription);
insightsClient = utils.createInsightsManagementClient(subscription); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__8() {
return client.redis.get(options.resourceGroup, options.name, __cb(_, __frame, 43, 34, function ___(__0, __1) { cacheDetails = __1; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__8() { if (e) {
if ((e.code === "ResourceNotFound")) {
return _(new Error(rediscacheUtils.showNotFoundError(options.resourceGroup, options.name))); }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__8() {
redisCacheResourceId = cacheDetails.id;
putParameters = { };
return insightsClient.serviceDiagnosticSettingsOperations.get(redisCacheResourceId, __cb(_, __frame, 93, 73, function ___(__0, __2) { getResponse = __2;
properties = getResponse.properties;
properties.storageAccountName = options.storageAccountName;
i = 0;
for (i = 0; (i < properties.logs.length); i++) {
properties.logs[i].enabled = true; };
for (i = 0; (i < properties.metrics.length); i++) {
properties.metrics[i].enabled = true; };
putParameters.properties = properties; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__8() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__8() {
insightsProgress = cli.interaction.progress(util.format($("Enabling diagnostics")));
return insightsClient.serviceDiagnosticSettingsOperations.put(redisCacheResourceId, putParameters, __cb(_, __frame, 116, 78, function ___(__0, __3) { insightsAccountSet = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__8() { if (e) {
log.error($("Could not enable Diagnostics. Error Details :"));
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__8() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__8() {
insightsProgress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__8() {
if (insightsAccountSet) {
log.info((" Successfully enabled Diagnostics for Cache " + options.name)); } ; _(); }); }); }, true)); }); }); }); });
rediscache.command("delete-diagnostics [name] [resource-group]").description($("Removes diagnostics on an existing Redis Cache")).usage("[--name <name> --resource-group <resource-group>]").option("-n, --name <name>", $("Name of the Redis Cache.")).option("-g, --resource-group <resource-group>", $("Name of the Resource Group under which Cache exists")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __9(name, resourceGroup, options, _) { var subscription, client, insightsClient, cacheDetails, redisCacheResourceId, putParameters, getResponse, properties, i, insightsAccountSet, insightsProgress; var __frame = { name: "__9", line: 877 }; return __func(_, this, arguments, __9, 3, __frame, function __$__9() {
log.verbose(("arguments: " + JSON.stringify({
name: name,
options: options })));
options.name = (options.name || name);
options.resourceGroup = (options.resourceGroup || resourceGroup);
if (!options.name) {
return _(null, cli.missingArgument("name")); } else {
if (!options.resourceGroup) {
return _(null, cli.missingArgument("resource-group")); } ; } ;
subscription = profile.current.getSubscription();
client = utils.createRedisCacheManagementClient(subscription);
insightsClient = utils.createInsightsManagementClient(subscription); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__9() {
return client.redis.get(options.resourceGroup, options.name, __cb(_, __frame, 35, 34, function ___(__0, __1) { cacheDetails = __1; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__9() { if (e) {
if ((e.code === "ResourceNotFound")) {
return _(new Error(rediscacheUtils.showNotFoundError(options.resourceGroup, options.name))); }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__9() {
redisCacheResourceId = cacheDetails.id;
putParameters = { };
return insightsClient.serviceDiagnosticSettingsOperations.get(redisCacheResourceId, __cb(_, __frame, 53, 73, function ___(__0, __2) { getResponse = __2;
properties = getResponse.properties;
properties.storageAccountName = null;
i = 0;
for (i = 0; (i < properties.logs.length); i++) {
properties.logs[i].enabled = false; };
for (i = 0; (i < properties.metrics.length); i++) {
properties.metrics[i].enabled = false; };
putParameters.properties = properties; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__9() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__9() {
insightsProgress = cli.interaction.progress(util.format($("Disabling diagnostics")));
return insightsClient.serviceDiagnosticSettingsOperations.put(redisCacheResourceId, putParameters, __cb(_, __frame, 76, 78, function ___(__0, __3) { insightsAccountSet = __3; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__9() { if (e) {
log.error($("Could not disable Diagnostics. Error Details :"));
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__9() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__9() {
insightsProgress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__9() {
if (insightsAccountSet) {
log.info((" Successfully disabled Diagnostics for Cache " + options.name)); } ; _(); }); }); }, true)); }); }); }); });};