UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

139 lines (73 loc) 6.76 kB
/*** 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,__tryCatch=__rt.__tryCatch; var __ = require("underscore"); var util = require("util"); var utils = require("../../../util/utils"); var StorageUtil = require("../../../util/storage.util"); var $ = utils.getLocaleString; function AemExtensionUtil(cli) { this.cli = cli;}; __.extend(AemExtensionUtil.prototype, { getStorageAccountProperties: function getStorageAccountProperties__1(serviceClients, storageAccounts, storageAccountName, _) { var saProperties, resourceGroupName, pattern, i, match, keys; var __frame = { name: "getStorageAccountProperties__1", line: 28 }; return __func(_, this, arguments, getStorageAccountProperties__1, 3, __frame, function __$getStorageAccountProperties__1() { saProperties = { }; saProperties.name = storageAccountName; resourceGroupName = null; storageAccountName = storageAccountName.toLowerCase(); pattern = new RegExp((("resourceGroups/(.+?)/.*/storageAccounts/" + storageAccountName) + "$")); for (i = 0; (i < storageAccounts.length); i++) { storageAccount = storageAccounts[i]; match = pattern.exec(storageAccount.id); if ((match && match[1])) { resourceGroupName = match[1]; if ((storageAccount.sku.name.slice(0, "Standard".length) === "Standard")) { saProperties.type = "Standard"; } else { saProperties.type = "Premium"; } ; saProperties.endpoints = storageAccount.primaryEndpoints; break; } ; }; if (!resourceGroupName) { return _(new Error(util.format($("Failed to get resource group name for storage account \"%s\""), storageAccountName))); } ; StorageUtil.startProgress(util.format($("Getting keys for storage account: \"%s\""), storageAccountName)); keys = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getStorageAccountProperties__1() { return serviceClients.storageManagementClient.storageAccounts.listKeys(resourceGroupName, storageAccountName, __cb(_, __frame, 31, 68, function ___(__0, __1) { keys = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getStorageAccountProperties__1() { StorageUtil.endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getStorageAccountProperties__1() { saProperties.key = keys.keys[0].value; return _(null, saProperties); }); }); }); }, enableStorageAccountAnalytics: function enableStorageAccountAnalytics__2(saProperties, _) { var options, client, getOperation, tips, loggingProperties, setOperation, defaultLoggingPerperties, __this = this; var __frame = { name: "enableStorageAccountAnalytics__2", line: 68 }; return __func(_, this, arguments, enableStorageAccountAnalytics__2, 1, __frame, function __$enableStorageAccountAnalytics__2() { options = { accountName: saProperties.name, accountKey: saProperties.key }; StorageUtil.init(__this.cli); client = StorageUtil.getServiceClient(StorageUtil.getBlobService, options); getOperation = StorageUtil.getStorageOperation(client, StorageUtil.OperationType.Blob, "getServiceProperties"); tips = null; loggingProperties = null; tips = util.format($("Checking storage logging properties for: %s"), saProperties.name); StorageUtil.startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$enableStorageAccountAnalytics__2() { return StorageUtil.performStorageOperation(getOperation, __cb(_, __frame, 17, 38, function ___(__0, __1) { loggingProperties = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$enableStorageAccountAnalytics__2() { StorageUtil.endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$enableStorageAccountAnalytics__2() { return (function __$enableStorageAccountAnalytics__2(__then) { if (((((((((((!loggingProperties || !loggingProperties.Logging) || !loggingProperties.Logging.Read) || !loggingProperties.Logging.Write) || !loggingProperties.Logging.Delete) || !loggingProperties.MinuteMetrics) || !loggingProperties.MinuteMetrics.Enabled) || !loggingProperties.MinuteMetrics.RetentionPolicy) || !loggingProperties.MinuteMetrics.RetentionPolicy.Enabled) || !loggingProperties.MinuteMetrics.RetentionPolicy.Days) || (loggingProperties.MinuteMetrics.RetentionPolicy.Days === 0))) { __this.cli.output.info(util.format($("Logging is not enabled for storage account \"%s\""), saProperties.name)); tips = util.format($("Setting storage logging properties for: %s"), saProperties.name); StorageUtil.startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$enableStorageAccountAnalytics__2() { setOperation = StorageUtil.getStorageOperation(client, StorageUtil.OperationType.Blob, "setServiceProperties"); defaultLoggingPerperties = __this.getDefaultLoggingPerperties(); return StorageUtil.performStorageOperation(setOperation, __cb(_, __frame, 39, 20, function __$enableStorageAccountAnalytics__2() { _(null, null, true); }, true), defaultLoggingPerperties); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$enableStorageAccountAnalytics__2() { StorageUtil.endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, __then); }); } else { __then(); } ; })(_); }); }); }); }, getDefaultLoggingPerperties: function() { return { Logging: { Version: "1.0", Delete: true, Read: true, Write: true, RetentionPolicy: { Enabled: true, Days: 13 } }, HourMetrics: { Version: "1.0", Enabled: true, IncludeAPIs: true, RetentionPolicy: { Enabled: true, Days: 13 } }, MinuteMetrics: { Version: "1.0", Enabled: true, IncludeAPIs: true, RetentionPolicy: { Enabled: true, Days: 13 } } }; }}); module.exports = AemExtensionUtil;