UNPKG

azure-storage

Version:

Microsoft Azure Storage Client Library for Node.js

541 lines (511 loc) 709 kB
// // Copyright (c) Microsoft and contributors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // limitations under the License. // /// <reference path="../typings/node-uuid/node-uuid.d.ts" /> declare module "azure-storage" { import * as events from 'events'; import * as url from 'url'; import * as stream from 'stream'; interface Map<T> { [index: string]: T; } interface SharedKeyGenerateSignatureArgs { /** The resource type, if the resource is a blob or container. Null if the resource is a queue or table. */ resourceType?: string; /** The table name, if the resource is a table. Null if the resource is a blob orqueue. */ tableName?: string; /** The optional header values to set for a blob returned wth this SAS. */ headers?: { /** The value of the Cache-Control response header to be returned when this SAS is used. */ CacheControl?: string; /** The value of the Content-Type response header to be returned when this SAS is used. */ ContentType?: string; /** The value of the Content-Encoding response header to be returned when this SAS is used. */ ContentEncoding?: string; /** The value of the Content-Language response header to be returned when this SAS is used. */ ContentLanguage?: string; /** The value of the Content-Disposition response header to be returned when this SAS is used. */ ContentDisposition: string; }; } interface SharedKeyGenerateQueryStringArgs extends SharedKeyGenerateSignatureArgs { /** The query string, if additional parameters are desired. */ queryString?: string; } interface TableAccessPolicy extends azurestorage.common.AccessPolicy { StartPk?: string; EndPk?: string; StartRk?: string; EndRk?: string; } module azurestorage { export interface StorageHost { primaryHost: string; secondaryHost?: string; } module services { module blob { // ########################### // ./services/blob/blobservice // ########################### module blobservice { export class BlobService extends StorageServiceClient { singleBlobPutThresholdInBytes: number; parallelOperationThreadCount: number; /** * Creates a new BlobService object. * If no connection string or storageaccount and storageaccesskey are provided, * the AZURE_STORAGE_CONNECTION_STRING or AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables will be used. * @class * The BlobService class is used to perform operations on the Microsoft Azure Blob Service. * The Blob Service provides storage for binary large objects, and provides * functions for working with data stored in blobs as either streams or pages of data. * * For more information on the Blob Service, as well as task focused information on using it in a Node.js application, see * [How to Use the Blob Service from Node.js](http://azure.microsoft.com/en-us/documentation/articles/storage-nodejs-how-to-use-blob-storage/). * The following defaults can be set on the blob service. * singleBlobPutThresholdInBytes The default maximum size, in bytes, of a blob before it must be separated into blocks. * defaultTimeoutIntervalInMs The default timeout interval, in milliseconds, to use for request made via the Blob service. * defaultMaximumExecutionTimeInMs The default maximum execution time across all potential retries, for requests made via the Blob service. * defaultLocationMode The default location mode for requests made via the Blob service. * parallelOperationThreadCount The number of parallel operations that may be performed when uploading a blob that is greater than * the value specified by the singleBlobPutThresholdInBytes property in size. * useNagleAlgorithm Determines whether the Nagle algorithm is used for requests made via the Blob service; true to use the * Nagle algorithm; otherwise, false. The default value is false. * @constructor * @extends {StorageServiceClient} * * @param {string} [storageAccountOrConnectionString] The storage account or the connection string. * @param {string} [storageAccessKey] The storage access key. * @param {string|object} [host] The host address. To define primary only, pass a string. * Otherwise 'host.primaryHost' defines the primary host and 'host.secondaryHost' defines the secondary host. * @param {string} [sasToken] The Shared Access Signature token. */ constructor(storageAccountOrConnectionString: string, storageAccessKey?: string, host?: string|StorageHost, sasToken?: string); /** * Gets the service stats for a storage account’s Blob service. * * @this {BlobService} * @param {object} [options] The request options. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {int} [options.timeoutIntervalInMs] The timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information if an error occurs; otherwise, `result` will contain the stats and * `response` will contain information related to this operation. */ getServiceStats(optionsOrCallback: any, callback: any): void; /** * Gets the properties of a storage account’s Blob service, including Azure Storage Analytics. * * @this {BlobService} * @param {object} [options] The request options. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information if an error occurs; otherwise, `result` will contain the properties * and `response` will contain information related to this operation. */ getServiceProperties(optionsOrCallback: any, callback: any): void; /** * Sets the properties of a storage account’s Blob service, including Azure Storage Analytics. * You can also use this operation to set the default request version for all incoming requests that do not have a version specified. * * @this {BlobService} * @param {object} serviceProperties The service properties. * @param {object} [options] The request options. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResponse} callback `error` will contain information * if an error occurs; otherwise, `response` * will contain information related to this operation. */ setServiceProperties(serviceProperties: any, optionsOrCallback: any, callback: any): void; /** * Lists a segment containing a collection of container items under the specified account. * * @this {BlobService} * @param {object} currentToken A continuation token returned by a previous listing operation. Please use 'null' or 'undefined' if this is the first operation. * @param {object} [options] The request options. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {int} [options.maxResults] Specifies the maximum number of containers to return per call to Azure storage. * @param {string} [options.include] Include this parameter to specify that the container's metadata be returned as part of the response body. (allowed values: '', 'metadata') * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain `entries` and `continuationToken`. * `entries` gives a list of containers and the `continuationToken` is used for the next listing operation. * `response` will contain information related to this operation. */ listContainersSegmented(currentToken: any, optionsOrCallback: any, callback: any): void; /** * Lists a segment containing a collection of container items whose names begin with the specified prefix under the specified account. * * @this {BlobService} * @param {string} prefix The prefix of the container name. * @param {object} currentToken A continuation token returned by a previous listing operation. Please use 'null' or 'undefined' if this is the first operation. * @param {object} [options] The request options. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {string} [options.prefix] Filters the results to return only containers whose name begins with the specified prefix. * @param {int} [options.maxResults] Specifies the maximum number of containers to return per call to Azure storage. * @param {string} [options.include] Include this parameter to specify that the container's metadata be returned as part of the response body. (allowed values: '', 'metadata') * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain `entries` and `continuationToken`. * `entries` gives a list of containers and the `continuationToken` is used for the next listing operation. * `response` will contain information related to this operation. */ listContainersSegmentedWithPrefix(prefix: any, currentToken: any, optionsOrCallback: any, callback: any): void; /** * Checks whether or not a container exists on the service. * * @this {BlobService} * @param {string} container The container name. * @param {object} [options] The request options. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will * be true if the container exists, or false if the container does not exist. * `response` will contain information related to this operation. */ doesContainerExist(container: string, options: common.RequestOptions, callback: ErrorOrResult<boolean>): void; /** * Checks whether or not a container exists on the service. * * @this {BlobService} * @param {string} container The container name. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will * be true if the container exists, or false if the container does not exist. * `response` will contain information related to this operation. */ doesContainerExist(container: string, callback: ErrorOrResult<boolean>): void; /** * Creates a new container under the specified account. * If a container with the same name already exists, the operation fails. * * @this {BlobService} * @param {string} container The container name. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain * the container information. * `response` will contain information related to this operation. */ createContainer(container: string, callback: ErrorOrResult<BlobService.ContainerResult>): void; /** * Creates a new container under the specified account. * If a container with the same name already exists, the operation fails. * * @this {BlobService} * @param {string} container The container name. * @param {object} [options] The request options. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {object} [options.metadata] The metadata key/value pairs. * @param {string} [options.publicAccessLevel] Specifies whether data in the container may be accessed publicly and the level of access. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain * the container information. * `response` will contain information related to this operation. */ createContainer(container: string, options: BlobService.CreateContainerOptions, callback: ErrorOrResult<BlobService.ContainerResult>): void; /** * Creates a new container under the specified account if the container does not exists. * * @this {BlobService} * @param {string} container The container name. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will * be true if the container was created, or false if the container * already exists. * `response` will contain information related to this operation. * * @example * var azure = require('azure-storage'); * var blobService = azure.createBlobService(); * blobService.createContainerIfNotExists('taskcontainer', {publicAccessLevel : 'blob'}, function(error) { * if(!error) { * // Container created or exists, and is public * } * }); */ createContainerIfNotExists(container: string, callback: ErrorOrResult<boolean>): void; /** * Creates a new container under the specified account if the container does not exists. * * @this {BlobService} * @param {string} container The container name. * @param {object} [options] The request options. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {object} [options.metadata] The metadata key/value pairs. * @param {string} [options.publicAccessLevel] Specifies whether data in the container may be accessed publicly and the level of access. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will * be true if the container was created, or false if the container * already exists. * `response` will contain information related to this operation. * * @example * var azure = require('azure-storage'); * var blobService = azure.createBlobService(); * blobService.createContainerIfNotExists('taskcontainer', {publicAccessLevel : 'blob'}, function(error) { * if(!error) { * // Container created or exists, and is public * } * }); */ createContainerIfNotExists(container: string, options: BlobService.CreateContainerOptions, callback: ErrorOrResult<boolean>): void; /** * Retrieves a container and its properties from a specified account. * * @this {BlobService} * @param {string} container The container name. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain * information for the container. * `response` will contain information related to this operation. */ getContainerProperties(container: string, callback: ErrorOrResult<BlobService.ContainerResult>): void; /** * Retrieves a container and its properties from a specified account. * * @this {BlobService} * @param {string} container The container name. * @param {object} [options] The request options. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {string} [options.leaseId] The container lease identifier. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain * information for the container. * `response` will contain information related to this operation. */ getContainerProperties(container: string, options: BlobService.ContainerOptions, callback: ErrorOrResult<BlobService.ContainerResult>): void; /** * Returns all user-defined metadata for the container. * * @this {BlobService} * @param {string} container The container name. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain * information for the container. * `response` will contain information related to this operation. */ getContainerMetadata(container: string, callback: ErrorOrResult<BlobService.ContainerResult>): void; /** * Returns all user-defined metadata for the container. * * @this {BlobService} * @param {string} container The container name. * @param {object} [options] The request options. * @param {string} [options.leaseId] The container lease identifier. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain * information for the container. * `response` will contain information related to this operation. */ getContainerMetadata(container: string, options: BlobService.ContainerOptions, callback: ErrorOrResult<BlobService.ContainerResult>): void; /** * Sets the container's metadata. * * Calling the Set Container Metadata operation overwrites all existing metadata that is associated with the container. * It's not possible to modify an individual name/value pair. * * @this {BlobService} * @param {string} container The container name. * @param {object} metadata The metadata key/value pairs. * @param {errorOrResponse} callback `error` will contain information * if an error occurs; otherwise * `response` will contain information related to this operation. */ setContainerMetadata(container: string, metadata: Map<string>, callback: ErrorOrResult<BlobService.ContainerResult>): void; /** * Sets the container's metadata. * * Calling the Set Container Metadata operation overwrites all existing metadata that is associated with the container. * It's not possible to modify an individual name/value pair. * * @this {BlobService} * @param {string} container The container name. * @param {object} metadata The metadata key/value pairs. * @param {object} [options] The request options. * @param {string} [options.leaseId] The container lease identifier. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {object} [options.accessConditions] See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResponse} callback `error` will contain information * if an error occurs; otherwise * `response` will contain information related to this operation. */ setContainerMetadata(container: string, metadata: Map<string>, options: BlobService.ContainerOptions, callback: ErrorOrResult<BlobService.ContainerResult>): void; /** * Gets the container's ACL. * * @this {BlobService} * @param {string} container The container name. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain * information for the container. * `response` will contain information related to this operation. */ getContainerAcl(container: string, callback: ErrorOrResult<BlobService.ContainerAclResult>): void; /** * Gets the container's ACL. * * @this {BlobService} * @param {string} container The container name. * @param {object} [options] The request options. * @param {string} [options.leaseId] The container lease identifier. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain * information for the container. * `response` will contain information related to this operation. */ getContainerAcl(container: string, options: BlobService.ContainerOptions, callback: ErrorOrResult<BlobService.ContainerAclResult>): void; /** * Updates the container's ACL. * * @this {BlobService} * @param {string} container The container name. * @param {object} signedIdentifiers The signed identifiers. Signed identifiers must be in an array. * @param {object} [options] The request options. * @param {string} [options.publicAccessLevel] Specifies whether data in the container may be accessed publicly and the level of access. * @param {string} [options.leaseId] The container lease identifier. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResult} callback `error` will contain information * if an error occurs; otherwise `result` will contain * information for the container. * `response` will contain information related to this operation. */ setContainerAcl(container: string, signedIdentifiers: common.SignedIdentifier[], options: BlobService.ContainerAclOptions, callback: ErrorOrResult<BlobService.ContainerAclResult>): void; /** * Marks the specified container for deletion. * The container and any blobs contained within it are later deleted during garbage collection. * * @this {BlobService} * @param {string} container The container name. * @param {errorOrResponse} callback `error` will contain information * if an error occurs; otherwise * `response` will contain information related to this operation. */ deleteContainer(container: string, callback: ErrorOrResponse): void; /** * Marks the specified container for deletion. * The container and any blobs contained within it are later deleted during garbage collection. * * @this {BlobService} * @param {string} container The container name. * @param {object} [options] The request options. * @param {string} [options.leaseId] The container lease identifier. * @param {LocationMode} [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. * Please see StorageUtilities.LocationMode for the possible values. * @param {int} [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. * @param {int} [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. * The maximum execution time interval begins at the time that the client begins building the request. The maximum * execution time is checked intermittently while performing requests, and before executing retries. * @param {bool} [options.useNagleAlgorithm] Determines whether the Nagle algorithm is used; true to use the Nagle algorithm; otherwise, false. * The default value is false. * @param {errorOrResponse} callback `error` will contain information * if an error occurs; otherwise * `response` will contain information related to this operation. */ deleteContainer(container: string, options: BlobService.ContainerOptions, callback: ErrorOrResponse): void; /** * Marks the specified container for deletion if it exists. * The container and any blobs contained within it are later deleted during garbage collection. * * @this {BlobService} * @param {string} container The container name. * @param {errorOrResult} callback `error` will contain information *