UNPKG

@azure/storage-file-datalake

Version:

Microsoft Azure Storage SDK for JavaScript - DataLake

1,143 lines (1,116 loc) 245 kB
import type { AbortSignalLike } from '@azure/abort-controller'; import { AnonymousCredential } from '@azure/storage-blob'; import { AnonymousCredentialPolicy } from '@azure/storage-blob'; import { AzureLogger } from '@azure/logger'; import { BaseRequestPolicy } from '@azure/storage-blob'; import type { BlobLeaseClient } from '@azure/storage-blob'; import type { BlobQueryArrowConfiguration } from '@azure/storage-blob'; import type { ContainerRenameResponse } from '@azure/storage-blob'; import type { ContainerUndeleteResponse } from '@azure/storage-blob'; import * as coreClient from '@azure/core-client'; import * as coreHttpCompat from '@azure/core-http-compat'; import * as coreRestPipeline from '@azure/core-rest-pipeline'; import { Credential as Credential_2 } from '@azure/storage-blob'; import { CredentialPolicy } from '@azure/storage-blob'; import { ServiceGetPropertiesResponse as DataLakeServiceGetPropertiesResponse } from '@azure/storage-blob'; import { BlobServiceProperties as DataLakeServiceProperties } from '@azure/storage-blob'; import { HttpHeadersLike as HttpHeaders } from '@azure/core-http-compat'; import { CompatResponse as HttpOperationResponse } from '@azure/core-http-compat'; import { RequestBodyType as HttpRequestBody } from '@azure/core-rest-pipeline'; import { isPipelineLike } from '@azure/storage-blob'; import type { KeepAliveOptions } from '@azure/core-http-compat'; import { Lease } from '@azure/storage-blob'; import { LeaseAccessConditions } from '@azure/storage-blob'; import { LeaseOperationOptions } from '@azure/storage-blob'; import { LeaseOperationResponse } from '@azure/storage-blob'; import type { ModifiedAccessConditions as ModifiedAccessConditions_3 } from '@azure/storage-blob'; import type { OperationTracingOptions } from '@azure/core-tracing'; import type { PagedAsyncIterableIterator } from '@azure/core-paging'; import { Pipeline } from '@azure/storage-blob'; import { PipelineLike } from '@azure/storage-blob'; import { PipelineOptions } from '@azure/storage-blob'; import type { ProxySettings } from '@azure/core-rest-pipeline'; import type { Readable } from 'stream'; import { RequestPolicy } from '@azure/core-http-compat'; import { RequestPolicyFactory } from '@azure/core-http-compat'; import { RequestPolicyOptionsLike as RequestPolicyOptions } from '@azure/core-http-compat'; import { RestError } from '@azure/core-rest-pipeline'; import { ServiceClientOptions } from '@azure/storage-blob'; import type { ServiceGetPropertiesOptions } from '@azure/storage-blob'; import { ServiceListContainersSegmentResponse } from '@azure/storage-blob'; import type { ServiceRenameContainerOptions } from '@azure/storage-blob'; import type { ServiceSetPropertiesOptions } from '@azure/storage-blob'; import type { ServiceSetPropertiesResponse } from '@azure/storage-blob'; import { StorageBrowserPolicy } from '@azure/storage-blob'; import { StorageBrowserPolicyFactory } from '@azure/storage-blob'; import { StorageRetryOptions } from '@azure/storage-blob'; import { StorageRetryPolicy } from '@azure/storage-blob'; import { StorageRetryPolicyFactory } from '@azure/storage-blob'; import { StorageRetryPolicyType } from '@azure/storage-blob'; import { StorageSharedKeyCredential } from '@azure/storage-blob'; import { StorageSharedKeyCredentialPolicy } from '@azure/storage-blob'; import type { TokenCredential } from '@azure/core-auth'; import type { TransferProgressEvent } from '@azure/core-rest-pipeline'; import type { UserAgentPolicyOptions } from '@azure/core-rest-pipeline'; import { UserDelegationKeyModel } from '@azure/storage-blob'; import { WebResourceLike as WebResource } from '@azure/core-http-compat'; import type { WithResponse } from '@azure/storage-blob'; /** * AccessControlChangeCounters contains counts of operations that change Access Control Lists recursively. */ export declare interface AccessControlChangeCounters { /** * Returns number of directories where Access Control List has been updated successfully. */ changedDirectoriesCount: number; /** * Returns number of files where Access Control List has been updated successfully. */ changedFilesCount: number; /** * Returns number of paths where Access Control List update has failed. */ failedChangesCount: number; } /** * Represents an entry that failed to update Access Control List during `setAccessControlRecursive`, `updateAccessControlRecursive` and `removeAccessControlRecursive`. */ export declare interface AccessControlChangeError { /** * Returns name of an entry. */ name: string; /** * Returns whether entry is a directory. */ isDirectory: boolean; /** * Returns error message that is the reason why entry failed to update. */ message: string; } /** * AccessControlChanges contains batch and cumulative counts of operations that change Access Control Lists recursively. * Additionally it exposes path entries that failed to update while these operations progress. */ export declare interface AccessControlChanges { /** * Path entries that failed to update Access Control List within single batch. */ batchFailures: AccessControlChangeError[]; /** * Counts of paths changed within single batch. */ batchCounters: AccessControlChangeCounters; /** * Counts of paths changed from start of the operation. */ aggregateCounters: AccessControlChangeCounters; /** * Optional. Value is present when operation is split into multiple batches and can be used to resume progress. */ continuationToken?: string; } export declare type AccessControlType = "user" | "group" | "mask" | "other"; export declare interface AccessPolicy { startsOn?: Date; expiresOn?: Date; permissions: string; } /** * ONLY AVAILABLE IN NODE.JS RUNTIME. * * This is a helper class to construct a string representing the permissions granted by an AccountSAS. Setting a value * to true means that any SAS which uses these permissions will grant permissions for that operation. Once all the * values are set, this should be serialized with toString and set as the permissions field on an * {@link AccountSASSignatureValues} object. It is possible to construct the permissions string without this class, but * the order of the permissions is particular and this class guarantees correctness. */ export declare class AccountSASPermissions { /** * Parse initializes the AccountSASPermissions fields from a string. * * @param permissions - */ static parse(permissions: string): AccountSASPermissions; /** * Permission to read resources and list queues and tables granted. */ read: boolean; /** * Permission to write resources granted. */ write: boolean; /** * Permission to delete blobs and files granted. */ delete: boolean; /** * Permission to list blob containers, blobs, shares, directories, and files granted. */ list: boolean; /** * Permission to add messages, table entities, and append to blobs granted. */ add: boolean; /** * Permission to create blobs and files granted. */ create: boolean; /** * Permissions to update messages and table entities granted. */ update: boolean; /** * Permission to get and delete messages granted. */ process: boolean; /** * Produces the SAS permissions string for an Azure Storage account. * Call this method to set AccountSASSignatureValues Permissions field. * * Using this method will guarantee the resource types are in * an order accepted by the service. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas * */ toString(): string; } /** * ONLY AVAILABLE IN NODE.JS RUNTIME. * * This is a helper class to construct a string representing the resources accessible by an AccountSAS. Setting a value * to true means that any SAS which uses these permissions will grant access to that resource type. Once all the * values are set, this should be serialized with toString and set as the resources field on an * {@link AccountSASSignatureValues} object. It is possible to construct the resources string without this class, but * the order of the resources is particular and this class guarantees correctness. */ export declare class AccountSASResourceTypes { /** * Creates an {@link AccountSASResourceTypes} from the specified resource types string. This method will throw an * Error if it encounters a character that does not correspond to a valid resource type. * * @param resourceTypes - */ static parse(resourceTypes: string): AccountSASResourceTypes; /** * Permission to access service level APIs granted. */ service: boolean; /** * Permission to access container level APIs (Blob Containers, Tables, Queues, File Shares, File Systems) granted. */ container: boolean; /** * Permission to access object level APIs (Blobs, Table Entities, Queue Messages, Files, Directories) granted. */ object: boolean; /** * Converts the given resource types to a string. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas * */ toString(): string; } /** * ONLY AVAILABLE IN NODE.JS RUNTIME. * * This is a helper class to construct a string representing the services accessible by an AccountSAS. Setting a value * to true means that any SAS which uses these permissions will grant access to that service. Once all the * values are set, this should be serialized with toString and set as the services field on an * {@link AccountSASSignatureValues} object. It is possible to construct the services string without this class, but * the order of the services is particular and this class guarantees correctness. */ export declare class AccountSASServices { /** * Creates an {@link AccountSASServices} from the specified services string. This method will throw an * Error if it encounters a character that does not correspond to a valid service. * * @param services - */ static parse(services: string): AccountSASServices; /** * Permission to access blob and data lake resources granted. */ blob: boolean; /** * Permission to access file resources granted. */ file: boolean; /** * Permission to access queue resources granted. */ queue: boolean; /** * Permission to access table resources granted. */ table: boolean; /** * Converts the given services to a string. * */ toString(): string; } /** * ONLY AVAILABLE IN NODE.JS RUNTIME. * * AccountSASSignatureValues is used to generate a Shared Access Signature (SAS) for an Azure Storage account. Once * all the values here are set appropriately, call {@link generateAccountSASQueryParameters} to obtain a representation * of the SAS which can actually be applied to data lake urls. Note: that both this class and {@link SASQueryParameters} * exist because the former is mutable and a logical representation while the latter is immutable and used to generate * actual REST requests. * * @see https://learn.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1 * for more conceptual information on SAS * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas * for descriptions of the parameters, including which are required */ export declare interface AccountSASSignatureValues { /** * If not provided, this defaults to the service version targeted by this version of the library. */ version?: string; /** * Optional. SAS protocols allowed. */ protocol?: SASProtocol; /** * Optional. When the SAS will take effect. */ startsOn?: Date; /** * The time after which the SAS will no longer work. */ expiresOn: Date; /** * Specifies which operations the SAS user may perform. Please refer to {@link AccountSASPermissions} for help * constructing the permissions string. */ permissions: AccountSASPermissions; /** * Optional. IP range allowed. */ ipRange?: SasIPRange; /** * Optional. Encryption scope to use when sending requests authorized with this SAS URI. */ encryptionScope?: string; /** * The values that indicate the services accessible with this SAS. Please refer to {@link AccountSASServices} to * construct this value. */ services: string; /** * The values that indicate the resource types accessible with this SAS. Please refer * to {@link AccountSASResourceTypes} to construct this value. */ resourceTypes: string; } declare interface AclFailedEntry { name?: string; type?: string; errorMessage?: string; } export { AnonymousCredential } export { AnonymousCredentialPolicy } export { BaseRequestPolicy } export declare interface BlobHierarchyListSegment { blobPrefixes?: BlobPrefix[]; blobItems: BlobItemModel[]; } /** An Azure Storage blob */ export declare interface BlobItemModel { name: string; deleted: boolean; snapshot: string; versionId?: string; isCurrentVersion?: boolean; /** Properties of a blob */ properties: BlobPropertiesModel; deletionId?: string; } export declare interface BlobPrefix { name: string; } /** Properties of a blob */ export declare interface BlobPropertiesModel { creationTime?: Date; lastModified: Date; etag: string; /** Size in bytes */ contentLength?: number; contentType?: string; contentEncoding?: string; contentLanguage?: string; contentMD5?: Uint8Array; contentDisposition?: string; cacheControl?: string; blobSequenceNumber?: number; copyId?: string; copySource?: string; copyProgress?: string; copyCompletionTime?: Date; copyStatusDescription?: string; serverEncrypted?: boolean; incrementalCopy?: boolean; destinationSnapshot?: string; deletedTime?: Date; remainingRetentionDays?: number; accessTierInferred?: boolean; customerProvidedKeySha256?: string; /** The name of the encryption scope under which the blob is encrypted. */ encryptionScope?: string; accessTierChangeTime?: Date; tagCount?: number; expiresOn?: Date; sealed?: boolean; lastAccessedOn?: Date; } /** * Common options of the {@link FileSystemGenerateSasUrlOptions}, {@link DirectoryGenerateSasUrlOptions} * and {@link FileGenerateSasUrlOptions}. */ export declare interface CommonGenerateSasUrlOptions { /** * The version of the service this SAS will target. If not specified, it will default to the version targeted by the * library. */ version?: string; /** * Optional. SAS protocols, HTTPS only or HTTPSandHTTP */ protocol?: SASProtocol; /** * Optional. When the SAS will take effect. */ startsOn?: Date; /** * Optional only when identifier is provided. The time after which the SAS will no longer work. */ expiresOn?: Date; /** * Optional. IP ranges allowed in this SAS. */ ipRange?: SasIPRange; /** * Optional. The name of the access policy on the container this SAS references if any. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/establishing-a-stored-access-policy */ identifier?: string; /** * Optional. Encryption scope to use when sending requests authorized with this SAS URI. */ encryptionScope?: string; /** * Optional. The cache-control header for the SAS. */ cacheControl?: string; /** * Optional. The content-disposition header for the SAS. */ contentDisposition?: string; /** * Optional. The content-encoding header for the SAS. */ contentEncoding?: string; /** * Optional. The content-language header for the SAS. */ contentLanguage?: string; /** * Optional. The content-type header for the SAS. */ contentType?: string; } /** * An interface for options common to every remote operation. */ export declare interface CommonOptions { tracingOptions?: OperationTracingOptions; } export declare type CopyStatusType = "pending" | "success" | "aborted" | "failed"; /** Parameter group */ export declare interface CpkInfo { /** Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. */ encryptionKey?: string; /** The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. */ encryptionKeySha256?: string; /** The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. */ encryptionAlgorithm?: EncryptionAlgorithmType; } export { Credential_2 as Credential } export { CredentialPolicy } /** * An error thrown when an operation is interrupted and can be continued later on. */ export declare class DataLakeAclChangeFailedError extends Error { /** * Continuation token to continue next batch of operations. */ continuationToken?: string; /** * Internal error. */ innerError: RestError | Error; constructor(error: RestError | Error, continuationToken?: string); } /** * A DataLakeDirectoryClient represents a URL to the Azure Storage directory. */ export declare class DataLakeDirectoryClient extends DataLakePathClient { /** * Create a directory. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param resourceType - Resource type, must be "directory" for DataLakeDirectoryClient. * @param options - Optional. Options when creating directory. */ create(resourceType: PathResourceTypeModel, options?: PathCreateOptions): Promise<PathCreateResponse>; /** * Create a directory. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param options - Optional. Options when creating directory. */ create(options?: DirectoryCreateOptions): Promise<DirectoryCreateResponse>; /** * Create a directory if it doesn't already exists. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param resourceType - Resource type, must be "directory" for DataLakeDirectoryClient. * @param options - */ createIfNotExists(resourceType: PathResourceTypeModel, options?: PathCreateIfNotExistsOptions): Promise<PathCreateIfNotExistsResponse>; /** * Create a directory if it doesn't already exists. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param options - */ createIfNotExists(options?: DirectoryCreateIfNotExistsOptions): Promise<DirectoryCreateIfNotExistsResponse>; /** * Creates a {@link DataLakeDirectoryClient} object under current directory. * * @param subdirectoryName - Subdirectory name. */ getSubdirectoryClient(subdirectoryName: string): DataLakeDirectoryClient; /** * Creates a {@link DataLakeFileClient} object under current directory. * * @param fileName - */ getFileClient(fileName: string): DataLakeFileClient; /** * Only available for clients constructed with a shared key credential. * * Generates a Service Shared Access Signature (SAS) URI based on the client properties * and parameters passed in. The SAS is signed by the shared key credential of the client. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas * * @param options - Optional parameters. * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateSasUrl(options: DirectoryGenerateSasUrlOptions): Promise<string>; /** * Generates string to sign for a Service Shared Access Signature (SAS) URI based on the client properties * and parameters passed in. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas * * @param options - Optional parameters. * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateSasStringToSign(options: DirectoryGenerateSasUrlOptions): string; /** * Generates a Service Shared Access Signature (SAS) URI based on the client properties * and parameters passed in. The SAS is signed by the input user delegation key. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas * * @param options - Optional parameters. * @param userDelegationKey - Return value of `blobServiceClient.getUserDelegationKey()` * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateUserDelegationSasUrl(options: DirectoryGenerateSasUrlOptions, userDelegationKey: UserDelegationKey): Promise<string>; /** * Generates string to sign for a Service Shared Access Signature (SAS) URI based on the client properties * and parameters passed in The SAS is signed by the input user delegation key. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas * * @param options - Optional parameters. * @param userDelegationKey - Return value of `blobServiceClient.getUserDelegationKey()` * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateUserDelegationSasStringToSign(options: DirectoryGenerateSasUrlOptions, userDelegationKey: UserDelegationKey): string; } /** * A DataLakeFileClient represents a URL to the Azure Storage file. */ export declare class DataLakeFileClient extends DataLakePathClient { /** * pathContextInternal provided by protocol layer. */ private pathContextInternal; /** * pathContextInternal provided by protocol layer, with its url pointing to the Blob endpoint. */ private pathContextInternalToBlobEndpoint; /** * blockBlobClientInternal provided by `@azure/storage-blob` package. */ private blockBlobClientInternal; /** * Creates an instance of DataLakeFileClient from url and credential. * * @param url - A Client string pointing to Azure Storage data lake file, such as * "https://myaccount.dfs.core.windows.net/filesystem/file". * You can append a SAS if using AnonymousCredential, such as "https://myaccount.dfs.core.windows.net/filesystem/directory/file?sasString". * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used. * @param options - Optional. Options to configure the HTTP pipeline. */ constructor(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions); /** * Creates an instance of DataLakeFileClient from url and pipeline. * * @param url - A Client string pointing to Azure Storage data lake file, such as * "https://myaccount.dfs.core.windows.net/filesystem/file". * You can append a SAS if using AnonymousCredential, such as "https://myaccount.dfs.core.windows.net/filesystem/directory/file?sasString". * @param pipeline - Call newPipeline() to create a default * pipeline, or provide a customized pipeline. */ constructor(url: string, pipeline: Pipeline); /** * Create a file. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param resourceType - Resource type, must be "file" for DataLakeFileClient. * @param options - Optional. Options when creating file. */ create(resourceType: PathResourceTypeModel, options?: PathCreateOptions): Promise<PathCreateResponse>; /** * Create a file. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param options - Optional. Options when creating file. */ create(options?: FileCreateOptions): Promise<FileCreateResponse>; /** * Create a file if it doesn't already exists. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param resourceType - Resource type, must be "file" for DataLakeFileClient. * @param options - */ createIfNotExists(resourceType: PathResourceTypeModel, options?: PathCreateIfNotExistsOptions): Promise<PathCreateIfNotExistsResponse>; /** * Create a file if it doesn't already exists. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param options - Optional. Options when creating file. */ createIfNotExists(options?: FileCreateIfNotExistsOptions): Promise<FileCreateIfNotExistsResponse>; /** * Downloads a file from the service, including its metadata and properties. * * * In Node.js, data returns in a Readable stream readableStreamBody * * In browsers, data returns in a promise contentAsBlob * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob * * * Example usage (Node.js): * * ```js * // Download and convert a file to a string * const downloadResponse = await fileClient.read(); * const downloaded = await streamToBuffer(downloadResponse.readableStreamBody); * console.log("Downloaded file content:", downloaded.toString()); * * async function streamToBuffer(readableStream) { * return new Promise((resolve, reject) => { * const chunks = []; * readableStream.on("data", (data) => { * chunks.push(typeof data === "string" ? Buffer.from(data) : data); * }); * readableStream.on("end", () => { * resolve(Buffer.concat(chunks)); * }); * readableStream.on("error", reject); * }); * } * ``` * * Example usage (browser): * * ```js * // Download and convert a file to a string * const downloadResponse = await fileClient.read(); * const downloaded = await blobToString(await downloadResponse.contentAsBlob); * console.log("Downloaded file content", downloaded); * * async function blobToString(blob: Blob): Promise<string> { * const fileReader = new FileReader(); * return new Promise<string>((resolve, reject) => { * fileReader.onloadend = (ev: any) => { * resolve(ev.target!.result); * }; * fileReader.onerror = reject; * fileReader.readAsText(blob); * }); * } * ``` * * @param offset - Optional. Offset to read file, default value is 0. * @param count - Optional. How many bytes to read, default will read from offset to the end. * @param options - Optional. Options when reading file. */ read(offset?: number, count?: number, options?: FileReadOptions): Promise<FileReadResponse>; /** * Uploads data to be appended to a file. Data can only be appended to a file. * To apply perviously uploaded data to a file, call flush. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update * * @param body - Content to be uploaded. * @param offset - Append offset in bytes. * @param length - Length of content to append in bytes. * @param options - Optional. Options when appending data. */ append(body: HttpRequestBody, offset: number, length: number, options?: FileAppendOptions): Promise<FileAppendResponse>; /** * Flushes (writes) previously appended data to a file. * * @param position - File position to flush. * This parameter allows the caller to upload data in parallel and control the order in which it is appended to the file. * It is required when uploading data to be appended to the file and when flushing previously uploaded data to the file. * The value must be the position where the data is to be appended. Uploaded data is not immediately flushed, or written, * to the file. To flush, the previously uploaded data must be contiguous, the position parameter must be specified and * equal to the length of the file after all data has been written, and there must not be a request entity body included * with the request. * @param options - Optional. Options when flushing data. */ flush(position: number, options?: FileFlushOptions): Promise<FileFlushResponse>; /** * ONLY AVAILABLE IN NODE.JS RUNTIME. * * Uploads a local file to a Data Lake file. * * @param filePath - Full path of the local file * @param options - */ uploadFile(filePath: string, options?: FileParallelUploadOptions): Promise<FileUploadResponse>; /** * Uploads a Buffer(Node.js)/Blob/ArrayBuffer/ArrayBufferView to a File. * * @param data - Buffer(Node), Blob, ArrayBuffer or ArrayBufferView * @param options - */ upload(data: Buffer | Blob | ArrayBuffer | ArrayBufferView, options?: FileParallelUploadOptions): Promise<FileUploadResponse>; private uploadSeekableInternal; /** * ONLY AVAILABLE IN NODE.JS RUNTIME. * * Uploads a Node.js Readable stream into a Data Lake file. * This method will try to create a file, then starts uploading chunk by chunk. * Please make sure potential size of stream doesn't exceed FILE_MAX_SIZE_BYTES and * potential number of chunks doesn't exceed BLOCK_BLOB_MAX_BLOCKS. * * PERFORMANCE IMPROVEMENT TIPS: * * Input stream highWaterMark is better to set a same value with options.chunkSize * parameter, which will avoid Buffer.concat() operations. * * @param stream - Node.js Readable stream. * @param options - */ uploadStream(stream: Readable, options?: FileParallelUploadOptions): Promise<FileUploadResponse>; /** * ONLY AVAILABLE IN NODE.JS RUNTIME. * * Reads a Data Lake file in parallel to a buffer. * Offset and count are optional, pass 0 for both to read the entire file. * * Warning: Buffers can only support files up to about one gigabyte on 32-bit systems or about two * gigabytes on 64-bit systems due to limitations of Node.js/V8. For files larger than this size, * consider {@link readToFile}. * * @param buffer - Buffer to be fill, must have length larger than count * @param offset - From which position of the Data Lake file to read * @param count - How much data to be read. Will read to the end when passing undefined * @param options - */ readToBuffer(buffer: Buffer, offset?: number, count?: number, options?: FileReadToBufferOptions): Promise<Buffer>; /** * ONLY AVAILABLE IN NODE.JS RUNTIME * * Reads a Data Lake file in parallel to a buffer. * Offset and count are optional, pass 0 for both to read the entire file * * Warning: Buffers can only support files up to about one gigabyte on 32-bit systems or about two * gigabytes on 64-bit systems due to limitations of Node.js/V8. For files larger than this size, * consider {@link readToFile}. * * @param offset - From which position of the Data Lake file to read(in bytes) * @param count - How much data(in bytes) to be read. Will read to the end when passing undefined * @param options - */ readToBuffer(offset?: number, count?: number, options?: FileReadToBufferOptions): Promise<Buffer>; /** * ONLY AVAILABLE IN NODE.JS RUNTIME. * * Downloads a Data Lake file to a local file. * Fails if the the given file path already exits. * Offset and count are optional, pass 0 and undefined respectively to download the entire file. * * @param filePath - * @param offset - From which position of the file to download. * @param count - How much data to be downloaded. Will download to the end when passing undefined. * @param options - Options to read Data Lake file. * @returns The response data for file read operation, * but with readableStreamBody set to undefined since its * content is already read and written into a local file * at the specified path. */ readToFile(filePath: string, offset?: number, count?: number, options?: FileReadOptions): Promise<FileReadResponse>; /** * Quick query for a JSON or CSV formatted file. * * Example usage (Node.js): * * ```js * // Query and convert a file to a string * const queryResponse = await fileClient.query("select * from BlobStorage"); * const downloaded = (await streamToBuffer(queryResponse.readableStreamBody)).toString(); * console.log("Query file content:", downloaded); * * async function streamToBuffer(readableStream) { * return new Promise((resolve, reject) => { * const chunks = []; * readableStream.on("data", (data) => { * chunks.push(typeof data === "string" ? Buffer.from(data) : data); * }); * readableStream.on("end", () => { * resolve(Buffer.concat(chunks)); * }); * readableStream.on("error", reject); * }); * } * ``` * * @param query - * @param options - */ query(query: string, options?: FileQueryOptions): Promise<FileReadResponse>; /** * Sets an expiry time on a file, once that time is met the file is deleted. * * @param mode - * @param options - */ setExpiry(mode: FileExpiryMode, options?: FileSetExpiryOptions): Promise<FileSetExpiryResponse>; /** * Only available for clients constructed with a shared key credential. * * Generates a Service Shared Access Signature (SAS) URI based on the client properties * and parameters passed in. The SAS is signed by the shared key credential of the client. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas * * @param options - Optional parameters. * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateSasUrl(options: FileGenerateSasUrlOptions): Promise<string>; /** * Only available for clients constructed with a shared key credential. * * Generates string to sign for a Service Shared Access Signature (SAS) URI based on the client properties * and parameters passed in. The SAS is signed by the shared key credential of the client. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas * * @param options - Optional parameters. * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateSasStringToSign(options: FileGenerateSasUrlOptions): string; /** * Generates a Service Shared Access Signature (SAS) URI based on the client properties * and parameters passed in. The SAS is signed by the input user delegation key. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas * * @param options - Optional parameters. * @param userDelegationKey - Return value of `blobServiceClient.getUserDelegationKey()` * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateUserDelegationSasUrl(options: FileGenerateSasUrlOptions, userDelegationKey: UserDelegationKey): Promise<string>; /** * Generates string to sign for a Service Shared Access Signature (SAS) URI based on the client properties * and parameters passed in. The SAS is signed by the input user delegation key. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas * * @param options - Optional parameters. * @param userDelegationKey - Return value of `blobServiceClient.getUserDelegationKey()` * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateUserDelegationSasStringToSign(options: FileGenerateSasUrlOptions, userDelegationKey: UserDelegationKey): string; } /** * A DataLakeFileSystemClient represents a URL to the Azure Storage file system * allowing you to manipulate its directories and files. */ export declare class DataLakeFileSystemClient extends StorageClient { /** * fileSystemContext provided by protocol layer. */ private fileSystemContext; /** * fileSystemContext provided by protocol layer. */ private fileSystemContextToBlobEndpoint; /** * blobContainerClient provided by `@azure/storage-blob` package. */ private blobContainerClient; /** * Creates an instance of DataLakeFileSystemClient from url and credential. * * @param url - A Client string pointing to Azure Storage data lake file system, such as * "https://myaccount.dfs.core.windows.net/filesystem". You can append a SAS * if using AnonymousCredential, such as "https://myaccount.dfs.core.windows.net/filesystem?sasString". * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used. * @param options - Optional. Options to configure the HTTP pipeline. */ constructor(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions); /** * Creates an instance of DataLakeFileSystemClient from url and pipeline. * * @param url - A Client string pointing to Azure Storage data lake file system, such as * "https://myaccount.dfs.core.windows.net/filesystem". You can append a SAS * if using AnonymousCredential, such as "https://myaccount.dfs.core.windows.net/filesystem?sasString". * @param pipeline - Call newPipeline() to create a default * pipeline, or provide a customized pipeline. */ constructor(url: string, pipeline: Pipeline); /** * Name of current file system. * * @readonly */ get name(): string; /** * Creates a {@link DataLakeDirectoryClient} object under current file system. * * @param directoryName - */ getDirectoryClient(directoryName: string): DataLakeDirectoryClient; /** * Creates a {@link DataLakeFileClient} object under current file system. * * @param fileName - */ getFileClient(fileName: string): DataLakeFileClient; /** * Get a {@link DataLakeLeaseClient} that manages leases on the file system. * * @param proposeLeaseId - Optional. Initial proposed lease Id. */ getDataLakeLeaseClient(proposeLeaseId?: string): DataLakeLeaseClient; /** * Creates a new file system under the specified account. If the file system with * the same name already exists, the operation fails. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/create-container * * @param options - Optional. Options when creating file system. */ create(options?: FileSystemCreateOptions): Promise<FileSystemCreateResponse>; /** * Creates a new file system under the specified account. If the file system with * the same name already exists, it is not changed. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/create-container * * @param options - */ createIfNotExists(options?: FileSystemCreateOptions): Promise<FileSystemCreateIfNotExistsResponse>; /** * Returns true if the File system represented by this client exists; false otherwise. * * NOTE: use this function with care since an existing file system might be deleted by other clients or * applications. Vice versa new file system with the same name might be added by other clients or * applications after this function completes. * * @param options - */ exists(options?: FileSystemExistsOptions): Promise<boolean>; /** * Delete current file system. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/delete-container * * @param options - Optional. Options when deleting file system. */ delete(options?: FileSystemDeleteOptions): Promise<FileSystemDeleteResponse>; /** * Delete current file system if it exists. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/delete-container * * @param options - */ deleteIfExists(options?: FileSystemDeleteOptions): Promise<FileSystemDeleteIfExistsResponse>; /** * Returns all user-defined metadata and system properties for the specified * file system. * * WARNING: The `metadata` object returned in the response will have its keys in lowercase, even if * they originally contained uppercase characters. This differs from the metadata keys returned by * the `listFileSystems` method of {@link DataLakeServiceClient} using the `includeMetadata` option, which * will retain their original casing. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/get-container-properties * * @param options - Optional. Options when getting file system properties. */ getProperties(options?: FileSystemGetPropertiesOptions): Promise<FileSystemGetPropertiesResponse>; /** * Sets one or more user-defined name-value pairs for the specified file system. * * If no option provided, or no metadata defined in the parameter, the file system * metadata will be removed. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/set-container-metadata * * @param metadata - Replace existing metadata with this value. * If no value provided the existing metadata will be removed. * @param options - Optional. Options when setting file system metadata. */ setMetadata(metadata?: Metadata, options?: FileSystemSetMetadataOptions): Promise<FileSystemSetMetadataResponse>; /** * Gets the permissions for the specified file system. The permissions indicate * whether file system data may be accessed publicly. * * WARNING: JavaScript Date will potentially lose precision when parsing startsOn and expiresOn strings. * For example, new Date("2018-12-31T03:44:23.8827891Z").toISOString() will get "2018-12-31T03:44:23.882Z". * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/get-container-acl * * @param options - Optional. Options when getting file system access policy. */ getAccessPolicy(options?: FileSystemGetAccessPolicyOptions): Promise<FileSystemGetAccessPolicyResponse>; /** * Sets the permissions for the specified file system. The permissions indicate * whether directories or files in a file system may be accessed publicly. * * When you set permissions for a file system, the existing permissions are replaced. * If no access or containerAcl provided, the existing file system ACL will be * removed. * * @see https://learn.microsoft.com/en-us/rest/api/storageservices/set-container-acl * * @param access - Optional. The level of public access to data in the file system. * @param fileSystemAcl - Optional. Array of elements each having a unique Id and details of the access policy. * @param options - Optional. Options when setting file system access policy. */ setAccessPolicy(access?: PublicAccessType, fileSystemAcl?: SignedIdentifier<AccessPolicy>[], options?: FileSystemSetAccessPolicyOptions): Promise<FileSystemSetAccessPolicyResponse>; /** * Returns an async iterable iterator to list all the paths (directories and files) * under the specified file system. * * .byPage() returns an async iterable iterator to list the paths in pages. * * Example using `for await` syntax: * * ```js * // Get the fileSystemClient before you run these snippets, * // Can be obtained from `serviceClient.getFileSystemClient("<your-filesystem-name>");` * let i = 1; * for await (const path of fileSystemClient.listPaths()) { * console.log(`Path ${i++}: ${path.name}, isDirectory?: ${path.isDirectory}`); * } * ``` * * Example using `iter.next()`: * * ```js * let i = 1; * let iter = fileSystemClient.listPaths(); * let pathItem = await iter.next(); * while (!pathItem.done) { * console.log(`Path ${i++}: ${pathItem.value.name}, isDirectory?: ${pathItem.value.isDirectory}`); * pathItem = await iter.next(); * } * ``` * * Example using `byPage()`: * * ```js * // passing optional maxPageSize in the page settings * let i = 1; * for await (const response of fileSystemClient.listPaths().byPage({ maxPageSize: 20 })) { * for (const path of response.pathItems) { * console.log(`Path ${i++}: ${path.name}, isDirectory?: ${path.isDirectory}`); * } * } * ``` * * Example using paging with a marker: * * ```js * let i = 1; * let iterator = fileSystemClient.listPaths().byPage({ maxPageSize: 2 }); * let response = (await iterator.next()).value; * * // Prints 2 path names * for (const path of response.pathItems) { * console.log(`Path ${i++}: ${path.name}, isDirectory?: ${path.isDirectory}`); * } * * // Gets next marker * let marker = response.continuationToken; * * // Passing next marker as continuationToken * * iterator = fileSystemClient.listPaths().byPage({ continuationToken: marker, maxPageSize: 10 }); * response = (await iterator.next()).value; * * // Prints 10 path names * for (const path of response.pathItems) { * console.log(`Path ${i++}: ${path.name}, isDirectory?: ${path.isDirectory}`); * } * ``` * * @see https://learn.microsoft.com/rest/api/storageservices/list-blobs * * @param options - Optional. Options when listing paths. */ listPaths(options?: ListPathsOptions): PagedAsyncIterableIterator<Path, FileSystemListPathsResponse>; private listItems; private listSegments; private listPathsSegment; /** * Returns an async iterable iterator to list all the paths (directories and files) * under the specified file system. * * .byPage() returns an async iterable iterator to list the paths in pages. * * Example using `for await` syntax: * * ```js * // Get the fileSystemClient before you run these snippets, * // Can be obtained from `serviceClient.getFileSystemClient("<your-filesystem-name>");` * let i = 1; * for a