From 34da00610a3691c28364905d13a83d8a607a211f Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Sun, 14 Sep 2014 22:25:00 +0200 Subject: [PATCH 1/4] Big update of Azure SDK for Node definitions --- node-azure/azure.d.ts | 1576 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 1516 insertions(+), 60 deletions(-) diff --git a/node-azure/azure.d.ts b/node-azure/azure.d.ts index 95ff46c25b..05cb58dea3 100644 --- a/node-azure/azure.d.ts +++ b/node-azure/azure.d.ts @@ -1,6 +1,8 @@ -// Type definitions for Azure SDK for Node - v0.6.10 +// Type definitions for Azure SDK for Node - v0.9.16 // Project: https://github.com/WindowsAzure/azure-sdk-for-node -// Definitions by: Andrew Gaspar , Anti Veeranna +// Definitions by: Andrew Gaspar , +// Anti Veeranna , +// Maxime LUCE // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -10,6 +12,8 @@ */ declare module "azure" { import events = require("events"); + import stream = require("stream"); + import url = require("url"); //#region Services export class TableService extends BatchServiceClient { @@ -18,6 +22,8 @@ declare module "azure" { static incorrectTableQuery: string; static incorrectPartitionErr: string; + //#region Constructors + /** * Creates a new TableService object. * Uses the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables. @@ -48,29 +54,42 @@ declare module "azure" { */ constructor(storageAccount: string, storageAccessKey: string, host?: string, authenticationProvider?: string); - getServiceProperties(callback?: (error: any, servicePropertiesResult: any, response: any) => void ): void; - getServiceProperties(options: TimeoutIntervalOptions, callback?: (error: any, servicePropertiesResult: any, response: any) => void ): void; + //#endregion - setServiceProperties(serviceProperties: any, options: TimeoutIntervalOptions, callback?: Function): void; + //#region Service Methods - getTable(table: string, callback?: TableRequestCallback ): void; - getTable(table: string, options: TimeoutIntervalOptions, callback?: TableRequestCallback ): void; + getServiceProperties(callback: StorageServicePropertiesCallback): void; + getServiceProperties(options: TimeoutIntervalOptions, callback: StorageServicePropertiesCallback): void; - createTable(table: string, callback?: TableRequestCallback ): void; - createTable(table: string, options: TimeoutIntervalOptions, callback?: TableRequestCallback ): void; + setServiceProperties(serviceProperties: StorageServiceProperties, callback: StorageCallbackVoid): void; + setServiceProperties(serviceProperties: StorageServiceProperties, options: TimeoutIntervalOptions, callback: StorageCallbackVoid): void; - createTableIfNotExists(table: string, callback?: CreateTableIfNotExistsCallback ): void; + //#endregion + + //#region Table Methods + + getTable(table: string, callback?: TableRequestCallback): void; + getTable(table: string, options: TimeoutIntervalOptions, callback?: TableRequestCallback): void; + + createTable(table: string, callback?: TableRequestCallback): void; + createTable(table: string, options: TimeoutIntervalOptions, callback?: TableRequestCallback): void; + + createTableIfNotExists(table: string, callback?: CreateTableIfNotExistsCallback): void; createTableIfNotExists(table: string, options: TimeoutIntervalOptions, callback?: CreateTableIfNotExistsCallback): void; - deleteTable(table: string, callback?: DeleteTableCallback ): void; - deleteTable(table: string, options: TimeoutIntervalOptions, callback?: DeleteTableCallback ): void; + deleteTable(table: string, callback?: DeleteTableCallback): void; + deleteTable(table: string, options: TimeoutIntervalOptions, callback?: DeleteTableCallback): void; - queryTables(callback?: QueryTablesCallback ): void; - queryTables(options: QueryTablesOptions, callback?: QueryTablesCallback ): void; + queryTables(callback?: QueryTablesCallback): void; + queryTables(options: QueryTablesOptions, callback?: QueryTablesCallback): void; + + //#endregion + + //#region Entities Methods + + queryEntity(table: string, partitionKey: string, rowKey: string, callback?: QueryEntityCallback): void; + queryEntity(table: string, partitionKey: string, rowKey: string, options: TimeoutIntervalOptions, callback?: QueryEntityCallback): void; - queryEntity(table: string, partitionKey: string, rowKey: string, callback?: QueryEntityCallback ): void; - queryEntity(table: string, partitionKey: string, rowKey: string, options: TimeoutIntervalOptions, callback?: QueryEntityCallback ): void; - queryEntities(tableQuery: TableQuery, callback?: QueryEntitiesCallback): void; queryEntities(tableQuery: TableQuery, options: TimeoutIntervalOptions, callback?: QueryEntitiesCallback): void; @@ -91,14 +110,513 @@ declare module "azure" { deleteEntity(tableName: string, entityDescriptor: Entity, callback?: DeleteEntityCallback): void; deleteEntity(tableName: string, entityDescriptor: Entity, options: UpdateEntityOptions, callback?: DeleteEntityCallback): void; + + //#endregion } - export class BlobService { + export class BlobService extends StorageServiceClient { + singleBlobPutThresholdInBytes: number; + parallelOperationThreadCount: number; + SpeedSummary: typeof SpeedSummary; + + //#region Constructors + + /** + * Creates a new BlobService object. + * Uses the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables. + * + * @constructor + * @extends {StorageServiceClient} + */ + constructor(); + + /** + * Creates a new BlobService object. + * Uses a connectionString to connect + * + * @constructor + * @extends {StorageServiceClient} + * @param {string} connectionString The connection string. + */ + constructor(connectionString: string); + + /** + * Creates a new BlobService object. + * Uses a storage account and an access key. + * + * @constructor + * @extends {StorageServiceClient} + * @param {string} storageAccount The storage account or the connection string. + * @param {string} storageAccessKey The storage access key. + * @param {string} host The host address. + * @param {object} sasToken The Shared Access Signature token. + */ + constructor(storageAccount: string, storageAccessKey: string, host?: string, sasToken?: string); + + //#endregion + + //#region Service Methods + + /** + * Gets the properties of a storage account’s Blob service, including Azure Storage Analytics. + */ + getServiceProperties(callback: StorageServicePropertiesCallback): void; + getServiceProperties(options: TimeoutIntervalOptions, callback: StorageServicePropertiesCallback): 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. + */ + setServiceProperties(serviceProperties: StorageServiceProperties, callback: StorageCallbackVoid): void; + setServiceProperties(serviceProperties: StorageServiceProperties, options: TimeoutIntervalOptions, callback: StorageCallbackVoid): void; + + //#endregion + + //#region Containers Methods + + /** + * Lists a segment containing a collection of container items under the specified account. + */ + listContainers(callback: ListContainersCallback): void; + listContainers(options: ListContainersOptions, callback: ListContainersCallback): void; + + /** + * Creates a new container under the specified account. + * If a container with the same name already exists, the operation fails. + */ + createContainer(container: string, callback: StorageCallback): void; + createContainer(container: string, options: CreateContainerOptions, callback: StorageCallback): void; + + /** + * Creates a new container under the specified account if the container does not exists. + */ + createContainerIfNotExists(container: string, callback: StorageCallback): void; + createContainerIfNotExists(container: string, options: CreateContainerOptions, callback: StorageCallback): void; + + /** + * Retrieves a container and its properties from a specified account. + */ + getContainerProperties(container: string, callback: StorageCallback): void; + getContainerProperties(container: string, options: GetContainerPropertiesOptions, callback: StorageCallback): void; + + /** + * Returns all user-defined metadata for the container. + */ + getContainerMetadata(container: string, callback: StorageCallback): void; + getContainerMetadata(container: string, options: GetContainerPropertiesOptions, callback: StorageCallback): void; + + /** + * Sets the container's metadata. + */ + setContainerMetadata(container: string, metadata: StorageMetadata, callback: StorageCallback): void; + setContainerMetadata(container: string, metadata: StorageMetadata, options: AccessConditionsOptions, callback: StorageCallback): void; + + /** + * Gets the container's ACL. + */ + getContainerAcl(container: string, callback: StorageCallback): void; + getContainerAcl(container: string, options: GetContainerPropertiesOptions, callback: StorageCallback): void; + + /** + * Updates the container's ACL. + */ + setContainerAcl(container: string, publicAccessLevel: string, callback: StorageCallback): void; + setContainerAcl(container: string, publicAccessLevel: string, options: StorageAclOptions, callback: StorageCallback): void; + + /** + * Marks the specified container for deletion. + * The container and any blobs contained within it are later deleted during garbage collection. + */ + deleteContainer(container: string, callback: StorageCallbackVoid): void; + deleteContainer(container: string, options: LeaseIdOptions, callback: StorageCallbackVoid): void; + + //#endregion + + //#region Blob Methods + + /** + * Lists all of the blobs in the given container. + */ + listBlobs(container: string, callback: ListBlobsCallback): void; + listBlobs(container: string, options: ListBlobsOptions, callback: ListBlobsCallback): void; + + /** + * Returns all user-defined metadata, standard HTTP properties, and system properties for the blob. + * It does not return or modify the content of the blob. + */ + getBlobProperties(container: string, blob: string, callback: StorageCallback): void; + getBlobProperties(container: string, blob: string, options: GetBlobPropertiesOptions, callback: StorageCallback): void; + + /** + * Sets user-defined properties for the specified blob or snapshot. + * It does not return or modify the content of the blob. + */ + setBlobProperties(container: string, blob: string, callback: StorageCallback): void; + setBlobProperties(container: string, blob: string, options: SetBlobPropertiesOptions, callback: StorageCallback): void; + + /** + * Sets user-defined metadata for the specified blob or snapshot as one or more name-value pairs + * It does not return or modify the content of the blob. + */ + setBlobMetadata(container: string, blob: string, metadata: StorageMetadata, callback: StorageCallback): void; + setBlobMetadata(container: string, blob: string, metadata: StorageMetadata, options: GetBlobPropertiesOptions, callback: StorageCallback): void; + + /** + * Provides a stream to read from a blob. + */ + getBlob(container: string, blob: string, callback: StorageCallback): stream.Readable; + getBlob(container: string, blob: string, options: ReadBlobOptions, callback: StorageCallback): stream.Readable; + + /** + * Downloads a blob into a file. + */ + getBlobToFile(container: string, blob: string, localFileName: string, callback: StorageCallback): void; + getBlobToFile(container: string, blob: string, localFileName: string, options: ReadBlobOptions, callback: StorageCallback): void; + + /** + * Downloads a blob into a stream. + */ + getBlobToStream(container: string, blob: string, stream: stream.Writable, callback: StorageCallback): void; + getBlobToStream(container: string, blob: string, stream: stream.Writable, options: ReadBlobOptions, callback: StorageCallback): void; + + /** + * Downloads a blob into a text string. + */ + getBlobToText(container: string, blob: string, callback: GetBlobToTextCallback): void; + getBlobToText(container: string, blob: string, options: ReadBlobOptions, callback: GetBlobToTextCallback): void; + + /** + * Marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. + * If a blob has snapshots, you must delete them when deleting the blob. Using the deleteSnapshots option, you can choose either to delete both the blob and its snapshots, + * or to delete only the snapshots but not the blob itself. If the blob has snapshots, you must include the deleteSnapshots option or the blob service will return an error + * and nothing will be deleted. + * If you are deleting a specific snapshot using the snapshotId option, the deleteSnapshots option must NOT be included. + */ + deleteBlob(container: string, blob: string, callback: StorageCallback): void; + deleteBlob(container: string, blob: string, options: DeleteBlobOptions, callback: StorageCallback): void; + + /** + * Creates a read-only snapshot of a blob. + */ + createBlobSnapshot(container: string, blob: string, callback: StorageCallback): void; + createBlobSnapshot(container: string, blob: string, options: BlobSnapshotOptions, callback: StorageCallback): void; + + /** + * Starts to copy a blob to a destination within the storage account. The Copy Blob operation copies the entire committed blob. + */ + copyBlob(sourceUri: string, targetContainer: string, targetBlob: string, callback: StorageCallback): void; + copyBlob(sourceUri: string, targetContainer: string, targetBlob: string, options: CopyBlobOptions, callback: StorageCallback): void; + + /** + * Creates a read-only snapshot of a blob. + */ + abortCopyBlob(container: string, blob: string, copyId: string, callback: StorageCallbackVoid): void; + abortCopyBlob(container: string, blob: string, copyId: string, options: LeaseIdOptions, callback: StorageCallbackVoid): void; + + /** + * Retrieves a shared access signature token. + */ + generateSharedAccessSignature(container: string, blob: string, sharedAccessPolicy: SharedAccessPolicy): string; + + /** + * Retrieves a blob or container URL. + */ + getBlobUrl(container: string): string; + getBlobUrl(container: string, blob: string): string; + getBlobUrl(container: string, blob: string, sharedAccessPolicy: SharedAccessPolicy): string; + + /** + * Uploads a blob. + */ + createBlob(container: string, blob: string, blobType: string, callback: StorageCallback): stream.Writable; + createBlob(container: string, blob: string, blobType: string, options: UploadBlockBlobOptions, callback: StorageCallback): stream.Writable; + + //#endregion + + //#region Page Blob Methods + + /** + * Creates a page blob of the specified length. + */ + createPageBlob(container: string, blob: string, length: number, callback: StorageCallbackVoid): void; + createPageBlob(container: string, blob: string, length: number, options: SetBlobPropertiesOptions, callback: StorageCallbackVoid): void; + + /** + * Updates a page blob from a stream. + */ + createBlobPagesFromStream(container: string, blob: string, readStream: stream.Readable, rangeStart: number, rangeEnd: number, callback: StorageCallback): void; + createBlobPagesFromStream(container: string, blob: string, readStream: stream.Readable, rangeStart: number, rangeEnd: number, options: CreatePagesOptions, callback: StorageCallback): void; + + /** + * Updates a page blob from a text string. + */ + createBlobPagesFromText(container: string, blob: string, text: string, rangeStart: number, rangeEnd: number, callback: StorageCallback): void; + createBlobPagesFromText(container: string, blob: string, text: string, rangeStart: number, rangeEnd: number, options: CreatePagesOptions, callback: StorageCallback): void; + + /** + * Lists page ranges. + * Lists all of the page ranges by default, or only the page ranges over a specific range of bytes if rangeStart and rangeEnd are specified. + */ + listBlobRegions(container: string, blob: string, callback: StorageCallback): void; + listBlobRegions(container: string, blob: string, options: PageRangeOptions, callback: StorageCallback): void; + + /** + * Clears a range of pages. + */ + clearBlobPages(container: string, blob: string, rangeStart: number, rangeEnd: number, callback: StorageCallbackVoid): void; + clearBlobPages(container: string, blob: string, rangeStart: number, rangeEnd: number, options: LeaseAccessConditionsOptions, callback: StorageCallbackVoid): void; + + /** + * Resizes a page blob. + */ + resizePageBlob(container: string, blob: string, size: number, callback: StorageCallback): void; + resizePageBlob(container: string, blob: string, size: number, options: LeaseAccessConditionsOptions, callback: StorageCallback): void; + + /** + * Sets the page blob's sequence number. + */ + setPageBlobSequenceNumber(container: string, blob: string, sequenceNumberAction: string, sequenceNumber: string, callback: StorageCallback): void; + setPageBlobSequenceNumber(container: string, blob: string, sequenceNumberAction: string, sequenceNumber: string, options: AccessConditionsOptions, callback: StorageCallback): void; + + //#endregion + + //#region Block Blob Methods + + /** + * Uploads a block blob from file. + */ + putBlockBlobFromFile(container: string, blob: string, localFileName: string, callback: StorageCallback): SpeedSummary; + putBlockBlobFromFile(container: string, blob: string, localFileName: string, options: UploadBlockBlobOptions, callback: StorageCallback): SpeedSummary; + createBlockBlobFromFile(container: string, blob: string, localFileName: string, callback: StorageCallback): SpeedSummary; + createBlockBlobFromFile(container: string, blob: string, localFileName: string, options: UploadBlockBlobOptions, callback: StorageCallback): SpeedSummary; + + /** + * Uploads a block blob from a stream. + */ + putBlockBlobFromStream(container: string, blob: string, stream: stream.Stream, streamLength: number, callback: StorageCallback): SpeedSummary; + putBlockBlobFromStream(container: string, blob: string, stream: stream.Stream, streamLength: number, options: UploadBlockBlobOptions, callback: StorageCallback): SpeedSummary; + createBlockBlobFromStream(container: string, blob: string, stream: stream.Stream, streamLength: number, callback: StorageCallback): SpeedSummary; + createBlockBlobFromStream(container: string, blob: string, stream: stream.Stream, streamLength: number, options: UploadBlockBlobOptions, callback: StorageCallback): SpeedSummary; + + /** + * Uploads a block blob from a text string. + */ + createBlockBlobFromText(container: string, blob: string, text: string, callback: StorageCallback): SpeedSummary; + createBlockBlobFromText(container: string, blob: string, text: string, options: UploadBlockBlobOptions, callback: StorageCallback): SpeedSummary; + + /** + * Creates a new block to be committed as part of a blob. + */ + createBlobBlockFromStream(blockId: string, container: string, blob: string, readStream: stream.Stream, streamLength: number, callback: StorageCallbackVoid): void; + createBlobBlockFromStream(blockId: string, container: string, blob: string, readStream: stream.Stream, streamLength: number, options: CreateBlockOptions, callback: StorageCallbackVoid): void; + + /** + * Creates a new block to be committed as part of a blob. + */ + createBlobBlockFromText(blockId: string, container: string, blob: string, text: string, callback: StorageCallbackVoid): void; + createBlobBlockFromText(blockId: string, container: string, blob: string, text: string, options: CreateBlockOptions, callback: StorageCallbackVoid): void; + + /** + * Writes a blob by specifying the list of block IDs that make up the blob. + * In order to be written as part of a blob, a block must have been successfully written to the server in a prior + * createBlock operation. + */ + commitBlobBlocks(container: string, blob: string, blockList: BlockList, callback: StorageCallback): void; + commitBlobBlocks(container: string, blob: string, blockList: BlockList, options: CreateBlockOptions, callback: StorageCallback): void; + + /** + * Retrieves the list of blocks that have been uploaded as part of a block blob. + */ + listBlobBlocks(container: string, blob: string, blockListType: string, callback: StorageCallback): void; + listBlobBlocks(container: string, blob: string, blockListType: string, options: GetBlobPropertiesOptions, callback: StorageCallback): void; + + /** + * Generate a random block id prefix. + */ + generateBlockIdPrefix(): string; + /** + * Get a block id according to prefix and block number. + */ + getBlockId(prefix: string, number: number): string; + + //#endregion + + //#region Lease Methods + + /** + * Acquires a new lease. + * If container and blob are specified, acquires a blob lease. + * Otherwise, if only container is specified and blob is null, acquires a container lease. + */ + acquireLease(container: string, blob: string, callback: StorageCallback): void; + acquireLease(container: string, blob: string, options: LeaseOptions, callback: StorageCallback): void; + + /** + * Renews an existing lease. + * If container and blob are specified, renews the blob lease. + * Otherwise, if only container is specified and blob is null, renews the container lease. + */ + renewLease(container: string, blob: string, leaseId: string, callback: StorageCallback): void; + renewLease(container: string, blob: string, leaseId: string, options: AccessConditionsOptions, callback: StorageCallback): void; + + /** + * Releases the lease. + * If container and blob are specified, releases the blob lease. + * Otherwise, if only container is specified and blob is null, releases the container lease. + */ + releaseLease(container: string, blob: string, leaseId: string, callback: StorageCallback): void; + releaseLease(container: string, blob: string, leaseId: string, options: AccessConditionsOptions, callback: StorageCallback): void; + + /** + * Breaks the lease but ensures that another client cannot acquire a new lease until the current lease period has expired. + * If container and blob are specified, breaks the blob lease. + * Otherwise, if only container is specified and blob is null, breaks the container lease. + */ + breakLease(container: string, blob: string, leaseId: string, callback: StorageCallback): void; + breakLease(container: string, blob: string, leaseId: string, options: BreakLeaseOptions, callback: StorageCallback): void; + + //#endregion } - export class QueueService { + export class QueueService extends StorageServiceClient { + authenticationProvider: SharedKey; + //#region Constructors + + /** + * Creates a new BlobService object. + * Uses the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables. + * + * @constructor + * @extends {StorageServiceClient} + */ + constructor(); + + /** + * Creates a new BlobService object. + * Uses a connectionString to connect + * + * @constructor + * @extends {StorageServiceClient} + * @param {string} connectionString The connection string. + */ + constructor(connectionString: string); + + /** + * Creates a new BlobService object. + * Uses a storage account and an access key. + * + * @constructor + * @extends {StorageServiceClient} + * @param {string} storageAccount The storage account or the connection string. + * @param {string} storageAccessKey The storage access key. + * @param {string} host The host address. + * @param {object} sasToken The Shared Access Signature token. + */ + constructor(storageAccount: string, storageAccessKey: string, host?: string, sasToken?: string); + + //#endregion + + //#region Service Methods + + /** + * Gets the properties of a storage account’s Blob service, including Azure Storage Analytics. + */ + getServiceProperties(callback: StorageServicePropertiesCallback): void; + getServiceProperties(options: TimeoutIntervalOptions, callback: StorageServicePropertiesCallback): 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. + */ + setServiceProperties(serviceProperties: StorageServiceProperties, callback: StorageCallbackVoid): void; + setServiceProperties(serviceProperties: StorageServiceProperties, options: TimeoutIntervalOptions, callback: StorageCallbackVoid): void; + + //#endregion + + //#region Queue Methods + + /** + * Lists all queues under the given account. + */ + listQueues(callback: ListQueuesCallback): void; + listQueues(options: ListQueuesOptions, callback: ListQueuesCallback): void; + + /** + * Creates a new queue under the given account. + */ + createQueue(queue: string, callback: StorageCallback): void; + createQueue(queue: string, options: MetadataOptions, callback: StorageCallback): void; + + /** + * Creates a new queue under the given account if it doesn't exist. + */ + createQueueIfNotExists(queue: string, callback: StorageCallback): void; + createQueueIfNotExists(queue: string, options: MetadataOptions, callback: StorageCallback): void; + + /** + * Permanently deletes the specified queue. + */ + deleteQueue(queue: string, callback: StorageCallback): void; + deleteQueue(queue: string, options: TimeoutIntervalOptions, callback: StorageCallback): void; + + /** + * Returns queue properties, including user-defined metadata. + */ + getQueueMetadata(queue: string, callback: StorageCallback): void; + getQueueMetadata(queue: string, options: TimeoutIntervalOptions, callback: StorageCallback): void; + + /** + * Sets user-defined metadata on the specified queue. Metadata is associated with the queue as name-value pairs. + */ + setQueueMetadata(queue: string, metadata: StorageMetadata, callback: StorageCallback): void; + setQueueMetadata(queue: string, metadata: StorageMetadata, options: TimeoutIntervalOptions, callback: StorageCallback): void; + + //#endregion + + //#region Message Methods + + /** + * Adds a new message to the back of the message queue. A visibility timeout can also be specified to make the message + * invisible until the visibility timeout expires. A message must be in a format that can be included in an XML request + * with UTF-8 encoding. The encoded message can be up to 64KB in size for versions 2011-08-18 and newer, or 8KB in size + * for previous versions. + */ + createMessage(queue: string, messageText: string, callback: StorageCallback): void + createMessage(queue: string, messageText: string, options: CreateQueueMessageOptions, callback: StorageCallback): void + + /** + * Retrieves a message from the queue and makes it invisible to other consumers. + */ + getMessages(queue: string, callback: StorageCallback): void; + getMessages(queue: string, options: GetQueueMessagesOptions, callback: StorageCallback): void; + + /** + * Retrieves a message from the front of the queue, without changing the message visibility. + */ + peekMessages(queue: string, callback: StorageCallback): void; + peekMessages(queue: string, options: PeekQueueMessagesOptions, callback: StorageCallback): void; + + /** + * Deletes a specified message from the queue. + */ + deleteMessage(queue: string, messageId: string, popreceipt: string, callback: StorageCallback): void + deleteMessage(queue: string, messageId: string, popreceipt: string, options: TimeoutIntervalOptions, callback: StorageCallback): void + + /** + * Clears all messages from the queue. + */ + clearMessages(queue: string, callback: StorageCallbackVoid): void; + clearMessages(queue: string, options: TimeoutIntervalOptions, callback: StorageCallbackVoid): void; + + /** + * Deletes a specified message from the queue. + */ + updateMessage(queue: string, messageId: string, popreceipt: string, visibilitytimeout: number, callback: StorageCallback): void + updateMessage(queue: string, messageId: string, popreceipt: string, visibilitytimeout: number, options: UpdateQueueMessagesOptions, callback: StorageCallback): void + + //#endregion } export class ServiceBusService { @@ -116,6 +634,7 @@ declare module "azure" { export class SqlManagementService { } //#endregion + //#region Service Creators export function createTableService(): TableService; export function createTableService(connectionString: string): TableService; @@ -140,25 +659,122 @@ declare module "azure" { export function createSqlManagementService(subscriptionId: string, authentication: string, hostOptions: string): SqlManagementService; //#endregion + //#region RoleEnvironment + interface RoleEnvironmentInterface extends events.EventEmitter { - getCurrentRoleInstance(callback: (error: any, instance: any) => void): void; - getDeploymentId(callback: (error: any, id:string) => void): void; - isAvailable(callback: (error: any, available: boolean) => void): void; - isEmulated(callback: (error: any, emulated: boolean) => void): void; - getRoles(callback: (error: any, roles: any) => void): void; - getConfigurationSettings(callback: (error: any, settings: any) => void): void; - getLocalResources(callback: (error: any, resources: any) => void): void; - requestRecycle(callback: (error: any) => void): void; - setStatus(roleInstanceStatus: any, expirationUtc: any, callback: (error: any) => void): void; - clearStatus(callback: (error: any) => void): void; + incorrectCallbackErr: string; + clientId: string; + VersionEndpointFixedPath: string; + EnvironmentVariables: { + [key: string]: string; + VersionEndpointEnvironmentName: string; + }; + + /** + * Returns a RoleInstance object that represents the role instance + * in which this code is currently executing. + */ + getCurrentRoleInstance(callback: SimpleCallback): void; + + /** + * Returns the deployment ID that uniquely identifies the deployment in + * which this role instance is running. + */ + getDeploymentId(callback: SimpleCallback): void; + + /** + * Indicates whether the role instance is running in the Microsoft Azure + * environment. It is good practice to enclose any code that uses + * service runtime in the isAvailable callback. + */ + isAvailable(callback: SimpleCallback): void; + + /** + * Indicates whether the role instance is running in the development fabric. + */ + isEmulated(callback: SimpleCallback): void; + + /** + * Returns the set of Role objects defined for your service. + * Roles are defined in the service definition file. + */ + getRoles(callback: SimpleCallback>): void; + + /** + * Retrieves the settings in the service configuration file. + * + * A role's configuration settings are defined in the service definition file. + * Values for configuration settings are set in the service configuration file. + * For more information on configuration settings, see the [Service Definition Schema](http://msdn.microsoft.com/en-us/library/windowsazure/ee758711.aspx) + * and [Service Configuration Schema](http://msdn.microsoft.com/en-us/library/windowsazure/ee758710.aspx). + */ + getConfigurationSettings(callback: SimpleCallback>): void; + + /** + * Retrieves the set of named local storage resources, along with the path. + * For example, the DiagnosticStore resource which is defined for every role + * provides a location for runtime diagnostics and logs. + */ + getLocalResources(callback: SimpleCallback>): void; + + /** + * Requests that the current role instance be stopped and restarted. + * + * Before the role instance is recycled, the Microsoft Azure load balancer takes the role instance out of rotation. + * This ensures that no new requests are routed to the instance while it is restarting. + * + * A call to `RequestRecycle` initiates the normal shutdown cycle. Microsoft Azure raises the + * `Stopping` event and calls the `OnStop` method so that you can run the necessary code to + * prepare the instance to be recycled. + */ + requestRecycle(callback: ErrorCallback): void; + + /** + * Sets the status of the role instance. + * + * An instance may indicate that it is in one of two states: Ready or Busy. If an instance's state is Ready, it is + * prepared to receive requests from the load balancer. If the instance's state is Busy, it will not receive + * requests from the load balancer. + */ + setStatus(roleInstanceStatus: string, expirationUtc: Date, callback: ErrorCallback): void; + + /** + * Clears the status of the role instance. + * An instance may indicate that it has completed communicating status by calling this method. + */ + clearStatus(callback: ErrorCallback): void; } export var RoleEnvironment: RoleEnvironmentInterface; - + + //#endregion //#region Export of internal classes export class WebResource { + rawResponse: boolean; + queryString: Dictionary; + constructor(); + + get(path: string): WebResource; + put(path: string): WebResource; + post(path: string): WebResource; + merge(path: string): WebResource; + head(path: string): WebResource; + del(path: string): WebResource; + + withProperty(name: string, value: string): WebResource; + withRawResponse(rawResponse: boolean): WebResource; + withHeadersOnly(headersOnly: boolean): WebResource; + withQueryOption(name: string, value: string, defaultValue: string): WebResource; + withQueryOptions(queryOptions: Dictionary): WebResource; + withHeader(name: string, value: string): WebResource; + withHeaders(headers: Dictionary): WebResource; + withBody(body: any): WebResource; + addOptionalMetadataHeaders(metadata: StorageMetadata): WebResource; + + validResponse(statusCode: number): boolean; + pipeInput(inputStream: stream.Stream, destStream: stream.Stream): stream.Stream; } export class ServiceClient extends events.EventEmitter { @@ -185,12 +801,27 @@ declare module "azure" { performRequest(webResource: WebResource, outputData: string, options: any, callback: Function): void; performRequestOutputStream(webResource: WebResource, outputStream: any, options: any, callback: Function): void; performRequestInputStream(webResource: WebResource, outputData: string, inputStream: any, options: any, callback: Function): void; - withFilter(newFilter: { handle: (requestOptions: any, next: Function) => void; }): ServiceClient; + withFilter(newFilter: Filter): ServiceClient; parseMetadataHeaders(headers: any): any; isEmulated(): boolean; setProxy(proxyUrl: string, proxyPort: number): void; } + export class BatchServiceClient extends StorageServiceClient { + operations: any[]; + + constructor(storageAccount: string, storageAccessKey: string, host: string, usePathstyleUri: boolean, authenticationProvider: any); + beginBatch(): void; + isInBatch(): boolean; + rollback(): void; + hasOperations(): boolean; + addOperation(webResource: WebResource, outputData: any): void; + commitBatch(callback: (error: any, operationResponses: any[], response: any) => void): void; + commitBatch(options: any, callback: (error: any, operationResponses: any[], response: any) => void): void; + processResponse(responseObject: any, requestOperations: any[]): any[]; + processOperation(webResource: WebResource, rawResponse: string): any; + } + export class ServiceManagementClient { } @@ -208,77 +839,531 @@ declare module "azure" { toPath(): string; } - export class BatchServiceClient extends StorageServiceClient { - operations: any[]; + export class BlobResult { + blob: string; + container: string; - constructor(storageAccount: string, storageAccessKey: string, host: string, usePathstyleUri: boolean, authenticationProvider: any); - beginBatch(): void; - isInBatch(): boolean; - rollback(): void; - hasOperations(): boolean; - addOperation(webResource: WebResource, outputData: any): void; - commitBatch(callback: (error: any, operationResponses: any[], response: any) => void ): void; - commitBatch(options: any, callback: (error: any, operationResponses: any[], response: any) => void ): void; - processResponse(responseObject: any, requestOperations: any[]): any[]; - processOperation(webResource: WebResource, rawResponse: string): any; + etag: string; + lastModified: Date; + contentType: string; + contentEncoding: string; + contentLanguage: string; + contentMD5: string; + cacheControl: string; + contentRange: string; + contentTypeHeader: string; + contentEncodingHeader: string; + contentLanguageHeader: string; + contentMD5Header: string; + cacheControlHeader: string; + contentLength: number; + contentLengthHeader: number; + contentDisposition: string; + contentDispositionHeader: string; + range: string; + rangeHeader: string; + getContentMd5: string; + acceptRanges: string; + blobType: string; + leaseStatus: string; + leaseId: string; + leaseDuration: string; + leaseState: string; + sequenceNumber: string; + copyStatus: string; + copyCompletionTime: string; + copyStatusDescription: string; + copyId: string; + copyProgress: number; + requestId: string; + + metadata: StorageMetadata; + + constructor(); + constructor(container: string); + constructor(container: string, blob: string); + + static parse(blobXml: any): BlobResult; + static setHeadersFromBlob(webResource: WebResource, blob: BlobResult); + + getPropertiesFromHeaders(headers: any): void; + } + + export class ContainerResult { + name: string; + publicAccessLevel: string; + + etag: string; + lastModified: Date; + leaseStatus: string; + leaseDuration: string; + leaseState: string; + requestId: string; + + metadata: StorageMetadata; + signedIdentifiers: SignedIdentifier[]; + + constructor(); + constructor(name: string); + constructor(name: string, publicAccessLevel: string); + + static parse(containerXml: any): ContainerResult; + + getPropertiesFromHeaders(headers: any): void; + } + + export class LeaseResult { + container: string; + blob: string; + id: string; + time: Date; + etag: string; + lastModified: Date; + + constructor(); + constructor(container: string); + constructor(container: string, blob: string); + constructor(container: string, blob: string, id: string); + constructor(container: string, blob: string, id: string, time: Date); + + getPropertiesFromHeaders(header: any): void; + } + + export class QueueResult { + name: string; + metadata: StorageMetadata; + approximatemessagecount: number; + + constructor(); + constructor(name: string); + constructor(name: string, metadata: StorageMetadata); + + static parse(messageXml: any): QueueResult; + + getPropertiesFromHeaders(headers: any): void; + } + + export class QueueMessageResult { + queue: string; + messageid: string; + popreceipt: string; + metadata: StorageMetadata; + + constructor(); + constructor(queue: string); + constructor(queue: string, messageid: string); + constructor(queue: string, messageid: string, popreceipt: string); + constructor(queue: string, messageid: string, popreceipt: string, metadata: StorageMetadata); + + static serialize(messageJs: string): string; + static parse(messageXml: any): QueueMessageResult; + + getPropertiesFromHeaders(headers: any): void; + } + + export class SpeedSummary { + name: string; + totalSize: number; + completeSize: number; + + _startTime: Date; + _timeWindowInSeconds: number; + _timeWindow: number; + _totalWindowSize: number; + _speedTracks: number[]; + _speedTrackPtr: number; + + constructor(name: string); + + /** + * Get running seconds + */ + getElapsedSeconds(): string; + getElapsedSeconds(humanReadable: boolean): number; + + /** + * Get complete percentage + */ + getCompletePercent(): number; + getCompletePercent(len: number): number; + + /** + * Get average upload/download speed + */ + getAverageSpeed(): string; + getAverageSpeed(humanReadable: boolean): number; + + /** + * Get internal speed + */ + getSpeed(): string; + getSpeed(humanReadable: boolean): number; + + /** + * Get auto increment function + */ + getSpeed(size: number): (error: Error, value: any) => void; + + /** + * Get total size + */ + getTotalSize(): string; + getTotalSize(humanReadable: boolean): number; + + /** + * Get completed data size + */ + getCompleteSize(): string; + getCompleteSize(humanReadable: boolean): number; } export module Constants { } - export class LinearRetryPolicyFilter { + export interface Filter { + handle(requestOptions: any, next: Function): void; + } + + export class LinearRetryPolicyFilter implements Filter { constructor(retryCount?: number, retryInterval?: number); retryCount: number; retryInterval: number; + handle(requestOptions: any, next: Function): void; } - export class ExponentialRetryPolicyFilter { + export class ExponentialRetryPolicyFilter implements Filter { constructor(retryCount?: number, retryInterval?: number, minRetryInterval?: number, maxRetryInterval?: number); retryCount: number; retryInterval: number; minRetryInterval: number; maxRetryInterval: number; + handle(requestOptions: any, next: Function): void; + } + + export class HmacSha256Sign { + } export class SharedAccessSignature { + storageAccount: string; + storageAccessKey: string; + permissionSet: string[]; + signer: HmacSha256Sign; + constructor(storageAccount: string, storageAccessKey: string, permissionSet: string[]) + + /** + * Generates the query string for a shared access signature signing. + */ + generateSignedQueryString(path: string, queryString: Dictionary, resourceType: string, sharedAccessPolicy: SharedAccessPolicy): Dictionary; + + /** + * Signs a request with the signature header. + */ + signRequest(webResource: WebResource, callback: ErrorCallback): void; + + /** + * Generates the shared access signature for a resource. + */ + _generateSignature(path: string, resourceType: string, sharedAccessPolicy: SharedAccessPolicy): string; + + /** + * Generates the query string for a shared access signature signing. + */ + _permissionMatchesRequest(sharedAccessSignature: string, webResource: WebResource, resourceType: string, requiredPermissions: string[]): string; } export class SharedKey { + storageAccount: string; + storageAccessKey: string; + usePathStyleUri: string; + signer: HmacSha256Sign; + constructor(storageAccount: string, storageAccessKey: string, usePathStyleUri: boolean); + + /** + * Signs a request with the Authentication header. + */ + signRequest(webResource: WebResource, callback: ErrorCallback): void; + + /** + * Retrieves the webresource's canonicalized resource string. + */ + _getCanonicalizedResource(webResource: WebResource): string; + + /** + * Constructs the Canonicalized Headers string. + * + * To construct the CanonicalizedHeaders portion of the signature string, + * follow these steps: 1. Retrieve all headers for the resource that begin + * with x-ms-, including the x-ms-date header. 2. Convert each HTTP header + * name to lowercase. 3. Sort the headers lexicographically by header name, + * in ascending order. Each header may appear only once in the + * string. 4. Unfold the string by replacing any breaking white space with a + * single space. 5. Trim any white space around the colon in the header. 6. + * Finally, append a new line character to each canonicalized header in the + * resulting list. Construct the CanonicalizedHeaders string by + * concatenating all headers in this list into a single string. + */ + _getCanonicalizedHeaders(webResource: WebResource): string; } export class SharedKeyLite { + storageAccount: string; + storageAccessKey: string; + usePathStyleUri: string; + signer: HmacSha256Sign; + constructor(storageAccount: string, storageAccessKey: string, usePathStyleUri: boolean); + + /** + * Signs a request with the Authentication header. + */ + signRequest(webResource: WebResource, callback: ErrorCallback): void; + + /** + * Retrieves the webresource's canonicalized resource string. + */ + _getCanonicalizedResource(webResource: WebResource): string; + + /** + * Constructs the Canonicalized Headers string. + * + * To construct the CanonicalizedHeaders portion of the signature string, + * follow these steps: 1. Retrieve all headers for the resource that begin + * with x-ms-, including the x-ms-date header. 2. Convert each HTTP header + * name to lowercase. 3. Sort the headers lexicographically by header name, + * in ascending order. Each header may appear only once in the + * string. 4. Unfold the string by replacing any breaking white space with a + * single space. 5. Trim any white space around the colon in the header. 6. + * Finally, append a new line character to each canonicalized header in the + * resulting list. Construct the CanonicalizedHeaders string by + * concatenating all headers in this list into a single string. + */ + _getCanonicalizedHeaders(webResource: WebResource): string; } export class SharedKeyTable { + storageAccount: string; + storageAccessKey: string; + usePathStyleUri: string; + signer: HmacSha256Sign; + constructor(storageAccount: string, storageAccessKey: string, usePathStyleUri: boolean); + + /** + * Signs a request with the Authentication header. + */ + signRequest(webResource: WebResource, callback: ErrorCallback): void; + + /** + * Retrieves the webresource's canonicalized resource string. + */ + _getCanonicalizedResource(webResource: WebResource): string; } export class SharedKeyLiteTable { + torageAccount: string; + storageAccessKey: string; + usePathStyleUri: string; + signer: HmacSha256Sign; + constructor(storageAccount: string, storageAccessKey: string, usePathStyleUri: boolean); + + /** + * Signs a request with the Authentication header. + */ + signRequest(webResource: WebResource, callback: ErrorCallback): void; + + /** + * Retrieves the webresource's canonicalized resource string. + */ + _getCanonicalizedResource(webResource: WebResource): string; } export module ISO8061Date { + /** + * Formats a date into an iso 8061 string. + */ + export function format(date: Date): string; + /** + * Parses an ISO 8061 date string into a date object. + */ + export function parse(stringDateTime: string): Date; } export class Logger { + level: string; + loggerFunction: (level: string, message: string) => void; + static LogLevels: { + EMERGENCY: string; + ALERT: string; + CRITICAL: string; + ERROR: string; + WARNING: string; + NOTICE: string; + INFO: string; + DEBUG: string; + }; + static logPriority: string[]; + + log(level: string, message: string): void; + emergency(message: string): void; + alert(message: string): void; + critical(message: string): void; + error(message: string): void; + warning(message: string): void; + notice(message: string): void; + info(message: string): void; + debug(message: string): void; + + defaultLoggerFunction(level: string, message: string): void; } export class ConnectionStringParser { + _value: string; + _pos: number; + _state: string; + constructor(connectionString: string); + + _parse(options: ConnectionStringParseOptions): Dictionary; + + _extractKey(): string; + _extractString(quote: string): string; + _extractValue(): string; + + _skipWhitespaces(): void; + _skipOperator(operator: string): void; + + static parse(connectionString: string): Dictionary; } export module ServiceSettings { + export var DEFAULT_PROTOCOL: string; + export class NoMatchError implements Error { + name: string; + message: string; + constr: any; + + constructor(); + constructor(message: string); + constructor(message: string, constr: any); + } + + /** + * Throws an exception if the connection string format does not match any of the + * available formats. + */ + export function noMatchConnectionString(connectionString: string): void; + + /** + * Throws an exception if the settings dont match any of the available formats. + */ + export function noMatchSettings(settings: any): void; + + /** + * Parses the connection string and then validate that the parsed keys belong to + * the validSettingKeys + */ + export function parseAndValidateKeys(connectionString: string, validKeys: string[]): string[]; + + /** + * Creates an anonymous function that acts as predicate to perform a validation. + */ + export function getValidator(requirements: Dictionary, isRequired: boolean, atLeastOne: boolean): ValidatorFunction; + + /** + * Creates a setting value condition that validates it is one of the passed valid values. + */ + export function setting(name: string): string[]; + + /** + * Creates an "at least one" predicate for the provided list of requirements. + */ + export function atLeastOne(...args: any[]): ValidatorFunction; + + /** + * Creates an optional predicate for the provided list of requirements. + */ + export function optional(...args: any[]): ValidatorFunction; + + /** + * Creates an required predicate for the provided list of requirements. + */ + export function allRequired(...args: any[]): ValidatorFunction; + + /** + * Creates a setting value condition using the passed predicate. + */ + export function settingWithFunc(name: string, predicate: Function): Requirement[]; + + /** + * Tests to see if a given list of settings matches a set of filters exactly. + */ + export function matchedSpecification(settings: Dictionary): boolean; + + /** + * Tests to see if a given list of settings matches a set of filters exactly. + */ + export function parseHost(uri: string): url.Url; } export class StorageServiceSettings { + _name: string; + _key: string; + _blobEndpointUri: string; + _queueEndpointUri: string; + _tableEndpointUri: string; + _usePathStyleUri: boolean; + constructor(name: string, key: string, blobEndpointUri: string, queueEndpointUri: string, tableEndpointUri: string, usePathStyleUri: boolean); + + /** + * Returns a StorageServiceSettings with development storage credentials using + * the specified proxy Uri. + */ + static _getDevelopmentStorageAccount(): StorageServiceSettings; + static _getDevelopmentStorageAccount(proxy: string): StorageServiceSettings; + + /** + * Gets a StorageServiceSettings object that references the development storage + * account. + */ + static getDevelopmentStorageAccountSettings(): StorageServiceSettings; + + /** + * Gets the default service endpoint using the specified protocol and account + * name. + */ + static _getDefaultServiceEndpoint(settings: Dictionary, dns: string): string; + + /** + * Creates StorageServiceSettings object given endpoints uri. + */ + static _createStorageServiceSettings(settings: Dictionary, blobEndpointUri: string, queueEndpointUri: string, tableEndpointUri: string): StorageServiceSettings; + + /** + * Creates a ServiceBusSettings object from a set of settings. + */ + static createFromSettings(settings: Dictionary): StorageServiceSettings; + + /** + * Creates a StorageServiceSettings object from the given connection string. + */ + static createFromConnectionString(connectionString: string): StorageServiceSettings; + + static createExplicitlyOrFromEnvironment(storageAccount: string, storageAccessKey: string, host: string): StorageServiceSettings; + + static isDevelopmentStorage(storageAccount: string, storageAccessKey: string, parsedHost: string): boolean; + + static createFromConfig(config: any): StorageServiceSettings; + + static customizeConfig(config: any): void; } export class ServiceBusSettings { @@ -290,11 +1375,87 @@ declare module "azure" { } export module Validate { + /** + * Checks if the given uri is valid or not. + */ + export function isValidUri(uri: string): boolean; + /** + * Validates that a clusterCreationObject is properly formed. + */ + export function isValidHDInsightCreationObject(clusterCreationObject: ClusterCreationOptions): void; + export function isValidHDInsightCreationObject(clusterCreationObject: ClusterCreationOptions, callback: ErrorCallback): void; + + export function isValidUuid(uuid: string): void; + export function isValidUuid(uuid: string, callback: ErrorCallback): void; + + /** + * Creates a anonymous function that check if a given key is base 64 encoded. + */ + export function isBase64Encoded(key: string): boolean; + + /** + * Validates a function. + */ + export function isValidFunction(functionObject: any, functionName: string): void; + + /** + * Validates that a Service Bus namespace name + * is legally allowable. Does not check availability. + */ + export function namespaceNameIsValid(name: string): boolean; + export function namespaceNameIsValid(name: string, callback: ErrorCallback): boolean; + + /** + * Validates a container name. + */ + export function containerNameIsValid(containerName: string): boolean; + export function containerNameIsValid(containerName: string, callback: ErrorCallback): boolean; + + /** + * Validates a blob name. + */ + export function blobNameIsValid(containerName: string, blob: string): boolean; + export function blobNameIsValid(containerName: string, blob: string, callback: ErrorCallback): boolean; + + /** + * Validates a table name. + */ + export function tableNameIsValid(tableName: string): boolean; + export function tableNameIsValid(tableName: string, callback: ErrorCallback): boolean; + + /** + * Validates a queue name. + */ + export function queueNameIsValid(queueName: string): boolean; + export function queueNameIsValid(queueName: string, callback: ErrorCallback): boolean; + + export function pageRangesAreValid(rangeStart: number, rangeEnd: number, writeBlockSizeInBytes: number): boolean; + export function pageRangesAreValid(rangeStart: number, rangeEnd: number, writeBlockSizeInBytes: number, callback: ErrorCallback): boolean; + + export function validateArgs(functionName: string, validationRules: Function): boolean; } export module date { + /** + * Generates a Date object which is in the given days from now. + */ + export function daysFromNow(days: number): Date; + /** + * Generates a Date object which is in the given hours from now. + */ + export function hoursFromNow(hours: number): Date; + + /** + * Generates a Date object which is in the given minutes from now. + */ + export function minutesFromNow(minutes: number): Date; + + /** + * Generates a Date object which is in the given seconds from now. + */ + export function secondsFromNow(seconds: number): Date; } //#endregion @@ -302,28 +1463,104 @@ declare module "azure" { export interface WebResponse { isSuccessful: boolean; statusCode: number; - body: { - entry: { - id: string; - title: any; - updated: string; - author: { - name: any; - }; - link: any; - category: any; - content: any; - }; + body: { + entry: { + id: string; + title: any; + updated: string; + author: { + name: any; + }; + link: any; + category: any; + content: any; + }; }; headers: any; md5: any; } + //#region Common Interfaces + export interface SimpleCallback { + (error: Error, result: T): void; + } + export interface ErrorCallback { + (error: Error): void; + } + export interface StorageCallbackVoid { + (err: Error, response: WebResponse): void; + } + export interface StorageCallback { + (err: Error, result: T, response: WebResponse): void; + } + export interface StorageServiceStatsCallback extends StorageCallback { } + export interface StorageServicePropertiesCallback extends StorageCallback { } + export interface TimeoutIntervalOptions { + locationMode?: string; timeoutIntervalInMs?: number; + maximumExecutionTimeInMs?: number; + } + export interface MetadataOptions extends TimeoutIntervalOptions { + metadata?: StorageMetadata; + } + export interface StorageAclOptions extends TimeoutIntervalOptions { + leaseId?: string; + signedIdentifiers: SignedIdentifier[] } - ///#region TableService Callbacks + export interface Dictionary { + [key: string]: T; + } + export interface StorageServiceProperties { + Logging: { + Version: number; + Delete: boolean; + Read: boolean; + Write: boolean; + RetentionPolicy: { + Enabled: boolean; + Days: number; + }; + }; + Metrics: { + Version: number; + Enabled: boolean; + IncludeAPIs: boolean; + RetentionPolicy: { + Enabled: boolean; + Days: number; + }; + }; + DefaultServiceVersion: string; + } + export interface StorageServiceStats { + GeoReplication: { + Status: string; + LastSyncTime: Date; + } + } + export interface SignedIdentifier { + Id: string; + AccessPolicy: SharedAccessPolicy; + } + export interface StorageMetadata { + [key: string]: string; + } + export interface ContinuationToken { + nextMarker: string; + targetLocation: string; + } + export interface SharedAccessPolicy { + Id?: string; + AccessPolicy: { + Start?: Date; + Expiry: Date; + Permission?: string; + } + } + //#endregion + //#region TableService Interfaces export interface TableRequestCallback { (error: Error, tableResult: { TableName: string; }, response: WebResponse): void; } @@ -387,13 +1624,233 @@ declare module "azure" { etag?: string; } //#endregion + //#region BlobService Interfaces + export interface LeaseIdOptions extends TimeoutIntervalOptions { + leaseId?: string; + } + export interface AccessConditionsOptions extends TimeoutIntervalOptions { + accessConditions?: StorageAccessCondition; + } + export interface LeaseAccessConditionsOptions extends LeaseIdOptions { + accessConditions?: StorageAccessCondition; + } + + export interface ListContainersOptions extends TimeoutIntervalOptions { + prefix?: string; + maxresults?: number; + marker: string; + include?: string; + } + export interface ListContainersCallback { + (err: Error, containers: ContainerResult[], continuationToken: ContinuationToken, response: WebResponse): void; + } + export interface CreateContainerOptions extends TimeoutIntervalOptions { + metadata?: StorageMetadata; + publicAccessLevel?: string; + } + export interface GetContainerPropertiesOptions extends TimeoutIntervalOptions { + leaseId?: string; + } + export interface GetContainerMetadataOptions extends GetContainerPropertiesOptions { + accessConditions?: StorageAccessCondition; + } + + export interface ListBlobsOptions extends ListContainersOptions { + prefix?: string; + delimiter?: string; + } + export interface ListBlobsCallback { + (err: Error, blobs: BlobResult[], continuationToken: ContinuationToken, response: WebResponse): void; + } + export interface GetBlobPropertiesOptions extends LeaseAccessConditionsOptions { + snapshotId?: string; + } + export interface SetBlobPropertiesOptions extends LeaseAccessConditionsOptions { + contentType?: string; + contentEncoding?: string; + contentLanguage?: string; + contentMD5?: string; + cacheControl?: string; + contentDisposition?: string; + } + export interface ReadBlobOptions extends GetBlobPropertiesOptions { + rangeStart?: string; + rangeEnd?: string; + useTransactionalMD5?: boolean; + disableContentMD5Validation?: boolean; + } + export interface GetBlobToTextCallback { + (err: Error, text: string, result: BlobResult, response: WebResponse): void; + } + export interface DeleteBlobOptions extends GetBlobPropertiesOptions { + deleteSnapshots?: string; + } + export interface BlobSnapshotOptions extends GetBlobPropertiesOptions { + metadata?: StorageMetadata; + } + export interface CopyBlobOptions extends BlobSnapshotOptions { + sourceLeaseId?: string; + sourceAccessConditions: StorageAccessCondition; + } + + export interface UploadBlobOptions extends SetBlobPropertiesOptions { + metadata?: StorageMetadata; + speedSummary?: SpeedSummary; + parallelOperationThreadCount?: number; + storeBlobContentMD5?: boolean; + useTransactionalMD5?: boolean; + } + export interface CreatePagesOptions extends LeaseAccessConditionsOptions { + contentMD5?: string; + useTransactionalMD5?: boolean; + } + export interface PageRangeOptions extends LeaseIdOptions { + snapshotId?: string; + rangeStart?: number; + rangeEnd?: number; + } + + export interface UploadBlockBlobOptions extends UploadBlobOptions { + blockIdPrefix?: string; + } + export interface CreateBlockOptions extends LeaseAccessConditionsOptions { + contentMD5?: string; + useTransactionalMD5?: boolean; + } + + export interface LeaseOptions extends AccessConditionsOptions { + leaseDuration?: string; + proposedLeaseId?: string; + } + export interface BreakLeaseOptions extends AccessConditionsOptions { + leaseBreakPeriod?: number; + } + + export interface BlobHeaders { + cacheControl?: string; + contentType?: string; + contentEncoding?: string; + contentLanguage?: string; + contentDisposition?: string; + } + export interface PageRange { + start: number; + end: number; + } + export interface BlockList { + LatestBlocks: string[]; + CommittedBlocks: string[]; + UncommittedBlocks: string[]; + } + export interface StorageAccessCondition { + "If-Modified-Since": Date; + "If-Unmodified-Since": Date; + "If-Match": string; + "If-None-Match": string; + } + //#endregion + //#region QueueService Interfaces + export interface ListQueuesOptions extends TimeoutIntervalOptions { + prefix?: string; + maxresults?: number; + marker: string; + include?: string; + } + export interface ListQueuesCallback { + (err: Error, queues: QueueResult[], continuationToken: ContinuationToken, response: WebResponse): void; + } + + export interface CreateQueueMessageOptions extends TimeoutIntervalOptions { + messagettl?: number; + visibilitytimeout?: number; + } + export interface PeekQueueMessagesOptions extends TimeoutIntervalOptions { + numofmessages?: number; + } + export interface GetQueueMessagesOptions extends PeekQueueMessagesOptions { + peekonly?: boolean; + visibilitytimeout?: number; + } + export interface UpdateQueueMessagesOptions extends TimeoutIntervalOptions { + messagetext?: string; + } + //#endregion + + //#region RoleEnvironment Interfaces + export interface Role { + name: string; + instances: { + [instanceId: string]: RoleInstance; + }; + } + export interface RoleInstance { + id: string; + faultDomain: string; + updateDomain: string; + endpoints: { + [endpoint: string]: RoleInstanceEndpoint + }; + } + export interface RoleInstanceEndpoint { + protocol: string; + address: string; + port: number; + } + export interface RoleLocalResource { + name: string; + path: string; + maximumSizeInMegabytes: number; + } + //#endregion + //#region ConnectionStringParser Interfaces + export interface ConnectionStringParseOptions { + skipLowerCase: boolean; + } + //#endregion + //#region Validate Interfaces + export interface ClusterCreationOptions { + name: string; + location: string; + defaultStorageAccountName: string; + defaultStorageAccountKey: string; + defaultStorageContainer: string; + user: string; + password: string; + nodes: number; + additionalStorageAccounts?: { + name: string; + key: string; + }[]; + oozieMetastore?: { + server: string; + database: string; + user: string; + password: string; + }; + hiveMetastore?: { + server: string; + database: string; + user: string; + password: string; + }; + } + //#endregion + //#region ServiceSettings Interfaces + export interface Requirement { + SettingName: string; + SettingPredicate: Function; + } + export interface ValidatorFunction { + (userSettings: Dictionary): any; + } + //#endregion //#endregion //#region Un-exported internal classes class StorageServiceClient extends ServiceClient { static incorrectStorageAccountErr: string; static incorrectStorageAccessKeyErr: string; - static getStorageSettings(connectionString: string) : StorageServiceSettings; + static getStorageSettings(connectionString: string): StorageServiceSettings; static getStorageSettings(storageAccount?: string, storageAccessKey?: string, host?: string): StorageServiceSettings; apiVersion: string; @@ -404,5 +1861,4 @@ declare module "azure" { //#endregion export function isEmulated(): boolean; - } From c46325e6f8d6d3013e7655e0f3414090681d6d39 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Mon, 15 Sep 2014 04:27:48 +0200 Subject: [PATCH 2/4] Fix some syntax issues --- node-azure/azure.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node-azure/azure.d.ts b/node-azure/azure.d.ts index 05cb58dea3..cb1f3b694f 100644 --- a/node-azure/azure.d.ts +++ b/node-azure/azure.d.ts @@ -1,7 +1,7 @@ // Type definitions for Azure SDK for Node - v0.9.16 // Project: https://github.com/WindowsAzure/azure-sdk-for-node // Definitions by: Andrew Gaspar , -// Anti Veeranna , +// Anti Veeranna , // Maxime LUCE // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -884,7 +884,7 @@ declare module "azure" { constructor(container: string, blob: string); static parse(blobXml: any): BlobResult; - static setHeadersFromBlob(webResource: WebResource, blob: BlobResult); + static setHeadersFromBlob(webResource: WebResource, blob: BlobResult): void; getPropertiesFromHeaders(headers: any): void; } From 1785970ea15696f6975b66b73560e5214b0c1d3b Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Tue, 16 Sep 2014 04:38:45 +0200 Subject: [PATCH 3/4] Add contributors for azure sdk --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index ef83ff093c..b0e4d7a2e9 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -270,6 +270,7 @@ All definitions files include a header with the author and editors, so at some p * [nock](https://github.com/pgte/nock) (by [bonnici](https://github.com/bonnici)) * [Node.js](http://nodejs.org/) (from TypeScript samples) * [node_redis](https://github.com/mranney/node_redis) (by [Boris Yankov](https://github.com/borisyankov)) +* [node-azure](https://github.com/Azure/azure-sdk-for-node) (by [Andrew Gaspar](https://github.com/AndrewGaspar), [Anti Veeranna](https://github.com/antiveeranna) and [Maxime LUCE](https://github.com/SomaticIT)) * [node-ffi](https://github.com/rbranson/node-ffi) (by [Paul Loyd](https://github.com/loyd)) * [node-form](https://github.com/rsamec/form) (by [Roman Samec](https://github.com/rsamec)) * [node-git](https://github.com/christkv/node-git) (by [vvakame](https://github.com/vvakame)) From 837677d435964108fd0b328dc7fba5aa6e45a076 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Wed, 17 Sep 2014 23:43:10 +0200 Subject: [PATCH 4/4] Fix issue in generateSharedAccessSignature function of BlobService --- node-azure/azure.d.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/node-azure/azure.d.ts b/node-azure/azure.d.ts index cb1f3b694f..cb759f19e4 100644 --- a/node-azure/azure.d.ts +++ b/node-azure/azure.d.ts @@ -317,7 +317,7 @@ declare module "azure" { /** * Retrieves a shared access signature token. */ - generateSharedAccessSignature(container: string, blob: string, sharedAccessPolicy: SharedAccessPolicy): string; + generateSharedAccessSignature(container: string, blob: string, sharedAccessPolicy: SharedAccessPolicy): SharedAccessSignatureResult; /** * Retrieves a blob or container URL. @@ -1726,6 +1726,18 @@ declare module "azure" { leaseBreakPeriod?: number; } + export interface SharedAccessSignatureResult { + baseUrl: string; + path: string; + queryString: { + se: string; + sp: string; + sr: string; + sv: string; + sig: string; + }; + url: () => string; + } export interface BlobHeaders { cacheControl?: string; contentType?: string;