azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
851 lines (361 loc) • 83.8 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 fs = require("fs");
var progress = require("progress");
var profile = require("../../../util/profile");
var utils = require("../../../util/utils");
var tagUtils = require("../tag/tagUtils");
var $ = utils.getLocaleString;
var dataLakeStoreUtils = require("./datalakestore.utils");
var readStreamToBuffer = function(strm, callback) {
var bufs = [];
strm.on("data", function(d) {
bufs.push(d); });
strm.on("end", function() {
callback(null, Buffer.concat(bufs)); });};
exports.init = function(cli) {
var log = cli.output;
var withProgress = cli.interaction.withProgress.bind(cli.interaction);
var dataLakeCommands = cli.category("datalake").description($("Commands to manage your Data Lake objects"));
var dataLakeStoreCommands = dataLakeCommands.category("store").description($("Commands to manage your Data Lake Storage objects"));
var dataLakeStoreFileSystem = dataLakeStoreCommands.category("filesystem").description($("Commands to manage your Data Lake Storage FileSystem"));
var dataLakeStoreFileSystemExpiry = dataLakeStoreFileSystem.category("expiry").description($("Commands to manage expiration of your Data Lake Storage FileSystem"));
dataLakeStoreFileSystemExpiry.command("set [accountName] [path]").description($("sets or removes the absolute expiration time of the specified path (files only).")).usage("[options] <accountName> <path>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the folder to list (e.g. /someFolder or /someFolder/someNestedFolder)")).option("-e --expiration <expiration time in ticks since epoch>", $("the expiration time to set for the file. Values <= 0 or >= 253402300800000 indicate the file will never expire.)")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __1(accountName, path, options, _) { var subscription, client, fileStatus, params; var __frame = { name: "__1", line: 63 }; return __func(_, this, arguments, __1, 3, __frame, function __$__1() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription);
return client.fileSystem.getFileStatus(accountName, path, __cb(_, __frame, 11, 39, function ___(__0, __1) { fileStatus = __1.fileStatus;
if ((fileStatus.type !== "FILE")) {
return _(new Error($(("Expiration can only be set on files (not on folders). Please specify a file path with the --path parameter. Path given: " + path)))); } ; return (function __$__1(__then) {
if (((options.expiration && (parseInt(options.expiration) > 0)) && (parseInt(options.expiration) < 253402300800000))) {
params = {
expireTime: parseInt(options.expiration) };
return client.fileSystem.setFileExpiry(accountName, path, "Absolute", params, __cb(_, __frame, 22, 24, __then, true)); } else {
return client.fileSystem.setFileExpiry(accountName, path, "NeverExpire", __cb(_, __frame, 26, 24, __then, true)); } ; })(function __$__1() {
return client.fileSystem.getFileStatus(accountName, path, __cb(_, __frame, 29, 35, function ___(__0, __2) { fileStatus = __2.fileStatus;
dataLakeStoreUtils.formatOutput(cli, log, options, fileStatus); _(); }, true)); }); }, true)); }); });
dataLakeStoreFileSystem.command("list [accountName] [path]").description($("Lists the contents of the specified path (files and folders).")).usage("[options] <accountName> <path>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the folder to list (e.g. /someFolder or /someFolder/someNestedFolder)")).option("-l --listSize <listSize>", $("the optional number of entries to list. The default is all entries, which can potentially take some time for large directories.)")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __2(accountName, path, options, _) { var subscription, client, parameters, fileStatuses; var __frame = { name: "__2", line: 103 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription);
parameters = { };
if (options.listSize) {
parameters = {
listSize: parseInt(options.listSize) }; } ;
return client.fileSystem.listFileStatus(accountName, path, parameters, __cb(_, __frame, 18, 41, function ___(__0, __1) { fileStatuses = __1.fileStatuses.fileStatus;
dataLakeStoreUtils.formatOutputList(cli, log, options, fileStatuses); _(); }, true)); }); });
dataLakeStoreFileSystem.command("show [accountName] [path]").description($("Gets the specified Data Lake Store file or folder details")).usage("[options] <accountName> <path>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the folder or file to get (e.g. /someFolder or /someFolder/someFile.txt)")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __3(accountName, path, options, _) { var subscription, client, fileStatus; var __frame = { name: "__3", line: 131 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription);
return client.fileSystem.getFileStatus(accountName, path, __cb(_, __frame, 12, 39, function ___(__0, __1) { fileStatus = __1.fileStatus;
dataLakeStoreUtils.formatOutput(cli, log, options, fileStatus); _(); }, true)); }); });
dataLakeStoreFileSystem.command("delete [accountName] [path]").description($("deletes the specified Data Lake Store file or folder, with the option for recursive delete (if the folder has contents)")).usage("[options] <accountName> <path>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the folder or file to get (e.g. /someFolder or /someFolder/someFile.txt)")).option("-r --recurse", $("optionally indicates that this should be a recursive delete, which will delete a folder and all contents underneath it.")).option("-q --quiet", $("optionally indicates the delete should be immediately performed with no confirmation or prompting. Use carefully.")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __4(accountName, path, options, _) { var subscription, client, params; var __frame = { name: "__4", line: 155 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ; return (function __$__4(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete the file or folder at path: %s? [y/n] "), path), __cb(_, __frame, 9, 43, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -154, 17, function ___(__0, __2) { return (function __$__4(__then) { if (__2) { return _(null); } else { __then(); } ; })(function __$__4() {
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription);
params = { };
if (!options.recurse) {
params.recursive = false; }
else {
params.recursive = true; } ;
return client.fileSystem.deleteMethod(accountName, path, params, __cb(_, __frame, 24, 22, function __$__4() {
log.info($(("Successfully deleted the item at path: " + path))); _(); }, true)); }); }, true)); }); });
dataLakeStoreFileSystem.command("create [accountName] [path]").description($("Creates the specified folder or file, with the option to include content in file creation.")).usage("[options] <accountName> <path>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the file to add content to (e.g. /someFolder/someFile.txt)")).option("-v --value <value>", $("optional indicates the contents (as a string) to create the file with. NOTE: This parameter cannot be specified with --folder (-d)")).option("-d --folder", $("optionally specify that the item being created is a folder, not a file. If this is not specified, a file will be created. NOTE: This parameter cannot be specified with --encoding (-e) or --value (-v)")).option("-f --force", $("optionally indicates that the file or folder being created can overwrite the file or folder at path if it already exists (default is false). 'true' must be passed in for the overwrite to work")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __5(accountName, path, options, _) { var subscription, clientOptions, client, result, parameters; var __frame = { name: "__5", line: 192 }; return __func(_, this, arguments, __5, 3, __frame, function __$__5() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
if (((options.value && options.folder))) {
return _(new Error($("--folder cannot be specified with --value"))); } ;
subscription = profile.current.getSubscription(options.subscription);
clientOptions = {
disableLogFilter: true };
client = utils.createDataLakeStoreFileSystemManagementClient(subscription, clientOptions); return (function __$__5(__then) {
if (options.folder) {
return client.fileSystem.mkdirs(accountName, path, __cb(_, __frame, 21, 37, function ___(__0, __2) { result = __2;
if ((result.operationResult !== true)) {
return _(new Error($("Failed to create the desired directory!"))); } ; __then(); }, true)); } else {
parameters = { };
if (options.force) {
parameters.overwrite = true; }
else {
parameters.overwrite = false; } ;
parameters.permission = null;
return withProgress(util.format($("Creating file %s"), path), function __1(log, _) { var __frame = { name: "__1", line: 230 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
if (options.value) {
parameters.streamContents = new Buffer(options.value); } ;
return client.fileSystem.create(accountName, path, parameters, __cb(_, __frame, 6, 26, function __$__1() { _(); }, true)); }); }, __cb(_, __frame, 37, 6, __then, true)); } ; })(function __$__5() {
log.info($(("Successfully created the specified item at path: " + path))); _(); }); }); });
dataLakeStoreFileSystem.command("import [accountName] [path] [destination]").description($("Uploads the specified the specified file, to the target destination in an Azure Data Lake.")).usage("[options] <accountName> <path> <destination>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full local path to the file to import (e.g. /someFolder/someFile.txt or C:somefoldersomeFile.txt)")).option("-d --destination <destination>", $("the full path in the Data Lake Store where the file should be imported to (e.g. /someFolder/someFile.txt")).option("-f --force", $("optionally indicates that the file or folder being created can overwrite the file or folder at path if it already exists (default is false). 'true' must be passed in for the overwrite to work")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __6(accountName, path, destination, options, _) { var subscription, clientOptions, client, parameters, fileStats, fileSizeInBytes, maxBytesToRead, fileHandle, maxAttempts, offset, bar, bytesToRead, appendSucceeded, attemptCount, buffer; var __frame = { name: "__6", line: 251 }; return __func(_, this, arguments, __6, 4, __frame, function __$__6() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
if (!destination) {
return _(null, cli.missingArgument("destination")); } ;
subscription = profile.current.getSubscription(options.subscription);
clientOptions = {
disableLogFilter: true };
client = utils.createDataLakeStoreFileSystemManagementClient(subscription, clientOptions);
parameters = { };
if (options.force) {
parameters.overwrite = true; }
else {
parameters.overwrite = false; } ;
parameters.permission = null;
return fs.stat(path, __cb(_, __frame, 31, 23, function ___(__0, __1) { fileStats = __1;
if (fileStats.isDirectory()) {
return _(new Error($("Cannot import directories, please specify a valid file path"))); } ;
log.info($("Uploading file %s to the Data Lake Store location: %s ..."), path, destination);
fileSizeInBytes = fileStats.size;
maxBytesToRead = ((8 * 1024) * 1024);
return fs.open(path, "r", __cb(_, __frame, 40, 24, function ___(__0, __2) { fileHandle = __2;
maxAttempts = 4; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() {
offset = 0;
bar = new progress(" uploading [:bar] :percent :etas", {
complete: "=",
incomplete: " ",
width: 40,
total: fileSizeInBytes }); return (function __$__6(__then) {
if ((fileSizeInBytes === 0)) {
return client.fileSystem.create(accountName, destination, __cb(_, __frame, 53, 26, __then, true)); } else { return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$__6() { __more = false;
var __6 = (offset < fileSizeInBytes); if (__6) {
bytesToRead = maxBytesToRead;
if (((offset + maxBytesToRead) > fileSizeInBytes)) {
bytesToRead = (fileSizeInBytes - offset); } ;
appendSucceeded = false;
attemptCount = 0; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$__6() { __more = false;
var __7 = (!appendSucceeded && (attemptCount < maxAttempts)); if (__7) {
attemptCount++; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() {
buffer = new Buffer(bytesToRead);
return fs.read(fileHandle, buffer, 0, bytesToRead, offset, __cb(_, __frame, 68, 17, function __$__6() { return (function __$__6(__then) {
if ((offset === 0)) {
parameters.streamContents = buffer;
return client.fileSystem.create(accountName, destination, parameters, __cb(_, __frame, 72, 34, __then, true)); } else {
return client.fileSystem.append(accountName, destination, buffer, __cb(_, __frame, 75, 34, __then, true)); } ; })(function __$__6() {
appendSucceeded = true;
offset += bytesToRead;
bar.tick(bytesToRead); __then(); }); }, true)); }); })(function ___(err, __result) { __catch(function __$__6() { if (err) {
if ((attemptCount >= maxAttempts)) {
return _(err); } ;
dataLakeStoreUtils.waitForRetry(attemptCount, true); __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__6() { while (__more) { __loop(); }; __more = true; }); }); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$__6() { while (__more) { __loop(); }; __more = true; }); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(__then); } ; })(function __$__6() { _(null, null, true); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__6() {
fs.close(fileHandle); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__6() {
log.info($(("Successfully created the specified item at path: " + destination))); _(); }); }); }, true)); }, true)); }); });
dataLakeStoreFileSystem.command("concat [accountName] [paths] [destination]").description($("Concatenates the specified list of files into the specified destination file.")).usage("[options] <accountName> <paths> <destination>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --paths <paths>", $("a comma seperated list of full paths to concatenate (e.g. '/someFolder/someFile.txt,/somefolder/somefile2.txt,/anotherFolder/newFile.txt')")).option("-d --destination <destination>", $("specify the target file that all of the files in --paths should be concatenated into (e.g /someFolder/targetFile.txt)")).option("-f --force", $("optionally indicates that the file or folder being created can overwrite the file or folder at path if it already exists (default is false). 'true' must be passed in for the overwrite to work")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __7(accountName, paths, destination, force, options, _) { var subscription, client, fileStatus, pathsBuf; var __frame = { name: "__7", line: 361 }; return __func(_, this, arguments, __7, 5, __frame, function __$__7() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!paths) {
return _(null, cli.missingArgument("paths")); } ;
if (!destination) {
return _(null, cli.missingArgument("destination")); } ;
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription); return (function __$__7(__then) {
if (options.force) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__7() {
return client.fileSystem.getFileStatus(accountName, destination, __cb(_, __frame, 18, 43, function ___(__0, __2) { fileStatus = __2.fileStatus; return (function __$__7(__then) {
if ((fileStatus.type.toLowerCase() === "file")) {
return client.fileSystem.deleteMethod(accountName, destination, false, __cb(_, __frame, 20, 28, __then, true)); } else {
return _(new Error($("Cannot forcibly concatenate files into a path that is an existing directory. Please use the delete command to remove the directory and try again."))); } ; })(__then); }, true)); }); })(function ___(err, __result) { __catch(function __$__7() { if (err) { __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else { __then(); } ; })(function __$__7() {
pathsBuf = new Buffer(("sources=" + paths));
return withProgress(util.format($("Concatenating specified files into target location: %s"), destination), function __1(log, _) { var __frame = { name: "__1", line: 394 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
return client.fileSystem.msConcat(accountName, destination, pathsBuf, false, __cb(_, __frame, 1, 24, function __$__1() { _(); }, true)); }); }, __cb(_, __frame, 32, 4, function __$__7() {
log.info($(("Successfully concatenated the file list into the specified item at path: " + destination))); _(); }, true)); }); }); });
dataLakeStoreFileSystem.command("move [accountName] [path] [destination]").description($("Moves (renames) the specified file or folder into the specified destination file or folder.")).usage("[options] <accountName> <path> <destination>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the path to the file or folder to move (e.g. /someFolder or /someFolder/someFile.txt)")).option("-d --destination <destination>", $("specify the target location to move the file or folder to")).option("-f --force", $("optionally indicates that the file or folder being created can overwrite the file or folder at path if it already exists (default is false). 'true' must be passed in for the overwrite to work")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __8(accountName, path, destination, options, _) { var subscription, client; var __frame = { name: "__8", line: 408 }; return __func(_, this, arguments, __8, 4, __frame, function __$__8() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("paths")); } ;
if (!destination) {
return _(null, cli.missingArgument("destination")); } ;
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription); return (function __$__8(__then) {
if (options.force) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__8() {
return client.fileSystem.deleteMethod(accountName, destination, true, __cb(_, __frame, 18, 26, __then, true)); }); })(function ___(err, __result) { __catch(function __$__8() { if (err) { __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else { __then(); } ; })(function __$__8() {
return client.fileSystem.rename(accountName, path, destination, __cb(_, __frame, 25, 22, function __$__8() {
log.info($(("Successfully moved the file or folder to: " + destination))); _(); }, true)); }); }); });
dataLakeStoreFileSystem.command("addcontent [accountName] [path] [value]").description($("Appends the specified content to the end of the Data Lake Store file path specified.")).usage("[options] <accountName> <path> <value>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the file to add content to (e.g. /someFolder/someFile.txt)")).option("-v --value <value>", $("the contents to append to the file")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __9(accountName, path, value, options, _) { var subscription, clientOptions, client; var __frame = { name: "__9", line: 444 }; return __func(_, this, arguments, __9, 4, __frame, function __$__9() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
if (!value) {
return _(null, cli.missingArgument("value")); } ;
subscription = profile.current.getSubscription(options.subscription);
clientOptions = {
disableLogFilter: true };
client = utils.createDataLakeStoreFileSystemManagementClient(subscription, clientOptions);
return withProgress(util.format($("Adding specified content to file %s"), path), function __1(log, _) { var __frame = { name: "__1", line: 465 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
return client.fileSystem.append(accountName, path, value, __cb(_, __frame, 1, 24, function __$__1() { _(); }, true)); }); }, __cb(_, __frame, 20, 4, function __$__9() {
log.info($(("Successfully appended content at the specified path: " + path))); _(); }, true)); }); });
dataLakeStoreFileSystem.command("export [accountName] [path] [destination]").description($("Downloads the specified file to the target location.")).usage("[options] <accountName> <path> <destination>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path in the Data Lake Store where the file should be imported to (e.g. /someFolder/someFile.txt")).option("-d --destination <destination>", $("the full local path to the file to import (e.g. /someFolder/someFile.txt or C:somefoldersomeFile.txt)")).option("-f --force", $("optionally indicates that the file being created can overwrite the file at path if it already exists (default is false).")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __10(accountName, path, destination, options, _) { var subscription, client, maxBytesToRead, fileStatus, fileSizeInBytes, fileHandle, offset, maxAttempts, bar, bytesToRead, parameters, attemptCount, readSucceeded, response, buff; var __frame = { name: "__10", line: 479 }; return __func(_, this, arguments, __10, 4, __frame, function __$__10() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
if (!destination) {
return _(null, cli.missingArgument("destination")); } ;
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription);
maxBytesToRead = ((8 * 1024) * 1024);
return client.fileSystem.getFileStatus(accountName, path, __cb(_, __frame, 16, 39, function ___(__0, __1) { fileStatus = __1.fileStatus;
log.info($("Downloading file %s to the specified location: %s"), path, destination);
fileSizeInBytes = fileStatus.length; return (function __$__10(__then) {
if (options.force) {
return fs.open(destination, "w", __cb(_, __frame, 23, 22, function ___(__0, __2) { fileHandle = __2; __then(); }, true)); } else { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__10() {
return fs.open(destination, "wx", __cb(_, __frame, 27, 24, function ___(__0, __3) { fileHandle = __3; __then(); }, true)); }); })(function ___(err, __result) { __catch(function __$__10() { if (err) {
return _(new Error($(((("The file at path: " + destination) + " already exists. Please use the --force option to overwrite this file. Actual error reported: ") + err)))); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } ; })(function __$__10() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__10() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__10() {
offset = 0;
maxAttempts = 4;
bar = new progress(" downloading [:bar] :percent :etas", {
complete: "=",
incomplete: " ",
width: 40,
total: fileSizeInBytes }); return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$__10() { __more = false;
var __9 = (offset < fileSizeInBytes); if (__9) {
bytesToRead = maxBytesToRead;
if (((offset + maxBytesToRead) > fileSizeInBytes)) {
bytesToRead = (fileSizeInBytes - offset); } ;
parameters = {
length: bytesToRead,
offset: offset };
attemptCount = 0;
readSucceeded = false; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$__10() { __more = false;
var __10 = (!readSucceeded && (attemptCount < maxAttempts)); if (__10) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__10() {
return client.fileSystem.open(accountName, path, parameters, __cb(_, __frame, 58, 45, function ___(__0, __4) { response = __4;
return readStreamToBuffer(response, __cb(_, __frame, 59, 23, function ___(__0, __5) { buff = __5;
return fs.write(fileHandle, buff, 0, bytesToRead, offset, __cb(_, __frame, 60, 15, function __$__10() {
readSucceeded = true;
offset += bytesToRead;
bar.tick(bytesToRead); __then(); }, true)); }, true)); }, true)); }); })(function ___(err, __result) { __catch(function __$__10() { if (err) {
if ((attemptCount >= maxAttempts)) {
return _(err); } ;
dataLakeStoreUtils.waitForRetry(attemptCount, true); __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__10() { while (__more) { __loop(); }; __more = true; }); }); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$__10() { while (__more) { __loop(); }; __more = true; }); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(__then); }); })(function ___(err, __result) { __catch(function __$__10() { if (err) {
log.info(err); __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__10() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__10() {
fs.close(fileHandle); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__10() {
log.info($(((("Successfully downloaded the specified item at path: " + path) + " to local path: ") + destination))); _(); }); }); }); }, true)); }); });
dataLakeStoreFileSystem.command("read [accountName] [path]").description($("Previews the specified Data Lake Store file starting at index 0 (or the specified offset) until the length is reached, displaying the results to the console.")).usage("[options] <accountName> <path>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the file to download (e.g. /someFolder/someFile.txt)")).option("-l --length <length>", $("optionally specify the length, in bytes, to read from the file. If not specified will attempt to display all content after offset. If that length is greater than 1MB a length must be specified.")).option("-o --offset <offset>", $("the optional offset to begin reading at (default is 0)")).option("-f --force", $("optionally forces previewing of a full file. Use with caution, as this can cause instability and hangs with very large files.")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __11(accountName, path, options, _) { var parameters, maxLength, subscription, client, fileInfo, length, response, buff; var __frame = { name: "__11", line: 575 }; return __func(_, this, arguments, __11, 3, __frame, function __$__11() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
if ((options.offset && (parseInt(options.offset) < 0))) {
return _(new Error($(("--offset must be greater than or equal to 0. Value passed in: " + options.offset)))); } ;
parameters = { };
if (options.offset) {
parameters.offset = parseInt(options.offset); }
else {
parameters.offset = 0; } ;
maxLength = ((1 * 1024) * 1024);
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription);
return client.fileSystem.getFileStatus(accountName, path, __cb(_, __frame, 24, 37, function ___(__0, __2) { fileInfo = __2;
length = 0;
if ((!options.length || (options.length <= 0))) {
length = (fileInfo.length - parameters.offset); }
else {
length = parseInt(options.length); } ;
if ((parameters.offset >= fileInfo.length)) {
return _(new Error($(((("--offset must be less than than the length of the file. File length: " + fileInfo.length) + ". Value passed in: ") + options.offset)))); } ;
if (((fileInfo.length - parameters.offset) < length)) {
length = (fileInfo.length - parameters.offset); } ;
if (((length > maxLength) && !options.force)) {
return _(new Error($(((("The remaining data to preview is greater than " + maxLength) + " bytes. Please specify a length or use the --force parameter to preview the entire file. The length of the file that would have been previewed: ") + length)))); } ;
parameters.length = length;
return withProgress(util.format($("Previewing contents of file %s"), path), function __1(log, _) { var __frame = { name: "__1", line: 625 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
return client.fileSystem.open(accountName, path, parameters, __cb(_, __frame, 2, 35, function ___(__0, __1) { response = __1; _(); }, true)); }); }, __cb(_, __frame, 49, 4, function __$__11() {
return readStreamToBuffer(response, __cb(_, __frame, 55, 15, function ___(__0, __3) { buff = __3;
log.data(buff.toString()); _(); }, true)); }, true)); }, true)); }); });
var dataLakeStoreFileSystemPermissions = dataLakeStoreCommands.category("permissions").description($("Commands to manage your Data Lake Storage FileSystem Permissions"));
dataLakeStoreFileSystemPermissions.command("show [accountName] [path]").description($("Gets the specified Data Lake Store folder ACL")).usage("[options] <accountName> <path>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the folder or file to get (e.g. /someFolder or /someFolder/someFile.txt)")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __12(accountName, path, options, _) { var subscription, client, aclStatus; var __frame = { name: "__12", line: 643 }; return __func(_, this, arguments, __12, 3, __frame, function __$__12() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription);
return client.fileSystem.getAclStatus(accountName, path, __cb(_, __frame, 12, 38, function ___(__0, __1) { aclStatus = __1.aclStatus;
dataLakeStoreUtils.formatOutput(cli, log, options, aclStatus); _(); }, true)); }); });
dataLakeStoreFileSystemPermissions.command("delete [accountName] [path]").description($("Deletes the entire ACL associated with a folder (not including un-named ACL entries)")).usage("[options] <accountName> <path>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the folder to remove ACLs from (e.g. /someFolder)")).option("-d --defaultAcl", $("optionally indicates that the default ACL should be removed instead of the regular ACL. Default is false.")).option("-q, --quiet", $("quiet mode (do not ask for delete confirmation)")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __13(accountName, path, options, _) { var subscription, client; var __frame = { name: "__13", line: 667 }; return __func(_, this, arguments, __13, 3, __frame, function __$__13() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ; return (function __$__13(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete Data Lake Store ACLs for account %s at path %s? [y/n] "), accountName, path), __cb(_, __frame, 9, 43, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -666, 17, function ___(__0, __2) { return (function __$__13(__then) { if (__2) { return _(null); } else { __then(); } ; })(function __$__13() {
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription); return (function __$__13(__then) {
if (options.defaultAcl) {
return client.fileSystem.removeDefaultAcl(accountName, path, __cb(_, __frame, 17, 24, __then, true)); } else {
return client.fileSystem.removeAcl(accountName, path, __cb(_, __frame, 20, 24, __then, true)); } ; })(function __$__13() {
log.info($("Successfully removed the specified ACL")); _(); }); }); }, true)); }); });
var dataLakeStoreFileSystemPermissionsEntries = dataLakeStoreFileSystemPermissions.category("entry").description($("Commands to manage your Data Lake Storage FileSystem granular permissions entries"));
dataLakeStoreFileSystemPermissionsEntries.command("delete [accountName] [path] [aclEntries]").description($("deletes the specific ACE entry or entries from the path")).usage("[options] <accountName> <path> <aclEntries>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the folder to remove ACEs from (e.g. /someFolder)")).option("-a --aclEntries <aclEntries>", $("a comma delimited list of the fully qualified ACE entry or entries to delete in the format [default:]<user>|<group>:<object Id> (e.g 'user:5546499e-795f-4f5f-b411-8179051f8b0a' or 'default:group:5546499e-795f-4f5f-b411-8179051f8b0a')")).option("-q, --quiet", $("quiet mode (do not ask for delete confirmation)")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __14(accountName, path, aclEntries, options, _) { var subscription, client; var __frame = { name: "__14", line: 703 }; return __func(_, this, arguments, __14, 4, __frame, function __$__14() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
if (!aclEntries) {
return _(null, cli.missingArgument("aclEntries")); } ; return (function __$__14(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete Data Lake Store ACL entries: %s for account %s at path %s? [y/n] "), aclEntries, accountName, path), __cb(_, __frame, 13, 43, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -702, 17, function ___(__0, __2) { return (function __$__14(__then) { if (__2) { return _(null); } else { __then(); } ; })(function __$__14() {
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription);
return client.fileSystem.removeAclEntries(accountName, path, aclEntries, __cb(_, __frame, 20, 22, function __$__14() {
log.info($("Successfully removed the specified ACL entries")); _(); }, true)); }); }, true)); }); });
dataLakeStoreFileSystemPermissionsEntries.command("set [accountName] [path] [aclEntries]").description($("sets the specified Data Lake Store folder ACE entry or entries")).usage("[options] <accountName> <path> <aclEntries>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the folder to set ACEs on (e.g. /someFolder)")).option("-a --aclEntries <aclEntries>", $("a comma delimited list of the fully qualified ACE entries to set in the format [default:]<user>|<group>:<object Id>:<permissions> (e.g 'user:5546499e-795f-4f5f-b411-8179051f8b0a:r-x' or 'default:group:5546499e-795f-4f5f-b411-8179051f8b0a:rwx')")).option("-q, --quiet", $("quiet mode (do not ask for overwrite confirmation)")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __15(accountName, path, aclEntries, options, _) { var subscription, client; var __frame = { name: "__15", line: 735 }; return __func(_, this, arguments, __15, 4, __frame, function __$__15() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
if (!aclEntries) {
return _(null, cli.missingArgument("aclEntries")); } ; return (function __$__15(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Potentially overwrite existing Data Lake Store ACL entries: %s for account %s at path %s? [y/n] "), aclEntries, accountName, path), __cb(_, __frame, 13, 43, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -734, 17, function ___(__0, __2) { return (function __$__15(__then) { if (__2) { return _(null); } else { __then(); } ; })(function __$__15() {
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription);
return client.fileSystem.modifyAclEntries(accountName, path, aclEntries, __cb(_, __frame, 20, 22, function __$__15() {
log.info($("Successfully set the specified ACL entries")); _(); }, true)); }); }, true)); }); });
dataLakeStoreFileSystemPermissions.command("set [accountName] [path] [aclSpec]").description($("sets the specified Data Lake Store folder ACL (overwriting the previous ACL entries)")).usage("[options] <accountName> <path> <aclSpec>").option("-n --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-p --path <path>", $("the full path to the folder to remove ACLs from (e.g. /someFolder)")).option("-a --aclSpec <aclSpec>", $("a comma delimited list of fully qualified ACL entries to set in the format [default:]<user>|<group>:<object Id>:<permissions> (e.g 'user:5546499e-795f-4f5f-b411-8179051f8b0a:r-x' or 'default:group:5546499e-795f-4f5f-b411-8179051f8b0a:rwx'). This list must also include default entries (no object ID in the middle)")).option("-q, --quiet", $("quiet mode (do not ask for overwrite confirmation)")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __16(accountName, path, aclSpec, options, _) { var subscription, client; var __frame = { name: "__16", line: 767 }; return __func(_, this, arguments, __16, 4, __frame, function __$__16() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!path) {
return _(null, cli.missingArgument("path")); } ;
if (!aclSpec) {
return _(null, cli.missingArgument("aclSpec")); } ; return (function __$__16(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Overwrite existing Data Lake Store ACL with the following ACL: %s for account %s at path %s? [y/n] "), aclSpec, accountName, path), __cb(_, __frame, 13, 43, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -766, 17, function ___(__0, __2) { return (function __$__16(__then) { if (__2) { return _(null); } else { __then(); } ; })(function __$__16() {
subscription = profile.current.getSubscription(options.subscription);
client = utils.createDataLakeStoreFileSystemManagementClient(subscription);
return client.fileSystem.setAcl(accountName, path, aclSpec, __cb(_, __frame, 20, 22, function __$__16() {
log.info($("Successfully set the ACL")); _(); }, true)); }); }, true)); }); });
var dataLakeStoreFirewallRules = dataLakeStoreCommands.category("firewall").description($("Commands to manage your Data Lake Storage account firewall rules"));
dataLakeStoreFirewallRules.command("create [accountName] [name] [startIpAddress] [endIpAddress]").description($("adds the specified firewall rule to the specified Data Lake Store account.")).usage("[options] <accountName> <name> <startIpAddress> <endIpAddress>").option("-a --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-n --name <firewall rule name>", $("the name of the firewall rule to add")).option("-t --startIpAddress <start ip address>", $("the start of the valid ip range for the firewall rule")).option("-e, --endIpAddress <end ip address>", $("the end of the valid ip range for the firewall rule")).option("-g --resource-group <resource-group>", $("optionally explicitly set the resource group. If not specified, will attempt to discover it.")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __17(accountName, name, startIpAddress, endIpAddress, options, _) { var subscription, client, parameters, result; var __frame = { name: "__17", line: 803 }; return __func(_, this, arguments, __17, 5, __frame, function __$__17() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!name) {
return _(null, cli.missingArgument("name")); } ;
if (!startIpAddress) {
return _(null, cli.missingArgument("startIpAddress")); } ;
if (!endIpAddress) {
return _(null, cli.missingArgument("endIpAddress")); } ;
subscription = profile.current.getSubscription(options.subscription); return (function __$__17(__then) {
if (!options.resourceGroup) {
return getResourceGroupByAccountName(subscription, options.resourceGroup, accountName, __cb(_, __frame, 20, 30, function ___(__0, __1) { options.resourceGroup = __1; __then(); }, true)); } else { __then(); } ; })(function __$__17() {
client = utils.createDataLakeStoreManagementClient(subscription);
parameters = {
startIpAddress: startIpAddress,
endIpAddress: endIpAddress };
return client.firewallRules.createOrUpdate(options.resourceGroup, accountName, name, parameters, __cb(_, __frame, 29, 38, function ___(__0, __2) { result = __2;
dataLakeStoreUtils.formatOutput(cli, log, options, result); _(); }, true)); }); }); });
dataLakeStoreFirewallRules.command("set [accountName] [name]").description($("updates the specified firewall rule in the specified Data Lake Store account.")).usage("[options] <accountName> <name>").option("-a --accountName <accountName>", $("the Data Lake Store account name to execute the action on")).option("-n --name <firewall rule name>", $("the name of the firewall rule to update")).option("-t --startIpAddress <start ip address>", $("the optional new start of the valid ip range for the firewall rule")).option("-e, --endIpAddress <end ip address>", $("the optional new end of the valid ip range for the firewall rule")).option("-g --resource-group <resource-group>", $("optionally explicitly set the resource group. If not specified, will attempt to discover it.")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __18(accountName, name, options, _) { var subscription, client, currentRule, parameters, result; var __frame = { name: "__18", line: 845 }; return __func(_, this, arguments, __18, 3, __frame, function __$__18() {
if (!accountName) {
return _(null, cli.missingArgument("accountName")); } ;
if (!name) {