UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

934 lines (375 loc) 63.6 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,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var storage = require("azure-storage"); var StorageUtil = require("../../util/storage.util"); var util = require("util"); var pathUtil = require("path"); var fs = require("fs"); var utils = require("../../util/utils"); var validation = require("../../util/validation"); var commander = require("commander"); var performStorageOperation = StorageUtil.performStorageOperation; var startProgress = StorageUtil.startProgress; var endProgress = StorageUtil.endProgress; var SpeedSummary = storage.BlobService.SpeedSummary; var __ = require("underscore"); var $ = utils.getLocaleString; commander.Command.prototype.addStorageAccountOption = function() { this.option("-a, --account-name <accountName>", $("the storage account name or omit it to use environment variable [AZURE_STORAGE_ACCOUNT]")); this.option("-k, --account-key <accountKey>", $("the storage account key or omit it to use environment variable [AZURE_STORAGE_ACCESS_KEY]")); this.option("-c, --connection-string <connectionString>", $("the storage connection string or omit it to use environment variable [AZURE_STORAGE_CONNECTION_STRING]")); this.option("-vv", $("run storage command in debug mode")); return this;}; exports.init = function(cli) { StorageUtil.init(cli); var storage = cli.category("storage").description($("Commands to manage your Storage objects")); var logger = cli.output; var interaction = cli.interaction; var share = storage.category("share").description($("Commands to manage your Storage file shares")); share.command("create [share]").description($("Create a storage file share")).option("--share <share>", $("the storage file share name")).option("--quota <quota>", $("the storage file share quota (in GB)")).addStorageAccountOption().execute(createShare); share.command("show [share]").description($("Show details of the storage file share")).option("--share <share>", $("the storage file share name")).addStorageAccountOption().execute(showShare); share.command("set [share]").description($("Set properties of the storage file share")).option("--share <share>", $("the storage file share name")).option("--quota <quota>", $("the storage file share quota (in GB)")).addStorageAccountOption().execute(setShare); share.command("delete [share]").description($("Delete the specified storage file share")).option("--share <share>", $("the storage file share name")).option("-q, --quiet", $("remove the specified storage file share without confirmation")).addStorageAccountOption().execute(deleteShare); share.command("list [prefix]").description($("List storage shares with prefix")).option("-p, --prefix <prefix>", $("the storage share name prefix")).addStorageAccountOption().execute(listShares); var shareSas = share.category("sas").description($("Commands to manage shared access signatures of your Storage file shares")); shareSas.command("create [share] [permissions] [expiry]").description($("Generate shared access signature of storage share")).option("--share <share>", $("the storage share name")).option("--permissions <permissions>", $("the operation permissions combining symbols of r(Read)/w(Write)/d(Delete)/l(List)")).option("--protocol <protocol>", $("the protocol permitted for a request made with the SAS. Possible values are HttpsOnly and HttpsOrHttp")).option("--ip-range <ipRange>", $("an IP address or a range of IP addresses from which to accept requests. When specifying a range of IP addresses, note that the range is inclusive. For example, specifying 168.1.5.65 or 168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses.")).option("--start <start>", $("the UTC time at which the SAS becomes valid")).option("--expiry <expiry>", $("the UTC time at which the SAS expires")).option("--policy <policy>", $("the stored access policy identifier")).addStorageAccountOption().execute(createShareSas); var policy = share.category("policy").description($("Commands to manage stored access policies of your Storage file share")); policy.command("create [share] [name]").usage("[options] [share] [name]").description($("Create a stored access policy on the share")).option("--share <share>", $("the storage share name")).option("--name <name>", $("the policy name")).option("--start <start>", $("the UTC time at which the policy becomes valid")).option("--expiry <expiry>", $("the UTC time at which the policy expires")).option("--permissions <permissions>", $("the operation permissions combining symbols of r(Read)/w(Write)/d(Delete)/l(List)")).addStorageAccountOption().execute(createSharePolicy); policy.command("show [share] [name]").usage("[options] [share] [name]").description($("Show a stored access policy on the share")).option("--share <share>", $("the storage share name")).option("--name <name>", $("the policy name")).addStorageAccountOption().execute(showSharePolicy); policy.command("list [share]").usage("[options] [share]").description($("List stored access policies on the share")).option("--share <share>", $("the storage share name")).addStorageAccountOption().execute(listSharePolicy); policy.command("set [share] [name]").usage("[options] [share] [name]").description($("Set a stored access policy on the share")).option("--share <share>", $("the storage share name")).option("--name <name>", $("the policy name")).option("--start <start>", $("the UTC time at which the policy becomes valid and passing two spaces means to remove the existing setting")).option("--expiry <expiry>", $("the UTC time at which the policy expires and passing two spaces means to remove the existing setting")).option("--permissions <permissions>", $("the operation permissions combining symbols of r(Read)/w(Write)/d(Delete)/l(List) and passing two spaces means to remove the existing setting")).addStorageAccountOption().execute(setSharePolicy); policy.command("delete [share] [name]").usage("[options] [share] [name]").description($("Delete a stored access policy on the share")).option("--share <share>", $("the storage share name")).option("--name <name>", $("the policy name")).addStorageAccountOption().execute(deleteSharePolicy); var file = storage.category("file").description($("Commands to manage your Storage files")); file.command("list [share] [path]").usage("[options] [share] [path]").description($("List storage files in the specified share under specific path")).option("--share <share>", $("the storage share name")).option("-p, --path <path>", $("the path to be listed")).option("--prefix <prefix>", $("the storage file name prefix")).option("--sas <sas>", $("the shared access signature of the storage file share")).addStorageAccountOption().execute(listFiles); file.command("delete [share] [path]").usage("[options] [share] [path]").description($("Delete the specified storage file")).option("--share <share>", $("the storage share name")).option("-p, --path <path>", $("the path to the storage file")).option("-q, --quiet", $("remove the specified storage file without confirmation")).option("--sas <sas>", $("the shared access signature of the storage file share")).addStorageAccountOption().execute(deleteFile); file.command("upload [source] [share] [path]").usage("[options] [source] [share] [path]").description($("Upload the specified local file to storage")).option("-s, --source <source>", $("the local file path")).option("--share <share>", $("the storage share name")).option("-p, --path <path>", $("the path to the storage file")).option("--concurrenttaskcount <concurrenttaskcount>", $("the maximum number of concurrent upload requests")).option("-q, --quiet", $("overwrite the specified storage file without confirmation")).option("--sas <sas>", $("the shared access signature of the storage file share")).addStorageAccountOption().execute(uploadFile); file.command("download [share] [path] [destination]").usage("[options] [share] [path] [destination]").description($("Download the specified storage file")).option("--share <share>", $("the storage share name")).option("-p, --path <path>", $("the path to the storage file")).option("-d, --destination <destination>", $("path to the destination file or directory")).option("-m, --checkmd5", $("check md5sum for the downloaded file")).option("--concurrenttaskcount <concurrenttaskcount>", $("the maximum number of concurrent download requests")).option("-q, --quiet", $("overwrite the destination file without confirmation")).option("--sas <sas>", $("the shared access signature of the storage file share")).addStorageAccountOption().execute(downloadFile); var copy = file.category("copy").description($("Commands to manage your file copy operations")); copy.command("start [sourceUri] [destShare]").usage("[options] [sourceUri] [destShare]").description($("Start to copy the resource to the specified storage file which completes asynchronously")).option("--source-sas <sourceSas>", $("the shared access signature of the source storage")).option("--source-uri <sourceUri>", $("the source storage blob or file absolute uri")).option("--source-share <sourceShare>", $("the source storage share name when copies a file to a blob")).option("--source-path <sourcePath>", $("the source storage file path when copies a file to a blob")).option("--source-container <sourceContainer>", $("the source storage container name when copies a blob to a blob")).option("--source-blob <sourceBlob>", $("the source storage blob name when copies a blob to a blob")).option("--dest-account-name <destAccountName>", $("the destination storage account name")).option("--dest-account-key <destAccountKey>", $("the destination storage account key")).option("--dest-connection-string <destConnectionString>", $("the destination storage connection string")).option("--dest-sas <destSas>", $("the shared access signature of the destination storage share or file")).option("--dest-share <destShare>", $("the destination storage share name")).option("--dest-path <destPath>", $("the destination storage file path")).option("-q, --quiet", $("overwrite the destination file without confirmation")).addStorageAccountOption().execute(startFileCopy); copy.command("show [share] [path]").usage("[options] [share] [path]").description($("Show the copy status")).option("--share <share>", $("the destination share in the file copy start operation")).option("--path <path>", $("the destination file path in the file copy start operation")).option("--sas <sas>", $("the shared access signature of the destination storage share or file")).addStorageAccountOption().execute(showFileCopy); copy.command("stop [share] [path] [copyid]").usage("[options] [share] [path] [copyid]").description($("Stop the copy operation")).option("--share <share>", $("the destination share in the file copy start operation")).option("--path <path>", $("the destination file path in the file copy start operation")).option("--copyid <copyid>", $("the copy ID which is returned from file copy start operation")).addStorageAccountOption().execute(stopFileCopy); var fileSas = file.category("sas").description($("Commands to manage shared access signatures of your Storage file")); fileSas.command("create [share] [path] [permissions] [expiry]").description($("Generate shared access signature of storage file")).option("--share <share>", $("the storage share name")).option("-p, --path <path>", $("the path to the storage file")).option("--permissions <permissions>", $("the operation permissions combining symbols of r(Read)/w(Write)/d(Delete)")).option("--protocol <protocol>", $("the protocol permitted for a request made with the SAS. Possible values are HttpsOnly and HttpsOrHttp")).option("--ip-range <ipRange>", $("an IP address or a range of IP addresses from which to accept requests. When specifying a range of IP addresses, note that the range is inclusive. For example, specifying 168.1.5.65 or 168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses.")).option("--start <start>", $("the UTC time at which the SAS becomes valid")).option("--expiry <expiry>", $("the UTC time at which the SAS expires")).option("--policy <policy>", $("the stored access policy identifier")).addStorageAccountOption().execute(createFileSas); var directory = storage.category("directory").description($("Commands to manage your Storage file directory")); directory.command("create [share] [path]").description($("Create a storage file directory")).option("--share <share>", $("the storage file share name")).option("-p, --path <path>", $("the path to the storage file directory to be created")).option("--sas <sas>", $("the shared access signature of the storage file share")).addStorageAccountOption().execute(createDirectory); directory.command("delete [share] [path]").description($("Delete the specified storage file directory")).option("--share <share>", $("the storage share name")).option("-p, --path <path>", $("the path to the storage file directory to be deleted")).option("-q, --quiet", $("remove the specified storage file directory without confirmation")).option("--sas <sas>", $("the shared access signature of the storage file share")).addStorageAccountOption().execute(deleteDirectory); function getFileServiceClient(options) { var serviceClient = StorageUtil.getServiceClient(StorageUtil.getFileService, options); applyFileServicePatch(serviceClient); return serviceClient; }; function getStorageFileOperation(serviceClient, operationName) { return StorageUtil.getStorageOperation(serviceClient, StorageUtil.OperationType.File, operationName); }; function getStorageFileOperationDefaultOption() { var option = StorageUtil.getStorageOperationDefaultOption(); option.parallelOperationThreadCount = StorageUtil.threadsInOperation; return option; }; function createSharePolicySetting(options) { var policySettings = { }; policySettings.accessType = StorageUtil.AccessType.Share; policySettings.serviceClient = getFileServiceClient(options); policySettings.getAclOperation = getStorageFileOperation(policySettings.serviceClient, "getShareAcl"); policySettings.setAclOperation = getStorageFileOperation(policySettings.serviceClient, "setShareAcl"); policySettings.storageOptions = getStorageFileOperationDefaultOption(); policySettings.policyOptions = options; return policySettings; }; function createShare(share, options, _) { var fileService, operation, tips, storageOptions, created; var __frame = { name: "createShare", line: 336 }; return __func(_, this, arguments, createShare, 2, __frame, function __$createShare() { fileService = getFileServiceClient(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 24, function ___(__0, __1) { share = __1; operation = getStorageFileOperation(fileService, "createShare"); tips = util.format($("Creating storage file share %s"), share); storageOptions = getStorageFileOperationDefaultOption(); if (options.quota) { storageOptions.quota = options.quota; } ; startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$createShare() { return performStorageOperation(operation, __cb(_, __frame, 12, 20, function ___(__0, __2) { created = __2; if ((created === false)) { return _(new Error(util.format($("Share '%s' already exists"), share))); } ; _(null, null, true); }, true), share, storageOptions); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$createShare() { endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$createShare() { logger.verbose(util.format($("Share %s has been created successfully"), share)); return showShare(share, StorageUtil.getStorageAccountOptions(options), __cb(_, __frame, 21, 4, function __$createShare() { _(); }, true)); }); }); }, true)); }); }; function deleteShare(share, options, _) { var fileService, operation, tips, storageOptions, force; var __frame = { name: "deleteShare", line: 363 }; return __func(_, this, arguments, deleteShare, 2, __frame, function __$deleteShare() { fileService = getFileServiceClient(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 24, function ___(__0, __1) { share = __1; operation = getStorageFileOperation(fileService, "deleteShare"); tips = util.format($("Deleting storage file share %s"), share); storageOptions = getStorageFileOperationDefaultOption(); force = !!options.quiet; return (function __$deleteShare(__then) { if ((force !== true)) { return interaction.confirm(util.format($("Do you want to delete share %s? "), share), __cb(_, __frame, 9, 26, function ___(__0, __2) { force = __2; if ((force !== true)) { return _(null); } ; __then(); }, true)); } else { __then(); } ; })(function __$deleteShare() { startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteShare() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteShare() { return performStorageOperation(operation, __cb(_, __frame, 18, 6, __then, true), share, storageOptions); }); })(function ___(e, __result) { __catch(function __$deleteShare() { if (e) { if (StorageUtil.isNotFoundException(e)) { return _(new Error(util.format($("Can not find share '%s'"), share))); } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$deleteShare() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$deleteShare() { endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$deleteShare() { logger.info(util.format($("Share %s has been deleted successfully"), share)); _(); }); }); }); }, true)); }); }; function showShare(share, options, _) { var fileService, operation, tips, storageOptions, properties, getStatsOperation, stats; var __frame = { name: "showShare", line: 398 }; return __func(_, this, arguments, showShare, 2, __frame, function __$showShare() { fileService = getFileServiceClient(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 24, function ___(__0, __1) { share = __1; operation = getStorageFileOperation(fileService, "getShareProperties"); tips = $("Getting Storage share information"); storageOptions = getStorageFileOperationDefaultOption(); properties = []; startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showShare() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showShare() { return performStorageOperation(operation, __cb(_, __frame, 10, 19, function ___(__0, __2) { properties = __2; getStatsOperation = getStorageFileOperation(fileService, "getShareStats"); return performStorageOperation(getStatsOperation, __cb(_, __frame, 13, 18, function ___(__0, __3) { stats = __3; properties.shareUsage = stats.shareStats.shareUsage; __then(); }, true), share, storageOptions); }, true), share, storageOptions); }); })(function ___(e, __result) { __catch(function __$showShare() { if (e) { if (StorageUtil.isNotFoundException(e)) { return _(new Error(util.format($("Share %s doesn't exist"), share))); } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$showShare() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$showShare() { endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$showShare() { logger.json(properties); _(); }); }); }, true)); }); }; function setShare(share, options, _) { var fileService, tips, properties, getPropertiesOperation, storageOptions, setPropertiesOperation; var __frame = { name: "setShare", line: 429 }; return __func(_, this, arguments, setShare, 2, __frame, function __$setShare() { fileService = getFileServiceClient(options); if ((options.quota && !validation.isInt(options.quota))) { return _(new Error(util.format($("The share quota must be an integer in GB")))); } ; return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 7, 24, function ___(__0, __1) { share = __1; tips = $("Setting share"); startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$setShare() { getPropertiesOperation = getStorageFileOperation(fileService, "getShareProperties"); storageOptions = getStorageFileOperationDefaultOption(); return performStorageOperation(getPropertiesOperation, __cb(_, __frame, 15, 19, function ___(__0, __2) { properties = __2; setPropertiesOperation = getStorageFileOperation(fileService, "setShareProperties"); if (options.quota) { properties.quota = options.quota; } ; return performStorageOperation(setPropertiesOperation, __cb(_, __frame, 21, 6, function __$setShare() { _(null, null, true); }, true), share, properties, storageOptions); }, true), share, storageOptions); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$setShare() { endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$setShare() { return showShare(share, StorageUtil.getStorageAccountOptions(options), __cb(_, __frame, 26, 4, function __$setShare() { _(); }, true)); }); }); }, true)); }); }; function listShares(prefix, options, _) { var fileService, listOperation, tips, storageOptions, shares; var __frame = { name: "listShares", line: 464 }; return __func(_, this, arguments, listShares, 2, __frame, function __$listShares() { fileService = getFileServiceClient(options); listOperation = getStorageFileOperation(fileService, "listAllShares"); tips = $("Getting storage shares"); storageOptions = getStorageFileOperationDefaultOption(); validateSharePrefix(prefix); storageOptions.prefix = prefix; startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listShares() { return performStorageOperation(listOperation, __cb(_, __frame, 12, 15, function ___(__0, __1) { shares = __1; _(null, null, true); }, true), storageOptions); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$listShares() { endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$listShares() { cli.interaction.formatOutput(shares, function(outputData) { if ((outputData.length === 0)) { logger.info($("No share found")); } else { logger.table(outputData, function(row, item) { row.cell($("Name"), item.name); row.cell($("Last Modified"), item.lastModified); }); } ; }); _(); }); }); }); }; function createShareSas(share, permissions, expiry, options, _) { var __frame = { name: "createShareSas", line: 496 }; return __func(_, this, arguments, createShareSas, 4, __frame, function __$createShareSas() { return createSas(share, null, permissions, options.protocol, options.ipRange, expiry, options, true, __cb(_, __frame, 1, 4, function __$createShareSas() { _(); }, true)); }); }; function createFileSas(share, path, permissions, expiry, options, _) { var __frame = { name: "createFileSas", line: 503 }; return __func(_, this, arguments, createFileSas, 5, __frame, function __$createFileSas() { return createSas(share, path, permissions, options.protocol, options.ipRange, expiry, options, false, __cb(_, __frame, 1, 4, function __$createFileSas() { _(); }, true)); }); }; function createSas(share, path, permissions, protocol, ipRange, expiry, options, isShare, _) { var fileService, accessType, start, output, sharedAccessPolicy, tips, result, directory, file; var __frame = { name: "createSas", line: 510 }; return __func(_, this, arguments, createSas, 8, __frame, function __$createSas() { fileService = getFileServiceClient(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 24, function ___(__0, __1) { share = __1; return (function __$createSas(__then) { if (!isShare) { return interaction.promptIfNotGiven($("File path: "), path, __cb(_, __frame, 6, 25, function ___(__0, __2) { path = __2; accessType = StorageUtil.AccessType.File; __then(); }, true)); } else { accessType = StorageUtil.AccessType.Share; __then(); } ; })(function __$createSas() { return (function __$createSas(__then) { if (!options.policy) { return interaction.promptIfNotGiven($("Permissions: "), permissions, __cb(_, __frame, 13, 32, function ___(__0, __3) { permissions = __3; StorageUtil.validatePermissions(accessType, permissions); return interaction.promptIfNotGiven($("Expiry: "), expiry, __cb(_, __frame, 16, 27, function ___(__0, __4) { expiry = __4; expiry = utils.parseDateTime(expiry); __then(); }, true)); }, true)); } else { __then(); } ; })(function __$createSas() { if (options.start) { start = utils.parseDateTime(options.start); } ; output = { sas: "" }; sharedAccessPolicy = StorageUtil.getSharedAccessPolicy(accessType, permissions, protocol, ipRange, start, expiry, null, options.policy); if (isShare) { tips = util.format($("Creating shared access signature for share %s"), share); } else { tips = util.format($("Creating shared access signature for file %s"), ((share + "/") + path)); } ; startProgress(tips); result = { dirname: null, basename: null }; if (!isShare) { path = StorageUtil.normalizePath(path); result = StorageUtil.fetchBasenameAndDirname(path); } ; directory = (result.dirname ? result.dirname : ""); file = result.basename; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$createSas() { output.sas = fileService.generateSharedAccessSignature(share, directory, file, sharedAccessPolicy); output.url = fileService.getUrl(share, directory, file, output.sas); _(null, null, true); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$createSas() { endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$createSas() { cli.interaction.formatOutput(output, function(outputData) { logger.data($("Shared Access Signature"), outputData.sas); logger.data($("Shared Access URL"), outputData.url); }); _(); }); }); }); }); }, true)); }); }; function createSharePolicy(share, name, options, _) { var createPolicySettings, policies; var __frame = { name: "createSharePolicy", line: 570 }; return __func(_, this, arguments, createSharePolicy, 3, __frame, function __$createSharePolicy() { createPolicySettings = createSharePolicySetting(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 52, function ___(__0, __1) { createPolicySettings.resourceName = __1; return interaction.promptIfNotGiven($("Policy name: "), name, __cb(_, __frame, 3, 50, function ___(__0, __2) { createPolicySettings.policyName = __2; createPolicySettings.tips = util.format($("Creating the stored access policy %s on the share %s"), createPolicySettings.policyName, createPolicySettings.resourceName); if (options.permissions) { StorageUtil.validatePermissions(StorageUtil.AccessType.Share, options.permissions); } ; return StorageUtil.createPolicy(createPolicySettings, __cb(_, __frame, 10, 31, function ___(__0, __3) { policies = __3; cli.interaction.formatOutput(policies, function(outputData) { logger.info(util.format($("The stored access policies on share %s are: "), createPolicySettings.resourceName)); StorageUtil.showPolicyResults(outputData); }); _(); }, true)); }, true)); }, true)); }); }; function listSharePolicy(share, options, _) { var listPolicySettings, policies; var __frame = { name: "listSharePolicy", line: 590 }; return __func(_, this, arguments, listSharePolicy, 2, __frame, function __$listSharePolicy() { listPolicySettings = createSharePolicySetting(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 50, function ___(__0, __1) { listPolicySettings.resourceName = __1; listPolicySettings.tips = util.format($("Listing the stored access policies on the share %s"), listPolicySettings.resourceName); return StorageUtil.selectPolicy(listPolicySettings, __cb(_, __frame, 5, 31, function ___(__0, __2) { policies = __2; cli.interaction.formatOutput(policies, function(outputData) { if (outputData) { StorageUtil.showPolicyResults(outputData); } else { logger.info(util.format($("There is no stored access policy on the share %s."), listPolicySettings.resourceName)); } ; }); _(); }, true)); }, true)); }); }; function showSharePolicy(share, name, options, _) { var showPolicySettings, policy; var __frame = { name: "showSharePolicy", line: 608 }; return __func(_, this, arguments, showSharePolicy, 3, __frame, function __$showSharePolicy() { showPolicySettings = createSharePolicySetting(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 50, function ___(__0, __1) { showPolicySettings.resourceName = __1; return interaction.promptIfNotGiven($("Policy name: "), name, __cb(_, __frame, 3, 48, function ___(__0, __2) { showPolicySettings.policyName = __2; showPolicySettings.tips = util.format($("Showing the stored access policy %s on the share %s"), showPolicySettings.policyName, showPolicySettings.resourceName); return StorageUtil.selectPolicy(showPolicySettings, __cb(_, __frame, 6, 29, function ___(__0, __3) { policy = __3; cli.interaction.formatOutput(policy, function(outputData) { StorageUtil.showPolicyResults(outputData); }); _(); }, true)); }, true)); }, true)); }); }; function setSharePolicy(share, name, options, _) { var setPolicySettings, policies; var __frame = { name: "setSharePolicy", line: 623 }; return __func(_, this, arguments, setSharePolicy, 3, __frame, function __$setSharePolicy() { setPolicySettings = createSharePolicySetting(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 49, function ___(__0, __1) { setPolicySettings.resourceName = __1; return interaction.promptIfNotGiven($("Policy name: "), name, __cb(_, __frame, 3, 47, function ___(__0, __2) { setPolicySettings.policyName = __2; setPolicySettings.tips = util.format($("Setting the stored access policy %s on the share %s"), setPolicySettings.policyName, setPolicySettings.resourceName); if (options.permissions) { StorageUtil.validatePermissions(StorageUtil.AccessType.Share, options.permissions); } ; return StorageUtil.setPolicy(setPolicySettings, __cb(_, __frame, 10, 31, function ___(__0, __3) { policies = __3; cli.interaction.formatOutput(policies, function(outputData) { logger.info(util.format($("The stored access policies on share %s are: "), setPolicySettings.resourceName)); StorageUtil.showPolicyResults(outputData); }); _(); }, true)); }, true)); }, true)); }); }; function deleteSharePolicy(share, name, options, _) { var deletePolicySettings, policies; var __frame = { name: "deleteSharePolicy", line: 643 }; return __func(_, this, arguments, deleteSharePolicy, 3, __frame, function __$deleteSharePolicy() { deletePolicySettings = createSharePolicySetting(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 52, function ___(__0, __1) { deletePolicySettings.resourceName = __1; return interaction.promptIfNotGiven($("Policy name: "), name, __cb(_, __frame, 3, 50, function ___(__0, __2) { deletePolicySettings.policyName = __2; deletePolicySettings.tips = util.format($("Deleting the stored access policy %s on the share %s"), deletePolicySettings.policyName, deletePolicySettings.resourceName); return StorageUtil.deletePolicy(deletePolicySettings, __cb(_, __frame, 6, 31, function ___(__0, __3) { policies = __3; cli.interaction.formatOutput(policies, function(outputData) { if (outputData) { logger.info(util.format($("The stored access policies on share %s are: "), deletePolicySettings.resourceName)); StorageUtil.showPolicyResults(outputData); } else { logger.info(util.format($("There is no stored access policy on the share %s."), deletePolicySettings.resourceName)); } ; }); _(); }, true)); }, true)); }, true)); }); }; function listFiles(share, path, options, _) { var fileService, listOperation, tips, storageOptions, listResults, setUriFunc; var __frame = { name: "listFiles", line: 667 }; return __func(_, this, arguments, listFiles, 3, __frame, function __$listFiles() { fileService = getFileServiceClient(options); listOperation = getStorageFileOperation(fileService, "listFilesAndDirectories"); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 3, 24, function ___(__0, __1) { share = __1; if (__.isUndefined(path)) { path = ""; } ; path = StorageUtil.normalizePath(path); tips = util.format($("Getting storage files under '%s' of share %s"), path, share); storageOptions = getStorageFileOperationDefaultOption(); startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listFiles() { return performStorageOperation(listOperation, __cb(_, __frame, 16, 20, function ___(__0, __2) { listResults = __2; _(null, null, true); }, true), share, path, options.prefix, storageOptions); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$listFiles() { endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$listFiles() { if (cli.output.format().json) { setUriFunc = function(item) { item.uri = fileService.getUrl(share, path, item.name); }; listResults.directories.forEach(setUriFunc); listResults.files.forEach(setUriFunc); } ; cli.interaction.formatOutput(listResults, function(outputData) { if (((outputData.directories.length + outputData.files.length) > 0)) { logger.table(outputData.directories.concat(outputData.files), function(row, item) { row.cell($("Name"), item.name); if (item.contentLength) { row.cell($("Length"), item.contentLength); row.cell($("Type"), ""); } else { row.cell($("Length"), ""); row.cell($("Type"), "<DIR>"); } ; }); } ; }); _(); }); }); }, true)); }); }; function deleteFile(share, path, options, _) { var fileService, operation, tips, storageOptions, force, result, directory, file; var __frame = { name: "deleteFile", line: 716 }; return __func(_, this, arguments, deleteFile, 3, __frame, function __$deleteFile() { fileService = getFileServiceClient(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 24, function ___(__0, __1) { share = __1; return interaction.promptIfNotGiven($("Path to the file: "), path, __cb(_, __frame, 3, 23, function ___(__0, __2) { path = __2; operation = getStorageFileOperation(fileService, "deleteFile"); tips = util.format($("Deleting storage file '%s' in share %s"), path, share); storageOptions = getStorageFileOperationDefaultOption(); force = !!options.quiet; return (function __$deleteFile(__then) { if ((force !== true)) { return interaction.confirm(util.format($("Do you want to delete file %s? "), path), __cb(_, __frame, 10, 26, function ___(__0, __3) { force = __3; if ((force !== true)) { return _(null); } ; __then(); }, true)); } else { __then(); } ; })(function __$deleteFile() { startProgress(tips); path = StorageUtil.normalizePath(path); result = StorageUtil.fetchBasenameAndDirname(path); directory = result.dirname; file = result.basename; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteFile() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteFile() { return performStorageOperation(operation, __cb(_, __frame, 24, 6, __then, true), share, directory, file, storageOptions); }); })(function ___(e, __result) { __catch(function __$deleteFile() { if (e) { if (StorageUtil.isNotFoundException(e)) { return _(new Error(util.format($("Can not find file '%s' in share %s"), path, share))); } else { return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$deleteFile() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$deleteFile() { endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$deleteFile() { logger.info(util.format($("File '%s' in share %s has been deleted successfully"), path, share)); _(); }); }); }); }, true)); }, true)); }); }; function uploadFile(source, share, path, options, _) { var fileService, storageOptions, force, fsStatus, pathIsDirectory, remoteFileExists, directory, file, result, summary, printer, intervalId, succeeded, uploadFileResult; var __frame = { name: "uploadFile", line: 757 }; return __func(_, this, arguments, uploadFile, 4, __frame, function __$uploadFile() { fileService = getFileServiceClient(options); return interaction.promptIfNotGiven($("File to be uploaded: "), source, __cb(_, __frame, 2, 25, function ___(__0, __4) { source = __4; return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 3, 24, function ___(__0, __5) { share = __5; storageOptions = getStorageFileOperationDefaultOption(); storageOptions.storeFileContentMD5 = true; force = !!options.quiet; return utils.fileExists(source, __cb(_, __frame, 8, 15, function ___(__0, __7) { var __6 = !__7; return (function __$uploadFile(__then) { if (__6) { return _(new Error(util.format($("Local file %s doesn't exist"), source))); } else { __then(); } ; })(function __$uploadFile() { return fs.stat(source, __cb(_, __frame, 12, 22, function ___(__0, __8) { fsStatus = __8; if (!fsStatus.isFile()) { return _(new Error(util.format($("%s is not a file"), source))); } ; if ((fsStatus.size > StorageUtil.MaxFileSize)) { return _(new Error(util.format($("The local file size %d exceeds the Azure file size limit %d"), fsStatus.size, StorageUtil.MaxFileSize))); } ; pathIsDirectory = ((path && (path.length > 0)) && (((path[(path.length - 1)] === "/") || (path[(path.length - 1)] === "\\")))); remoteFileExists = false; startProgress(util.format($("Checking file or directory '%s' in share %s"), (path ? path : ""), share)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$uploadFile() { return (function __$uploadFile(__then) { if (path) { path = StorageUtil.normalizePath(path); result = StorageUtil.fetchBasenameAndDirname(path); directory = result.dirname; file = result.basename; return (function __$uploadFile(_) { var __1 = (!utils.stringIsNullOrEmpty(file) && !pathIsDirectory); if (!__1) { return _(null, __1); } ; return performStorageOperation(getStorageFileOperation(fileService, "doesFileExist"), __cb(_, __frame, 42, 10, function ___(__0, __3) { var __2 = __3.exists; return _(null, __2); }, true), share, directory, file, storageOptions); })(__cb(_, __frame, -756, 18, function ___(__0, __9) { return (function __$uploadFile(__then) { if (__9) { remoteFileExists = true; __then(); } else { return (function __$uploadFile(_) { var __2 = pathIsDirectory; if (__2) { return _(null, __2); } ; return performStorageOperation(getStorageFileOperation(fileService, "doesDirectoryExist"), __cb(_, __frame, 54, 36, function ___(__0, __4) { var __3 = __4.exists; return _(null, __3); }, true), share, path); })(__cb(_, __frame, -756, 18, function ___(__0, __10) { return (function __$uploadFile(__then) { if (__10) { directory = path; file = pathUtil.basename(source); __then(); } else { return performStorageOperation(getStorageFileOperation(fileService, "doesDirectoryExist"), __cb(_, __frame, 65, 17, function ___(__0, __12) { var __11 = __12.exists; return (function __$uploadFile(__then) { if (__11) { __then(); } else { return _(new Error(util.format($("Path '%s' is neither an existing file nor under an existing directory"), path))); } ; })(__then); }, true), share, directory); } ; })(__then); }, true)); } ; })(__then); }, true)); } else { directory = ""; file = pathUtil.basename(source); __then(); } ; })(function __$uploadFile() { return (function __$uploadFile(_) { var __3 = remoteFileExists; if (__3) { return _(null, __3); } ; return performStorageOperation(getStorageFileOperation(fileService, "doesFileExist"), __cb(_, __frame, 87, 30, function ___(__0, __5) { var __4 = __5.exists; return _(null, __4); }, true), share, directory, file, storageOptions); })(__cb(_, __frame, -756, 18, function ___(__0, __13) { return (function __$uploadFile(__then) { if (__13) { remoteFileExists = true; __then(); } else { __then(); } ; })(function __$uploadFile() { _(null, null, true); }); }, true)); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$uploadFile() { endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$uploadFile() { return (function __$uploadFile(__then) { if ((remoteFileExists === true)) { return (function __$uploadFile(__then) { if ((force !== true)) { return interaction.confirm(util.format($("Do you want to overwrite remote file %s? "), pathUtil.join(directory, file)), __cb(_, __frame, 102, 28, function ___(__0, __14) { force = __14; if ((force !== true)) { return _(null); } ; __then(); }, true)); } else { __then(); } ; })(__then); } else { __then(); } ; })(function __$uploadFile() { startProgress(util.format($("Uploading file '%s' to '%s' under share %s"), source, directory, share)); endProgress(); summary = new SpeedSummary(file); storageOptions.speedSummary = summary; storageOptions.parallelOperationThreadCount = (options.concurrenttaskcount || storageOptions.parallelOperationThreadCount); printer = StorageUtil.getSpeedPrinter(summary); intervalId = -1; if (!logger.format().json) { intervalId = setInterval(printer, 1000); } ; succeeded = false; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$uploadFile() { return performStorageOperation(getStorageFileOperation(fileService, "createFileFromLocalFile"), __cb(_, __frame, 124, 25, function ___(__0, __15) { uploadFileResult = __15; succeeded = true; _(null, null, true); }, true), share, directory, file, source, storageOptions); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$uploadFile() { printer(true); clearInterval(intervalId); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$uploadFile() { if ((succeeded === true)) { uploadFileResult = StorageUtil.embedTransferSummary(uploadFileResult, summary); cli.interaction.formatOutput(uploadFileResult, function() { logger.info(util.format($("Successfully uploaded file '%s' to share %s"), source, share)); }); } ; _(); }); }); }); }); }); }, true)); }); }, true)); }, true)); }, true)); }); }; function downloadFile(share, path, destination, options, _) { var fileService, storageOptions, force, result, directory, file, stat, operation, summary, printer, intervalId, downloadedFile; var __frame = { name: "downloadFile", line: 904 }; return __func(_, this, arguments, downloadFile, 4, __frame, function __$downloadFile() { fileService = getFileServiceClient(options); return interaction.promptIfNotGiven($("Share name: "), share, __cb(_, __frame, 2, 24, function ___(__0, __1) { share = __1; return interaction.promptIfNotGiven($("Path of the file to be downloaded: "), path, __cb(_, __frame, 3, 23, function ___(__0, __2) { path = __2; storageOptions = getStorageFileOperationDefaultOption(); force = !!options.quiet; path = StorageUtil.normalizePath(path); result = StorageUtil.fetchBasenameAndDirname(path); directory = result.dirname; file = result.basename; logger.verbose(directory); logger.verbose(file); return (function __$downloadFile(__then) { if (destination) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$downloadFile() { return fs.stat(destination, __cb(_, __frame, 17, 18, function ___(__0, __3) { stat = __3; if (stat.isDirectory()) { destination = pathUtil.join(destination, file); } ; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$downloadFile() { if (err) { if (!StorageUtil.isFileNotFoundException(err)) { return _(err); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else { destination = pathUtil.join(".", file); __then(); } ; })(fu