import { AbortSignalLike } from '@azure/core-http'; import { AnonymousCredential } from '@azure/storage-blob'; import { CommonOptions } from '@azure/storage-blob'; import { PagedAsyncIterableIterator } from '@azure/core-paging'; import { Pipeline } from '@azure/storage-blob'; import { StoragePipelineOptions } from '@azure/storage-blob'; import { StorageSharedKeyCredential } from '@azure/storage-blob'; import { TokenCredential } from '@azure/core-http'; /** * The AccessTier. */ export declare type AccessTier = "P4" | "P6" | "P10" | "P15" | "P20" | "P30" | "P40" | "P50" | "P60" | "P70" | "P80" | "Hot" | "Cool" | "Archive"; /** * BlobChangeFeedClient. * @see https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal */ export declare class BlobChangeFeedClient { /** * blobServiceClient provided by `@azure/storage-blob` package. */ private blobServiceClient; private changeFeedFactory; private changeFeedClientOptions; /** * * Creates an instance of BlobChangeFeedClient from connection string. * * @param connectionString - Account connection string or a SAS connection string of an Azure storage account. * [ Note - Account connection string can only be used in NODE.JS runtime. ] * Account connection string example - * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net` * SAS connection string example - * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString` * @param options - Optional. Options to configure the HTTP pipeline. */ static fromConnectionString(connectionString: string, options?: StoragePipelineOptions, changeFeedClientOptions?: BlobChangeFeedClientOptions): BlobChangeFeedClient; /** * Creates an instance of BlobChangeFeedClient. * * @param url - A Client string pointing to Azure Storage blob service, such as * "https://myaccount.blob.core.windows.net". You can append a SAS * if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString". * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used. * @param options - Optional. Options to configure the HTTP pipeline. * * Example using DefaultAzureCredential from `@azure/identity`: * * ```js * const account = ""; * * const defaultAzureCredential = new DefaultAzureCredential(); * * const blobChangeFeedClient = new BlobChangeFeedClient( * `https://${account}.blob.core.windows.net`, * defaultAzureCredential * ); * ``` * * Example using an account name/key: * * ```js * const account = "" * const sharedKeyCredential = new StorageSharedKeyCredential(account, ""); * * const blobChangeFeedClient = new BlobChangeFeedClient( * `https://${account}.blob.core.windows.net`, * sharedKeyCredential * ); * ``` */ constructor(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions, changeFeedClientOptions?: BlobChangeFeedClientOptions); /** * Creates an instance of BlobChangeFeedClient. * * @param url - A Client string pointing to Azure Storage blob service, such as * "https://myaccount.blob.core.windows.net". You can append a SAS * if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString". * @param pipeline - Call newPipeline() to create a default * pipeline, or provide a customized pipeline. */ constructor(url: string, pipeline: Pipeline); private getChange; private getPage; /** * Returns an async iterable iterator to list all the change feed events * in the specified account. * * .byPage() returns an async iterable iterator to list the change feed events in pages. * * Example using `for await` syntax: * * ```js * let i = 1; * for await (const event of blobChangeFeedClient.listChanges()) { * console.log(`Event ${i++}, type: ${event.eventType}`); * } * ``` * * Example using `iter.next()`: * * ```js * let i = 1; * const iter = blobChangeFeedClient.listChanges(); * let eventItem = await iter.next(); * while (!eventItem.done) { * console.log(`Event ${i++}, type: ${eventItem.eventType}`); * eventItem = await iter.next(); * } * ``` * * Example using `byPage()`: * * ```js * // passing optional maxPageSize in the page settings * let i = 1; * for await (const eventPage of blobChangeFeedClient.listChanges().byPage({ maxPageSize: 20 })) { * if (eventPage.events) { * for (const event of eventPage.events) { * console.log(`Event ${i++}, type: ${event.eventType}`); * } * } * } * ``` * * Example using paging with a marker: * * ```js * let i = 1; * let iterator = blobChangeFeedClient.listChanges().byPage({ maxPageSize: 2 }); * let eventPage = (await iterator.next()).value; * * if (eventPage.events) { * for (const container of eventPage.events) { * console.log(`Event ${i++}, type: ${event.eventType}`); * } * } * * // Gets next marker * let marker = eventPage.continuationToken; * // Passing next marker as continuationToken * iterator = blobChangeFeedClient * .listChanges() * .byPage({ continuationToken: marker, maxPageSize: 10 }); * eventPage = (await iterator.next()).value; * * if (eventPage.events) { * for (const container of eventPage.events) { * console.log(`Event ${i++}, type: ${event.eventType}`); * } * } * ``` * * @param options - Options to list change feed events. * @returns An asyncIterableIterator that supports paging. */ listChanges(options?: BlobChangeFeedListChangesOptions): PagedAsyncIterableIterator; } /** * Blob Change Feed client options. */ export declare interface BlobChangeFeedClientOptions { /** * The maximum length of an transfer in bytes. */ maximumTransferSize?: number; } /** * Change feed event record. Contains response data for the {@link BlobChangeFeedClient.listChanges} operation. * @see https://docs.microsoft.com/en-us/azure/event-grid/event-schema-blob-storage?toc=/azure/storage/blobs/toc.json#event-properties */ export declare interface BlobChangeFeedEvent { /** * Full resource path to the event source. This field is not writeable. Event Grid provides this value. */ topic: string; /** * Publisher-defined path to the event subject. */ subject: string; /** * One of the registered event types for this event source. */ eventType: BlobChangeFeedEventType; /** * The time the event is generated based on the provider's UTC time. */ eventTime: Date; /** * Unique identifier for the event. */ id: string; /** * Blob storage event data. */ data: BlobChangeFeedEventData; /** * The schema version of the data object. The publisher defines the schema version. */ dataVersion?: string; /** * The schema version of the data object. The publisher defines the schema version. */ schemaVersion?: number; /** * The schema version of the event metadata. Event Grid defines the schema of the top-level properties. Event Grid provides this value. */ metadataVersion: string; } /** * Change feed Blob storage event data. */ export declare interface BlobChangeFeedEventData { /** * The operation that triggered the event. */ api: string; /** * A client-provided request id for the storage API operation. This id can be used to * correlate to Azure Storage diagnostic logs using the "client-request-id" field in the logs, * and can be provided in client requests using the "x-ms-client-request-id" header. */ clientRequestId: string; /** * Service-generated request id for the storage API operation. Can be used to correlate to Azure Storage * diagnostic logs using the "request-id-header" field in the logs and is returned from initiating API call * in the 'x-ms-request-id' header. */ requestId: string; /** * The value that you can use to perform operations conditionally. */ etag: string; /** * The content type specified for the blob. */ contentType: string; /** * The size of the blob in bytes. */ contentLength: number; /** * The offset in bytes of a write operation taken at the point where the event-triggering application completed * writing to the file. * Appears only for events triggered on blob storage accounts that have a hierarchical namespace. */ contentOffset?: number; /** * The type of blob. */ blobType: BlobType; /** * The path to the blob. If the client uses a Blob REST API, then the url has this structure: * .blob.core.windows.net//. */ url: string; /** * The url of the file that will exist after the operation completes. For example, if a file is renamed, * the destinationUrl property contains the url of the new file name. * Appears only for events triggered on blob storage accounts that have a hierarchical namespace. */ destinationUrl?: string; /** * The url of the file that exists prior to the operation. For example, if a file is renamed, the sourceUrl * contains the url of the original file name prior to the rename operation. * Appears only for events triggered on blob storage accounts that have a hierarchical namespace. */ sourceUrl?: string; /** * True to perform the operation on all child directories; otherwise False. * Appears only for events triggered on blob storage accounts that have a hierarchical namespace. */ isRecursive?: boolean; /** * An opaque string value representing the logical sequence of events for any particular blob name. * Users can use standard string comparison to understand the relative sequence of two events on the same blob name. */ sequencer: string; /** * Previous info for the blob. */ previousInfo?: ChangeFeedEventPreviousInfo; /** * Blob properties that were updated during this event. */ updatedBlobProperties?: UpdatedBlobProperties; /** * Blob tags that were updated during this event. */ updatedBlobTags?: BlobTagsChange; /** * The Snapshot associated with the event. */ snapshot?: string; /** * Version of the blob. */ blobVersion?: string; /** * Version of the container the blob is in. */ containerVersion?: string; /** * Access Tier of the blob. */ blobAccessTier?: AccessTier; /** * AsyncOperationInfo */ longRunningOperationInfo?: BlobOperationResult; } /** * Contains paged response data for the {@link BlobChangeFeedClient.listChanges} operation. */ export declare class BlobChangeFeedEventPage { /** * Array of {@link BlobChangeFeedEvent}. */ events: BlobChangeFeedEvent[]; /** * The token that keeps track of where to continue the iterator. */ continuationToken: string; constructor(); } /** * Change feed event record types. */ export declare type BlobChangeFeedEventType = "UnspecifiedEventType" | "BlobCreated" | "BlobDeleted" | "BlobPropertiesUpdated" | "BlobSnapshotCreated" | "Control" | "BlobTierChanged" | "BlobAsyncOperationInitiated" | "BlobMetadataUpdated" | "RestorePointMarkerCreated"; /** * Options to configure {@link BlobChangeFeedClient.listChanges} operation. */ export declare interface BlobChangeFeedListChangesOptions extends CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. */ abortSignal?: AbortSignalLike; /** * Specify the start of the time range during which the change feed records will be fetched. * Note that for now the change feed client will round start time down to the nearest hour. */ start?: Date; /** * Specify the end of the time range during which the change feed records will be fetched. * Note that for now the change feed client will round end time up to the nearest hour. */ end?: Date; } /** * ChangeFeedEvent AsyncOperationInfo */ export declare interface BlobOperationResult { /** * Destination access tier. */ destinationAccessTier?: AccessTier; /** * If the operation was async. */ isAsync: boolean; /** * Copy Id. */ copyId?: string; } /** * A blob property that was updated. */ export declare interface BlobPropertyChange { /** * The name of the property that was updated. */ propertyName: string; /** * The previous value of the property. */ oldValue: string; /** * The new value of the property. */ newValue: string; } /** * Blob tags that were updated as part of the change feed event. */ export declare interface BlobTagsChange { /** * Previous Tags. */ oldTags: Record; /** * New Tags. */ newTags: Record; } /** * The type of blob. */ export declare type BlobType = "BlockBlob" | "AppendBlob" | "PageBlob"; /** * Previous info for Change Feed Event. */ export declare interface ChangeFeedEventPreviousInfo { /** * Soft delete snapshot. */ softDeleteSnapshot?: string; /** * If the blob was soft deleted. */ isBlobSoftDeleted: boolean; /** * Blob version. */ newBlobVersion?: string; /** * Last version. */ oldBlobVersion?: string; /** * Previous Access Tier */ previousTier?: AccessTier; } /** * Creates a new Pipeline object with Credential provided. * * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used. * @param pipelineOptions - Optional. Options. * @returns A new Pipeline object. */ export declare function newPipeline(credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, pipelineOptions?: StoragePipelineOptions): Pipeline; /** * Blob properties that were updated during an event. */ export declare type UpdatedBlobProperties = Record; export {};