From d11707aadd6958d85cdb866ebb2fff5686b1f28a Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 14 Jul 2020 16:17:02 -0700 Subject: [PATCH 01/34] [EventGrid] Delete existing Track 1 client In preperation for rewriting the client using the track two guidelines, remove the existing client. --- sdk/eventgrid/eventgrid/LICENSE.txt | 21 - sdk/eventgrid/eventgrid/README.md | 119 - sdk/eventgrid/eventgrid/package.json | 58 - sdk/eventgrid/eventgrid/rollup.config.js | 37 - .../eventgrid/src/eventGridClient.ts | 106 - .../eventgrid/src/eventGridClientContext.ts | 55 - sdk/eventgrid/eventgrid/src/models/index.ts | 2617 ----------- sdk/eventgrid/eventgrid/src/models/mappers.ts | 3898 ----------------- .../eventgrid/src/models/parameters.ts | 44 - sdk/eventgrid/eventgrid/tsconfig.json | 19 - 10 files changed, 6974 deletions(-) delete mode 100644 sdk/eventgrid/eventgrid/LICENSE.txt delete mode 100644 sdk/eventgrid/eventgrid/README.md delete mode 100644 sdk/eventgrid/eventgrid/package.json delete mode 100644 sdk/eventgrid/eventgrid/rollup.config.js delete mode 100644 sdk/eventgrid/eventgrid/src/eventGridClient.ts delete mode 100644 sdk/eventgrid/eventgrid/src/eventGridClientContext.ts delete mode 100644 sdk/eventgrid/eventgrid/src/models/index.ts delete mode 100644 sdk/eventgrid/eventgrid/src/models/mappers.ts delete mode 100644 sdk/eventgrid/eventgrid/src/models/parameters.ts delete mode 100644 sdk/eventgrid/eventgrid/tsconfig.json diff --git a/sdk/eventgrid/eventgrid/LICENSE.txt b/sdk/eventgrid/eventgrid/LICENSE.txt deleted file mode 100644 index b73b4a1293c3..000000000000 --- a/sdk/eventgrid/eventgrid/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2019 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md deleted file mode 100644 index 6d5166ca35bd..000000000000 --- a/sdk/eventgrid/eventgrid/README.md +++ /dev/null @@ -1,119 +0,0 @@ -## Azure EventGridClient SDK for JavaScript - -This package contains an isomorphic SDK for EventGridClient. - -### Currently supported environments - -- Node.js version 6.x.x or higher -- Browser JavaScript - -### How to Install - -```bash -npm install @azure/eventgrid -``` - -### How to use - -#### nodejs - Authentication, client creation and publishEvents as an example written in TypeScript. - -##### Install @azure/ms-rest-nodeauth - -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` - -##### Sample code - -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { EventGridClient, EventGridModels, EventGridMappers } from "@azure/eventgrid"; -const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; - -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new EventGridClient(creds, subscriptionId); - const topicHostname = "testtopicHostname"; - const events = [{ - id: "testid", - topic: "testtopic", - subject: "testsubject", - data: {}, - eventType: "testeventType", - eventTime: new Date().toISOString(), - dataVersion: "testdataVersion" - }]; - client.publishEvents(topicHostname, events).then((result) => { - console.log("The result is:"); - console.log(result); - }); -}).catch((err) => { - console.error(err); -}); -``` - -#### browser - Authentication, client creation and publishEvents as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` - -##### Sample code - -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - -- index.html -```html - - - - @azure/eventgrid sample - - - - - - - - -``` - -## Related projects - -- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/eventgrid/eventgrid/README.png) diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json deleted file mode 100644 index fddae13a0aa3..000000000000 --- a/sdk/eventgrid/eventgrid/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@azure/eventgrid", - "author": "Microsoft Corporation", - "description": "EventGridClient Library with typescript type definitions for node.js and browser.", - "version": "2.0.0", - "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.1", - "@azure/ms-rest-js": "^2.0.4", - "tslib": "^1.10.0" - }, - "keywords": [ - "node", - "azure", - "typescript", - "browser", - "isomorphic" - ], - "license": "MIT", - "main": "./dist/eventgrid.js", - "module": "./esm/eventGridClient.js", - "types": "./esm/eventGridClient.d.ts", - "devDependencies": { - "typescript": "^3.5.3", - "rollup": "^1.18.0", - "rollup-plugin-node-resolve": "^5.2.0", - "rollup-plugin-sourcemaps": "^0.4.2", - "uglify-js": "^3.6.0" - }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/eventgrid/eventgrid", - "repository": { - "type": "git", - "url": "https://github.com/Azure/azure-sdk-for-js.git" - }, - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "files": [ - "dist/**/*.js", - "dist/**/*.js.map", - "dist/**/*.d.ts", - "dist/**/*.d.ts.map", - "esm/**/*.js", - "esm/**/*.js.map", - "esm/**/*.d.ts", - "esm/**/*.d.ts.map", - "src/**/*.ts", - "README.md", - "rollup.config.js", - "tsconfig.json" - ], - "scripts": { - "build": "tsc && rollup -c rollup.config.js && npm run minify", - "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/eventgrid.js.map'\" -o ./dist/eventgrid.min.js ./dist/eventgrid.js", - "prepack": "npm install && npm run build" - }, - "sideEffects": false, - "autoPublish": true -} diff --git a/sdk/eventgrid/eventgrid/rollup.config.js b/sdk/eventgrid/eventgrid/rollup.config.js deleted file mode 100644 index 6425b241b4b4..000000000000 --- a/sdk/eventgrid/eventgrid/rollup.config.js +++ /dev/null @@ -1,37 +0,0 @@ -import rollup from "rollup"; -import nodeResolve from "rollup-plugin-node-resolve"; -import sourcemaps from "rollup-plugin-sourcemaps"; - -/** - * @type {rollup.RollupFileOptions} - */ -const config = { - input: "./esm/eventGridClient.js", - external: [ - "@azure/ms-rest-js", - "@azure/ms-rest-azure-js" - ], - output: { - file: "./dist/eventgrid.js", - format: "umd", - name: "Azure.Eventgrid", - sourcemap: true, - globals: { - "@azure/ms-rest-js": "msRest", - "@azure/ms-rest-azure-js": "msRestAzure" - }, - banner: `/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */` - }, - plugins: [ - nodeResolve({ mainFields: ['module', 'main'] }), - sourcemaps() - ] -}; - -export default config; diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts deleted file mode 100644 index 2405169a7c16..000000000000 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as Models from "./models"; -import * as Mappers from "./models/mappers"; -import * as Parameters from "./models/parameters"; -import { EventGridClientContext } from "./eventGridClientContext"; - - -class EventGridClient extends EventGridClientContext { - /** - * Initializes a new instance of the EventGridClient class. - * @param credentials Credentials needed for the client to connect to Azure. - * @param [options] The parameter options - */ - constructor(credentials: msRest.ServiceClientCredentials, options?: msRestAzure.AzureServiceClientOptions) { - super(credentials, options); - } - - /** - * Publishes a batch of events to an Azure Event Grid topic. - * @param topicHostname The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net - * @param events An array of events to be published to Event Grid. - * @param [options] The optional parameters - * @returns Promise - */ - publishEvents(topicHostname: string, events: Models.EventGridEvent[], options?: msRest.RequestOptionsBase): Promise; - /** - * @param topicHostname The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net - * @param events An array of events to be published to Event Grid. - * @param callback The callback - */ - publishEvents(topicHostname: string, events: Models.EventGridEvent[], callback: msRest.ServiceCallback): void; - /** - * @param topicHostname The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net - * @param events An array of events to be published to Event Grid. - * @param options The optional parameters - * @param callback The callback - */ - publishEvents(topicHostname: string, events: Models.EventGridEvent[], options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - publishEvents(topicHostname: string, events: Models.EventGridEvent[], options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.sendOperationRequest( - { - topicHostname, - events, - options - }, - publishEventsOperationSpec, - callback); - } -} - -// Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const publishEventsOperationSpec: msRest.OperationSpec = { - httpMethod: "POST", - path: "api/events", - urlParameters: [ - Parameters.topicHostname - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], - requestBody: { - parameterPath: "events", - mapper: { - required: true, - serializedName: "events", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "EventGridEvent" - } - } - } - } - }, - responses: { - 200: {}, - default: { - bodyMapper: Mappers.CloudError - } - }, - serializer -}; - -export { - EventGridClient, - EventGridClientContext, - Models as EventGridModels, - Mappers as EventGridMappers -}; diff --git a/sdk/eventgrid/eventgrid/src/eventGridClientContext.ts b/sdk/eventgrid/eventgrid/src/eventGridClientContext.ts deleted file mode 100644 index 965e8c7890a8..000000000000 --- a/sdk/eventgrid/eventgrid/src/eventGridClientContext.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; - -const packageName = "@azure/eventgrid"; -const packageVersion = "2.0.0"; - -export class EventGridClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; - apiVersion?: string; - - /** - * Initializes a new instance of the EventGridClient class. - * @param credentials Credentials needed for the client to connect to Azure. - * @param [options] The parameter options - */ - constructor(credentials: msRest.ServiceClientCredentials, options?: msRestAzure.AzureServiceClientOptions) { - if (credentials == undefined) { - throw new Error('\'credentials\' cannot be null.'); - } - - if (!options) { - options = {}; - } - if(!options.userAgent) { - const defaultUserAgent = msRestAzure.getDefaultUserAgentValue(); - options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; - } - - super(credentials, options); - - this.apiVersion = '2018-01-01'; - this.acceptLanguage = 'en-US'; - this.longRunningOperationRetryTimeout = 30; - this.baseUri = "https://{topicHostname}"; - this.requestContentType = "application/json; charset=utf-8"; - this.credentials = credentials; - - if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { - this.acceptLanguage = options.acceptLanguage; - } - if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { - this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; - } - } -} diff --git a/sdk/eventgrid/eventgrid/src/models/index.ts b/sdk/eventgrid/eventgrid/src/models/index.ts deleted file mode 100644 index e8d6da587fb4..000000000000 --- a/sdk/eventgrid/eventgrid/src/models/index.ts +++ /dev/null @@ -1,2617 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { BaseResource, CloudError } from "@azure/ms-rest-azure-js"; - -export { BaseResource, CloudError }; - -/** - * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.BlobCreated event. - */ -export interface StorageBlobCreatedEventData { - /** - * The name of the API/operation that triggered this event. - */ - api?: string; - /** - * A request id provided by the client of the storage API operation that triggered this event. - */ - clientRequestId?: string; - /** - * The request id generated by the Storage service for the storage API operation that triggered - * this event. - */ - requestId?: string; - /** - * The etag of the blob at the time this event was triggered. - */ - eTag?: string; - /** - * The content type of the blob. This is the same as what would be returned in the Content-Type - * header from the blob. - */ - contentType?: string; - /** - * The size of the blob in bytes. This is the same as what would be returned in the - * Content-Length header from the blob. - */ - contentLength?: number; - /** - * The offset of the blob in bytes. - */ - contentOffset?: number; - /** - * The type of blob. - */ - blobType?: string; - /** - * The path to the blob. - */ - url?: string; - /** - * 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; - /** - * The identity of the requester that triggered this event. - */ - identity?: string; - /** - * For service use only. Diagnostic data occasionally included by the Azure Storage service. This - * property should be ignored by event consumers. - */ - storageDiagnostics?: any; -} - -/** - * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.BlobDeleted event. - */ -export interface StorageBlobDeletedEventData { - /** - * The name of the API/operation that triggered this event. - */ - api?: string; - /** - * A request id provided by the client of the storage API operation that triggered this event. - */ - clientRequestId?: string; - /** - * The request id generated by the Storage service for the storage API operation that triggered - * this event. - */ - requestId?: string; - /** - * The content type of the blob. This is the same as what would be returned in the Content-Type - * header from the blob. - */ - contentType?: string; - /** - * The type of blob. - */ - blobType?: string; - /** - * The path to the blob. - */ - url?: string; - /** - * 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; - /** - * The identity of the requester that triggered this event. - */ - identity?: string; - /** - * For service use only. Diagnostic data occasionally included by the Azure Storage service. This - * property should be ignored by event consumers. - */ - storageDiagnostics?: any; -} - -/** - * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.DirectoryCreated - * event. - */ -export interface StorageDirectoryCreatedEventData { - /** - * The name of the API/operation that triggered this event. - */ - api?: string; - /** - * A request id provided by the client of the storage API operation that triggered this event. - */ - clientRequestId?: string; - /** - * The request id generated by the storage service for the storage API operation that triggered - * this event. - */ - requestId?: string; - /** - * The etag of the directory at the time this event was triggered. - */ - eTag?: string; - /** - * The path to the directory. - */ - url?: string; - /** - * An opaque string value representing the logical sequence of events for any particular - * directory name. Users can use standard string comparison to understand the relative sequence - * of two events on the same directory name. - */ - sequencer?: string; - /** - * The identity of the requester that triggered this event. - */ - identity?: string; - /** - * For service use only. Diagnostic data occasionally included by the Azure Storage service. This - * property should be ignored by event consumers. - */ - storageDiagnostics?: any; -} - -/** - * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.DirectoryDeleted - * event. - */ -export interface StorageDirectoryDeletedEventData { - /** - * The name of the API/operation that triggered this event. - */ - api?: string; - /** - * A request id provided by the client of the storage API operation that triggered this event. - */ - clientRequestId?: string; - /** - * The request id generated by the storage service for the storage API operation that triggered - * this event. - */ - requestId?: string; - /** - * The path to the deleted directory. - */ - url?: string; - /** - * Is this event for a recursive delete operation. - */ - recursive?: boolean; - /** - * An opaque string value representing the logical sequence of events for any particular - * directory name. Users can use standard string comparison to understand the relative sequence - * of two events on the same directory name. - */ - sequencer?: string; - /** - * The identity of the requester that triggered this event. - */ - identity?: string; - /** - * For service use only. Diagnostic data occasionally included by the Azure Storage service. This - * property should be ignored by event consumers. - */ - storageDiagnostics?: any; -} - -/** - * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.BlobRenamed event. - */ -export interface StorageBlobRenamedEventData { - /** - * The name of the API/operation that triggered this event. - */ - api?: string; - /** - * A request id provided by the client of the storage API operation that triggered this event. - */ - clientRequestId?: string; - /** - * The request id generated by the storage service for the storage API operation that triggered - * this event. - */ - requestId?: string; - /** - * The path to the blob that was renamed. - */ - sourceUrl?: string; - /** - * The new path to the blob after the rename operation. - */ - destinationUrl?: string; - /** - * 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; - /** - * The identity of the requester that triggered this event. - */ - identity?: string; - /** - * For service use only. Diagnostic data occasionally included by the Azure Storage service. This - * property should be ignored by event consumers. - */ - storageDiagnostics?: any; -} - -/** - * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.DirectoryRenamed - * event. - */ -export interface StorageDirectoryRenamedEventData { - /** - * The name of the API/operation that triggered this event. - */ - api?: string; - /** - * A request id provided by the client of the storage API operation that triggered this event. - */ - clientRequestId?: string; - /** - * The request id generated by the storage service for the storage API operation that triggered - * this event. - */ - requestId?: string; - /** - * The path to the directory that was renamed. - */ - sourceUrl?: string; - /** - * The new path to the directory after the rename operation. - */ - destinationUrl?: string; - /** - * An opaque string value representing the logical sequence of events for any particular - * directory name. Users can use standard string comparison to understand the relative sequence - * of two events on the same directory name. - */ - sequencer?: string; - /** - * The identity of the requester that triggered this event. - */ - identity?: string; - /** - * For service use only. Diagnostic data occasionally included by the Azure Storage service. This - * property should be ignored by event consumers. - */ - storageDiagnostics?: any; -} - -/** - * Schema of the Data property of an EventGridEvent for an Microsoft.EventHub.CaptureFileCreated - * event. - */ -export interface EventHubCaptureFileCreatedEventData { - /** - * The path to the capture file. - */ - fileurl?: string; - /** - * The file type of the capture file. - */ - fileType?: string; - /** - * The shard ID. - */ - partitionId?: string; - /** - * The file size. - */ - sizeInBytes?: number; - /** - * The number of events in the file. - */ - eventCount?: number; - /** - * The smallest sequence number from the queue. - */ - firstSequenceNumber?: number; - /** - * The last sequence number from the queue. - */ - lastSequenceNumber?: number; - /** - * The first time from the queue. - */ - firstEnqueueTime?: Date; - /** - * The last time from the queue. - */ - lastEnqueueTime?: Date; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceWriteSuccess - * event. This is raised when a resource create or update operation succeeds. - */ -export interface ResourceWriteSuccessData { - /** - * The tenant ID of the resource. - */ - tenantId?: string; - /** - * The subscription ID of the resource. - */ - subscriptionId?: string; - /** - * The resource group of the resource. - */ - resourceGroup?: string; - /** - * The resource provider performing the operation. - */ - resourceProvider?: string; - /** - * The URI of the resource in the operation. - */ - resourceUri?: string; - /** - * The operation that was performed. - */ - operationName?: string; - /** - * The status of the operation. - */ - status?: string; - /** - * The requested authorization for the operation. - */ - authorization?: string; - /** - * The properties of the claims. - */ - claims?: string; - /** - * An operation ID used for troubleshooting. - */ - correlationId?: string; - /** - * The details of the operation. - */ - httpRequest?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceWriteFailure - * event. This is raised when a resource create or update operation fails. - */ -export interface ResourceWriteFailureData { - /** - * The tenant ID of the resource. - */ - tenantId?: string; - /** - * The subscription ID of the resource. - */ - subscriptionId?: string; - /** - * The resource group of the resource. - */ - resourceGroup?: string; - /** - * The resource provider performing the operation. - */ - resourceProvider?: string; - /** - * The URI of the resource in the operation. - */ - resourceUri?: string; - /** - * The operation that was performed. - */ - operationName?: string; - /** - * The status of the operation. - */ - status?: string; - /** - * The requested authorization for the operation. - */ - authorization?: string; - /** - * The properties of the claims. - */ - claims?: string; - /** - * An operation ID used for troubleshooting. - */ - correlationId?: string; - /** - * The details of the operation. - */ - httpRequest?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceWriteCancel - * event. This is raised when a resource create or update operation is canceled. - */ -export interface ResourceWriteCancelData { - /** - * The tenant ID of the resource. - */ - tenantId?: string; - /** - * The subscription ID of the resource. - */ - subscriptionId?: string; - /** - * The resource group of the resource. - */ - resourceGroup?: string; - /** - * The resource provider performing the operation. - */ - resourceProvider?: string; - /** - * The URI of the resource in the operation. - */ - resourceUri?: string; - /** - * The operation that was performed. - */ - operationName?: string; - /** - * The status of the operation. - */ - status?: string; - /** - * The requested authorization for the operation. - */ - authorization?: string; - /** - * The properties of the claims. - */ - claims?: string; - /** - * An operation ID used for troubleshooting. - */ - correlationId?: string; - /** - * The details of the operation. - */ - httpRequest?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceDeleteSuccess - * event. This is raised when a resource delete operation succeeds. - */ -export interface ResourceDeleteSuccessData { - /** - * The tenant ID of the resource. - */ - tenantId?: string; - /** - * The subscription ID of the resource. - */ - subscriptionId?: string; - /** - * The resource group of the resource. - */ - resourceGroup?: string; - /** - * The resource provider performing the operation. - */ - resourceProvider?: string; - /** - * The URI of the resource in the operation. - */ - resourceUri?: string; - /** - * The operation that was performed. - */ - operationName?: string; - /** - * The status of the operation. - */ - status?: string; - /** - * The requested authorization for the operation. - */ - authorization?: string; - /** - * The properties of the claims. - */ - claims?: string; - /** - * An operation ID used for troubleshooting. - */ - correlationId?: string; - /** - * The details of the operation. - */ - httpRequest?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceDeleteFailure - * event. This is raised when a resource delete operation fails. - */ -export interface ResourceDeleteFailureData { - /** - * The tenant ID of the resource. - */ - tenantId?: string; - /** - * The subscription ID of the resource. - */ - subscriptionId?: string; - /** - * The resource group of the resource. - */ - resourceGroup?: string; - /** - * The resource provider performing the operation. - */ - resourceProvider?: string; - /** - * The URI of the resource in the operation. - */ - resourceUri?: string; - /** - * The operation that was performed. - */ - operationName?: string; - /** - * The status of the operation. - */ - status?: string; - /** - * The requested authorization for the operation. - */ - authorization?: string; - /** - * The properties of the claims. - */ - claims?: string; - /** - * An operation ID used for troubleshooting. - */ - correlationId?: string; - /** - * The details of the operation. - */ - httpRequest?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for an Microsoft.Resources.ResourceDeleteCancel - * event. This is raised when a resource delete operation is canceled. - */ -export interface ResourceDeleteCancelData { - /** - * The tenant ID of the resource. - */ - tenantId?: string; - /** - * The subscription ID of the resource. - */ - subscriptionId?: string; - /** - * The resource group of the resource. - */ - resourceGroup?: string; - /** - * The resource provider performing the operation. - */ - resourceProvider?: string; - /** - * The URI of the resource in the operation. - */ - resourceUri?: string; - /** - * The operation that was performed. - */ - operationName?: string; - /** - * The status of the operation. - */ - status?: string; - /** - * The requested authorization for the operation. - */ - authorization?: string; - /** - * The properties of the claims. - */ - claims?: string; - /** - * An operation ID used for troubleshooting. - */ - correlationId?: string; - /** - * The details of the operation. - */ - httpRequest?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceActionSuccess - * event. This is raised when a resource action operation succeeds. - */ -export interface ResourceActionSuccessData { - /** - * The tenant ID of the resource. - */ - tenantId?: string; - /** - * The subscription ID of the resource. - */ - subscriptionId?: string; - /** - * The resource group of the resource. - */ - resourceGroup?: string; - /** - * The resource provider performing the operation. - */ - resourceProvider?: string; - /** - * The URI of the resource in the operation. - */ - resourceUri?: string; - /** - * The operation that was performed. - */ - operationName?: string; - /** - * The status of the operation. - */ - status?: string; - /** - * The requested authorization for the operation. - */ - authorization?: string; - /** - * The properties of the claims. - */ - claims?: string; - /** - * An operation ID used for troubleshooting. - */ - correlationId?: string; - /** - * The details of the operation. - */ - httpRequest?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceActionFailure - * event. This is raised when a resource action operation fails. - */ -export interface ResourceActionFailureData { - /** - * The tenant ID of the resource. - */ - tenantId?: string; - /** - * The subscription ID of the resource. - */ - subscriptionId?: string; - /** - * The resource group of the resource. - */ - resourceGroup?: string; - /** - * The resource provider performing the operation. - */ - resourceProvider?: string; - /** - * The URI of the resource in the operation. - */ - resourceUri?: string; - /** - * The operation that was performed. - */ - operationName?: string; - /** - * The status of the operation. - */ - status?: string; - /** - * The requested authorization for the operation. - */ - authorization?: string; - /** - * The properties of the claims. - */ - claims?: string; - /** - * An operation ID used for troubleshooting. - */ - correlationId?: string; - /** - * The details of the operation. - */ - httpRequest?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for an Microsoft.Resources.ResourceActionCancel - * event. This is raised when a resource action operation is canceled. - */ -export interface ResourceActionCancelData { - /** - * The tenant ID of the resource. - */ - tenantId?: string; - /** - * The subscription ID of the resource. - */ - subscriptionId?: string; - /** - * The resource group of the resource. - */ - resourceGroup?: string; - /** - * The resource provider performing the operation. - */ - resourceProvider?: string; - /** - * The URI of the resource in the operation. - */ - resourceUri?: string; - /** - * The operation that was performed. - */ - operationName?: string; - /** - * The status of the operation. - */ - status?: string; - /** - * The requested authorization for the operation. - */ - authorization?: string; - /** - * The properties of the claims. - */ - claims?: string; - /** - * An operation ID used for troubleshooting. - */ - correlationId?: string; - /** - * The details of the operation. - */ - httpRequest?: string; -} - -/** - * Properties of an event published to an Event Grid topic. - */ -export interface EventGridEvent { - /** - * An unique identifier for the event. - */ - id: string; - /** - * The resource path of the event source. - */ - topic?: string; - /** - * A resource path relative to the topic path. - */ - subject: string; - /** - * Event data specific to the event type. - */ - data: any; - /** - * The type of the event that occurred. - */ - eventType: string; - /** - * The time (in UTC) the event was generated. - */ - eventTime: Date; - /** - * The schema version of the event metadata. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly metadataVersion?: string; - /** - * The schema version of the data object. - */ - dataVersion: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a - * Microsoft.EventGrid.SubscriptionValidationEvent. - */ -export interface SubscriptionValidationEventData { - /** - * The validation code sent by Azure Event Grid to validate an event subscription. To complete - * the validation handshake, the subscriber must either respond with this validation code as part - * of the validation response, or perform a GET request on the validationUrl (available starting - * version 2018-05-01-preview). - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly validationCode?: string; - /** - * The validation URL sent by Azure Event Grid (available starting version 2018-05-01-preview). - * To complete the validation handshake, the subscriber must either respond with the - * validationCode as part of the validation response, or perform a GET request on the - * validationUrl (available starting version 2018-05-01-preview). - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly validationUrl?: string; -} - -/** - * To complete an event subscription validation handshake, a subscriber can use either the - * validationCode or the validationUrl received in a SubscriptionValidationEvent. When the - * validationCode is used, the SubscriptionValidationResponse can be used to build the response. - */ -export interface SubscriptionValidationResponse { - /** - * The validation response sent by the subscriber to Azure Event Grid to complete the validation - * of an event subscription. - */ - validationResponse?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a - * Microsoft.EventGrid.SubscriptionDeletedEvent. - */ -export interface SubscriptionDeletedEventData { - /** - * The Azure resource ID of the deleted event subscription. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly eventSubscriptionId?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a device life cycle event (DeviceCreated, - * DeviceDeleted). - */ -export interface DeviceLifeCycleEventProperties { - /** - * The unique identifier of the device. This case-sensitive string can be up to 128 characters - * long, and supports ASCII 7-bit alphanumeric characters plus the following special characters: - * - : . + % _ # * ? ! ( ) , = @ ; $ '. - */ - deviceId?: string; - /** - * Name of the IoT Hub where the device was created or deleted. - */ - hubName?: string; - /** - * Information about the device twin, which is the cloud representation of application device - * metadata. - */ - twin?: DeviceTwinInfo; -} - -/** - * Event data for Microsoft.Devices.DeviceCreated event. - */ -export interface IotHubDeviceCreatedEventData extends DeviceLifeCycleEventProperties { -} - -/** - * Event data for Microsoft.Devices.DeviceDeleted event. - */ -export interface IotHubDeviceDeletedEventData extends DeviceLifeCycleEventProperties { -} - -/** - * Schema of the Data property of an EventGridEvent for a device connection state event - * (DeviceConnected, DeviceDisconnected). - */ -export interface DeviceConnectionStateEventProperties { - /** - * The unique identifier of the device. This case-sensitive string can be up to 128 characters - * long, and supports ASCII 7-bit alphanumeric characters plus the following special characters: - * - : . + % _ # * ? ! ( ) , = @ ; $ '. - */ - deviceId?: string; - /** - * The unique identifier of the module. This case-sensitive string can be up to 128 characters - * long, and supports ASCII 7-bit alphanumeric characters plus the following special characters: - * - : . + % _ # * ? ! ( ) , = @ ; $ '. - */ - moduleId?: string; - /** - * Name of the IoT Hub where the device was created or deleted. - */ - hubName?: string; - /** - * Information about the device connection state event. - */ - deviceConnectionStateEventInfo?: DeviceConnectionStateEventInfo; -} - -/** - * Event data for Microsoft.Devices.DeviceConnected event. - */ -export interface IotHubDeviceConnectedEventData extends DeviceConnectionStateEventProperties { -} - -/** - * Event data for Microsoft.Devices.DeviceDisconnected event. - */ -export interface IotHubDeviceDisconnectedEventData extends DeviceConnectionStateEventProperties { -} - -/** - * Schema of the Data property of an EventGridEvent for a device telemetry event (DeviceTelemetry). - */ -export interface DeviceTelemetryEventProperties { - /** - * The content of the message from the device. - */ - body?: any; - /** - * Application properties are user-defined strings that can be added to the message. These fields - * are optional. - */ - properties?: { [propertyName: string]: string }; - /** - * System properties help identify contents and source of the messages. - */ - systemProperties?: { [propertyName: string]: string }; -} - -/** - * Event data for Microsoft.Devices.DeviceTelemetry event. - */ -export interface IotHubDeviceTelemetryEventData extends DeviceTelemetryEventProperties { -} - -/** - * Metadata information for the properties JSON document. - */ -export interface DeviceTwinMetadata { - /** - * The ISO8601 timestamp of the last time the properties were updated. - */ - lastUpdated?: string; -} - -/** - * A portion of the properties that can be written only by the application back-end, and read by - * the device. - */ -export interface DeviceTwinProperties { - /** - * Metadata information for the properties JSON document. - */ - metadata?: DeviceTwinMetadata; - /** - * Version of device twin properties. - */ - version?: number; -} - -/** - * Properties JSON element. - */ -export interface DeviceTwinInfoProperties { - /** - * A portion of the properties that can be written only by the application back-end, and read by - * the device. - */ - desired?: DeviceTwinProperties; - /** - * A portion of the properties that can be written only by the device, and read by the - * application back-end. - */ - reported?: DeviceTwinProperties; -} - -/** - * The thumbprint is a unique value for the x509 certificate, commonly used to find a particular - * certificate in a certificate store. The thumbprint is dynamically generated using the SHA1 - * algorithm, and does not physically exist in the certificate. - */ -export interface DeviceTwinInfoX509Thumbprint { - /** - * Primary thumbprint for the x509 certificate. - */ - primaryThumbprint?: string; - /** - * Secondary thumbprint for the x509 certificate. - */ - secondaryThumbprint?: string; -} - -/** - * Information about the device twin, which is the cloud representation of application device - * metadata. - */ -export interface DeviceTwinInfo { - /** - * Authentication type used for this device: either SAS, SelfSigned, or CertificateAuthority. - */ - authenticationType?: string; - /** - * Count of cloud to device messages sent to this device. - */ - cloudToDeviceMessageCount?: number; - /** - * Whether the device is connected or disconnected. - */ - connectionState?: string; - /** - * The unique identifier of the device twin. - */ - deviceId?: string; - /** - * A piece of information that describes the content of the device twin. Each etag is guaranteed - * to be unique per device twin. - */ - etag?: string; - /** - * The ISO8601 timestamp of the last activity. - */ - lastActivityTime?: string; - /** - * Properties JSON element. - */ - properties?: DeviceTwinInfoProperties; - /** - * Whether the device twin is enabled or disabled. - */ - status?: string; - /** - * The ISO8601 timestamp of the last device twin status update. - */ - statusUpdateTime?: string; - /** - * An integer that is incremented by one each time the device twin is updated. - */ - version?: number; - /** - * The thumbprint is a unique value for the x509 certificate, commonly used to find a particular - * certificate in a certificate store. The thumbprint is dynamically generated using the SHA1 - * algorithm, and does not physically exist in the certificate. - */ - x509Thumbprint?: DeviceTwinInfoX509Thumbprint; -} - -/** - * Information about the device connection state event. - */ -export interface DeviceConnectionStateEventInfo { - /** - * Sequence number is string representation of a hexadecimal number. string compare can be used - * to identify the larger number because both in ASCII and HEX numbers come after alphabets. If - * you are converting the string to hex, then the number is a 256 bit number. - */ - sequenceNumber?: string; -} - -/** - * The content of the event request message. - */ -export interface ContainerRegistryEventData { - /** - * The event ID. - */ - id?: string; - /** - * The time at which the event occurred. - */ - timestamp?: Date; - /** - * The action that encompasses the provided event. - */ - action?: string; - /** - * The target of the event. - */ - target?: ContainerRegistryEventTarget; - /** - * The request that generated the event. - */ - request?: ContainerRegistryEventRequest; - /** - * The agent that initiated the event. For most situations, this could be from the authorization - * context of the request. - */ - actor?: ContainerRegistryEventActor; - /** - * The registry node that generated the event. Put differently, while the actor initiates the - * event, the source generates it. - */ - source?: ContainerRegistryEventSource; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.ContainerRegistry.ImagePushed - * event. - */ -export interface ContainerRegistryImagePushedEventData extends ContainerRegistryEventData { -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.ContainerRegistry.ImageDeleted - * event. - */ -export interface ContainerRegistryImageDeletedEventData extends ContainerRegistryEventData { -} - -/** - * The content of the event request message. - */ -export interface ContainerRegistryArtifactEventData { - /** - * The event ID. - */ - id?: string; - /** - * The time at which the event occurred. - */ - timestamp?: Date; - /** - * The action that encompasses the provided event. - */ - action?: string; - /** - * The target of the event. - */ - target?: ContainerRegistryArtifactEventTarget; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.ContainerRegistry.ChartPushed - * event. - */ -export interface ContainerRegistryChartPushedEventData extends ContainerRegistryArtifactEventData { -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.ContainerRegistry.ChartDeleted - * event. - */ -export interface ContainerRegistryChartDeletedEventData extends ContainerRegistryArtifactEventData { -} - -/** - * The target of the event. - */ -export interface ContainerRegistryEventTarget { - /** - * The MIME type of the referenced object. - */ - mediaType?: string; - /** - * The number of bytes of the content. Same as Length field. - */ - size?: number; - /** - * The digest of the content, as defined by the Registry V2 HTTP API Specification. - */ - digest?: string; - /** - * The number of bytes of the content. Same as Size field. - */ - length?: number; - /** - * The repository name. - */ - repository?: string; - /** - * The direct URL to the content. - */ - url?: string; - /** - * The tag name. - */ - tag?: string; -} - -/** - * The request that generated the event. - */ -export interface ContainerRegistryEventRequest { - /** - * The ID of the request that initiated the event. - */ - id?: string; - /** - * The IP or hostname and possibly port of the client connection that initiated the event. This - * is the RemoteAddr from the standard http request. - */ - addr?: string; - /** - * The externally accessible hostname of the registry instance, as specified by the http host - * header on incoming requests. - */ - host?: string; - /** - * The request method that generated the event. - */ - method?: string; - /** - * The user agent header of the request. - */ - useragent?: string; -} - -/** - * The agent that initiated the event. For most situations, this could be from the authorization - * context of the request. - */ -export interface ContainerRegistryEventActor { - /** - * The subject or username associated with the request context that generated the event. - */ - name?: string; -} - -/** - * The registry node that generated the event. Put differently, while the actor initiates the - * event, the source generates it. - */ -export interface ContainerRegistryEventSource { - /** - * The IP or hostname and the port of the registry node that generated the event. Generally, this - * will be resolved by os.Hostname() along with the running port. - */ - addr?: string; - /** - * The running instance of an application. Changes after each restart. - */ - instanceID?: string; -} - -/** - * The target of the event. - */ -export interface ContainerRegistryArtifactEventTarget { - /** - * The MIME type of the artifact. - */ - mediaType?: string; - /** - * The size in bytes of the artifact. - */ - size?: number; - /** - * The digest of the artifact. - */ - digest?: string; - /** - * The repository name of the artifact. - */ - repository?: string; - /** - * The tag of the artifact. - */ - tag?: string; - /** - * The name of the artifact. - */ - name?: string; - /** - * The version of the artifact. - */ - version?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a - * Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners event. - */ -export interface ServiceBusActiveMessagesAvailableWithNoListenersEventData { - /** - * The namespace name of the Microsoft.ServiceBus resource. - */ - namespaceName?: string; - /** - * The endpoint of the Microsoft.ServiceBus resource. - */ - requestUri?: string; - /** - * The entity type of the Microsoft.ServiceBus resource. Could be one of 'queue' or 'subscriber'. - */ - entityType?: string; - /** - * The name of the Microsoft.ServiceBus queue. If the entity type is of type 'subscriber', then - * this value will be null. - */ - queueName?: string; - /** - * The name of the Microsoft.ServiceBus topic. If the entity type is of type 'queue', then this - * value will be null. - */ - topicName?: string; - /** - * The name of the Microsoft.ServiceBus topic's subscription. If the entity type is of type - * 'queue', then this value will be null. - */ - subscriptionName?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a - * Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListenersEvent event. - */ -export interface ServiceBusDeadletterMessagesAvailableWithNoListenersEventData { - /** - * The namespace name of the Microsoft.ServiceBus resource. - */ - namespaceName?: string; - /** - * The endpoint of the Microsoft.ServiceBus resource. - */ - requestUri?: string; - /** - * The entity type of the Microsoft.ServiceBus resource. Could be one of 'queue' or 'subscriber'. - */ - entityType?: string; - /** - * The name of the Microsoft.ServiceBus queue. If the entity type is of type 'subscriber', then - * this value will be null. - */ - queueName?: string; - /** - * The name of the Microsoft.ServiceBus topic. If the entity type is of type 'queue', then this - * value will be null. - */ - topicName?: string; - /** - * The name of the Microsoft.ServiceBus topic's subscription. If the entity type is of type - * 'queue', then this value will be null. - */ - subscriptionName?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Media.JobStateChange event. - */ -export interface MediaJobStateChangeEventData { - /** - * The previous state of the Job. Possible values include: 'Canceled', 'Canceling', 'Error', - * 'Finished', 'Processing', 'Queued', 'Scheduled' - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly previousState?: MediaJobState; - /** - * The new state of the Job. Possible values include: 'Canceled', 'Canceling', 'Error', - * 'Finished', 'Processing', 'Queued', 'Scheduled' - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly state?: MediaJobState; - /** - * Gets the Job correlation data. - */ - correlationData?: { [propertyName: string]: string }; -} - -/** - * Details of JobOutput errors. - */ -export interface MediaJobErrorDetail { - /** - * Code describing the error detail. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly code?: string; - /** - * A human-readable representation of the error. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly message?: string; -} - -/** - * Details of JobOutput errors. - */ -export interface MediaJobError { - /** - * Error code describing the error. Possible values include: 'ServiceError', - * 'ServiceTransientError', 'DownloadNotAccessible', 'DownloadTransientError', - * 'UploadNotAccessible', 'UploadTransientError', 'ConfigurationUnsupported', 'ContentMalformed', - * 'ContentUnsupported' - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly code?: MediaJobErrorCode; - /** - * A human-readable language-dependent representation of the error. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly message?: string; - /** - * Helps with categorization of errors. Possible values include: 'Service', 'Download', 'Upload', - * 'Configuration', 'Content' - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly category?: MediaJobErrorCategory; - /** - * Indicates that it may be possible to retry the Job. If retry is unsuccessful, please contact - * Azure support via Azure Portal. Possible values include: 'DoNotRetry', 'MayRetry' - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly retry?: MediaJobRetry; - /** - * An array of details about specific errors that led to this reported error. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly details?: MediaJobErrorDetail[]; -} - -/** - * Contains the possible cases for MediaJobOutput. - */ -export type MediaJobOutputUnion = MediaJobOutput | MediaJobOutputAsset; - -/** - * The event data for a Job output. - */ -export interface MediaJobOutput { - /** - * Polymorphic Discriminator - */ - odatatype: "MediaJobOutput"; - /** - * Gets the Job output error. - */ - error?: MediaJobError; - /** - * Gets the Job output label. - */ - label?: string; - /** - * Gets the Job output progress. - */ - progress: number; - /** - * Gets the Job output state. Possible values include: 'Canceled', 'Canceling', 'Error', - * 'Finished', 'Processing', 'Queued', 'Scheduled' - */ - state: MediaJobState; -} - -/** - * The event data for a Job output asset. - */ -export interface MediaJobOutputAsset { - /** - * Polymorphic Discriminator - */ - odatatype: "#Microsoft.Media.JobOutputAsset"; - /** - * Gets the Job output error. - */ - error?: MediaJobError; - /** - * Gets the Job output label. - */ - label?: string; - /** - * Gets the Job output progress. - */ - progress: number; - /** - * Gets the Job output state. Possible values include: 'Canceled', 'Canceling', 'Error', - * 'Finished', 'Processing', 'Queued', 'Scheduled' - */ - state: MediaJobState; - /** - * Gets the Job output asset name. - */ - assetName?: string; -} - -/** - * Job Output Progress Event Data. - */ -export interface MediaJobOutputProgressEventData { - /** - * Gets the Job output label. - */ - label?: string; - /** - * Gets the Job output progress. - */ - progress?: number; - /** - * Gets the Job correlation data. - */ - jobCorrelationData?: { [propertyName: string]: string }; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Media.JobOutputStateChange - * event. - */ -export interface MediaJobOutputStateChangeEventData { - /** - * The previous state of the Job. Possible values include: 'Canceled', 'Canceling', 'Error', - * 'Finished', 'Processing', 'Queued', 'Scheduled' - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly previousState?: MediaJobState; - /** - * Gets the output. - */ - output?: MediaJobOutputUnion; - /** - * Gets the Job correlation data. - */ - jobCorrelationData?: { [propertyName: string]: string }; -} - -/** - * Job scheduled event data - */ -export interface MediaJobScheduledEventData extends MediaJobStateChangeEventData { -} - -/** - * Job processing event data - */ -export interface MediaJobProcessingEventData extends MediaJobStateChangeEventData { -} - -/** - * Job canceling event data - */ -export interface MediaJobCancelingEventData extends MediaJobStateChangeEventData { -} - -/** - * Job finished event data - */ -export interface MediaJobFinishedEventData extends MediaJobStateChangeEventData { - /** - * Gets the Job outputs. - */ - outputs?: MediaJobOutputUnion[]; -} - -/** - * Job canceled event data - */ -export interface MediaJobCanceledEventData extends MediaJobStateChangeEventData { - /** - * Gets the Job outputs. - */ - outputs?: MediaJobOutputUnion[]; -} - -/** - * Job error state event data - */ -export interface MediaJobErroredEventData extends MediaJobStateChangeEventData { - /** - * Gets the Job outputs. - */ - outputs?: MediaJobOutputUnion[]; -} - -/** - * Job output canceled event data - */ -export interface MediaJobOutputCanceledEventData extends MediaJobOutputStateChangeEventData { -} - -/** - * Job output canceling event data - */ -export interface MediaJobOutputCancelingEventData extends MediaJobOutputStateChangeEventData { -} - -/** - * Job output error event data - */ -export interface MediaJobOutputErroredEventData extends MediaJobOutputStateChangeEventData { -} - -/** - * Job output finished event data - */ -export interface MediaJobOutputFinishedEventData extends MediaJobOutputStateChangeEventData { -} - -/** - * Job output processing event data - */ -export interface MediaJobOutputProcessingEventData extends MediaJobOutputStateChangeEventData { -} - -/** - * Job output scheduled event data - */ -export interface MediaJobOutputScheduledEventData extends MediaJobOutputStateChangeEventData { -} - -/** - * Encoder connect event data. - */ -export interface MediaLiveEventEncoderConnectedEventData { - /** - * Gets the ingest URL provided by the live event. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly ingestUrl?: string; - /** - * Gets the stream Id. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly streamId?: string; - /** - * Gets the remote IP. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly encoderIp?: string; - /** - * Gets the remote port. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly encoderPort?: string; -} - -/** - * Encoder connection rejected event data. - */ -export interface MediaLiveEventConnectionRejectedEventData { - /** - * Gets the ingest URL provided by the live event. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly ingestUrl?: string; - /** - * Gets the stream Id. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly streamId?: string; - /** - * Gets the remote IP. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly encoderIp?: string; - /** - * Gets the remote port. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly encoderPort?: string; - /** - * Gets the result code. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly resultCode?: string; -} - -/** - * Encoder disconnected event data. - */ -export interface MediaLiveEventEncoderDisconnectedEventData { - /** - * Gets the ingest URL provided by the live event. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly ingestUrl?: string; - /** - * Gets the stream Id. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly streamId?: string; - /** - * Gets the remote IP. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly encoderIp?: string; - /** - * Gets the remote port. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly encoderPort?: string; - /** - * Gets the result code. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly resultCode?: string; -} - -/** - * Encoder connect event data. - */ -export interface MediaLiveEventIncomingStreamReceivedEventData { - /** - * Gets the ingest URL provided by the live event. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly ingestUrl?: string; - /** - * Gets the type of the track (Audio / Video). - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly trackType?: string; - /** - * Gets the track name. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly trackName?: string; - /** - * Gets the bitrate of the track. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly bitrate?: number; - /** - * Gets the remote IP. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly encoderIp?: string; - /** - * Gets the remote port. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly encoderPort?: string; - /** - * Gets the first timestamp of the data chunk received. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly timestamp?: string; - /** - * Gets the duration of the first data chunk. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly duration?: string; - /** - * Gets the timescale in which timestamp is represented. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly timescale?: string; -} - -/** - * Incoming streams out of sync event data. - */ -export interface MediaLiveEventIncomingStreamsOutOfSyncEventData { - /** - * Gets the minimum last timestamp received. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly minLastTimestamp?: string; - /** - * Gets the type of stream with minimum last timestamp. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly typeOfStreamWithMinLastTimestamp?: string; - /** - * Gets the maximum timestamp among all the tracks (audio or video). - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly maxLastTimestamp?: string; - /** - * Gets the type of stream with maximum last timestamp. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly typeOfStreamWithMaxLastTimestamp?: string; - /** - * Gets the timescale in which "MinLastTimestamp" is represented. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly timescaleOfMinLastTimestamp?: string; - /** - * Gets the timescale in which "MaxLastTimestamp" is represented. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly timescaleOfMaxLastTimestamp?: string; -} - -/** - * Incoming video stream out of synch event data. - */ -export interface MediaLiveEventIncomingVideoStreamsOutOfSyncEventData { - /** - * Gets the first timestamp received for one of the quality levels. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly firstTimestamp?: string; - /** - * Gets the duration of the data chunk with first timestamp. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly firstDuration?: string; - /** - * Gets the timestamp received for some other quality levels. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly secondTimestamp?: string; - /** - * Gets the duration of the data chunk with second timestamp. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly secondDuration?: string; - /** - * Gets the timescale in which both the timestamps and durations are represented. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly timescale?: string; -} - -/** - * Ingest fragment dropped event data. - */ -export interface MediaLiveEventIncomingDataChunkDroppedEventData { - /** - * Gets the timestamp of the data chunk dropped. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly timestamp?: string; - /** - * Gets the type of the track (Audio / Video). - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly trackType?: string; - /** - * Gets the bitrate of the track. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly bitrate?: number; - /** - * Gets the timescale of the Timestamp. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly timescale?: string; - /** - * Gets the result code for fragment drop operation. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly resultCode?: string; - /** - * Gets the name of the track for which fragment is dropped. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly trackName?: string; -} - -/** - * Ingest fragment dropped event data. - */ -export interface MediaLiveEventIngestHeartbeatEventData { - /** - * Gets the type of the track (Audio / Video). - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly trackType?: string; - /** - * Gets the track name. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly trackName?: string; - /** - * Gets the bitrate of the track. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly bitrate?: number; - /** - * Gets the incoming bitrate. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly incomingBitrate?: number; - /** - * Gets the last timestamp. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly lastTimestamp?: string; - /** - * Gets the timescale of the last timestamp. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly timescale?: string; - /** - * Gets the fragment Overlap count. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly overlapCount?: number; - /** - * Gets the fragment Discontinuity count. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly discontinuityCount?: number; - /** - * Gets Non increasing count. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly nonincreasingCount?: number; - /** - * Gets a value indicating whether unexpected bitrate is present or not. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly unexpectedBitrate?: boolean; - /** - * Gets the state of the live event. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly state?: string; - /** - * Gets a value indicating whether preview is healthy or not. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly healthy?: boolean; -} - -/** - * Ingest track discontinuity detected event data. - */ -export interface MediaLiveEventTrackDiscontinuityDetectedEventData { - /** - * Gets the type of the track (Audio / Video). - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly trackType?: string; - /** - * Gets the track name. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly trackName?: string; - /** - * Gets the bitrate. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly bitrate?: number; - /** - * Gets the timestamp of the previous fragment. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly previousTimestamp?: string; - /** - * Gets the timestamp of the current fragment. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly newTimestamp?: string; - /** - * Gets the timescale in which both timestamps and discontinuity gap are represented. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly timescale?: string; - /** - * Gets the discontinuity gap between PreviousTimestamp and NewTimestamp. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly discontinuityGap?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a Geofence event (GeofenceEntered, - * GeofenceExited, GeofenceResult). - */ -export interface MapsGeofenceEventProperties { - /** - * Lists of the geometry ID of the geofence which is expired relative to the user time in the - * request. - */ - expiredGeofenceGeometryId?: string[]; - /** - * Lists the fence geometries that either fully contain the coordinate position or have an - * overlap with the searchBuffer around the fence. - */ - geometries?: MapsGeofenceGeometry[]; - /** - * Lists of the geometry ID of the geofence which is in invalid period relative to the user time - * in the request. - */ - invalidPeriodGeofenceGeometryId?: string[]; - /** - * True if at least one event is published to the Azure Maps event subscriber, false if no event - * is published to the Azure Maps event subscriber. - */ - isEventPublished?: boolean; -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Maps.GeofenceEntered event. - */ -export interface MapsGeofenceEnteredEventData extends MapsGeofenceEventProperties { -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Maps.GeofenceExited event. - */ -export interface MapsGeofenceExitedEventData extends MapsGeofenceEventProperties { -} - -/** - * Schema of the Data property of an EventGridEvent for a Microsoft.Maps.GeofenceResult event. - */ -export interface MapsGeofenceResultEventData extends MapsGeofenceEventProperties { -} - -/** - * The geofence geometry. - */ -export interface MapsGeofenceGeometry { - /** - * ID of the device. - */ - deviceId?: string; - /** - * Distance from the coordinate to the closest border of the geofence. Positive means the - * coordinate is outside of the geofence. If the coordinate is outside of the geofence, but more - * than the value of searchBuffer away from the closest geofence border, then the value is 999. - * Negative means the coordinate is inside of the geofence. If the coordinate is inside the - * polygon, but more than the value of searchBuffer away from the closest geofencing border,then - * the value is -999. A value of 999 means that there is great confidence the coordinate is well - * outside the geofence. A value of -999 means that there is great confidence the coordinate is - * well within the geofence. - */ - distance?: number; - /** - * The unique ID for the geofence geometry. - */ - geometryId?: string; - /** - * Latitude of the nearest point of the geometry. - */ - nearestLat?: number; - /** - * Longitude of the nearest point of the geometry. - */ - nearestLon?: number; - /** - * The unique id returned from user upload service when uploading a geofence. Will not be - * included in geofencing post API. - */ - udId?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for an - * Microsoft.AppConfiguration.KeyValueModified event. - */ -export interface AppConfigurationKeyValueModifiedEventData { - /** - * The key used to identify the key-value that was modified. - */ - key?: string; - /** - * The label, if any, used to identify the key-value that was modified. - */ - label?: string; - /** - * The etag representing the new state of the key-value. - */ - etag?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for an - * Microsoft.AppConfiguration.KeyValueDeleted event. - */ -export interface AppConfigurationKeyValueDeletedEventData { - /** - * The key used to identify the key-value that was deleted. - */ - key?: string; - /** - * The label, if any, used to identify the key-value that was deleted. - */ - label?: string; - /** - * The etag representing the key-value that was deleted. - */ - etag?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a - * Microsoft.SignalRService.ClientConnectionConnected event. - */ -export interface SignalRServiceClientConnectionConnectedEventData { - /** - * The time at which the event occurred. - */ - timestamp?: Date; - /** - * The hub of connected client connection. - */ - hubName?: string; - /** - * The connection Id of connected client connection. - */ - connectionId?: string; - /** - * The user Id of connected client connection. - */ - userId?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for a - * Microsoft.SignalRService.ClientConnectionDisconnected event. - */ -export interface SignalRServiceClientConnectionDisconnectedEventData { - /** - * The time at which the event occurred. - */ - timestamp?: Date; - /** - * The hub of connected client connection. - */ - hubName?: string; - /** - * The connection Id of connected client connection. - */ - connectionId?: string; - /** - * The user Id of connected client connection. - */ - userId?: string; - /** - * The message of error that cause the client connection disconnected. - */ - errorMessage?: string; -} - -/** - * Schema of the Data property of an EventGridEvent for an CertificateNewVersionCreated event. - */ -export interface KeyVaultCertificateNewVersionCreatedEventData { - /** - * The id of the object that triggered this event. - */ - id?: string; - /** - * Key vault name of the object that triggered this event. - */ - vaultName?: string; - /** - * The type of the object that triggered this event - */ - objectType?: string; - /** - * The name of the object that triggered this event - */ - objectName?: string; - /** - * The version of the object that triggered this event - */ - version?: string; - /** - * Not before date of the object that triggered this event - */ - nbf?: number; - /** - * The expiration date of the object that triggered this event - */ - exp?: number; -} - -/** - * Schema of the Data property of an EventGridEvent for an CertificateNearExpiry event. - */ -export interface KeyVaultCertificateNearExpiryEventData { - /** - * The id of the object that triggered this event. - */ - id?: string; - /** - * Key vault name of the object that triggered this event. - */ - vaultName?: string; - /** - * The type of the object that triggered this event - */ - objectType?: string; - /** - * The name of the object that triggered this event - */ - objectName?: string; - /** - * The version of the object that triggered this event - */ - version?: string; - /** - * Not before date of the object that triggered this event - */ - nbf?: number; - /** - * The expiration date of the object that triggered this event - */ - exp?: number; -} - -/** - * Schema of the Data property of an EventGridEvent for an CertificateExpired event. - */ -export interface KeyVaultCertificateExpiredEventData { - /** - * The id of the object that triggered this event. - */ - id?: string; - /** - * Key vault name of the object that triggered this event. - */ - vaultName?: string; - /** - * The type of the object that triggered this event - */ - objectType?: string; - /** - * The name of the object that triggered this event - */ - objectName?: string; - /** - * The version of the object that triggered this event - */ - version?: string; - /** - * Not before date of the object that triggered this event - */ - nbf?: number; - /** - * The expiration date of the object that triggered this event - */ - exp?: number; -} - -/** - * Schema of the Data property of an EventGridEvent for an KeyNewVersionCreated event. - */ -export interface KeyVaultKeyNewVersionCreatedEventData { - /** - * The id of the object that triggered this event. - */ - id?: string; - /** - * Key vault name of the object that triggered this event. - */ - vaultName?: string; - /** - * The type of the object that triggered this event - */ - objectType?: string; - /** - * The name of the object that triggered this event - */ - objectName?: string; - /** - * The version of the object that triggered this event - */ - version?: string; - /** - * Not before date of the object that triggered this event - */ - nbf?: number; - /** - * The expiration date of the object that triggered this event - */ - exp?: number; -} - -/** - * Schema of the Data property of an EventGridEvent for an KeyNearExpiry event. - */ -export interface KeyVaultKeyNearExpiryEventData { - /** - * The id of the object that triggered this event. - */ - id?: string; - /** - * Key vault name of the object that triggered this event. - */ - vaultName?: string; - /** - * The type of the object that triggered this event - */ - objectType?: string; - /** - * The name of the object that triggered this event - */ - objectName?: string; - /** - * The version of the object that triggered this event - */ - version?: string; - /** - * Not before date of the object that triggered this event - */ - nbf?: number; - /** - * The expiration date of the object that triggered this event - */ - exp?: number; -} - -/** - * Schema of the Data property of an EventGridEvent for an KeyExpired event. - */ -export interface KeyVaultKeyExpiredEventData { - /** - * The id of the object that triggered this event. - */ - id?: string; - /** - * Key vault name of the object that triggered this event. - */ - vaultName?: string; - /** - * The type of the object that triggered this event - */ - objectType?: string; - /** - * The name of the object that triggered this event - */ - objectName?: string; - /** - * The version of the object that triggered this event - */ - version?: string; - /** - * Not before date of the object that triggered this event - */ - nbf?: number; - /** - * The expiration date of the object that triggered this event - */ - exp?: number; -} - -/** - * Schema of the Data property of an EventGridEvent for an SecretNewVersionCreated event. - */ -export interface KeyVaultSecretNewVersionCreatedEventData { - /** - * The id of the object that triggered this event. - */ - id?: string; - /** - * Key vault name of the object that triggered this event. - */ - vaultName?: string; - /** - * The type of the object that triggered this event - */ - objectType?: string; - /** - * The name of the object that triggered this event - */ - objectName?: string; - /** - * The version of the object that triggered this event - */ - version?: string; - /** - * Not before date of the object that triggered this event - */ - nbf?: number; - /** - * The expiration date of the object that triggered this event - */ - exp?: number; -} - -/** - * Schema of the Data property of an EventGridEvent for an SecretNearExpiry event. - */ -export interface KeyVaultSecretNearExpiryEventData { - /** - * The id of the object that triggered this event. - */ - id?: string; - /** - * Key vault name of the object that triggered this event. - */ - vaultName?: string; - /** - * The type of the object that triggered this event - */ - objectType?: string; - /** - * The name of the object that triggered this event - */ - objectName?: string; - /** - * The version of the object that triggered this event - */ - version?: string; - /** - * Not before date of the object that triggered this event - */ - nbf?: number; - /** - * The expiration date of the object that triggered this event - */ - exp?: number; -} - -/** - * Schema of the Data property of an EventGridEvent for an SecretExpired event. - */ -export interface KeyVaultSecretExpiredEventData { - /** - * The id of the object that triggered this event. - */ - id?: string; - /** - * Key vault name of the object that triggered this event. - */ - vaultName?: string; - /** - * The type of the object that triggered this event - */ - objectType?: string; - /** - * The name of the object that triggered this event - */ - objectName?: string; - /** - * The version of the object that triggered this event - */ - version?: string; - /** - * Not before date of the object that triggered this event - */ - nbf?: number; - /** - * The expiration date of the object that triggered this event - */ - exp?: number; -} - -/** - * Schema of the Data property of an EventGridEvent for an - * Microsoft.MachineLearningServices.ModelRegistered event. - */ -export interface MachineLearningServicesModelRegisteredEventData { - /** - * The name of the model that was registered. - */ - modelName?: string; - /** - * The version of the model that was registered. - */ - modelVersion?: number; - /** - * The tags of the model that was registered. - */ - modelTags?: any; - /** - * The properties of the model that was registered. - */ - modelProperties?: any; -} - -/** - * Schema of the Data property of an EventGridEvent for an - * Microsoft.MachineLearningServices.ModelDeployed event. - */ -export interface MachineLearningServicesModelDeployedEventData { - /** - * The name of the deployed service. - */ - serviceName?: string; - /** - * The compute type (e.g. ACI, AKS) of the deployed service. - */ - serviceComputeType?: string; - /** - * A common separated list of model IDs. The IDs of the models deployed in the service. - */ - modelIds?: string; - /** - * The tags of the deployed service. - */ - serviceTags?: any; - /** - * The properties of the deployed service. - */ - serviceProperties?: any; -} - -/** - * Schema of the Data property of an EventGridEvent for an - * Microsoft.MachineLearningServices.RunCompleted event. - */ -export interface MachineLearningServicesRunCompletedEventData { - /** - * The ID of the experiment that the run belongs to. - */ - experimentId?: string; - /** - * The name of the experiment that the run belongs to. - */ - experimentName?: string; - /** - * The ID of the Run that was completed. - */ - runId?: string; - /** - * The Run Type of the completed Run. - */ - runType?: string; - /** - * The tags of the completed Run. - */ - runTags?: any; - /** - * The properties of the completed Run. - */ - runProperties?: any; -} - -/** - * Schema of the Data property of an EventGridEvent for an - * Microsoft.MachineLearningServices.DatasetDriftDetected event. - */ -export interface MachineLearningServicesDatasetDriftDetectedEventData { - /** - * The ID of the data drift monitor that triggered the event. - */ - dataDriftId?: string; - /** - * The name of the data drift monitor that triggered the event. - */ - dataDriftName?: string; - /** - * The ID of the Run that detected data drift. - */ - runId?: string; - /** - * The ID of the base Dataset used to detect drift. - */ - baseDatasetId?: string; - /** - * The ID of the target Dataset used to detect drift. - */ - targetDatasetId?: string; - /** - * The coefficient result that triggered the event. - */ - driftCoefficient?: number; - /** - * The start time of the target dataset time series that resulted in drift detection. - */ - startTime?: Date; - /** - * The end time of the target dataset time series that resulted in drift detection. - */ - endTime?: Date; -} - -/** - * Defines values for MediaJobState. - * Possible values include: 'Canceled', 'Canceling', 'Error', 'Finished', 'Processing', 'Queued', - * 'Scheduled' - * @readonly - * @enum {string} - */ -export type MediaJobState = 'Canceled' | 'Canceling' | 'Error' | 'Finished' | 'Processing' | 'Queued' | 'Scheduled'; - -/** - * Defines values for MediaJobErrorCode. - * Possible values include: 'ServiceError', 'ServiceTransientError', 'DownloadNotAccessible', - * 'DownloadTransientError', 'UploadNotAccessible', 'UploadTransientError', - * 'ConfigurationUnsupported', 'ContentMalformed', 'ContentUnsupported' - * @readonly - * @enum {string} - */ -export type MediaJobErrorCode = 'ServiceError' | 'ServiceTransientError' | 'DownloadNotAccessible' | 'DownloadTransientError' | 'UploadNotAccessible' | 'UploadTransientError' | 'ConfigurationUnsupported' | 'ContentMalformed' | 'ContentUnsupported'; - -/** - * Defines values for MediaJobErrorCategory. - * Possible values include: 'Service', 'Download', 'Upload', 'Configuration', 'Content' - * @readonly - * @enum {string} - */ -export type MediaJobErrorCategory = 'Service' | 'Download' | 'Upload' | 'Configuration' | 'Content'; - -/** - * Defines values for MediaJobRetry. - * Possible values include: 'DoNotRetry', 'MayRetry' - * @readonly - * @enum {string} - */ -export type MediaJobRetry = 'DoNotRetry' | 'MayRetry'; diff --git a/sdk/eventgrid/eventgrid/src/models/mappers.ts b/sdk/eventgrid/eventgrid/src/models/mappers.ts deleted file mode 100644 index ce98ef624266..000000000000 --- a/sdk/eventgrid/eventgrid/src/models/mappers.ts +++ /dev/null @@ -1,3898 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { CloudErrorMapper, BaseResourceMapper } from "@azure/ms-rest-azure-js"; -import * as msRest from "@azure/ms-rest-js"; - -export const CloudError = CloudErrorMapper; -export const BaseResource = BaseResourceMapper; - -export const StorageBlobCreatedEventData: msRest.CompositeMapper = { - serializedName: "StorageBlobCreatedEventData", - type: { - name: "Composite", - className: "StorageBlobCreatedEventData", - modelProperties: { - api: { - serializedName: "api", - type: { - name: "String" - } - }, - clientRequestId: { - serializedName: "clientRequestId", - type: { - name: "String" - } - }, - requestId: { - serializedName: "requestId", - type: { - name: "String" - } - }, - eTag: { - serializedName: "eTag", - type: { - name: "String" - } - }, - contentType: { - serializedName: "contentType", - type: { - name: "String" - } - }, - contentLength: { - serializedName: "contentLength", - type: { - name: "Number" - } - }, - contentOffset: { - serializedName: "contentOffset", - type: { - name: "Number" - } - }, - blobType: { - serializedName: "blobType", - type: { - name: "String" - } - }, - url: { - serializedName: "url", - type: { - name: "String" - } - }, - sequencer: { - serializedName: "sequencer", - type: { - name: "String" - } - }, - identity: { - serializedName: "identity", - type: { - name: "String" - } - }, - storageDiagnostics: { - serializedName: "storageDiagnostics", - type: { - name: "Object" - } - } - } - } -}; - -export const StorageBlobDeletedEventData: msRest.CompositeMapper = { - serializedName: "StorageBlobDeletedEventData", - type: { - name: "Composite", - className: "StorageBlobDeletedEventData", - modelProperties: { - api: { - serializedName: "api", - type: { - name: "String" - } - }, - clientRequestId: { - serializedName: "clientRequestId", - type: { - name: "String" - } - }, - requestId: { - serializedName: "requestId", - type: { - name: "String" - } - }, - contentType: { - serializedName: "contentType", - type: { - name: "String" - } - }, - blobType: { - serializedName: "blobType", - type: { - name: "String" - } - }, - url: { - serializedName: "url", - type: { - name: "String" - } - }, - sequencer: { - serializedName: "sequencer", - type: { - name: "String" - } - }, - identity: { - serializedName: "identity", - type: { - name: "String" - } - }, - storageDiagnostics: { - serializedName: "storageDiagnostics", - type: { - name: "Object" - } - } - } - } -}; - -export const StorageDirectoryCreatedEventData: msRest.CompositeMapper = { - serializedName: "StorageDirectoryCreatedEventData", - type: { - name: "Composite", - className: "StorageDirectoryCreatedEventData", - modelProperties: { - api: { - serializedName: "api", - type: { - name: "String" - } - }, - clientRequestId: { - serializedName: "clientRequestId", - type: { - name: "String" - } - }, - requestId: { - serializedName: "requestId", - type: { - name: "String" - } - }, - eTag: { - serializedName: "eTag", - type: { - name: "String" - } - }, - url: { - serializedName: "url", - type: { - name: "String" - } - }, - sequencer: { - serializedName: "sequencer", - type: { - name: "String" - } - }, - identity: { - serializedName: "identity", - type: { - name: "String" - } - }, - storageDiagnostics: { - serializedName: "storageDiagnostics", - type: { - name: "Object" - } - } - } - } -}; - -export const StorageDirectoryDeletedEventData: msRest.CompositeMapper = { - serializedName: "StorageDirectoryDeletedEventData", - type: { - name: "Composite", - className: "StorageDirectoryDeletedEventData", - modelProperties: { - api: { - serializedName: "api", - type: { - name: "String" - } - }, - clientRequestId: { - serializedName: "clientRequestId", - type: { - name: "String" - } - }, - requestId: { - serializedName: "requestId", - type: { - name: "String" - } - }, - url: { - serializedName: "url", - type: { - name: "String" - } - }, - recursive: { - serializedName: "recursive", - type: { - name: "Boolean" - } - }, - sequencer: { - serializedName: "sequencer", - type: { - name: "String" - } - }, - identity: { - serializedName: "identity", - type: { - name: "String" - } - }, - storageDiagnostics: { - serializedName: "storageDiagnostics", - type: { - name: "Object" - } - } - } - } -}; - -export const StorageBlobRenamedEventData: msRest.CompositeMapper = { - serializedName: "StorageBlobRenamedEventData", - type: { - name: "Composite", - className: "StorageBlobRenamedEventData", - modelProperties: { - api: { - serializedName: "api", - type: { - name: "String" - } - }, - clientRequestId: { - serializedName: "clientRequestId", - type: { - name: "String" - } - }, - requestId: { - serializedName: "requestId", - type: { - name: "String" - } - }, - sourceUrl: { - serializedName: "sourceUrl", - type: { - name: "String" - } - }, - destinationUrl: { - serializedName: "destinationUrl", - type: { - name: "String" - } - }, - sequencer: { - serializedName: "sequencer", - type: { - name: "String" - } - }, - identity: { - serializedName: "identity", - type: { - name: "String" - } - }, - storageDiagnostics: { - serializedName: "storageDiagnostics", - type: { - name: "Object" - } - } - } - } -}; - -export const StorageDirectoryRenamedEventData: msRest.CompositeMapper = { - serializedName: "StorageDirectoryRenamedEventData", - type: { - name: "Composite", - className: "StorageDirectoryRenamedEventData", - modelProperties: { - api: { - serializedName: "api", - type: { - name: "String" - } - }, - clientRequestId: { - serializedName: "clientRequestId", - type: { - name: "String" - } - }, - requestId: { - serializedName: "requestId", - type: { - name: "String" - } - }, - sourceUrl: { - serializedName: "sourceUrl", - type: { - name: "String" - } - }, - destinationUrl: { - serializedName: "destinationUrl", - type: { - name: "String" - } - }, - sequencer: { - serializedName: "sequencer", - type: { - name: "String" - } - }, - identity: { - serializedName: "identity", - type: { - name: "String" - } - }, - storageDiagnostics: { - serializedName: "storageDiagnostics", - type: { - name: "Object" - } - } - } - } -}; - -export const EventHubCaptureFileCreatedEventData: msRest.CompositeMapper = { - serializedName: "EventHubCaptureFileCreatedEventData", - type: { - name: "Composite", - className: "EventHubCaptureFileCreatedEventData", - modelProperties: { - fileurl: { - serializedName: "fileurl", - type: { - name: "String" - } - }, - fileType: { - serializedName: "fileType", - type: { - name: "String" - } - }, - partitionId: { - serializedName: "partitionId", - type: { - name: "String" - } - }, - sizeInBytes: { - serializedName: "sizeInBytes", - type: { - name: "Number" - } - }, - eventCount: { - serializedName: "eventCount", - type: { - name: "Number" - } - }, - firstSequenceNumber: { - serializedName: "firstSequenceNumber", - type: { - name: "Number" - } - }, - lastSequenceNumber: { - serializedName: "lastSequenceNumber", - type: { - name: "Number" - } - }, - firstEnqueueTime: { - serializedName: "firstEnqueueTime", - type: { - name: "DateTime" - } - }, - lastEnqueueTime: { - serializedName: "lastEnqueueTime", - type: { - name: "DateTime" - } - } - } - } -}; - -export const ResourceWriteSuccessData: msRest.CompositeMapper = { - serializedName: "ResourceWriteSuccessData", - type: { - name: "Composite", - className: "ResourceWriteSuccessData", - modelProperties: { - tenantId: { - serializedName: "tenantId", - type: { - name: "String" - } - }, - subscriptionId: { - serializedName: "subscriptionId", - type: { - name: "String" - } - }, - resourceGroup: { - serializedName: "resourceGroup", - type: { - name: "String" - } - }, - resourceProvider: { - serializedName: "resourceProvider", - type: { - name: "String" - } - }, - resourceUri: { - serializedName: "resourceUri", - type: { - name: "String" - } - }, - operationName: { - serializedName: "operationName", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - authorization: { - serializedName: "authorization", - type: { - name: "String" - } - }, - claims: { - serializedName: "claims", - type: { - name: "String" - } - }, - correlationId: { - serializedName: "correlationId", - type: { - name: "String" - } - }, - httpRequest: { - serializedName: "httpRequest", - type: { - name: "String" - } - } - } - } -}; - -export const ResourceWriteFailureData: msRest.CompositeMapper = { - serializedName: "ResourceWriteFailureData", - type: { - name: "Composite", - className: "ResourceWriteFailureData", - modelProperties: { - tenantId: { - serializedName: "tenantId", - type: { - name: "String" - } - }, - subscriptionId: { - serializedName: "subscriptionId", - type: { - name: "String" - } - }, - resourceGroup: { - serializedName: "resourceGroup", - type: { - name: "String" - } - }, - resourceProvider: { - serializedName: "resourceProvider", - type: { - name: "String" - } - }, - resourceUri: { - serializedName: "resourceUri", - type: { - name: "String" - } - }, - operationName: { - serializedName: "operationName", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - authorization: { - serializedName: "authorization", - type: { - name: "String" - } - }, - claims: { - serializedName: "claims", - type: { - name: "String" - } - }, - correlationId: { - serializedName: "correlationId", - type: { - name: "String" - } - }, - httpRequest: { - serializedName: "httpRequest", - type: { - name: "String" - } - } - } - } -}; - -export const ResourceWriteCancelData: msRest.CompositeMapper = { - serializedName: "ResourceWriteCancelData", - type: { - name: "Composite", - className: "ResourceWriteCancelData", - modelProperties: { - tenantId: { - serializedName: "tenantId", - type: { - name: "String" - } - }, - subscriptionId: { - serializedName: "subscriptionId", - type: { - name: "String" - } - }, - resourceGroup: { - serializedName: "resourceGroup", - type: { - name: "String" - } - }, - resourceProvider: { - serializedName: "resourceProvider", - type: { - name: "String" - } - }, - resourceUri: { - serializedName: "resourceUri", - type: { - name: "String" - } - }, - operationName: { - serializedName: "operationName", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - authorization: { - serializedName: "authorization", - type: { - name: "String" - } - }, - claims: { - serializedName: "claims", - type: { - name: "String" - } - }, - correlationId: { - serializedName: "correlationId", - type: { - name: "String" - } - }, - httpRequest: { - serializedName: "httpRequest", - type: { - name: "String" - } - } - } - } -}; - -export const ResourceDeleteSuccessData: msRest.CompositeMapper = { - serializedName: "ResourceDeleteSuccessData", - type: { - name: "Composite", - className: "ResourceDeleteSuccessData", - modelProperties: { - tenantId: { - serializedName: "tenantId", - type: { - name: "String" - } - }, - subscriptionId: { - serializedName: "subscriptionId", - type: { - name: "String" - } - }, - resourceGroup: { - serializedName: "resourceGroup", - type: { - name: "String" - } - }, - resourceProvider: { - serializedName: "resourceProvider", - type: { - name: "String" - } - }, - resourceUri: { - serializedName: "resourceUri", - type: { - name: "String" - } - }, - operationName: { - serializedName: "operationName", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - authorization: { - serializedName: "authorization", - type: { - name: "String" - } - }, - claims: { - serializedName: "claims", - type: { - name: "String" - } - }, - correlationId: { - serializedName: "correlationId", - type: { - name: "String" - } - }, - httpRequest: { - serializedName: "httpRequest", - type: { - name: "String" - } - } - } - } -}; - -export const ResourceDeleteFailureData: msRest.CompositeMapper = { - serializedName: "ResourceDeleteFailureData", - type: { - name: "Composite", - className: "ResourceDeleteFailureData", - modelProperties: { - tenantId: { - serializedName: "tenantId", - type: { - name: "String" - } - }, - subscriptionId: { - serializedName: "subscriptionId", - type: { - name: "String" - } - }, - resourceGroup: { - serializedName: "resourceGroup", - type: { - name: "String" - } - }, - resourceProvider: { - serializedName: "resourceProvider", - type: { - name: "String" - } - }, - resourceUri: { - serializedName: "resourceUri", - type: { - name: "String" - } - }, - operationName: { - serializedName: "operationName", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - authorization: { - serializedName: "authorization", - type: { - name: "String" - } - }, - claims: { - serializedName: "claims", - type: { - name: "String" - } - }, - correlationId: { - serializedName: "correlationId", - type: { - name: "String" - } - }, - httpRequest: { - serializedName: "httpRequest", - type: { - name: "String" - } - } - } - } -}; - -export const ResourceDeleteCancelData: msRest.CompositeMapper = { - serializedName: "ResourceDeleteCancelData", - type: { - name: "Composite", - className: "ResourceDeleteCancelData", - modelProperties: { - tenantId: { - serializedName: "tenantId", - type: { - name: "String" - } - }, - subscriptionId: { - serializedName: "subscriptionId", - type: { - name: "String" - } - }, - resourceGroup: { - serializedName: "resourceGroup", - type: { - name: "String" - } - }, - resourceProvider: { - serializedName: "resourceProvider", - type: { - name: "String" - } - }, - resourceUri: { - serializedName: "resourceUri", - type: { - name: "String" - } - }, - operationName: { - serializedName: "operationName", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - authorization: { - serializedName: "authorization", - type: { - name: "String" - } - }, - claims: { - serializedName: "claims", - type: { - name: "String" - } - }, - correlationId: { - serializedName: "correlationId", - type: { - name: "String" - } - }, - httpRequest: { - serializedName: "httpRequest", - type: { - name: "String" - } - } - } - } -}; - -export const ResourceActionSuccessData: msRest.CompositeMapper = { - serializedName: "ResourceActionSuccessData", - type: { - name: "Composite", - className: "ResourceActionSuccessData", - modelProperties: { - tenantId: { - serializedName: "tenantId", - type: { - name: "String" - } - }, - subscriptionId: { - serializedName: "subscriptionId", - type: { - name: "String" - } - }, - resourceGroup: { - serializedName: "resourceGroup", - type: { - name: "String" - } - }, - resourceProvider: { - serializedName: "resourceProvider", - type: { - name: "String" - } - }, - resourceUri: { - serializedName: "resourceUri", - type: { - name: "String" - } - }, - operationName: { - serializedName: "operationName", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - authorization: { - serializedName: "authorization", - type: { - name: "String" - } - }, - claims: { - serializedName: "claims", - type: { - name: "String" - } - }, - correlationId: { - serializedName: "correlationId", - type: { - name: "String" - } - }, - httpRequest: { - serializedName: "httpRequest", - type: { - name: "String" - } - } - } - } -}; - -export const ResourceActionFailureData: msRest.CompositeMapper = { - serializedName: "ResourceActionFailureData", - type: { - name: "Composite", - className: "ResourceActionFailureData", - modelProperties: { - tenantId: { - serializedName: "tenantId", - type: { - name: "String" - } - }, - subscriptionId: { - serializedName: "subscriptionId", - type: { - name: "String" - } - }, - resourceGroup: { - serializedName: "resourceGroup", - type: { - name: "String" - } - }, - resourceProvider: { - serializedName: "resourceProvider", - type: { - name: "String" - } - }, - resourceUri: { - serializedName: "resourceUri", - type: { - name: "String" - } - }, - operationName: { - serializedName: "operationName", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - authorization: { - serializedName: "authorization", - type: { - name: "String" - } - }, - claims: { - serializedName: "claims", - type: { - name: "String" - } - }, - correlationId: { - serializedName: "correlationId", - type: { - name: "String" - } - }, - httpRequest: { - serializedName: "httpRequest", - type: { - name: "String" - } - } - } - } -}; - -export const ResourceActionCancelData: msRest.CompositeMapper = { - serializedName: "ResourceActionCancelData", - type: { - name: "Composite", - className: "ResourceActionCancelData", - modelProperties: { - tenantId: { - serializedName: "tenantId", - type: { - name: "String" - } - }, - subscriptionId: { - serializedName: "subscriptionId", - type: { - name: "String" - } - }, - resourceGroup: { - serializedName: "resourceGroup", - type: { - name: "String" - } - }, - resourceProvider: { - serializedName: "resourceProvider", - type: { - name: "String" - } - }, - resourceUri: { - serializedName: "resourceUri", - type: { - name: "String" - } - }, - operationName: { - serializedName: "operationName", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - authorization: { - serializedName: "authorization", - type: { - name: "String" - } - }, - claims: { - serializedName: "claims", - type: { - name: "String" - } - }, - correlationId: { - serializedName: "correlationId", - type: { - name: "String" - } - }, - httpRequest: { - serializedName: "httpRequest", - type: { - name: "String" - } - } - } - } -}; - -export const EventGridEvent: msRest.CompositeMapper = { - serializedName: "EventGridEvent", - type: { - name: "Composite", - className: "EventGridEvent", - modelProperties: { - id: { - required: true, - serializedName: "id", - type: { - name: "String" - } - }, - topic: { - serializedName: "topic", - type: { - name: "String" - } - }, - subject: { - required: true, - serializedName: "subject", - type: { - name: "String" - } - }, - data: { - required: true, - serializedName: "data", - type: { - name: "Object" - } - }, - eventType: { - required: true, - serializedName: "eventType", - type: { - name: "String" - } - }, - eventTime: { - required: true, - serializedName: "eventTime", - type: { - name: "DateTime" - } - }, - metadataVersion: { - readOnly: true, - serializedName: "metadataVersion", - type: { - name: "String" - } - }, - dataVersion: { - required: true, - serializedName: "dataVersion", - type: { - name: "String" - } - } - } - } -}; - -export const SubscriptionValidationEventData: msRest.CompositeMapper = { - serializedName: "SubscriptionValidationEventData", - type: { - name: "Composite", - className: "SubscriptionValidationEventData", - modelProperties: { - validationCode: { - readOnly: true, - serializedName: "validationCode", - type: { - name: "String" - } - }, - validationUrl: { - readOnly: true, - serializedName: "validationUrl", - type: { - name: "String" - } - } - } - } -}; - -export const SubscriptionValidationResponse: msRest.CompositeMapper = { - serializedName: "SubscriptionValidationResponse", - type: { - name: "Composite", - className: "SubscriptionValidationResponse", - modelProperties: { - validationResponse: { - serializedName: "validationResponse", - type: { - name: "String" - } - } - } - } -}; - -export const SubscriptionDeletedEventData: msRest.CompositeMapper = { - serializedName: "SubscriptionDeletedEventData", - type: { - name: "Composite", - className: "SubscriptionDeletedEventData", - modelProperties: { - eventSubscriptionId: { - readOnly: true, - serializedName: "eventSubscriptionId", - type: { - name: "String" - } - } - } - } -}; - -export const DeviceLifeCycleEventProperties: msRest.CompositeMapper = { - serializedName: "DeviceLifeCycleEventProperties", - type: { - name: "Composite", - className: "DeviceLifeCycleEventProperties", - modelProperties: { - deviceId: { - serializedName: "deviceId", - type: { - name: "String" - } - }, - hubName: { - serializedName: "hubName", - type: { - name: "String" - } - }, - twin: { - serializedName: "twin", - type: { - name: "Composite", - className: "DeviceTwinInfo" - } - } - } - } -}; - -export const IotHubDeviceCreatedEventData: msRest.CompositeMapper = { - serializedName: "IotHubDeviceCreatedEventData", - type: { - name: "Composite", - className: "IotHubDeviceCreatedEventData", - modelProperties: { - ...DeviceLifeCycleEventProperties.type.modelProperties - } - } -}; - -export const IotHubDeviceDeletedEventData: msRest.CompositeMapper = { - serializedName: "IotHubDeviceDeletedEventData", - type: { - name: "Composite", - className: "IotHubDeviceDeletedEventData", - modelProperties: { - ...DeviceLifeCycleEventProperties.type.modelProperties - } - } -}; - -export const DeviceConnectionStateEventProperties: msRest.CompositeMapper = { - serializedName: "DeviceConnectionStateEventProperties", - type: { - name: "Composite", - className: "DeviceConnectionStateEventProperties", - modelProperties: { - deviceId: { - serializedName: "deviceId", - type: { - name: "String" - } - }, - moduleId: { - serializedName: "moduleId", - type: { - name: "String" - } - }, - hubName: { - serializedName: "hubName", - type: { - name: "String" - } - }, - deviceConnectionStateEventInfo: { - serializedName: "deviceConnectionStateEventInfo", - type: { - name: "Composite", - className: "DeviceConnectionStateEventInfo" - } - } - } - } -}; - -export const IotHubDeviceConnectedEventData: msRest.CompositeMapper = { - serializedName: "IotHubDeviceConnectedEventData", - type: { - name: "Composite", - className: "IotHubDeviceConnectedEventData", - modelProperties: { - ...DeviceConnectionStateEventProperties.type.modelProperties - } - } -}; - -export const IotHubDeviceDisconnectedEventData: msRest.CompositeMapper = { - serializedName: "IotHubDeviceDisconnectedEventData", - type: { - name: "Composite", - className: "IotHubDeviceDisconnectedEventData", - modelProperties: { - ...DeviceConnectionStateEventProperties.type.modelProperties - } - } -}; - -export const DeviceTelemetryEventProperties: msRest.CompositeMapper = { - serializedName: "DeviceTelemetryEventProperties", - type: { - name: "Composite", - className: "DeviceTelemetryEventProperties", - modelProperties: { - body: { - serializedName: "body", - type: { - name: "Object" - } - }, - properties: { - serializedName: "properties", - type: { - name: "Dictionary", - value: { - type: { - name: "String" - } - } - } - }, - systemProperties: { - serializedName: "systemProperties", - type: { - name: "Dictionary", - value: { - type: { - name: "String" - } - } - } - } - } - } -}; - -export const IotHubDeviceTelemetryEventData: msRest.CompositeMapper = { - serializedName: "IotHubDeviceTelemetryEventData", - type: { - name: "Composite", - className: "IotHubDeviceTelemetryEventData", - modelProperties: { - ...DeviceTelemetryEventProperties.type.modelProperties - } - } -}; - -export const DeviceTwinMetadata: msRest.CompositeMapper = { - serializedName: "DeviceTwinMetadata", - type: { - name: "Composite", - className: "DeviceTwinMetadata", - modelProperties: { - lastUpdated: { - serializedName: "lastUpdated", - type: { - name: "String" - } - } - } - } -}; - -export const DeviceTwinProperties: msRest.CompositeMapper = { - serializedName: "DeviceTwinProperties", - type: { - name: "Composite", - className: "DeviceTwinProperties", - modelProperties: { - metadata: { - serializedName: "metadata", - type: { - name: "Composite", - className: "DeviceTwinMetadata" - } - }, - version: { - serializedName: "version", - type: { - name: "Number" - } - } - } - } -}; - -export const DeviceTwinInfoProperties: msRest.CompositeMapper = { - serializedName: "DeviceTwinInfo_properties", - type: { - name: "Composite", - className: "DeviceTwinInfoProperties", - modelProperties: { - desired: { - serializedName: "desired", - type: { - name: "Composite", - className: "DeviceTwinProperties" - } - }, - reported: { - serializedName: "reported", - type: { - name: "Composite", - className: "DeviceTwinProperties" - } - } - } - } -}; - -export const DeviceTwinInfoX509Thumbprint: msRest.CompositeMapper = { - serializedName: "DeviceTwinInfo_x509Thumbprint", - type: { - name: "Composite", - className: "DeviceTwinInfoX509Thumbprint", - modelProperties: { - primaryThumbprint: { - serializedName: "primaryThumbprint", - type: { - name: "String" - } - }, - secondaryThumbprint: { - serializedName: "secondaryThumbprint", - type: { - name: "String" - } - } - } - } -}; - -export const DeviceTwinInfo: msRest.CompositeMapper = { - serializedName: "DeviceTwinInfo", - type: { - name: "Composite", - className: "DeviceTwinInfo", - modelProperties: { - authenticationType: { - serializedName: "authenticationType", - type: { - name: "String" - } - }, - cloudToDeviceMessageCount: { - serializedName: "cloudToDeviceMessageCount", - type: { - name: "Number" - } - }, - connectionState: { - serializedName: "connectionState", - type: { - name: "String" - } - }, - deviceId: { - serializedName: "deviceId", - type: { - name: "String" - } - }, - etag: { - serializedName: "etag", - type: { - name: "String" - } - }, - lastActivityTime: { - serializedName: "lastActivityTime", - type: { - name: "String" - } - }, - properties: { - serializedName: "properties", - type: { - name: "Composite", - className: "DeviceTwinInfoProperties" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - statusUpdateTime: { - serializedName: "statusUpdateTime", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "Number" - } - }, - x509Thumbprint: { - serializedName: "x509Thumbprint", - type: { - name: "Composite", - className: "DeviceTwinInfoX509Thumbprint" - } - } - } - } -}; - -export const DeviceConnectionStateEventInfo: msRest.CompositeMapper = { - serializedName: "DeviceConnectionStateEventInfo", - type: { - name: "Composite", - className: "DeviceConnectionStateEventInfo", - modelProperties: { - sequenceNumber: { - serializedName: "sequenceNumber", - type: { - name: "String" - } - } - } - } -}; - -export const ContainerRegistryEventData: msRest.CompositeMapper = { - serializedName: "ContainerRegistryEventData", - type: { - name: "Composite", - className: "ContainerRegistryEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - timestamp: { - serializedName: "timestamp", - type: { - name: "DateTime" - } - }, - action: { - serializedName: "action", - type: { - name: "String" - } - }, - target: { - serializedName: "target", - type: { - name: "Composite", - className: "ContainerRegistryEventTarget" - } - }, - request: { - serializedName: "request", - type: { - name: "Composite", - className: "ContainerRegistryEventRequest" - } - }, - actor: { - serializedName: "actor", - type: { - name: "Composite", - className: "ContainerRegistryEventActor" - } - }, - source: { - serializedName: "source", - type: { - name: "Composite", - className: "ContainerRegistryEventSource" - } - } - } - } -}; - -export const ContainerRegistryImagePushedEventData: msRest.CompositeMapper = { - serializedName: "ContainerRegistryImagePushedEventData", - type: { - name: "Composite", - className: "ContainerRegistryImagePushedEventData", - modelProperties: { - ...ContainerRegistryEventData.type.modelProperties - } - } -}; - -export const ContainerRegistryImageDeletedEventData: msRest.CompositeMapper = { - serializedName: "ContainerRegistryImageDeletedEventData", - type: { - name: "Composite", - className: "ContainerRegistryImageDeletedEventData", - modelProperties: { - ...ContainerRegistryEventData.type.modelProperties - } - } -}; - -export const ContainerRegistryArtifactEventData: msRest.CompositeMapper = { - serializedName: "ContainerRegistryArtifactEventData", - type: { - name: "Composite", - className: "ContainerRegistryArtifactEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - timestamp: { - serializedName: "timestamp", - type: { - name: "DateTime" - } - }, - action: { - serializedName: "action", - type: { - name: "String" - } - }, - target: { - serializedName: "target", - type: { - name: "Composite", - className: "ContainerRegistryArtifactEventTarget" - } - } - } - } -}; - -export const ContainerRegistryChartPushedEventData: msRest.CompositeMapper = { - serializedName: "ContainerRegistryChartPushedEventData", - type: { - name: "Composite", - className: "ContainerRegistryChartPushedEventData", - modelProperties: { - ...ContainerRegistryArtifactEventData.type.modelProperties - } - } -}; - -export const ContainerRegistryChartDeletedEventData: msRest.CompositeMapper = { - serializedName: "ContainerRegistryChartDeletedEventData", - type: { - name: "Composite", - className: "ContainerRegistryChartDeletedEventData", - modelProperties: { - ...ContainerRegistryArtifactEventData.type.modelProperties - } - } -}; - -export const ContainerRegistryEventTarget: msRest.CompositeMapper = { - serializedName: "ContainerRegistryEventTarget", - type: { - name: "Composite", - className: "ContainerRegistryEventTarget", - modelProperties: { - mediaType: { - serializedName: "mediaType", - type: { - name: "String" - } - }, - size: { - serializedName: "size", - type: { - name: "Number" - } - }, - digest: { - serializedName: "digest", - type: { - name: "String" - } - }, - length: { - serializedName: "length", - type: { - name: "Number" - } - }, - repository: { - serializedName: "repository", - type: { - name: "String" - } - }, - url: { - serializedName: "url", - type: { - name: "String" - } - }, - tag: { - serializedName: "tag", - type: { - name: "String" - } - } - } - } -}; - -export const ContainerRegistryEventRequest: msRest.CompositeMapper = { - serializedName: "ContainerRegistryEventRequest", - type: { - name: "Composite", - className: "ContainerRegistryEventRequest", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - addr: { - serializedName: "addr", - type: { - name: "String" - } - }, - host: { - serializedName: "host", - type: { - name: "String" - } - }, - method: { - serializedName: "method", - type: { - name: "String" - } - }, - useragent: { - serializedName: "useragent", - type: { - name: "String" - } - } - } - } -}; - -export const ContainerRegistryEventActor: msRest.CompositeMapper = { - serializedName: "ContainerRegistryEventActor", - type: { - name: "Composite", - className: "ContainerRegistryEventActor", - modelProperties: { - name: { - serializedName: "name", - type: { - name: "String" - } - } - } - } -}; - -export const ContainerRegistryEventSource: msRest.CompositeMapper = { - serializedName: "ContainerRegistryEventSource", - type: { - name: "Composite", - className: "ContainerRegistryEventSource", - modelProperties: { - addr: { - serializedName: "addr", - type: { - name: "String" - } - }, - instanceID: { - serializedName: "instanceID", - type: { - name: "String" - } - } - } - } -}; - -export const ContainerRegistryArtifactEventTarget: msRest.CompositeMapper = { - serializedName: "ContainerRegistryArtifactEventTarget", - type: { - name: "Composite", - className: "ContainerRegistryArtifactEventTarget", - modelProperties: { - mediaType: { - serializedName: "mediaType", - type: { - name: "String" - } - }, - size: { - serializedName: "size", - type: { - name: "Number" - } - }, - digest: { - serializedName: "digest", - type: { - name: "String" - } - }, - repository: { - serializedName: "repository", - type: { - name: "String" - } - }, - tag: { - serializedName: "tag", - type: { - name: "String" - } - }, - name: { - serializedName: "name", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - } - } - } -}; - -export const ServiceBusActiveMessagesAvailableWithNoListenersEventData: msRest.CompositeMapper = { - serializedName: "ServiceBusActiveMessagesAvailableWithNoListenersEventData", - type: { - name: "Composite", - className: "ServiceBusActiveMessagesAvailableWithNoListenersEventData", - modelProperties: { - namespaceName: { - serializedName: "namespaceName", - type: { - name: "String" - } - }, - requestUri: { - serializedName: "requestUri", - type: { - name: "String" - } - }, - entityType: { - serializedName: "entityType", - type: { - name: "String" - } - }, - queueName: { - serializedName: "queueName", - type: { - name: "String" - } - }, - topicName: { - serializedName: "topicName", - type: { - name: "String" - } - }, - subscriptionName: { - serializedName: "subscriptionName", - type: { - name: "String" - } - } - } - } -}; - -export const ServiceBusDeadletterMessagesAvailableWithNoListenersEventData: msRest.CompositeMapper = { - serializedName: "ServiceBusDeadletterMessagesAvailableWithNoListenersEventData", - type: { - name: "Composite", - className: "ServiceBusDeadletterMessagesAvailableWithNoListenersEventData", - modelProperties: { - namespaceName: { - serializedName: "namespaceName", - type: { - name: "String" - } - }, - requestUri: { - serializedName: "requestUri", - type: { - name: "String" - } - }, - entityType: { - serializedName: "entityType", - type: { - name: "String" - } - }, - queueName: { - serializedName: "queueName", - type: { - name: "String" - } - }, - topicName: { - serializedName: "topicName", - type: { - name: "String" - } - }, - subscriptionName: { - serializedName: "subscriptionName", - type: { - name: "String" - } - } - } - } -}; - -export const MediaJobStateChangeEventData: msRest.CompositeMapper = { - serializedName: "MediaJobStateChangeEventData", - type: { - name: "Composite", - className: "MediaJobStateChangeEventData", - modelProperties: { - previousState: { - nullable: false, - readOnly: true, - serializedName: "previousState", - type: { - name: "Enum", - allowedValues: [ - "Canceled", - "Canceling", - "Error", - "Finished", - "Processing", - "Queued", - "Scheduled" - ] - } - }, - state: { - nullable: false, - readOnly: true, - serializedName: "state", - type: { - name: "Enum", - allowedValues: [ - "Canceled", - "Canceling", - "Error", - "Finished", - "Processing", - "Queued", - "Scheduled" - ] - } - }, - correlationData: { - serializedName: "correlationData", - type: { - name: "Dictionary", - value: { - type: { - name: "String" - } - } - } - } - } - } -}; - -export const MediaJobErrorDetail: msRest.CompositeMapper = { - serializedName: "MediaJobErrorDetail", - type: { - name: "Composite", - className: "MediaJobErrorDetail", - modelProperties: { - code: { - readOnly: true, - serializedName: "code", - type: { - name: "String" - } - }, - message: { - readOnly: true, - serializedName: "message", - type: { - name: "String" - } - } - } - } -}; - -export const MediaJobError: msRest.CompositeMapper = { - serializedName: "MediaJobError", - type: { - name: "Composite", - className: "MediaJobError", - modelProperties: { - code: { - nullable: false, - readOnly: true, - serializedName: "code", - type: { - name: "Enum", - allowedValues: [ - "ServiceError", - "ServiceTransientError", - "DownloadNotAccessible", - "DownloadTransientError", - "UploadNotAccessible", - "UploadTransientError", - "ConfigurationUnsupported", - "ContentMalformed", - "ContentUnsupported" - ] - } - }, - message: { - readOnly: true, - serializedName: "message", - type: { - name: "String" - } - }, - category: { - nullable: false, - readOnly: true, - serializedName: "category", - type: { - name: "Enum", - allowedValues: [ - "Service", - "Download", - "Upload", - "Configuration", - "Content" - ] - } - }, - retry: { - nullable: false, - readOnly: true, - serializedName: "retry", - type: { - name: "Enum", - allowedValues: [ - "DoNotRetry", - "MayRetry" - ] - } - }, - details: { - readOnly: true, - serializedName: "details", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "MediaJobErrorDetail" - } - } - } - } - } - } -}; - -export const MediaJobOutput: msRest.CompositeMapper = { - serializedName: "MediaJobOutput", - type: { - name: "Composite", - polymorphicDiscriminator: { - serializedName: "@odata.type", - clientName: "odatatype" - }, - uberParent: "MediaJobOutput", - className: "MediaJobOutput", - modelProperties: { - error: { - serializedName: "error", - type: { - name: "Composite", - className: "MediaJobError" - } - }, - label: { - serializedName: "label", - type: { - name: "String" - } - }, - progress: { - required: true, - serializedName: "progress", - type: { - name: "Number" - } - }, - state: { - required: true, - serializedName: "state", - type: { - name: "Enum", - allowedValues: [ - "Canceled", - "Canceling", - "Error", - "Finished", - "Processing", - "Queued", - "Scheduled" - ] - } - }, - odatatype: { - required: true, - serializedName: "@odata\\.type", - type: { - name: "String" - } - } - } - } -}; - -export const MediaJobOutputAsset: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobOutputAsset", - type: { - name: "Composite", - polymorphicDiscriminator: MediaJobOutput.type.polymorphicDiscriminator, - uberParent: "MediaJobOutput", - className: "MediaJobOutputAsset", - modelProperties: { - ...MediaJobOutput.type.modelProperties, - assetName: { - serializedName: "assetName", - type: { - name: "String" - } - } - } - } -}; - -export const MediaJobOutputProgressEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobOutputProgress", - type: { - name: "Composite", - className: "MediaJobOutputProgressEventData", - modelProperties: { - label: { - serializedName: "label", - type: { - name: "String" - } - }, - progress: { - serializedName: "progress", - type: { - name: "Number" - } - }, - jobCorrelationData: { - serializedName: "jobCorrelationData", - type: { - name: "Dictionary", - value: { - type: { - name: "String" - } - } - } - } - } - } -}; - -export const MediaJobOutputStateChangeEventData: msRest.CompositeMapper = { - serializedName: "MediaJobOutputStateChangeEventData", - type: { - name: "Composite", - className: "MediaJobOutputStateChangeEventData", - modelProperties: { - previousState: { - nullable: false, - readOnly: true, - serializedName: "previousState", - type: { - name: "Enum", - allowedValues: [ - "Canceled", - "Canceling", - "Error", - "Finished", - "Processing", - "Queued", - "Scheduled" - ] - } - }, - output: { - serializedName: "output", - type: { - name: "Composite", - className: "MediaJobOutput" - } - }, - jobCorrelationData: { - serializedName: "jobCorrelationData", - type: { - name: "Dictionary", - value: { - type: { - name: "String" - } - } - } - } - } - } -}; - -export const MediaJobScheduledEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobScheduled", - type: { - name: "Composite", - className: "MediaJobScheduledEventData", - modelProperties: { - ...MediaJobStateChangeEventData.type.modelProperties - } - } -}; - -export const MediaJobProcessingEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobProcessing", - type: { - name: "Composite", - className: "MediaJobProcessingEventData", - modelProperties: { - ...MediaJobStateChangeEventData.type.modelProperties - } - } -}; - -export const MediaJobCancelingEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobCanceling", - type: { - name: "Composite", - className: "MediaJobCancelingEventData", - modelProperties: { - ...MediaJobStateChangeEventData.type.modelProperties - } - } -}; - -export const MediaJobFinishedEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobFinished", - type: { - name: "Composite", - className: "MediaJobFinishedEventData", - modelProperties: { - ...MediaJobStateChangeEventData.type.modelProperties, - outputs: { - serializedName: "outputs", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "MediaJobOutput" - } - } - } - } - } - } -}; - -export const MediaJobCanceledEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobCanceled", - type: { - name: "Composite", - className: "MediaJobCanceledEventData", - modelProperties: { - ...MediaJobStateChangeEventData.type.modelProperties, - outputs: { - serializedName: "outputs", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "MediaJobOutput" - } - } - } - } - } - } -}; - -export const MediaJobErroredEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobErrored", - type: { - name: "Composite", - className: "MediaJobErroredEventData", - modelProperties: { - ...MediaJobStateChangeEventData.type.modelProperties, - outputs: { - serializedName: "outputs", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "MediaJobOutput" - } - } - } - } - } - } -}; - -export const MediaJobOutputCanceledEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobOutputCanceled", - type: { - name: "Composite", - className: "MediaJobOutputCanceledEventData", - modelProperties: { - ...MediaJobOutputStateChangeEventData.type.modelProperties - } - } -}; - -export const MediaJobOutputCancelingEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobOutputCanceling", - type: { - name: "Composite", - className: "MediaJobOutputCancelingEventData", - modelProperties: { - ...MediaJobOutputStateChangeEventData.type.modelProperties - } - } -}; - -export const MediaJobOutputErroredEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobOutputErrored", - type: { - name: "Composite", - className: "MediaJobOutputErroredEventData", - modelProperties: { - ...MediaJobOutputStateChangeEventData.type.modelProperties - } - } -}; - -export const MediaJobOutputFinishedEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobOutputFinished", - type: { - name: "Composite", - className: "MediaJobOutputFinishedEventData", - modelProperties: { - ...MediaJobOutputStateChangeEventData.type.modelProperties - } - } -}; - -export const MediaJobOutputProcessingEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobOutputProcessing", - type: { - name: "Composite", - className: "MediaJobOutputProcessingEventData", - modelProperties: { - ...MediaJobOutputStateChangeEventData.type.modelProperties - } - } -}; - -export const MediaJobOutputScheduledEventData: msRest.CompositeMapper = { - serializedName: "#Microsoft.Media.JobOutputScheduled", - type: { - name: "Composite", - className: "MediaJobOutputScheduledEventData", - modelProperties: { - ...MediaJobOutputStateChangeEventData.type.modelProperties - } - } -}; - -export const MediaLiveEventEncoderConnectedEventData: msRest.CompositeMapper = { - serializedName: "MediaLiveEventEncoderConnectedEventData", - type: { - name: "Composite", - className: "MediaLiveEventEncoderConnectedEventData", - modelProperties: { - ingestUrl: { - readOnly: true, - serializedName: "ingestUrl", - type: { - name: "String" - } - }, - streamId: { - readOnly: true, - serializedName: "streamId", - type: { - name: "String" - } - }, - encoderIp: { - readOnly: true, - serializedName: "encoderIp", - type: { - name: "String" - } - }, - encoderPort: { - readOnly: true, - serializedName: "encoderPort", - type: { - name: "String" - } - } - } - } -}; - -export const MediaLiveEventConnectionRejectedEventData: msRest.CompositeMapper = { - serializedName: "MediaLiveEventConnectionRejectedEventData", - type: { - name: "Composite", - className: "MediaLiveEventConnectionRejectedEventData", - modelProperties: { - ingestUrl: { - readOnly: true, - serializedName: "ingestUrl", - type: { - name: "String" - } - }, - streamId: { - readOnly: true, - serializedName: "streamId", - type: { - name: "String" - } - }, - encoderIp: { - readOnly: true, - serializedName: "encoderIp", - type: { - name: "String" - } - }, - encoderPort: { - readOnly: true, - serializedName: "encoderPort", - type: { - name: "String" - } - }, - resultCode: { - readOnly: true, - serializedName: "resultCode", - type: { - name: "String" - } - } - } - } -}; - -export const MediaLiveEventEncoderDisconnectedEventData: msRest.CompositeMapper = { - serializedName: "MediaLiveEventEncoderDisconnectedEventData", - type: { - name: "Composite", - className: "MediaLiveEventEncoderDisconnectedEventData", - modelProperties: { - ingestUrl: { - readOnly: true, - serializedName: "ingestUrl", - type: { - name: "String" - } - }, - streamId: { - readOnly: true, - serializedName: "streamId", - type: { - name: "String" - } - }, - encoderIp: { - readOnly: true, - serializedName: "encoderIp", - type: { - name: "String" - } - }, - encoderPort: { - readOnly: true, - serializedName: "encoderPort", - type: { - name: "String" - } - }, - resultCode: { - readOnly: true, - serializedName: "resultCode", - type: { - name: "String" - } - } - } - } -}; - -export const MediaLiveEventIncomingStreamReceivedEventData: msRest.CompositeMapper = { - serializedName: "MediaLiveEventIncomingStreamReceivedEventData", - type: { - name: "Composite", - className: "MediaLiveEventIncomingStreamReceivedEventData", - modelProperties: { - ingestUrl: { - readOnly: true, - serializedName: "ingestUrl", - type: { - name: "String" - } - }, - trackType: { - readOnly: true, - serializedName: "trackType", - type: { - name: "String" - } - }, - trackName: { - readOnly: true, - serializedName: "trackName", - type: { - name: "String" - } - }, - bitrate: { - readOnly: true, - serializedName: "bitrate", - type: { - name: "Number" - } - }, - encoderIp: { - readOnly: true, - serializedName: "encoderIp", - type: { - name: "String" - } - }, - encoderPort: { - readOnly: true, - serializedName: "encoderPort", - type: { - name: "String" - } - }, - timestamp: { - readOnly: true, - serializedName: "timestamp", - type: { - name: "String" - } - }, - duration: { - readOnly: true, - serializedName: "duration", - type: { - name: "String" - } - }, - timescale: { - readOnly: true, - serializedName: "timescale", - type: { - name: "String" - } - } - } - } -}; - -export const MediaLiveEventIncomingStreamsOutOfSyncEventData: msRest.CompositeMapper = { - serializedName: "MediaLiveEventIncomingStreamsOutOfSyncEventData", - type: { - name: "Composite", - className: "MediaLiveEventIncomingStreamsOutOfSyncEventData", - modelProperties: { - minLastTimestamp: { - readOnly: true, - serializedName: "minLastTimestamp", - type: { - name: "String" - } - }, - typeOfStreamWithMinLastTimestamp: { - readOnly: true, - serializedName: "typeOfStreamWithMinLastTimestamp", - type: { - name: "String" - } - }, - maxLastTimestamp: { - readOnly: true, - serializedName: "maxLastTimestamp", - type: { - name: "String" - } - }, - typeOfStreamWithMaxLastTimestamp: { - readOnly: true, - serializedName: "typeOfStreamWithMaxLastTimestamp", - type: { - name: "String" - } - }, - timescaleOfMinLastTimestamp: { - readOnly: true, - serializedName: "timescaleOfMinLastTimestamp", - type: { - name: "String" - } - }, - timescaleOfMaxLastTimestamp: { - readOnly: true, - serializedName: "timescaleOfMaxLastTimestamp", - type: { - name: "String" - } - } - } - } -}; - -export const MediaLiveEventIncomingVideoStreamsOutOfSyncEventData: msRest.CompositeMapper = { - serializedName: "MediaLiveEventIncomingVideoStreamsOutOfSyncEventData", - type: { - name: "Composite", - className: "MediaLiveEventIncomingVideoStreamsOutOfSyncEventData", - modelProperties: { - firstTimestamp: { - readOnly: true, - serializedName: "firstTimestamp", - type: { - name: "String" - } - }, - firstDuration: { - readOnly: true, - serializedName: "firstDuration", - type: { - name: "String" - } - }, - secondTimestamp: { - readOnly: true, - serializedName: "secondTimestamp", - type: { - name: "String" - } - }, - secondDuration: { - readOnly: true, - serializedName: "secondDuration", - type: { - name: "String" - } - }, - timescale: { - readOnly: true, - serializedName: "timescale", - type: { - name: "String" - } - } - } - } -}; - -export const MediaLiveEventIncomingDataChunkDroppedEventData: msRest.CompositeMapper = { - serializedName: "MediaLiveEventIncomingDataChunkDroppedEventData", - type: { - name: "Composite", - className: "MediaLiveEventIncomingDataChunkDroppedEventData", - modelProperties: { - timestamp: { - readOnly: true, - serializedName: "timestamp", - type: { - name: "String" - } - }, - trackType: { - readOnly: true, - serializedName: "trackType", - type: { - name: "String" - } - }, - bitrate: { - readOnly: true, - serializedName: "bitrate", - type: { - name: "Number" - } - }, - timescale: { - readOnly: true, - serializedName: "timescale", - type: { - name: "String" - } - }, - resultCode: { - readOnly: true, - serializedName: "resultCode", - type: { - name: "String" - } - }, - trackName: { - readOnly: true, - serializedName: "trackName", - type: { - name: "String" - } - } - } - } -}; - -export const MediaLiveEventIngestHeartbeatEventData: msRest.CompositeMapper = { - serializedName: "MediaLiveEventIngestHeartbeatEventData", - type: { - name: "Composite", - className: "MediaLiveEventIngestHeartbeatEventData", - modelProperties: { - trackType: { - readOnly: true, - serializedName: "trackType", - type: { - name: "String" - } - }, - trackName: { - readOnly: true, - serializedName: "trackName", - type: { - name: "String" - } - }, - bitrate: { - readOnly: true, - serializedName: "bitrate", - type: { - name: "Number" - } - }, - incomingBitrate: { - readOnly: true, - serializedName: "incomingBitrate", - type: { - name: "Number" - } - }, - lastTimestamp: { - readOnly: true, - serializedName: "lastTimestamp", - type: { - name: "String" - } - }, - timescale: { - readOnly: true, - serializedName: "timescale", - type: { - name: "String" - } - }, - overlapCount: { - readOnly: true, - serializedName: "overlapCount", - type: { - name: "Number" - } - }, - discontinuityCount: { - readOnly: true, - serializedName: "discontinuityCount", - type: { - name: "Number" - } - }, - nonincreasingCount: { - readOnly: true, - serializedName: "nonincreasingCount", - type: { - name: "Number" - } - }, - unexpectedBitrate: { - readOnly: true, - serializedName: "unexpectedBitrate", - type: { - name: "Boolean" - } - }, - state: { - readOnly: true, - serializedName: "state", - type: { - name: "String" - } - }, - healthy: { - readOnly: true, - serializedName: "healthy", - type: { - name: "Boolean" - } - } - } - } -}; - -export const MediaLiveEventTrackDiscontinuityDetectedEventData: msRest.CompositeMapper = { - serializedName: "MediaLiveEventTrackDiscontinuityDetectedEventData", - type: { - name: "Composite", - className: "MediaLiveEventTrackDiscontinuityDetectedEventData", - modelProperties: { - trackType: { - readOnly: true, - serializedName: "trackType", - type: { - name: "String" - } - }, - trackName: { - readOnly: true, - serializedName: "trackName", - type: { - name: "String" - } - }, - bitrate: { - readOnly: true, - serializedName: "bitrate", - type: { - name: "Number" - } - }, - previousTimestamp: { - readOnly: true, - serializedName: "previousTimestamp", - type: { - name: "String" - } - }, - newTimestamp: { - readOnly: true, - serializedName: "newTimestamp", - type: { - name: "String" - } - }, - timescale: { - readOnly: true, - serializedName: "timescale", - type: { - name: "String" - } - }, - discontinuityGap: { - readOnly: true, - serializedName: "discontinuityGap", - type: { - name: "String" - } - } - } - } -}; - -export const MapsGeofenceEventProperties: msRest.CompositeMapper = { - serializedName: "MapsGeofenceEventProperties", - type: { - name: "Composite", - className: "MapsGeofenceEventProperties", - modelProperties: { - expiredGeofenceGeometryId: { - serializedName: "expiredGeofenceGeometryId", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - }, - geometries: { - serializedName: "geometries", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "MapsGeofenceGeometry" - } - } - } - }, - invalidPeriodGeofenceGeometryId: { - serializedName: "invalidPeriodGeofenceGeometryId", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - }, - isEventPublished: { - serializedName: "isEventPublished", - type: { - name: "Boolean" - } - } - } - } -}; - -export const MapsGeofenceEnteredEventData: msRest.CompositeMapper = { - serializedName: "MapsGeofenceEnteredEventData", - type: { - name: "Composite", - className: "MapsGeofenceEnteredEventData", - modelProperties: { - ...MapsGeofenceEventProperties.type.modelProperties - } - } -}; - -export const MapsGeofenceExitedEventData: msRest.CompositeMapper = { - serializedName: "MapsGeofenceExitedEventData", - type: { - name: "Composite", - className: "MapsGeofenceExitedEventData", - modelProperties: { - ...MapsGeofenceEventProperties.type.modelProperties - } - } -}; - -export const MapsGeofenceResultEventData: msRest.CompositeMapper = { - serializedName: "MapsGeofenceResultEventData", - type: { - name: "Composite", - className: "MapsGeofenceResultEventData", - modelProperties: { - ...MapsGeofenceEventProperties.type.modelProperties - } - } -}; - -export const MapsGeofenceGeometry: msRest.CompositeMapper = { - serializedName: "MapsGeofenceGeometry", - type: { - name: "Composite", - className: "MapsGeofenceGeometry", - modelProperties: { - deviceId: { - serializedName: "deviceId", - type: { - name: "String" - } - }, - distance: { - serializedName: "distance", - type: { - name: "Number" - } - }, - geometryId: { - serializedName: "geometryId", - type: { - name: "String" - } - }, - nearestLat: { - serializedName: "nearestLat", - type: { - name: "Number" - } - }, - nearestLon: { - serializedName: "nearestLon", - type: { - name: "Number" - } - }, - udId: { - serializedName: "udId", - type: { - name: "String" - } - } - } - } -}; - -export const AppConfigurationKeyValueModifiedEventData: msRest.CompositeMapper = { - serializedName: "AppConfigurationKeyValueModifiedEventData", - type: { - name: "Composite", - className: "AppConfigurationKeyValueModifiedEventData", - modelProperties: { - key: { - serializedName: "key", - type: { - name: "String" - } - }, - label: { - serializedName: "label", - type: { - name: "String" - } - }, - etag: { - serializedName: "etag", - type: { - name: "String" - } - } - } - } -}; - -export const AppConfigurationKeyValueDeletedEventData: msRest.CompositeMapper = { - serializedName: "AppConfigurationKeyValueDeletedEventData", - type: { - name: "Composite", - className: "AppConfigurationKeyValueDeletedEventData", - modelProperties: { - key: { - serializedName: "key", - type: { - name: "String" - } - }, - label: { - serializedName: "label", - type: { - name: "String" - } - }, - etag: { - serializedName: "etag", - type: { - name: "String" - } - } - } - } -}; - -export const SignalRServiceClientConnectionConnectedEventData: msRest.CompositeMapper = { - serializedName: "SignalRServiceClientConnectionConnectedEventData", - type: { - name: "Composite", - className: "SignalRServiceClientConnectionConnectedEventData", - modelProperties: { - timestamp: { - serializedName: "timestamp", - type: { - name: "DateTime" - } - }, - hubName: { - serializedName: "hubName", - type: { - name: "String" - } - }, - connectionId: { - serializedName: "connectionId", - type: { - name: "String" - } - }, - userId: { - serializedName: "userId", - type: { - name: "String" - } - } - } - } -}; - -export const SignalRServiceClientConnectionDisconnectedEventData: msRest.CompositeMapper = { - serializedName: "SignalRServiceClientConnectionDisconnectedEventData", - type: { - name: "Composite", - className: "SignalRServiceClientConnectionDisconnectedEventData", - modelProperties: { - timestamp: { - serializedName: "timestamp", - type: { - name: "DateTime" - } - }, - hubName: { - serializedName: "hubName", - type: { - name: "String" - } - }, - connectionId: { - serializedName: "connectionId", - type: { - name: "String" - } - }, - userId: { - serializedName: "userId", - type: { - name: "String" - } - }, - errorMessage: { - serializedName: "errorMessage", - type: { - name: "String" - } - } - } - } -}; - -export const KeyVaultCertificateNewVersionCreatedEventData: msRest.CompositeMapper = { - serializedName: "KeyVaultCertificateNewVersionCreatedEventData", - type: { - name: "Composite", - className: "KeyVaultCertificateNewVersionCreatedEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - vaultName: { - serializedName: "vaultName", - type: { - name: "String" - } - }, - objectType: { - serializedName: "objectType", - type: { - name: "String" - } - }, - objectName: { - serializedName: "objectName", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - }, - nbf: { - serializedName: "nbf", - type: { - name: "Number" - } - }, - exp: { - serializedName: "exp", - type: { - name: "Number" - } - } - } - } -}; - -export const KeyVaultCertificateNearExpiryEventData: msRest.CompositeMapper = { - serializedName: "KeyVaultCertificateNearExpiryEventData", - type: { - name: "Composite", - className: "KeyVaultCertificateNearExpiryEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - vaultName: { - serializedName: "vaultName", - type: { - name: "String" - } - }, - objectType: { - serializedName: "objectType", - type: { - name: "String" - } - }, - objectName: { - serializedName: "objectName", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - }, - nbf: { - serializedName: "nbf", - type: { - name: "Number" - } - }, - exp: { - serializedName: "exp", - type: { - name: "Number" - } - } - } - } -}; - -export const KeyVaultCertificateExpiredEventData: msRest.CompositeMapper = { - serializedName: "KeyVaultCertificateExpiredEventData", - type: { - name: "Composite", - className: "KeyVaultCertificateExpiredEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - vaultName: { - serializedName: "vaultName", - type: { - name: "String" - } - }, - objectType: { - serializedName: "objectType", - type: { - name: "String" - } - }, - objectName: { - serializedName: "objectName", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - }, - nbf: { - serializedName: "nbf", - type: { - name: "Number" - } - }, - exp: { - serializedName: "exp", - type: { - name: "Number" - } - } - } - } -}; - -export const KeyVaultKeyNewVersionCreatedEventData: msRest.CompositeMapper = { - serializedName: "KeyVaultKeyNewVersionCreatedEventData", - type: { - name: "Composite", - className: "KeyVaultKeyNewVersionCreatedEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - vaultName: { - serializedName: "vaultName", - type: { - name: "String" - } - }, - objectType: { - serializedName: "objectType", - type: { - name: "String" - } - }, - objectName: { - serializedName: "objectName", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - }, - nbf: { - serializedName: "nbf", - type: { - name: "Number" - } - }, - exp: { - serializedName: "exp", - type: { - name: "Number" - } - } - } - } -}; - -export const KeyVaultKeyNearExpiryEventData: msRest.CompositeMapper = { - serializedName: "KeyVaultKeyNearExpiryEventData", - type: { - name: "Composite", - className: "KeyVaultKeyNearExpiryEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - vaultName: { - serializedName: "vaultName", - type: { - name: "String" - } - }, - objectType: { - serializedName: "objectType", - type: { - name: "String" - } - }, - objectName: { - serializedName: "objectName", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - }, - nbf: { - serializedName: "nbf", - type: { - name: "Number" - } - }, - exp: { - serializedName: "exp", - type: { - name: "Number" - } - } - } - } -}; - -export const KeyVaultKeyExpiredEventData: msRest.CompositeMapper = { - serializedName: "KeyVaultKeyExpiredEventData", - type: { - name: "Composite", - className: "KeyVaultKeyExpiredEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - vaultName: { - serializedName: "vaultName", - type: { - name: "String" - } - }, - objectType: { - serializedName: "objectType", - type: { - name: "String" - } - }, - objectName: { - serializedName: "objectName", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - }, - nbf: { - serializedName: "nbf", - type: { - name: "Number" - } - }, - exp: { - serializedName: "exp", - type: { - name: "Number" - } - } - } - } -}; - -export const KeyVaultSecretNewVersionCreatedEventData: msRest.CompositeMapper = { - serializedName: "KeyVaultSecretNewVersionCreatedEventData", - type: { - name: "Composite", - className: "KeyVaultSecretNewVersionCreatedEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - vaultName: { - serializedName: "vaultName", - type: { - name: "String" - } - }, - objectType: { - serializedName: "objectType", - type: { - name: "String" - } - }, - objectName: { - serializedName: "objectName", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - }, - nbf: { - serializedName: "nbf", - type: { - name: "Number" - } - }, - exp: { - serializedName: "exp", - type: { - name: "Number" - } - } - } - } -}; - -export const KeyVaultSecretNearExpiryEventData: msRest.CompositeMapper = { - serializedName: "KeyVaultSecretNearExpiryEventData", - type: { - name: "Composite", - className: "KeyVaultSecretNearExpiryEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - vaultName: { - serializedName: "vaultName", - type: { - name: "String" - } - }, - objectType: { - serializedName: "objectType", - type: { - name: "String" - } - }, - objectName: { - serializedName: "objectName", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - }, - nbf: { - serializedName: "nbf", - type: { - name: "Number" - } - }, - exp: { - serializedName: "exp", - type: { - name: "Number" - } - } - } - } -}; - -export const KeyVaultSecretExpiredEventData: msRest.CompositeMapper = { - serializedName: "KeyVaultSecretExpiredEventData", - type: { - name: "Composite", - className: "KeyVaultSecretExpiredEventData", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - vaultName: { - serializedName: "vaultName", - type: { - name: "String" - } - }, - objectType: { - serializedName: "objectType", - type: { - name: "String" - } - }, - objectName: { - serializedName: "objectName", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - }, - nbf: { - serializedName: "nbf", - type: { - name: "Number" - } - }, - exp: { - serializedName: "exp", - type: { - name: "Number" - } - } - } - } -}; - -export const MachineLearningServicesModelRegisteredEventData: msRest.CompositeMapper = { - serializedName: "MachineLearningServicesModelRegisteredEventData", - type: { - name: "Composite", - className: "MachineLearningServicesModelRegisteredEventData", - modelProperties: { - modelName: { - serializedName: "modelName", - type: { - name: "String" - } - }, - modelVersion: { - serializedName: "modelVersion", - type: { - name: "Number" - } - }, - modelTags: { - serializedName: "modelTags", - type: { - name: "Object" - } - }, - modelProperties: { - serializedName: "modelProperties", - type: { - name: "Object" - } - } - } - } -}; - -export const MachineLearningServicesModelDeployedEventData: msRest.CompositeMapper = { - serializedName: "MachineLearningServicesModelDeployedEventData", - type: { - name: "Composite", - className: "MachineLearningServicesModelDeployedEventData", - modelProperties: { - serviceName: { - serializedName: "serviceName", - type: { - name: "String" - } - }, - serviceComputeType: { - serializedName: "serviceComputeType", - type: { - name: "String" - } - }, - modelIds: { - serializedName: "modelIds", - type: { - name: "String" - } - }, - serviceTags: { - serializedName: "serviceTags", - type: { - name: "Object" - } - }, - serviceProperties: { - serializedName: "serviceProperties", - type: { - name: "Object" - } - } - } - } -}; - -export const MachineLearningServicesRunCompletedEventData: msRest.CompositeMapper = { - serializedName: "MachineLearningServicesRunCompletedEventData", - type: { - name: "Composite", - className: "MachineLearningServicesRunCompletedEventData", - modelProperties: { - experimentId: { - serializedName: "experimentId", - type: { - name: "String" - } - }, - experimentName: { - serializedName: "experimentName", - type: { - name: "String" - } - }, - runId: { - serializedName: "runId", - type: { - name: "String" - } - }, - runType: { - serializedName: "runType", - type: { - name: "String" - } - }, - runTags: { - serializedName: "runTags", - type: { - name: "Object" - } - }, - runProperties: { - serializedName: "runProperties", - type: { - name: "Object" - } - } - } - } -}; - -export const MachineLearningServicesDatasetDriftDetectedEventData: msRest.CompositeMapper = { - serializedName: "MachineLearningServicesDatasetDriftDetectedEventData", - type: { - name: "Composite", - className: "MachineLearningServicesDatasetDriftDetectedEventData", - modelProperties: { - dataDriftId: { - serializedName: "dataDriftId", - type: { - name: "String" - } - }, - dataDriftName: { - serializedName: "dataDriftName", - type: { - name: "String" - } - }, - runId: { - serializedName: "runId", - type: { - name: "String" - } - }, - baseDatasetId: { - serializedName: "baseDatasetId", - type: { - name: "String" - } - }, - targetDatasetId: { - serializedName: "targetDatasetId", - type: { - name: "String" - } - }, - driftCoefficient: { - serializedName: "driftCoefficient", - type: { - name: "Number" - } - }, - startTime: { - serializedName: "startTime", - type: { - name: "DateTime" - } - }, - endTime: { - serializedName: "endTime", - type: { - name: "DateTime" - } - } - } - } -}; - -export const discriminators = { - 'MediaJobOutput' : MediaJobOutput, - 'MediaJobOutput.#Microsoft.Media.JobOutputAsset' : MediaJobOutputAsset - -}; diff --git a/sdk/eventgrid/eventgrid/src/models/parameters.ts b/sdk/eventgrid/eventgrid/src/models/parameters.ts deleted file mode 100644 index e2fe552eddfe..000000000000 --- a/sdk/eventgrid/eventgrid/src/models/parameters.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as msRest from "@azure/ms-rest-js"; - -export const acceptLanguage: msRest.OperationParameter = { - parameterPath: "acceptLanguage", - mapper: { - serializedName: "accept-language", - defaultValue: 'en-US', - type: { - name: "String" - } - } -}; -export const apiVersion: msRest.OperationQueryParameter = { - parameterPath: "apiVersion", - mapper: { - required: true, - serializedName: "api-version", - type: { - name: "String" - } - } -}; -export const topicHostname: msRest.OperationURLParameter = { - parameterPath: "topicHostname", - mapper: { - required: true, - serializedName: "topicHostname", - defaultValue: '', - type: { - name: "String" - } - }, - skipEncoding: true -}; diff --git a/sdk/eventgrid/eventgrid/tsconfig.json b/sdk/eventgrid/eventgrid/tsconfig.json deleted file mode 100644 index 422b584abd5e..000000000000 --- a/sdk/eventgrid/eventgrid/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "module": "es6", - "moduleResolution": "node", - "strict": true, - "target": "es5", - "sourceMap": true, - "declarationMap": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], - "declaration": true, - "outDir": "./esm", - "importHelpers": true - }, - "include": ["./src/**/*.ts"], - "exclude": ["node_modules"] -} From 152bf8e8b0c2c4a531a2e87cb813cba33d3c9e4a Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 14 Jul 2020 16:29:30 -0700 Subject: [PATCH 02/34] [EventGrid] Initial commit of Track 2 client Initial commit of the Track 2 EventGrid client. Compared to the previous client, there are a few new high level features: - Sending events using the CloudEvent 1.0 schema, or a custom schema. - Authentication using a SAS Token - Generating SAS tokens - Converters to decode and consume events sent by Azure Services. --- common/config/rush/pnpm-lock.yaml | 65 +- dataplane.code-workspace | 4 + rush.json | 5 + sdk/eventgrid/eventgrid/.eslintrc.json | 4 + sdk/eventgrid/eventgrid/.nycrc | 14 + sdk/eventgrid/eventgrid/.vscode/launch.json | 76 + sdk/eventgrid/eventgrid/.vscode/settings.json | 26 + sdk/eventgrid/eventgrid/CHANGELOG.md | 7 + sdk/eventgrid/eventgrid/LICENSE | 21 + sdk/eventgrid/eventgrid/README.md | 210 + sdk/eventgrid/eventgrid/api-extractor.json | 31 + sdk/eventgrid/eventgrid/karma.conf.js | 148 + sdk/eventgrid/eventgrid/package.json | 137 + .../recording_sends_a_single_event.json | 32 + .../recording_sends_multiple_events.json | 34 + .../recording_sends_a_single_event.json | 28 + .../recording_sends_a_single_event.json | 32 + .../recording_sends_multiple_events.json | 34 + .../recording_sends_a_single_event.js | 23 + .../recording_sends_multiple_events.js | 23 + .../recording_sends_a_single_event.js | 23 + .../recording_sends_multiple_events.js | 23 + .../recording_sends_a_single_event.js | 23 + .../recording_sends_multiple_events.js | 23 + .../eventgrid/review/eventgrid.api.md | 206 + sdk/eventgrid/eventgrid/rollup.base.config.js | 134 + sdk/eventgrid/eventgrid/rollup.config.js | 14 + sdk/eventgrid/eventgrid/rollup.test.config.js | 3 + sdk/eventgrid/eventgrid/sample.env | 18 + sdk/eventgrid/eventgrid/src/constants.ts | 4 + sdk/eventgrid/eventgrid/src/consumer.ts | 170 + .../src/eventGridAuthenticationPolicy.ts | 70 + .../eventgrid/src/eventGridClient.ts | 185 + .../src/generated/generatedClient.ts | 134 + .../src/generated/generatedClientContext.ts | 42 + .../eventgrid/src/generated/models/index.ts | 3071 +++++++++++ .../eventgrid/src/generated/models/mappers.ts | 4750 +++++++++++++++++ .../src/generated/models/parameters.ts | 97 + sdk/eventgrid/eventgrid/src/index.ts | 160 + sdk/eventgrid/eventgrid/src/logger.ts | 9 + sdk/eventgrid/eventgrid/src/models.ts | 81 + sdk/eventgrid/eventgrid/src/predicates.ts | 126 + .../src/sharedAccessSignitureCredential.ts | 55 + .../eventgrid/src/systemEventDecoders.ts | 61 + sdk/eventgrid/eventgrid/src/util.ts | 63 + sdk/eventgrid/eventgrid/swagger/README.md | 52 + sdk/eventgrid/eventgrid/test/consumer.spec.ts | 169 + .../eventgrid/test/eventGridClient.spec.ts | 231 + sdk/eventgrid/eventgrid/test/util.spec.ts | 21 + .../eventgrid/test/utils/recordedClient.ts | 67 + .../eventgrid/test/utils/testData.ts | 172 + sdk/eventgrid/eventgrid/tests.yml | 19 + sdk/eventgrid/eventgrid/tsconfig.json | 17 + 53 files changed, 11246 insertions(+), 1 deletion(-) create mode 100644 sdk/eventgrid/eventgrid/.eslintrc.json create mode 100644 sdk/eventgrid/eventgrid/.nycrc create mode 100644 sdk/eventgrid/eventgrid/.vscode/launch.json create mode 100644 sdk/eventgrid/eventgrid/.vscode/settings.json create mode 100644 sdk/eventgrid/eventgrid/CHANGELOG.md create mode 100644 sdk/eventgrid/eventgrid/LICENSE create mode 100644 sdk/eventgrid/eventgrid/README.md create mode 100644 sdk/eventgrid/eventgrid/api-extractor.json create mode 100644 sdk/eventgrid/eventgrid/karma.conf.js create mode 100644 sdk/eventgrid/eventgrid/package.json create mode 100644 sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.json create mode 100644 sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.json create mode 100644 sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.json create mode 100644 sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_a_single_event.json create mode 100644 sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_multiple_events.json create mode 100644 sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.js create mode 100644 sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.js create mode 100644 sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.js create mode 100644 sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_multiple_events.js create mode 100644 sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_a_single_event.js create mode 100644 sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_multiple_events.js create mode 100644 sdk/eventgrid/eventgrid/review/eventgrid.api.md create mode 100644 sdk/eventgrid/eventgrid/rollup.base.config.js create mode 100644 sdk/eventgrid/eventgrid/rollup.config.js create mode 100644 sdk/eventgrid/eventgrid/rollup.test.config.js create mode 100644 sdk/eventgrid/eventgrid/sample.env create mode 100644 sdk/eventgrid/eventgrid/src/constants.ts create mode 100644 sdk/eventgrid/eventgrid/src/consumer.ts create mode 100644 sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts create mode 100644 sdk/eventgrid/eventgrid/src/eventGridClient.ts create mode 100644 sdk/eventgrid/eventgrid/src/generated/generatedClient.ts create mode 100644 sdk/eventgrid/eventgrid/src/generated/generatedClientContext.ts create mode 100644 sdk/eventgrid/eventgrid/src/generated/models/index.ts create mode 100644 sdk/eventgrid/eventgrid/src/generated/models/mappers.ts create mode 100644 sdk/eventgrid/eventgrid/src/generated/models/parameters.ts create mode 100644 sdk/eventgrid/eventgrid/src/index.ts create mode 100644 sdk/eventgrid/eventgrid/src/logger.ts create mode 100644 sdk/eventgrid/eventgrid/src/models.ts create mode 100644 sdk/eventgrid/eventgrid/src/predicates.ts create mode 100644 sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts create mode 100644 sdk/eventgrid/eventgrid/src/systemEventDecoders.ts create mode 100644 sdk/eventgrid/eventgrid/src/util.ts create mode 100644 sdk/eventgrid/eventgrid/swagger/README.md create mode 100644 sdk/eventgrid/eventgrid/test/consumer.spec.ts create mode 100644 sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts create mode 100644 sdk/eventgrid/eventgrid/test/util.spec.ts create mode 100644 sdk/eventgrid/eventgrid/test/utils/recordedClient.ts create mode 100644 sdk/eventgrid/eventgrid/test/utils/testData.ts create mode 100644 sdk/eventgrid/eventgrid/tests.yml create mode 100644 sdk/eventgrid/eventgrid/tsconfig.json diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 143a48beac07..960d5f68fcf1 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -18,6 +18,7 @@ dependencies: '@rush-temp/eslint-plugin-azure-sdk': 'file:projects/eslint-plugin-azure-sdk.tgz' '@rush-temp/event-hubs': 'file:projects/event-hubs.tgz' '@rush-temp/event-processor-host': 'file:projects/event-processor-host.tgz' + '@rush-temp/eventgrid': 'file:projects/eventgrid.tgz' '@rush-temp/eventhubs-checkpointstore-blob': 'file:projects/eventhubs-checkpointstore-blob.tgz' '@rush-temp/identity': 'file:projects/identity.tgz' '@rush-temp/keyvault-admin': 'file:projects/keyvault-admin.tgz' @@ -750,7 +751,7 @@ packages: integrity: sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA== /@types/resolve/0.0.8: dependencies: - '@types/node': 8.10.61 + '@types/node': 10.17.13 dev: false resolution: integrity: sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ== @@ -8335,6 +8336,66 @@ packages: integrity: sha512-QytC/CjcRtJZwlPxvYKLJ91gtaNaw860njdrpQZv0Ka1ZHwZzMkFaJPV15kGYqYrwZSz4IcBaRec90e8fccqOw== tarball: 'file:projects/event-processor-host.tgz' version: 0.0.0 + 'file:projects/eventgrid.tgz': + dependencies: + '@azure/core-tracing': 1.0.0-preview.8 + '@microsoft/api-extractor': 7.7.11 + '@opentelemetry/api': 0.6.1 + '@rollup/plugin-commonjs': 11.0.2_rollup@1.32.1 + '@rollup/plugin-json': 4.1.0_rollup@1.32.1 + '@rollup/plugin-multi-entry': 3.0.1_rollup@1.32.1 + '@rollup/plugin-node-resolve': 8.1.0_rollup@1.32.1 + '@rollup/plugin-replace': 2.3.3_rollup@1.32.1 + '@types/chai': 4.2.11 + '@types/chai-as-promised': 7.1.3 + '@types/mocha': 7.0.2 + '@types/node': 8.10.61 + '@types/sinon': 9.0.4 + '@typescript-eslint/eslint-plugin': 2.34.0_3787943315ebc5ea524d5c102dc9e452 + '@typescript-eslint/parser': 2.34.0_eslint@6.8.0+typescript@3.9.6 + chai: 4.2.0 + chai-as-promised: 7.1.1_chai@4.2.0 + cross-env: 7.0.2 + dotenv: 8.2.0 + eslint: 6.8.0 + eslint-config-prettier: 6.11.0_eslint@6.8.0 + eslint-plugin-no-null: 1.0.2_eslint@6.8.0 + eslint-plugin-no-only-tests: 2.4.0 + eslint-plugin-promise: 4.2.1 + karma: 4.4.1 + karma-chrome-launcher: 3.1.0 + karma-coverage: 2.0.2 + karma-edge-launcher: 0.4.2_karma@4.4.1 + karma-env-preprocessor: 0.1.1 + karma-firefox-launcher: 1.3.0 + karma-ie-launcher: 1.0.0_karma@4.4.1 + karma-json-preprocessor: 0.3.3_karma@4.4.1 + karma-json-to-file-reporter: 1.0.1 + karma-junit-reporter: 2.0.1_karma@4.4.1 + karma-mocha: 1.3.0 + karma-mocha-reporter: 2.2.5_karma@4.4.1 + karma-remap-istanbul: 0.6.0_karma@4.4.1 + mocha: 7.2.0 + mocha-junit-reporter: 1.23.3_mocha@7.2.0 + nyc: 14.1.1 + prettier: 1.19.1 + rimraf: 3.0.2 + rollup: 1.32.1 + rollup-plugin-shim: 1.0.0 + rollup-plugin-sourcemaps: 0.4.2_rollup@1.32.1 + rollup-plugin-terser: 5.3.0_rollup@1.32.1 + rollup-plugin-visualizer: 4.0.4_rollup@1.32.1 + sinon: 9.0.2 + source-map-support: 0.5.19 + ts-node: 8.10.2_typescript@3.9.6 + tslib: 2.0.0 + typescript: 3.9.6 + dev: false + name: '@rush-temp/eventgrid' + resolution: + integrity: sha512-q29krk9TEPgedtBlDanO3x5ERO5N+gKJn7NzwtEGLc+coLTxL0e+fvf2NeoysVJ0185wAPRts0WRDtgzuzQveg== + tarball: 'file:projects/eventgrid.tgz' + version: 0.0.0 'file:projects/eventhubs-checkpointstore-blob.tgz': dependencies: '@azure/event-hubs': 5.2.2 @@ -9462,6 +9523,7 @@ packages: integrity: sha512-wWCeWZLGFaZKJOdG2zTpsvZxIdzw5SSDZfCYo/gcI3i0/IK+ukijKncP1wy1SpQG7pnc0CRY3IaJ6UdaMI93bg== tarball: 'file:projects/testhub.tgz' version: 0.0.0 +registry: '' specifiers: '@rush-temp/abort-controller': 'file:./projects/abort-controller.tgz' '@rush-temp/ai-form-recognizer': 'file:./projects/ai-form-recognizer.tgz' @@ -9482,6 +9544,7 @@ specifiers: '@rush-temp/eslint-plugin-azure-sdk': 'file:./projects/eslint-plugin-azure-sdk.tgz' '@rush-temp/event-hubs': 'file:./projects/event-hubs.tgz' '@rush-temp/event-processor-host': 'file:./projects/event-processor-host.tgz' + '@rush-temp/eventgrid': 'file:./projects/eventgrid.tgz' '@rush-temp/eventhubs-checkpointstore-blob': 'file:./projects/eventhubs-checkpointstore-blob.tgz' '@rush-temp/identity': 'file:./projects/identity.tgz' '@rush-temp/keyvault-admin': 'file:./projects/keyvault-admin.tgz' diff --git a/dataplane.code-workspace b/dataplane.code-workspace index 6e6ac10bccc0..7306d1180dfc 100644 --- a/dataplane.code-workspace +++ b/dataplane.code-workspace @@ -52,6 +52,10 @@ "name": "cosmos", "path": "sdk\\cosmosdb\\cosmos" }, + { + "name": "eventgrid", + "path": "sdk\\eventgrid\\eventgrid" + }, { "name": "event-hubs", "path": "sdk\\eventhub\\event-hubs" diff --git a/rush.json b/rush.json index 328cd4e515e9..657ec6fc5215 100644 --- a/rush.json +++ b/rush.json @@ -407,6 +407,11 @@ "projectFolder": "common/tools/dev-tool", "versionPolicyName": "utility" }, + { + "packageName": "@azure/eventgrid", + "projectFolder": "sdk/eventgrid/eventgrid", + "versionPolicyName": "client" + }, { "packageName": "@azure/event-hubs", "projectFolder": "sdk/eventhub/event-hubs", diff --git a/sdk/eventgrid/eventgrid/.eslintrc.json b/sdk/eventgrid/eventgrid/.eslintrc.json new file mode 100644 index 000000000000..47d9fc35be4a --- /dev/null +++ b/sdk/eventgrid/eventgrid/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "plugins": ["@azure/azure-sdk"], + "extends": ["plugin:@azure/azure-sdk/azure-sdk-base"] +} diff --git a/sdk/eventgrid/eventgrid/.nycrc b/sdk/eventgrid/eventgrid/.nycrc new file mode 100644 index 000000000000..57d62a937719 --- /dev/null +++ b/sdk/eventgrid/eventgrid/.nycrc @@ -0,0 +1,14 @@ +{ + "include": [ + "dist-esm/src/**/*.js" + ], + "exclude": [ + "**/*.d.ts", + "dist-esm/src/generated/*" + ], + "exclude-after-remap": false, + "sourceMap": true, + "produce-source-map": true, + "instrument": true, + "all": true + } diff --git a/sdk/eventgrid/eventgrid/.vscode/launch.json b/sdk/eventgrid/eventgrid/.vscode/launch.json new file mode 100644 index 000000000000..0cda8fea0c32 --- /dev/null +++ b/sdk/eventgrid/eventgrid/.vscode/launch.json @@ -0,0 +1,76 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Debug Javascript Samples", + "program": "${workspaceFolder}/samples/javascript/basic.js", + "preLaunchTask": "npm: build:js-samples" + }, + { + "type": "node", + "request": "launch", + "name": "Debug Typescript Samples", + "program": "${workspaceFolder}/samples/typescript/basic.ts", + "preLaunchTask": "npm: build:ts-samples", + "outFiles": ["${workspaceFolder}/dist-esm/samples/typescript/*.js"] + }, + { + "type": "node", + "request": "launch", + "name": "Current TS File", + "args": [ + "${fileBasename}" + ], + "runtimeArgs": [ + "--nolazy", + "-r", + "ts-node/register" + ], + "env": { "TS_NODE_COMPILER_OPTIONS": "{\"module\": \"commonjs\"}" }, + "cwd": "${fileDirname}", + "sourceMaps": true, + "protocol": "inspector" + }, + { + "type": "node", + "request": "launch", + "name": "Debug Mocha Test [Without Rollup]", + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "args": [ + "-r", + "ts-node/register", + "--timeout", + "999999", + "--colors", + "${workspaceFolder}/test/*.spec.ts", + "${workspaceFolder}/test/node/*.spec.ts" + ], + "env": { "TS_NODE_COMPILER_OPTIONS": "{\"module\": \"commonjs\"}" }, + "envFile": "${workspaceFolder}/.env", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "protocol": "inspector" + }, + { + "type": "node", + "request": "launch", + "name": "Debug Unit Tests", + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "args": [ + "-u", + "tdd", + "--timeout", + "999999", + "--colors", + "${workspaceFolder}/dist-test/index.node.js" + ], + "internalConsoleOptions": "openOnSessionStart", + "preLaunchTask": "npm: build:test" + } + ] +} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/.vscode/settings.json b/sdk/eventgrid/eventgrid/.vscode/settings.json new file mode 100644 index 000000000000..c2ce48368a29 --- /dev/null +++ b/sdk/eventgrid/eventgrid/.vscode/settings.json @@ -0,0 +1,26 @@ +{ + "editor.detectIndentation": false, + "editor.formatOnSave": true, + "editor.insertSpaces": true, + "editor.tabSize": 2, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "javascript.preferences.quoteStyle": "double", + "typescript.preferences.quoteStyle": "double", + "search.exclude": { + "test-results*.xml": true, + "**/temp/*": true, + "**/dist/*": true, + "**/*.map": true, + "**/dist-*/*": true, + "**/test-dist/*": true, + "**/node_modules": true, + "**/bower_components": true, + "**/*.code-search": true, + "**/types/*": true, + "**/coverage/*": true, + "**/*.d.ts": true, + "**/test-browser/*": true + }, + "typescript.tsdk": "..\\..\\core\\core-http\\node_modules\\typescript\\lib" +} diff --git a/sdk/eventgrid/eventgrid/CHANGELOG.md b/sdk/eventgrid/eventgrid/CHANGELOG.md new file mode 100644 index 000000000000..15d4ae13e495 --- /dev/null +++ b/sdk/eventgrid/eventgrid/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 3.0.0-preview.1 (Unreleased) + +- This release is a preview of our efforts to create a client library that is user friendly and + idiomatic to the JavaScript ecosystem. The reasons for most of the changes in this update can be found in the + [Azure SDK Design Guidelines for TypeScript](https://azuresdkspecs.z5.web.core.windows.net/TypeScriptSpec.html). diff --git a/sdk/eventgrid/eventgrid/LICENSE b/sdk/eventgrid/eventgrid/LICENSE new file mode 100644 index 000000000000..ea8fb1516028 --- /dev/null +++ b/sdk/eventgrid/eventgrid/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md new file mode 100644 index 000000000000..9d327267f6a4 --- /dev/null +++ b/sdk/eventgrid/eventgrid/README.md @@ -0,0 +1,210 @@ +# Azure Event Grid client library for JavaScript + +[Azure Event Grid](https://azure.microsoft.com/en-us/services/event-grid/) is a cloud-based service that provides reliable event delivery at massive scale. + +Use the client library to: + +- Send events to Event Grid using either the Event Grid, Cloud Events 1.0 schemas, or a custom schema +- Decode and process events where were delivered to an Event Grid handler +- Generate Shared Access Signatures for Event Grid topics + +[Source code](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/eventgrid/eventgrid/) | +[Package (NPM)](https://www.npmjs.com/package/@azure/eventgrid) | +[API reference documentation](https://aka.ms/azsdk-js-eventgrid-ref-docs) | +[Product documentation](https://docs.microsoft.com/en-us/azure/event-grid/) | +[Samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/eventgrid/eventgrid/samples) + +## Getting started + +### Currently supported environments + +- Node.js version 8.x.x or higher + +### Prerequisites + +- An [Azure subscription][azure_sub]. +- An existing [Event Grid][event_grid] Topic or Domain. If you need to create the resource, you can use the [Azure Portal][azure_portal] or [Azure CLI][azure_cli]. + +If you use the Azure CLI, replace `` and `` with your own unique names and `` with an + +#### Create an Event Grid Topic + +```bash +az eventgrid topic create --location --resource-group --name +``` + +#### Create an Event Grid Domain + +```bash +az eventgrid domain create --location --resource-group --name +``` + +### Install the `@azure/eventgrid` package + +Install the Azure Event Grid client library for JavaScript with `npm`: + +```bash +npm install @azure/eventgrid +``` + +### Create and authenticate a `EventGridClient` + +To create a client object to access the Event Grid API, you will need the `endpoint` of your Event Grid topic and a `credential`. The Event Grid client can use either an Access Key or Shared Access Signature (SAS) created from an access key. + +You can find the endpoint for your Event Grid topic either in the [Azure Portal][azure_portal] or by using the [Azure CLI][azure_cli] snippet below: + +```bash +az eventgrid topic show --name --resource-group --query "endpoint" +``` + +#### Using an Access Key + +Use the [Azure Portal][azure_portal] to browse to your Event Grid resource and retrieve an Acess Key, or use the [Azure CLI][azure_cli] snippet below: + +```bash +az eventgrid topic key list --resource-group --name +``` + +Once you have an API key and endpoint, you can use the `AzureKeyCredential` class to authenticate the client as follows: + +```js +const { EventGridClient, AzureKeyCredential } = require("@azure/eventgrid"); + +const client = new EventGridClient("", new AzureKeyCredential("")); +``` + +#### Using a SAS Token + +Like an access key, a SAS token allows access to sending events to an Event Grid topic. Unlike an access key, which can be used until it is regenerated, a SAS token has an experation time, at which point it is no longer valid. To use a SAS token for authentication, use the `EventGridSharedAccesSignatureCredential` as follows: + +```js +const { EventGridClient, EventGridSharedAccessSignatureCredential } = require("@azure/eventgrid"); + +const client = new EventGridClient( + "", + new EventGridSharedAccessSignatureCredential("") +); +``` + +You can generate a SAS token by using the `generateSharedAccessSigniture` instance method on the `EventGridClient` type. Because the Topic's Access Key is used as part of generating the SAS token, you need to create the `EventGridClient` using an Access Key: + +```js +const { EventGridClient, AzureKeyCredential } = require("@azure/eventgrid"); + +const client = new EventGridClient("", new AzureKeyCredential("")); + +// Create a SAS Token which expires on 2020-01-01 at Midnight. +const token = client.generateSharedAccessSignature( + generateSharedAccessSignature(new Date(2020, 0, 1, 0, 0, 0)) +); +``` + +## Key concepts + +### EventGridClient + +`EventGridClient` is used sending events to an Event Grid Topic or an Event Grid Domain. + +### Event Schemas + +Event Grid supports multiple schemas for encoding events. When a Custom Topic or Domain is created, you specify the schema that will be used when publishing events. While you may configure your topic to use a _custom schema_ it is more common to use the already defined _Event Grid schema_ or _CloudEvents 1.0 schema_. [CloudEvents](https://cloudevents.io/) is a Cloud Native Computing Foundation project which produces a specification for describing event data in a common way. Regardless of what schmea your topic or domain is configured to use, `EventGridClient` will be used to publish events to it. However, you must use the correct method for publishing: + +| Schema | Publishing Method | +| ------------ | --------------------- | +| Event Grid | `publishEvents` | +| Cloud Events | `publishCloudEvents` | +| Custom | `publishCustomEvents` | + +Using the wrong method will result in an error from the service and your events will not be published. + +### EventGridConsumer + +TODO + +## Examples + +### Publish a Custom Event to an Event Grid Topic + +```js +const { v4: uuidv4 } = require("uuid"); +const { EventGridClient, AzureKeyCredential } = require("@azure/eventgrid"); + +const client = new EventGridClient("", new AzureKeyCredential("")); + +await client.sendEvents([ + { + id: uuidv4(), + eventTime: new Date(), + eventType: "Azure.Sdk.SampleEvent", + subject: "Event Subject", + dataVersion: "1.0", + data: { + hello: "world" + } + } +]); +``` + +### Publish a Custom Event to a Topic in an Event Grid Domain + +Publishing events to an Event Grid Domain is similar to publish to an Event Grid Topic, except that when using the Event Grid schema for events, you must include the `topic` property. When publishing events in the Cloud Events 1.0 schema, the required `source` property is used as the name of the topic in the domain to publish to + +```js +const { v4: uuidv4 } = require("uuid"); +const { EventGridClient, AzureKeyCredential } = require("@azure/eventgrid"); + +const client = new EventGridClient("", new AzureKeyCredential("")); + +await client.sendEvents([ + { + id: uuidv4(), + eventTime: new Date(), + topic: "my-sample-topic", + eventType: "Azure.Sdk.SampleEvent", + subject: "Event Subject", + dataVersion: "1.0", + data: { + hello: "world" + } + } +]); +``` + +### Decoding an Event + +TODO + +## Troubleshooting + +### Enable logs + +You can set the following environment variable to get the debug logging output when using this library. + +- Getting debug logs from the Azure Event Grid client library + +```bash +export AZURE_LOG_LEVEL=verbose +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/logger). + +## Next steps + +Please take a look at the +[samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/eventgrid/eventgrid/samples) +directory for detailed examples on how to use this library. + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/master/CONTRIBUTING.md) to learn more about how to build and test the code. + +## Related projects + +- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Feventgrid%2Feventgrid%2FREADME.png) + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_sub]: https://azure.microsoft.com/free/ +[event_grid]: https://docs.microsoft.com/en-us/azure/event-grid +[azure_portal]: https://portal.azure.com diff --git a/sdk/eventgrid/eventgrid/api-extractor.json b/sdk/eventgrid/eventgrid/api-extractor.json new file mode 100644 index 000000000000..b4df7e187999 --- /dev/null +++ b/sdk/eventgrid/eventgrid/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "types/src/index.d.ts", + "docModel": { + "enabled": false + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/eventgrid.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} diff --git a/sdk/eventgrid/eventgrid/karma.conf.js b/sdk/eventgrid/eventgrid/karma.conf.js new file mode 100644 index 000000000000..0b74b8bcbd5e --- /dev/null +++ b/sdk/eventgrid/eventgrid/karma.conf.js @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// https://github.com/karma-runner/karma-chrome-launcher +process.env.CHROME_BIN = require("puppeteer").executablePath(); +require("dotenv").config(); +const { + jsonRecordingFilterFunction, + isPlaybackMode, + isSoftRecordMode, + isRecordMode +} = require("@azure/test-utils-recorder"); + +module.exports = function(config) { + config.set({ + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: "./", + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ["mocha"], + + plugins: [ + "karma-mocha", + "karma-mocha-reporter", + "karma-chrome-launcher", + "karma-edge-launcher", + "karma-firefox-launcher", + "karma-ie-launcher", + "karma-env-preprocessor", + "karma-coverage", + "karma-remap-istanbul", + "karma-junit-reporter", + "karma-json-to-file-reporter", + "karma-json-preprocessor" + ], + + // list of files / patterns to load in the browser + files: ["dist-test/index.browser.js"].concat( + isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : [] + ), + + // list of files / patterns to exclude + exclude: [], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + "**/*.js": ["env"], + "recordings/browsers/**/*.json": ["json"] + // IMPORTANT: COMMENT following line if you want to debug in your browsers!! + // Preprocess source file to calculate code coverage, however this will make source file unreadable + // "test-browser/index.js": ["coverage"] + }, + + envPreprocessor: [ + "TEST_MODE", + "EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT", + "EVENT_GRID_EVENT_GRID_SCHEMA_API_KEY", + "EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT", + "EVENT_GRID_CUSTOM_SCHEMA_API_KEY", + "EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT", + "EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY", + ], + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ["mocha", "coverage", "karma-remap-istanbul", "junit", "json-to-file"], + + coverageReporter: { + // specify a common output directory + dir: "coverage-browser/", + reporters: [{ type: "json", subdir: ".", file: "coverage.json" }] + }, + + remapIstanbulReporter: { + src: "coverage-browser/coverage.json", + reports: { + lcovonly: "coverage-browser/lcov.info", + html: "coverage-browser/html/report", + "text-summary": null, + cobertura: "./coverage-browser/cobertura-coverage.xml" + } + }, + + junitReporter: { + outputDir: "", // results will be saved as $outputDir/$browserName.xml + outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile + suite: "", // suite will become the package name attribute in xml testsuite element + useBrowserName: false, // add browser name to report and classes names + nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element + classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element + properties: {} // key value pair of properties to add to the section of the report + }, + + jsonToFileReporter: { + filter: jsonRecordingFilterFunction, + outputPath: "." + }, + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: false, + + // --no-sandbox allows our tests to run in Linux without having to change the system. + // --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex. + browsers: ["ChromeHeadlessNoSandbox"], + customLaunchers: { + ChromeHeadlessNoSandbox: { + base: "ChromeHeadless", + flags: ["--no-sandbox", "--disable-web-security"] + } + }, + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: 1, + + browserNoActivityTimeout: 600000, + browserDisconnectTimeout: 10000, + browserDisconnectTolerance: 3, + browserConsoleLogOptions: { + terminal: !isRecordMode() + }, + + client: { + mocha: { + // change Karma's debug.html to the mocha web reporter + reporter: "html", + timeout: "600000" + } + } + }); +}; diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json new file mode 100644 index 000000000000..dda932dafbee --- /dev/null +++ b/sdk/eventgrid/eventgrid/package.json @@ -0,0 +1,137 @@ +{ + "name": "@azure/eventgrid", + "sdk-type": "client", + "author": "Microsoft Corporation", + "description": "An isomorphic client library for the Azure Event Grid service.", + "version": "3.0.0-preview.1", + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/src/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/eventgrid.d.ts", + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/eventgrid/eventgrid", + "repository": { + "type": "git", + "url": "https://github.com/Azure/azure-sdk-for-js.git" + }, + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/", + "dist-esm/src/", + "types/eventgrid.d.ts", + "README.md", + "LICENSE" + ], + "//metadata": { + "constantPaths": [ + { + "path": "src/generated/generatedClientContext.ts", + "prefix": "packageVersion" + }, + { + "path": "src/constants.ts", + "prefix": "SDK_VERSION" + } + ] + }, + "scripts": { + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "build:autorest": "autorest ./swagger/README.md --typescript --v3", + "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1", + "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1", + "build:samples": "node ../../../common/scripts/prep-samples.js && cd samples && tsc -p .", + "build:test": "tsc -p . && rollup -c rollup.test.config.js 2>&1", + "build": "tsc -p . && rollup -c 2>&1 && api-extractor run --local", + "check-format": "prettier --list-different --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "execute:js-samples": "node ../../../common/scripts/run-samples.js samples/javascript/", + "execute:ts-samples": "node ../../../common/scripts/run-samples.js samples/typescript/dist/samples/typescript/src/", + "execute:samples": "npm run build:samples && npm run execute:js-samples && npm run execute:ts-samples", + "extract-api": "tsc -p . && api-extractor run --local", + "format": "prettier --write --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "integration-test:browser": "karma start --single-run", + "integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace dist-esm/test/**/*.spec.js", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "lint:fix": "eslint \"src/**/*.ts\" --fix --fix-type [problem,suggestion]", + "lint": "eslint src --ext .ts -f html -o textAnalytics-lintReport.html", + "pack": "npm pack 2>&1", + "prebuild": "npm run clean", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", + "test:node": "npm run clean && npm run build:test && npm run unit-test:node", + "test": "npm run clean && npm run build:test && npm run unit-test", + "unit-test:browser": "karma start --single-run", + "unit-test:node": "mocha --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace dist-test/index.node.js", + "unit-test": "npm run unit-test:node && npm run unit-test:browser" + }, + "sideEffects": false, + "autoPublish": false, + "dependencies": { + "@azure/core-auth": "^1.1.3", + "@azure/core-http": "^1.1.4", + "@azure/core-tracing": "1.0.0-preview.8", + "@azure/logger": "^1.0.0", + "@opentelemetry/api": "^0.6.1", + "tslib": "^2.0.0" + }, + "devDependencies": { + "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@azure/test-utils-recorder": "^1.0.0", + "@microsoft/api-extractor": "7.7.11", + "@rollup/plugin-commonjs": "11.0.2", + "@rollup/plugin-json": "^4.0.0", + "@rollup/plugin-multi-entry": "^3.0.0", + "@rollup/plugin-node-resolve": "^8.0.0", + "@rollup/plugin-replace": "^2.2.0", + "@types/chai": "^4.1.6", + "@types/chai-as-promised": "^7.1.0", + "@types/mocha": "^7.0.2", + "@types/node": "^8.0.0", + "@types/sinon": "^9.0.4", + "@typescript-eslint/eslint-plugin": "^2.0.0", + "@typescript-eslint/parser": "^2.0.0", + "chai": "^4.2.0", + "chai-as-promised": "^7.1.1", + "cross-env": "^7.0.2", + "dotenv": "^8.2.0", + "eslint": "^6.1.0", + "eslint-config-prettier": "^6.0.0", + "eslint-plugin-no-null": "^1.0.2", + "eslint-plugin-no-only-tests": "^2.3.0", + "eslint-plugin-promise": "^4.1.1", + "karma": "^4.0.1", + "karma-chrome-launcher": "^3.0.0", + "karma-coverage": "^2.0.0", + "karma-edge-launcher": "^0.4.2", + "karma-env-preprocessor": "^0.1.1", + "karma-firefox-launcher": "^1.1.0", + "karma-ie-launcher": "^1.0.0", + "karma-json-preprocessor": "^0.3.3", + "karma-json-to-file-reporter": "^1.0.1", + "karma-junit-reporter": "^2.0.1", + "karma-mocha": "^1.3.0", + "karma-mocha-reporter": "^2.2.5", + "karma-remap-istanbul": "^0.6.0", + "mocha": "^7.1.1", + "mocha-junit-reporter": "^1.18.0", + "nyc": "^14.0.0", + "prettier": "^1.16.4", + "rimraf": "^3.0.0", + "rollup": "^1.16.3", + "rollup-plugin-shim": "^1.0.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "rollup-plugin-terser": "^5.1.1", + "rollup-plugin-visualizer": "^4.0.4", + "sinon": "^9.0.2", + "source-map-support": "^0.5.9", + "ts-node": "^8.3.0", + "typescript": "~3.9.3" + } +} diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.json new file mode 100644 index 000000000000..4e655f55c7e0 --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.json @@ -0,0 +1,32 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://endpoint/api/events", + "query": { + "api-version": "2018-01-01" + }, + "requestBody": "[{\"id\":\"cloudSingleEventId159477577224000148\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"data\":{\"hello\":\"world\"},\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-15T01:16:12.240Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\"}]", + "status": 200, + "response": "", + "responseHeaders": { + "api-supported-versions": "2018-01-01", + "content-length": "0", + "date": "Wed, 15 Jul 2020 01:16:13 GMT", + "server": "Microsoft-HTTPAPI/2.0", + "status": "200", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-request-id": "2b8da935-3c99-44f3-9470-e961f69f3824" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "cloudSingleEventId": "cloudSingleEventId159477577224000148" + }, + "newDate": { + "cloudSingleEventDate": "2020-07-15T01:16:12.240Z" + } + }, + "hash": "7fe25ee020ac364dae32ce81a81c7c3f" +} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.json new file mode 100644 index 000000000000..80324bc4251b --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.json @@ -0,0 +1,34 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://endpoint/api/events", + "query": { + "api-version": "2018-01-01" + }, + "requestBody": "[{\"id\":\"cloudMultiEventId1159477577228005600\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"data\":{\"hello\":\"world\"},\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-15T01:16:12.281Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"Multiple 1\"},{\"id\":\"cloudMultiEventId2159477577228106649\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"data\":{\"hello\":\"world\"},\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-15T01:16:12.281Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"Multiple 2\"}]", + "status": 200, + "response": "", + "responseHeaders": { + "api-supported-versions": "2018-01-01", + "content-length": "0", + "date": "Wed, 15 Jul 2020 01:16:13 GMT", + "server": "Microsoft-HTTPAPI/2.0", + "status": "200", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-request-id": "6f458132-db81-4cea-824d-f633633fdc48" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "cloudMultiEventId1": "cloudMultiEventId1159477577228005600", + "cloudMultiEventId2": "cloudMultiEventId2159477577228106649" + }, + "newDate": { + "cloudMultiEventDate1": "2020-07-15T01:16:12.281Z", + "cloudMultiEventDate2": "2020-07-15T01:16:12.281Z" + } + }, + "hash": "799392d36931d99dc2c24d3db67fcb0b" +} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.json new file mode 100644 index 000000000000..ee7df2bb7a9a --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.json @@ -0,0 +1,28 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://endpoint/api/events", + "query": { + "api-version": "2018-01-01" + }, + "requestBody": "[{\"ver\":\"1.0\",\"typ\":\"Azure.Sdk.TestEvent1\",\"sub\":\"Single\",\"payload\":{\"hello\":\"world\"}}]", + "status": 200, + "response": "", + "responseHeaders": { + "api-supported-versions": "2018-01-01", + "content-length": "0", + "date": "Wed, 15 Jul 2020 01:16:13 GMT", + "server": "Microsoft-HTTPAPI/2.0", + "status": "200", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-request-id": "569e58b3-97f9-4392-8c4b-a98c29fc9b08" + } + } + ], + "uniqueTestInfo": { + "uniqueName": {}, + "newDate": {} + }, + "hash": "3aa867d763b256df1511358d9616f18f" +} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_a_single_event.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_a_single_event.json new file mode 100644 index 000000000000..1b1651caee2f --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_a_single_event.json @@ -0,0 +1,32 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://endpoint/api/events", + "query": { + "api-version": "2018-01-01" + }, + "requestBody": "[{\"id\":\"singleEventId159477576968000871\",\"subject\":\"Single 1\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-15T01:16:09.680Z\",\"dataVersion\":\"1.0\"}]", + "status": 200, + "response": "", + "responseHeaders": { + "api-supported-versions": "2018-01-01", + "content-length": "0", + "date": "Wed, 15 Jul 2020 01:16:13 GMT", + "server": "Microsoft-HTTPAPI/2.0", + "status": "200", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-request-id": "2e8240bd-678e-453c-b63c-31d076f8c3c7" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "singleEventId": "singleEventId159477576968000871" + }, + "newDate": { + "singleEventDate": "2020-07-15T01:16:09.680Z" + } + }, + "hash": "9b44e18369316233af4458904ca8ae09" +} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_multiple_events.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_multiple_events.json new file mode 100644 index 000000000000..f66296c3e8fd --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_multiple_events.json @@ -0,0 +1,34 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://endpoint/api/events", + "query": { + "api-version": "2018-01-01" + }, + "requestBody": "[{\"id\":\"multiEventId1159477577219008240\",\"subject\":\"Multiple 1\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-15T01:16:12.190Z\",\"dataVersion\":\"1.0\"},{\"id\":\"multiEventId2159477577219001904\",\"subject\":\"Multiple 2\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-15T01:16:12.190Z\",\"dataVersion\":\"1.0\"}]", + "status": 200, + "response": "", + "responseHeaders": { + "api-supported-versions": "2018-01-01", + "content-length": "0", + "date": "Wed, 15 Jul 2020 01:16:13 GMT", + "server": "Microsoft-HTTPAPI/2.0", + "status": "200", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-request-id": "9bc216fc-b6e9-468d-a1c1-7f3e4a803d4e" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "multiEventId1": "multiEventId1159477577219008240", + "multiEventId2": "multiEventId2159477577219001904" + }, + "newDate": { + "multiEventDate1": "2020-07-15T01:16:12.190Z", + "multiEventDate2": "2020-07-15T01:16:12.190Z" + } + }, + "hash": "a1eefb69b1513dc523f50ee66055787d" +} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.js new file mode 100644 index 000000000000..862865535296 --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.js @@ -0,0 +1,23 @@ +let nock = require('nock'); + +module.exports.hash = "b15b1edb6fd215ff27f66c70053afbb8"; + +module.exports.testInfo = {"uniqueName":{"cloudSingleEventId":"cloudSingleEventId159477576171608507"},"newDate":{"cloudSingleEventDate":"2020-07-15T01:16:01.716Z"}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/api/events', [{"id":"cloudSingleEventId159477576171608507","source":"/earth/unitedstates/washington/kirkland/finnhill","data":{"hello":"world"},"type":"Azure.Sdk.TestEvent1","time":"2020-07-15T01:16:01.716Z","specversion":"1.0","datacontenttype":"application/json"}]) + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Server', + 'Microsoft-HTTPAPI/2.0', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'api-supported-versions', + '2018-01-01', + 'x-ms-request-id', + '76b94efe-2678-47c5-9874-5bce255ef496', + 'Date', + 'Wed, 15 Jul 2020 01:16:02 GMT' +]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.js new file mode 100644 index 000000000000..849bd8cdfba1 --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.js @@ -0,0 +1,23 @@ +let nock = require('nock'); + +module.exports.hash = "cefc29910fbb6c53981faf8430a3521b"; + +module.exports.testInfo = {"uniqueName":{"cloudMultiEventId1":"cloudMultiEventId1159477576192000975","cloudMultiEventId2":"cloudMultiEventId2159477576192004669"},"newDate":{"cloudMultiEventDate1":"2020-07-15T01:16:01.920Z","cloudMultiEventDate2":"2020-07-15T01:16:01.920Z"}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/api/events', [{"id":"cloudMultiEventId1159477576192000975","source":"/earth/unitedstates/washington/kirkland/finnhill","data":{"hello":"world"},"type":"Azure.Sdk.TestEvent1","time":"2020-07-15T01:16:01.920Z","specversion":"1.0","datacontenttype":"application/json","subject":"Multiple 1"},{"id":"cloudMultiEventId2159477576192004669","source":"/earth/unitedstates/washington/kirkland/finnhill","data":{"hello":"world"},"type":"Azure.Sdk.TestEvent1","time":"2020-07-15T01:16:01.920Z","specversion":"1.0","datacontenttype":"application/json","subject":"Multiple 2"}]) + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Server', + 'Microsoft-HTTPAPI/2.0', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'api-supported-versions', + '2018-01-01', + 'x-ms-request-id', + '5a7beed2-2df1-4d8b-887a-267d7c638fa3', + 'Date', + 'Wed, 15 Jul 2020 01:16:02 GMT' +]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.js new file mode 100644 index 000000000000..2dbbeed00f46 --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.js @@ -0,0 +1,23 @@ +let nock = require('nock'); + +module.exports.hash = "3243d9d0032a64c42cdeaf331c65085e"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/api/events', [{"ver":"1.0","typ":"Azure.Sdk.TestEvent1","sub":"Single","payload":{"hello":"world"}}]) + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Server', + 'Microsoft-HTTPAPI/2.0', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'api-supported-versions', + '2018-01-01', + 'x-ms-request-id', + '1c2dc6b2-5466-49e4-be00-1238811fe55c', + 'Date', + 'Wed, 15 Jul 2020 01:16:02 GMT' +]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_multiple_events.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_multiple_events.js new file mode 100644 index 000000000000..f8341da1163e --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_multiple_events.js @@ -0,0 +1,23 @@ +let nock = require('nock'); + +module.exports.hash = "d76e8a9024ff01c8e6c19fad4188cddb"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/api/events', [{"ver":"1.0","typ":"Azure.Sdk.TestEvent1","sub":"Multiple 1","payload":{"hello":"world"}},{"ver":"1.0","typ":"Azure.Sdk.TestEvent1","sub":"Multiple 2","payload":{"hello":"world"}}]) + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Server', + 'Microsoft-HTTPAPI/2.0', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'api-supported-versions', + '2018-01-01', + 'x-ms-request-id', + 'bf74ae91-2aa5-4373-8c4b-7dc77dcc6617', + 'Date', + 'Wed, 15 Jul 2020 01:16:03 GMT' +]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_a_single_event.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_a_single_event.js new file mode 100644 index 000000000000..82571eb58578 --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_a_single_event.js @@ -0,0 +1,23 @@ +let nock = require('nock'); + +module.exports.hash = "93ae44857b9e0329bc4ac9a07e444214"; + +module.exports.testInfo = {"uniqueName":{"singleEventId":"singleEventId159477576134002891"},"newDate":{"singleEventDate":"2020-07-15T01:16:01.340Z"}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/api/events', [{"id":"singleEventId159477576134002891","subject":"Single 1","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-15T01:16:01.340Z","dataVersion":"1.0"}]) + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Server', + 'Microsoft-HTTPAPI/2.0', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'api-supported-versions', + '2018-01-01', + 'x-ms-request-id', + 'b422b307-f041-46ef-a5d2-02ca35ab02be', + 'Date', + 'Wed, 15 Jul 2020 01:16:02 GMT' +]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_multiple_events.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_multiple_events.js new file mode 100644 index 000000000000..a38ade6f6182 --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_multiple_events.js @@ -0,0 +1,23 @@ +let nock = require('nock'); + +module.exports.hash = "b8c32c266a21a9129c07d237cc8e3d2b"; + +module.exports.testInfo = {"uniqueName":{"multiEventId1":"multiEventId1159477576164006772","multiEventId2":"multiEventId2159477576164007351"},"newDate":{"multiEventDate1":"2020-07-15T01:16:01.640Z","multiEventDate2":"2020-07-15T01:16:01.640Z"}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/api/events', [{"id":"multiEventId1159477576164006772","subject":"Multiple 1","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-15T01:16:01.640Z","dataVersion":"1.0"},{"id":"multiEventId2159477576164007351","subject":"Multiple 2","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-15T01:16:01.640Z","dataVersion":"1.0"}]) + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Server', + 'Microsoft-HTTPAPI/2.0', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'api-supported-versions', + '2018-01-01', + 'x-ms-request-id', + '8dbf7cf8-b65d-4d88-bc45-05cab784986b', + 'Date', + 'Wed, 15 Jul 2020 01:16:02 GMT' +]); diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md new file mode 100644 index 000000000000..e1d9e0f60717 --- /dev/null +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -0,0 +1,206 @@ +## API Report File for "@azure/eventgrid" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { AzureKeyCredential } from '@azure/core-auth'; +import { KeyCredential } from '@azure/core-auth'; +import { OperationOptions } from '@azure/core-http'; +import { PipelineOptions } from '@azure/core-http'; +import { RestResponse } from '@azure/core-http'; + +export { AzureKeyCredential } + +// @public +export interface CloudEvent { + [keyof: string]: any; + data?: T; + datacontenttype?: string; + dataschema?: string; + id: string; + source: string; + subject?: string; + time?: Date; + type: string; +} + +// @public +export interface ContainerRegistryArtifactEventData { + action?: string; + id?: string; + target?: ContainerRegistryArtifactEventTarget; + timestamp?: Date; +} + +// @public +export interface ContainerRegistryArtifactEventTarget { + digest?: string; + mediaType?: string; + name?: string; + repository?: string; + size?: number; + tag?: string; + version?: string; +} + +// @public +export type ContainerRegistryChartDeletedEventData = ContainerRegistryArtifactEventData & {}; + +// @public +export type ContainerRegistryChartPushedEventData = ContainerRegistryArtifactEventData & {}; + +// @public +export interface ContainerRegistryEventActor { + name?: string; +} + +// @public +export interface ContainerRegistryEventData { + action?: string; + actor?: ContainerRegistryEventActor; + id?: string; + request?: ContainerRegistryEventRequest; + source?: ContainerRegistryEventSource; + target?: ContainerRegistryEventTarget; + timestamp?: Date; +} + +// @public +export interface ContainerRegistryEventRequest { + addr?: string; + host?: string; + id?: string; + method?: string; + useragent?: string; +} + +// @public +export interface ContainerRegistryEventSource { + addr?: string; + instanceID?: string; +} + +// @public +export interface ContainerRegistryEventTarget { + digest?: string; + length?: number; + mediaType?: string; + repository?: string; + size?: number; + tag?: string; + url?: string; +} + +// @public +export type ContainerRegistryImageDeletedEventData = ContainerRegistryEventData & {}; + +// @public +export type ContainerRegistryImagePushedEventData = ContainerRegistryEventData & {}; + +// @public +export class EventGridClient { + constructor(endpointUrl: string, credential: KeyCredential | SignatureCredential, options?: EventGridClientOptions); + readonly apiVersion: string; + readonly endpointUrl: string; + generateSharedAccessSignature(expiresOnUtc: Date): string; + sendCloudEvents(events: CloudEvent[], options?: SendCloudEventsOptions): Promise; + sendCustomSchemaEvents(events: Record[], options?: SendCustomSchemaEventsOptions): Promise; + sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise; +} + +// @public +export type EventGridClientOptions = PipelineOptions; + +// @public +export class EventGridConsumer { + constructor(decoders?: Record); + // Warning: (ae-forgotten-export) The symbol "CustomEventDataDecoder" needs to be exported by the entry point index.d.ts + // + // (undocumented) + readonly customDecoders: Record; + decodeCloudEvents(encodedEvents: string): Promise[]>; + decodeCloudEvents(encodedEvents: object): Promise[]>; + decodeEventGridEvents(encodedEvents: string): Promise[]>; + decodeEventGridEvents(encodedEvents: object): Promise[]>; +} + +// @public +export interface EventGridEvent { + data: T; + dataVersion: string; + eventTime: Date; + eventType: string; + id: string; + subject: string; + topic?: string; +} + +// @public +export class EventGridSharedAccessSignatureCredential implements SignatureCredential { + constructor(signature: string); + get signature(): string; + update(newSignature: string): void; +} + +// @public +export interface EventHubCaptureFileCreatedEventData { + eventCount?: number; + fileType?: string; + fileurl?: string; + firstEnqueueTime?: Date; + firstSequenceNumber?: number; + lastEnqueueTime?: Date; + lastSequenceNumber?: number; + partitionId?: string; + sizeInBytes?: number; +} + +// @public +export function isContainerRegistryChartDeletedEvent(event: EventGridEvent): event is EventGridEvent; + +// @public +export function isContainerRegistryChartDeletedEvent(event: CloudEvent): event is CloudEvent; + +// @public +export function isContainerRegistryChartPushedEvent(event: EventGridEvent): event is EventGridEvent; + +// @public +export function isContainerRegistryChartPushedEvent(event: CloudEvent): event is CloudEvent; + +// @public +export function isContainerRegistryImageDeletedEvent(event: EventGridEvent): event is EventGridEvent; + +// @public +export function isContainerRegistryImageDeletedEvent(event: CloudEvent): event is CloudEvent; + +// @public +export function isContainerRegistryImagePushedEvent(event: EventGridEvent): event is EventGridEvent; + +// @public +export function isContainerRegistryImagePushedEvent(event: CloudEvent): event is CloudEvent; + +// @public +export function isEventHubCaptureFileCreatedEvent(event: EventGridEvent): event is EventGridEvent; + +// @public +export function isEventHubCaptureFileCreatedEvent(event: CloudEvent): event is CloudEvent; + +// @public +export type SendCloudEventsOptions = OperationOptions; + +// @public +export type SendCustomSchemaEventsOptions = OperationOptions; + +// @public +export type SendEventsOptions = OperationOptions; + +// @public +export interface SignatureCredential { + signature: string; +} + + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/eventgrid/eventgrid/rollup.base.config.js b/sdk/eventgrid/eventgrid/rollup.base.config.js new file mode 100644 index 000000000000..3ddc3cbf7a42 --- /dev/null +++ b/sdk/eventgrid/eventgrid/rollup.base.config.js @@ -0,0 +1,134 @@ +import path from "path"; +import nodeResolve from "@rollup/plugin-node-resolve"; +import multiEntry from "@rollup/plugin-multi-entry"; +import cjs from "@rollup/plugin-commonjs"; +import replace from "@rollup/plugin-replace"; +import shim from "rollup-plugin-shim"; +import { terser } from "rollup-plugin-terser"; +import sourcemaps from "rollup-plugin-sourcemaps"; +import viz from "rollup-plugin-visualizer"; + +const pkg = require("./package.json"); +const depNames = Object.keys(pkg.dependencies); +const devDepNames = Object.keys(pkg.devDependencies); +const input = "dist-esm/src/index.js"; +const production = process.env.NODE_ENV === "production"; + +export function nodeConfig(test = false) { + const externalNodeBuiltins = []; + const baseConfig = { + input: input, + external: depNames.concat(externalNodeBuiltins), + output: { file: "dist/src/index.js", format: "cjs", sourcemap: true }, + preserveSymlinks: false, + plugins: [ + sourcemaps(), + replace({ + delimiters: ["", ""], + values: { + // replace dynamic checks with if (true) since this is for node only. + // Allows rollup's dead code elimination to be more aggressive. + "if (isNode)": "if (true)" + } + }), + nodeResolve({ preferBuiltins: true }), + cjs() + ] + }; + + if (test) { + // Entry points - test files under the `test` folder(common for both browser and node), node specific test files + baseConfig.input = ["dist-esm/test/*.spec.js", "dist-esm/test/node/*.spec.js"]; + baseConfig.plugins.unshift(multiEntry({ exports: false })); + + // different output file + baseConfig.output.file = "dist-test/index.node.js"; + + // mark devdeps as external + baseConfig.external.push(...devDepNames); + + // Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting + // the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also + // applies to test code, which causes all tests to be removed by tree-shaking. + baseConfig.treeshake = false; + } else if (production) { + baseConfig.plugins.push(terser()); + } + + return baseConfig; +} + +export function browserConfig(test = false, production = false) { + const baseConfig = { + input: input, + output: { + file: "dist-browser/azure-eventgrid.js", + format: "umd", + name: "Azure.MessagingEventGrid", + sourcemap: true, + globals: { "@azure/core-http": "Azure.Core.HTTP" } + }, + preserveSymlinks: false, + external: ["fs-extra"], + plugins: [ + sourcemaps(), + replace({ + delimiters: ["", ""], + values: { + // replace dynamic checks with if (false) since this is for + // browser only. Rollup's dead code elimination will remove + // any code guarded by if (isNode) { ... } + "if (isNode)": "if (false)" + } + }), + shim({ + constants: `export default {}`, + fs: `export default {}`, + os: `export default {}`, + dotenv: `export function config() { }`, + path: `export default {}` + }), + nodeResolve({ + mainFields: ["module", "browser"], + preferBuiltins: false + }), + cjs({ + namedExports: { + chai: ["assert", "expect", "use"], + events: ["EventEmitter"], + "@opentelemetry/api": ["CanonicalCode", "SpanKind", "TraceFlags"] + } + }), + viz({ filename: "dist-browser/browser-stats.html", sourcemap: false }) + ] + }; + + if (test) { + // Entry points - test files under the `test` folder(common for both browser and node), browser specific test files + baseConfig.input = ["dist-esm/test/*.spec.js", "dist-esm/test/browser/*.spec.js"]; + baseConfig.plugins.unshift(multiEntry({ exports: false })); + baseConfig.output.file = "dist-test/index.browser.js"; + + baseConfig.onwarn = (warning) => { + if ( + warning.code === "CIRCULAR_DEPENDENCY" && + warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0) + ) { + // Chai contains circular references, but they are not fatal and can be ignored. + return; + } + + console.error(`(!) ${warning.message}`); + }; + + // Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting + // the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also + // applies to test code, which causes all tests to be removed by tree-shaking. + baseConfig.treeshake = false; + } else if (production) { + baseConfig.output.file = "dist-browser/azure-eventgrid.min.js"; + baseConfig.plugins.push(terser()); + } + + return baseConfig; +} diff --git a/sdk/eventgrid/eventgrid/rollup.config.js b/sdk/eventgrid/eventgrid/rollup.config.js new file mode 100644 index 000000000000..49a26bd6fdd6 --- /dev/null +++ b/sdk/eventgrid/eventgrid/rollup.config.js @@ -0,0 +1,14 @@ +import * as base from "./rollup.base.config"; + +const inputs = []; + +if (!process.env.ONLY_BROWSER) { + inputs.push(base.nodeConfig()); +} + +if (!process.env.ONLY_NODE) { + inputs.push(base.browserConfig()); + inputs.push(base.browserConfig(false, true)); +} + +export default inputs; diff --git a/sdk/eventgrid/eventgrid/rollup.test.config.js b/sdk/eventgrid/eventgrid/rollup.test.config.js new file mode 100644 index 000000000000..925a4421a53e --- /dev/null +++ b/sdk/eventgrid/eventgrid/rollup.test.config.js @@ -0,0 +1,3 @@ +import * as base from "./rollup.base.config"; + +export default [base.nodeConfig(true), base.browserConfig(true)]; diff --git a/sdk/eventgrid/eventgrid/sample.env b/sdk/eventgrid/eventgrid/sample.env new file mode 100644 index 000000000000..7475a57f5e34 --- /dev/null +++ b/sdk/eventgrid/eventgrid/sample.env @@ -0,0 +1,18 @@ +# An Event Grid Topic configured to use the Event Grid Schema +EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT="https://..eventgrid.azure.net/api/events" +EVENT_GRID_EVENT_GRID_SCHEMA_API_KEY="" + +# An Event Grid Topic configured to use the Cloud Event 1.0 Schema. +EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT="https://..eventgrid.azure.net/api/events" +EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY="" + +# An Event Grid Topic configured to use a custom schema, the topic should be configured with the following mappings: +# typ -> eventType +# sub -> subject +# ver -> dataVersion +EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT="https://..eventgrid.azure.net/api/events" +EVENT_GRID_CUSTOM_SCHEMA_API_KEY="" + +# Our tests assume that TEST_MODE is "playback" by default. You can +# change it to "record" to generate new recordings, or "live" to bypass the recorder entirely. +# TEST_MODE=playback diff --git a/sdk/eventgrid/eventgrid/src/constants.ts b/sdk/eventgrid/eventgrid/src/constants.ts new file mode 100644 index 000000000000..a0dfd04fd1ea --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/constants.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +export const SDK_VERSION: string = "3.0.0-preview.1"; diff --git a/sdk/eventgrid/eventgrid/src/consumer.ts b/sdk/eventgrid/eventgrid/src/consumer.ts new file mode 100644 index 000000000000..523707b5b03a --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/consumer.ts @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Serializer } from "@azure/core-http"; +import { CloudEvent, EventGridEvent, CustomEventDataDecoder } from "./models"; +import { + EventGridEvent as EventGridEventMapper, + CloudEvent as CloudEventMapper +} from "./generated/models/mappers"; +import { parseAndWrap } from "./util"; +import { systemDecoders } from "./systemEventDecoders"; + +const serializer = new Serializer(); + +function validateRequiredStringProperty(o: any, propertyName: string): void { + if (typeof o[propertyName] === "undefined") { + throw new TypeError(`event is missing required property '${propertyName}'`); + } + + if (typeof o[propertyName] !== "string") { + throw new TypeError( + `event property '${propertyName} should be a 'string', but is '${typeof o[propertyName]}'` + ); + } +} + +function validateRequiredAnyProperty(o: any, propertyName: string): void { + if (typeof o[propertyName] === "undefined") { + throw new TypeError(`event is missing required property '${propertyName}'`); + } +} + +function validateOptionalStringProperty(propertyName: string, o: any): void { + if (typeof o[propertyName] !== "undefined" && typeof o[propertyName] !== "string") { + throw new TypeError( + `event property '${propertyName}' should be a 'string' but it is a '${typeof o[ + propertyName + ]}'` + ); + } +} + +/** + * TODO(matell): Document this. + */ +export class EventGridConsumer { + readonly customDecoders: Record; + constructor(decoders: Record = {}) { + this.customDecoders = decoders; + } + + /** + * Decodes events encoded in the Event Grid schema. + * + * @param encodedEvents the JSON encoded representation of either a single event or an array of + * events, encoded in the Event Grid Schema. + */ + public async decodeEventGridEvents(encodedEvents: string): Promise[]>; + /** + * Decodes events encoded in the Event Grid schema. + * + * @param encodedEvents an object representing a single event, encoded in the Event Grid schema. + */ + public async decodeEventGridEvents(encodedEvents: object): Promise[]>; + public async decodeEventGridEvents( + encodedEvents: string | object + ): Promise[]> { + const decodedArray = parseAndWrap(encodedEvents); + + const events: EventGridEvent[] = []; + + for (const o of decodedArray) { + if (typeof o !== "object") { + throw new TypeError("event is not an object"); + } + + validateRequiredStringProperty(o, "eventType"); + validateRequiredStringProperty(o, "eventTime"); + validateRequiredStringProperty(o, "id"); + validateRequiredStringProperty(o, "subject"); + validateRequiredStringProperty(o, "topic"); + validateRequiredAnyProperty(o, "data"); + validateRequiredStringProperty(o, "dataVersion"); + validateRequiredStringProperty(o, "metadataVersion"); + + if (o.metadataVersion !== "1") { + throw new TypeError("event is not in the Event Grid schema"); + } + + const deserialized: EventGridEvent = serializer.deserialize(EventGridEventMapper, o, ""); + + if (systemDecoders[deserialized.eventType]) { + deserialized.data = await systemDecoders[deserialized.eventType](deserialized.data); + } else if (this.customDecoders[deserialized.eventType]) { + deserialized.data = await this.customDecoders[deserialized.eventType](deserialized.data); + } + + events.push(deserialized as EventGridEvent); + } + + return events; + } + + /** + * Decodes events encoded in the Cloud Events 1.0 schema. + * + * @param encodedEvents the JSON encoded representation of either a single event or an array of + * events, encoded in the Cloud Events 1.0 Schema. + */ + public async decodeCloudEvents(encodedEvents: string): Promise[]>; + /** + * Decodes events encoded in the Cloud Events 1.0 schema. + * + * @param encodedEvents an object representing a single event, encoded in the Cloud Events 1.0 schema. + */ + public async decodeCloudEvents(encodedEvents: object): Promise[]>; + public async decodeCloudEvents(encodedEvents: string | object): Promise[]> { + const decodedArray = parseAndWrap(encodedEvents); + + const events: CloudEvent[] = []; + + for (const o of decodedArray) { + if (typeof o !== "object") { + throw new TypeError("encoded event is not an object"); + } + + // Check that the required fields are present and of the correct type and the optional fields are missing + // or of the correct type. + + validateRequiredStringProperty(o, "type"); + validateRequiredStringProperty(o, "source"); + validateRequiredStringProperty(o, "id"); + validateRequiredStringProperty(o, "specversion"); + validateOptionalStringProperty(o, "time"); + validateOptionalStringProperty(o, "dataschema"); + validateOptionalStringProperty(o, "datacontenttype"); + validateOptionalStringProperty(o, "subject"); + + if (o.specversion !== "1.0") { + throw new TypeError("event is not in the Cloud Event 1.0 schema"); + } + + const deserialized: CloudEvent = serializer.deserialize(CloudEventMapper, o, ""); + + // If the data the event represents binary, it is encoded as base64 text in a different property on the event and we need to transform it. + if (deserialized.dataBase64 !== undefined) { + if (deserialized.data !== undefined) { + throw new TypeError("event contains both a data and data_base64 field"); + } + + if (typeof deserialized.dataBase64 !== "string") { + throw new TypeError("event data_base64 property should be a string"); + } + + deserialized.data = Buffer.from(deserialized.dataBase64, "base64"); + delete deserialized.dataBase64; + } + + if (systemDecoders[deserialized.type]) { + deserialized.data = await systemDecoders[deserialized.type](deserialized.data); + } else if (this.customDecoders[deserialized.type]) { + deserialized.data = await this.customDecoders[deserialized.type](deserialized.data); + } + + events.push(deserialized as CloudEvent); + } + + return events; + } +} diff --git a/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts b/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts new file mode 100644 index 000000000000..231432e30cc0 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { KeyCredential } from "@azure/core-auth"; +import { + RequestPolicyFactory, + RequestPolicy, + BaseRequestPolicy, + WebResourceLike, + HttpOperationResponse, + RequestPolicyOptionsLike +} from "@azure/core-http"; + +import { SignatureCredential } from "./sharedAccessSignitureCredential"; +import { isKeyCredentialLike } from "./util"; + +/** + * The name of the header to include when a Shared Key is used for authentication. + */ +const API_KEY_HEADER_NAME = "aeg-sas-key"; + +/** + * The name of the header to include when Shared Access Signature is used for authentication. + */ +const SAS_TOKEN_HEAER_NAME = "aeg-sas-token"; + +/** + * Create an HTTP pipeline policy to authenticate a request + * using an `AzureKeyCredential` for Event Grid + */ +export function createEventGridCredentialPolicy( + credential: KeyCredential | SignatureCredential +): RequestPolicyFactory { + return { + create: (nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike) => { + return new EventGridAzureKeyCredentialPolicy(nextPolicy, options, credential); + } + }; +} + +/** + * A concrete implementation of an AzureKeyCredential policy + * using the appropriate header for Event Grid + */ +class EventGridAzureKeyCredentialPolicy extends BaseRequestPolicy { + private credential: KeyCredential | SignatureCredential; + + constructor( + nextPolicy: RequestPolicy, + options: RequestPolicyOptionsLike, + credential: KeyCredential | SignatureCredential + ) { + super(nextPolicy, options); + this.credential = credential; + } + + public async sendRequest(webResource: WebResourceLike): Promise { + if (!webResource) { + throw new Error("webResource cannot be null or undefined"); + } + + if (isKeyCredentialLike(this.credential)) { + webResource.headers.set(API_KEY_HEADER_NAME, this.credential.key); + } else { + webResource.headers.set(SAS_TOKEN_HEAER_NAME, this.credential.signature); + } + + return this._nextPolicy.sendRequest(webResource); + } +} diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts new file mode 100644 index 000000000000..1bbdc5a3676e --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { KeyCredential } from "@azure/core-auth"; +import { + PipelineOptions, + createPipelineFromOptions, + RestResponse, + OperationOptions +} from "@azure/core-http"; + +import { createHmac } from "crypto"; + +import { createEventGridCredentialPolicy } from "./eventGridAuthenticationPolicy"; +import { SignatureCredential } from "./sharedAccessSignitureCredential"; + +import { SDK_VERSION } from "./constants"; +import { GeneratedClient } from "./generated/generatedClient"; +import { CloudEvent, EventGridEvent } from "./models"; +import { dateToServiceTimeString, isKeyCredentialLike } from "./util"; + +/** + * Options for the Event Grid Client. + */ +export type EventGridClientOptions = PipelineOptions; + +/** + * Options for the send events operation. + */ +export type SendEventsOptions = OperationOptions; + +/** + * Options for the send cloud events operation. + */ +export type SendCloudEventsOptions = OperationOptions; + +/** + * Options for the send custom schema events operation. + */ +export type SendCustomSchemaEventsOptions = OperationOptions; + +/** + * Client class for interacting with the Event Grid Service. + */ +export class EventGridClient { + /** + * The URL to the Event Grid endpoint. + */ + public readonly endpointUrl: string; + + /** + * The version of the Even Grid service. + */ + public readonly apiVersion: string; + + /** + * The AutoRest generated client for the EventGrid dataplane. + */ + private readonly client: GeneratedClient; + + /** + * The credential used to construct the client, when it is constructed with a shared key instead of a + * signature. + */ + private readonly keyCredential?: KeyCredential; + + /** + * Creates an instance of EventGridClient. + * + * Example usage: + * ```ts + * import { EventGridClient, AzureKeyCredential } from "@azure/eventgrid"; + * + * const client = new EventGridClient( + * "", + * new AzureKeyCredential("") + * ); + * ``` + * + * @param endpointUrl The URL to the EventGrid endpoint, e.g. https://eg-topic.westus2-1.eventgrid.azure.net/api/events + * @param credential Used to authenticate requests to the service. + * @param options Used to configure the Event Grid Client + */ + constructor( + endpointUrl: string, + credential: KeyCredential | SignatureCredential, + options: EventGridClientOptions = {} + ) { + this.endpointUrl = endpointUrl; + + // If the user suplied a key credential (instead of a signature credential), save it on the client so we can generate + // SAS tokens with `generateSharedAccessSignature`. + if (isKeyCredentialLike(credential)) { + this.keyCredential = credential; + } + + const libInfo = `azsdk-js-eventgrid/${SDK_VERSION}`; + const pipelineOptions = { ...options }; + + if (!pipelineOptions.userAgentOptions) { + pipelineOptions.userAgentOptions = {}; + } + + if (pipelineOptions.userAgentOptions.userAgentPrefix) { + pipelineOptions.userAgentOptions.userAgentPrefix = `${pipelineOptions.userAgentOptions.userAgentPrefix} ${libInfo}`; + } else { + pipelineOptions.userAgentOptions.userAgentPrefix = libInfo; + } + + const authPolicy = createEventGridCredentialPolicy(credential); + const pipeline = createPipelineFromOptions(options, authPolicy); + + this.client = new GeneratedClient(pipeline); + this.apiVersion = this.client.apiVersion; + } + + /** + * Publishes events in the Event Grid scheama. The topic must be configured to expect events in the Event Grid schema. + * + * @param message One or more events to publish + */ + sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise { + return this.client.publishEvents(this.endpointUrl, events, options); + } + + /** + * Publishes events in the Cloud Events 1.0 schema. The topic must be configured to expect events in the Cloud Events 1.0 schema. + * + * @param message One or more events to publish + */ + + sendCloudEvents( + events: CloudEvent[], + options?: SendCloudEventsOptions + ): Promise { + const toPublish = events.map((msg) => { + // TODO(matell): If data is of type `Buffer` or other binary data we should Base64 encoded the data and set + // `data_base64` instead. We also need to validate that `datacontenttype` is set in this case. + return { + ...msg, + specversion: "1.0", + datacontenttype: msg.datacontenttype ?? "application/json" + }; + }); + + return this.client.publishCloudEventEvents(this.endpointUrl, toPublish, options); + } + + /** + * Publishes events written using a custom schema. The topic must be configured to expect events in a custom schema. + * + * @param message One or more events to publish + */ + sendCustomSchemaEvents( + events: Record[], + options?: SendCustomSchemaEventsOptions + ): Promise { + return this.client.publishCustomEventEvents(this.endpointUrl, events, options); + } + + /** + * Generate a shared access signature, which allows a client to send events to an Event Grid Topic for a limited period of time. This + * function may only be called when the EventGridClient was constructed with a KeyCredential instance. + * + * @param expiresOn The time at which the shared signature is no longer valid. + */ + generateSharedAccessSignature(expiresOnUtc: Date): string { + if (!this.keyCredential) { + throw new Error( + "generateSharedAccessSignature may only be called when the client is constructed with a key credential" + ); + } + + const expiresOnString = dateToServiceTimeString(expiresOnUtc); + const unsignedSas = `r=${encodeURIComponent( + `${this.endpointUrl}?apiVersion=${this.apiVersion}` + )}&e=${encodeURIComponent(expiresOnString)}`; + const digest = createHmac("sha256", Buffer.from(this.keyCredential?.key, "base64")) + .update(unsignedSas) + .digest() + .toString("base64"); + + return `${unsignedSas}&s=${encodeURIComponent(digest)}`; + } +} diff --git a/sdk/eventgrid/eventgrid/src/generated/generatedClient.ts b/sdk/eventgrid/eventgrid/src/generated/generatedClient.ts new file mode 100644 index 000000000000..80ed26cec84a --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/generated/generatedClient.ts @@ -0,0 +1,134 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; +import * as Parameters from "./models/parameters"; +import * as Models from "./models"; +import * as Mappers from "./models/mappers"; +import { GeneratedClientContext } from "./generatedClientContext"; +import { + GeneratedClientOptionalParams, + EventGridEvent, + CloudEvent +} from "./models"; + +class GeneratedClient extends GeneratedClientContext { + /** + * Initializes a new instance of the GeneratedClient class. + * @param options The parameter options + */ + constructor(options?: GeneratedClientOptionalParams) { + super(options); + } + + /** + * Publishes a batch of events to an Azure Event Grid topic. + * @param topicHostname The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net + * @param events An array of events to be published to Event Grid. + * @param options The options parameters. + */ + publishEvents( + topicHostname: string, + events: EventGridEvent[], + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { topicHostname, events, options: operationOptions }, + publishEventsOperationSpec + ) as Promise; + } + + /** + * Publishes a batch of events to an Azure Event Grid topic. + * @param topicHostname The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net + * @param events An array of events to be published to Event Grid. + * @param options The options parameters. + */ + publishCloudEventEvents( + topicHostname: string, + events: CloudEvent[], + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { topicHostname, events, options: operationOptions }, + publishCloudEventEventsOperationSpec + ) as Promise; + } + + /** + * Publishes a batch of events to an Azure Event Grid topic. + * @param topicHostname The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net + * @param events An array of events to be published to Event Grid. + * @param options The options parameters. + */ + publishCustomEventEvents( + topicHostname: string, + events: any[], + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { topicHostname, events, options: operationOptions }, + publishCustomEventEventsOperationSpec + ) as Promise; + } +} +// Operation Specifications + +const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false); + +const publishEventsOperationSpec: coreHttp.OperationSpec = { + path: "/api/events", + httpMethod: "POST", + responses: { 200: {}, default: {} }, + requestBody: Parameters.events, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.topicHostname], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const publishCloudEventEventsOperationSpec: coreHttp.OperationSpec = { + path: "/api/events", + httpMethod: "POST", + responses: { 200: {}, default: {} }, + requestBody: Parameters.events1, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.topicHostname], + headerParameters: [Parameters.contentType1], + mediaType: "json", + serializer +}; +const publishCustomEventEventsOperationSpec: coreHttp.OperationSpec = { + path: "/api/events", + httpMethod: "POST", + responses: { 200: {}, default: {} }, + requestBody: Parameters.events2, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.topicHostname], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; + +// Operation Specifications + +export { + GeneratedClient, + GeneratedClientContext, + Models as GeneratedModels, + Mappers as GeneratedMappers +}; diff --git a/sdk/eventgrid/eventgrid/src/generated/generatedClientContext.ts b/sdk/eventgrid/eventgrid/src/generated/generatedClientContext.ts new file mode 100644 index 000000000000..0f3881153af0 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/generated/generatedClientContext.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; +import { GeneratedClientOptionalParams } from "./models"; + +const packageName = "@azure/eventgrid"; +const packageVersion = "1.0.0"; + +export class GeneratedClientContext extends coreHttp.ServiceClient { + apiVersion: string; + + /** + * Initializes a new instance of the GeneratedClientContext class. + * @param options The parameter options + */ + constructor(options?: GeneratedClientOptionalParams) { + // Initializing default values for options + if (!options) { + options = {}; + } + + if (!options.userAgent) { + const defaultUserAgent = coreHttp.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(undefined, options); + + this.requestContentType = "application/json; charset=utf-8"; + + this.baseUri = options.endpoint || "https://{topicHostname}"; + + // Assigning values to Constant parameters + this.apiVersion = options.apiVersion || "2018-01-01"; + } +} diff --git a/sdk/eventgrid/eventgrid/src/generated/models/index.ts b/sdk/eventgrid/eventgrid/src/generated/models/index.ts new file mode 100644 index 000000000000..3d54535bd959 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/generated/models/index.ts @@ -0,0 +1,3071 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; + +export type MediaJobOutputUnion = MediaJobOutput | MediaJobOutputAsset; + +/** + * Properties of an event published to an Event Grid topic using the EventGrid Schema. + */ +export interface EventGridEvent { + /** + * An unique identifier for the event. + */ + id: string; + /** + * The resource path of the event source. + */ + topic?: string; + /** + * A resource path relative to the topic path. + */ + subject: string; + /** + * Event data specific to the event type. + */ + data: any; + /** + * The type of the event that occurred. + */ + eventType: string; + /** + * The time (in UTC) the event was generated. + */ + eventTime: Date; + /** + * The schema version of the event metadata. + */ + readonly metadataVersion?: string; + /** + * The schema version of the data object. + */ + dataVersion: string; +} + +/** + * Properties of an event published to an Event Grid topic using the CloudEvent 1.0 Schema + */ +export interface CloudEvent { + /** + * Describes unknown properties. The value of an unknown property can be of "any" type. + */ + [property: string]: any; + /** + * An identifier for the event. The combination of id and source must be unique for each distinct event. + */ + id: string; + /** + * Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. + */ + source: string; + /** + * Event data specific to the event type. + */ + data?: any; + /** + * Event data specific to the event type, encoded as a base64 string. + */ + dataBase64?: string; + /** + * Type of event related to the originating occurrence. + */ + type: string; + /** + * The time (in UTC) the event was generated, in RFC3339 format. + */ + time?: Date; + /** + * The version of the CloudEvents specification which the event uses. + */ + specversion: string; + /** + * Identifies the schema that data adheres to. + */ + dataschema?: string; + /** + * Content type of data value. + */ + datacontenttype?: string; + /** + * This describes the subject of the event in the context of the event producer (identified by source). + */ + subject?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.BlobCreated event. + */ +export interface StorageBlobCreatedEventData { + /** + * The name of the API/operation that triggered this event. + */ + api?: string; + /** + * A request id provided by the client of the storage API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The request id generated by the Storage service for the storage API operation that triggered this event. + */ + requestId?: string; + /** + * The etag of the blob at the time this event was triggered. + */ + eTag?: string; + /** + * The content type of the blob. This is the same as what would be returned in the Content-Type header from the blob. + */ + contentType?: string; + /** + * The size of the blob in bytes. This is the same as what would be returned in the Content-Length header from the blob. + */ + contentLength?: number; + /** + * The offset of the blob in bytes. + */ + contentOffset?: number; + /** + * The type of blob. + */ + blobType?: string; + /** + * The path to the blob. + */ + url?: string; + /** + * 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; + /** + * The identity of the requester that triggered this event. + */ + identity?: string; + /** + * For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored by event consumers. + */ + storageDiagnostics?: any; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.BlobDeleted event. + */ +export interface StorageBlobDeletedEventData { + /** + * The name of the API/operation that triggered this event. + */ + api?: string; + /** + * A request id provided by the client of the storage API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The request id generated by the Storage service for the storage API operation that triggered this event. + */ + requestId?: string; + /** + * The content type of the blob. This is the same as what would be returned in the Content-Type header from the blob. + */ + contentType?: string; + /** + * The type of blob. + */ + blobType?: string; + /** + * The path to the blob. + */ + url?: string; + /** + * 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; + /** + * The identity of the requester that triggered this event. + */ + identity?: string; + /** + * For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored by event consumers. + */ + storageDiagnostics?: any; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.DirectoryCreated event. + */ +export interface StorageDirectoryCreatedEventData { + /** + * The name of the API/operation that triggered this event. + */ + api?: string; + /** + * A request id provided by the client of the storage API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The request id generated by the storage service for the storage API operation that triggered this event. + */ + requestId?: string; + /** + * The etag of the directory at the time this event was triggered. + */ + eTag?: string; + /** + * The path to the directory. + */ + url?: string; + /** + * An opaque string value representing the logical sequence of events for any particular directory name. Users can use standard string comparison to understand the relative sequence of two events on the same directory name. + */ + sequencer?: string; + /** + * The identity of the requester that triggered this event. + */ + identity?: string; + /** + * For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored by event consumers. + */ + storageDiagnostics?: any; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.DirectoryDeleted event. + */ +export interface StorageDirectoryDeletedEventData { + /** + * The name of the API/operation that triggered this event. + */ + api?: string; + /** + * A request id provided by the client of the storage API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The request id generated by the storage service for the storage API operation that triggered this event. + */ + requestId?: string; + /** + * The path to the deleted directory. + */ + url?: string; + /** + * Is this event for a recursive delete operation. + */ + recursive?: boolean; + /** + * An opaque string value representing the logical sequence of events for any particular directory name. Users can use standard string comparison to understand the relative sequence of two events on the same directory name. + */ + sequencer?: string; + /** + * The identity of the requester that triggered this event. + */ + identity?: string; + /** + * For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored by event consumers. + */ + storageDiagnostics?: any; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.BlobRenamed event. + */ +export interface StorageBlobRenamedEventData { + /** + * The name of the API/operation that triggered this event. + */ + api?: string; + /** + * A request id provided by the client of the storage API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The request id generated by the storage service for the storage API operation that triggered this event. + */ + requestId?: string; + /** + * The path to the blob that was renamed. + */ + sourceUrl?: string; + /** + * The new path to the blob after the rename operation. + */ + destinationUrl?: string; + /** + * 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; + /** + * The identity of the requester that triggered this event. + */ + identity?: string; + /** + * For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored by event consumers. + */ + storageDiagnostics?: any; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.DirectoryRenamed event. + */ +export interface StorageDirectoryRenamedEventData { + /** + * The name of the API/operation that triggered this event. + */ + api?: string; + /** + * A request id provided by the client of the storage API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The request id generated by the storage service for the storage API operation that triggered this event. + */ + requestId?: string; + /** + * The path to the directory that was renamed. + */ + sourceUrl?: string; + /** + * The new path to the directory after the rename operation. + */ + destinationUrl?: string; + /** + * An opaque string value representing the logical sequence of events for any particular directory name. Users can use standard string comparison to understand the relative sequence of two events on the same directory name. + */ + sequencer?: string; + /** + * The identity of the requester that triggered this event. + */ + identity?: string; + /** + * For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored by event consumers. + */ + storageDiagnostics?: any; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.EventHub.CaptureFileCreated event. + */ +export interface EventHubCaptureFileCreatedEventData { + /** + * The path to the capture file. + */ + fileurl?: string; + /** + * The file type of the capture file. + */ + fileType?: string; + /** + * The shard ID. + */ + partitionId?: string; + /** + * The file size. + */ + sizeInBytes?: number; + /** + * The number of events in the file. + */ + eventCount?: number; + /** + * The smallest sequence number from the queue. + */ + firstSequenceNumber?: number; + /** + * The last sequence number from the queue. + */ + lastSequenceNumber?: number; + /** + * The first time from the queue. + */ + firstEnqueueTime?: Date; + /** + * The last time from the queue. + */ + lastEnqueueTime?: Date; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceWriteSuccess event. This is raised when a resource create or update operation succeeds. + */ +export interface ResourceWriteSuccessEventData { + /** + * The tenant ID of the resource. + */ + tenantId?: string; + /** + * The subscription ID of the resource. + */ + subscriptionId?: string; + /** + * The resource group of the resource. + */ + resourceGroup?: string; + /** + * The resource provider performing the operation. + */ + resourceProvider?: string; + /** + * The URI of the resource in the operation. + */ + resourceUri?: string; + /** + * The operation that was performed. + */ + operationName?: string; + /** + * The status of the operation. + */ + status?: string; + /** + * The requested authorization for the operation. + */ + authorization?: string; + /** + * The properties of the claims. + */ + claims?: string; + /** + * An operation ID used for troubleshooting. + */ + correlationId?: string; + /** + * The details of the operation. + */ + httpRequest?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceWriteFailure event. This is raised when a resource create or update operation fails. + */ +export interface ResourceWriteFailureEventData { + /** + * The tenant ID of the resource. + */ + tenantId?: string; + /** + * The subscription ID of the resource. + */ + subscriptionId?: string; + /** + * The resource group of the resource. + */ + resourceGroup?: string; + /** + * The resource provider performing the operation. + */ + resourceProvider?: string; + /** + * The URI of the resource in the operation. + */ + resourceUri?: string; + /** + * The operation that was performed. + */ + operationName?: string; + /** + * The status of the operation. + */ + status?: string; + /** + * The requested authorization for the operation. + */ + authorization?: string; + /** + * The properties of the claims. + */ + claims?: string; + /** + * An operation ID used for troubleshooting. + */ + correlationId?: string; + /** + * The details of the operation. + */ + httpRequest?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceWriteCancel event. This is raised when a resource create or update operation is canceled. + */ +export interface ResourceWriteCancelEventData { + /** + * The tenant ID of the resource. + */ + tenantId?: string; + /** + * The subscription ID of the resource. + */ + subscriptionId?: string; + /** + * The resource group of the resource. + */ + resourceGroup?: string; + /** + * The resource provider performing the operation. + */ + resourceProvider?: string; + /** + * The URI of the resource in the operation. + */ + resourceUri?: string; + /** + * The operation that was performed. + */ + operationName?: string; + /** + * The status of the operation. + */ + status?: string; + /** + * The requested authorization for the operation. + */ + authorization?: string; + /** + * The properties of the claims. + */ + claims?: string; + /** + * An operation ID used for troubleshooting. + */ + correlationId?: string; + /** + * The details of the operation. + */ + httpRequest?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceDeleteSuccess event. This is raised when a resource delete operation succeeds. + */ +export interface ResourceDeleteSuccessEventData { + /** + * The tenant ID of the resource. + */ + tenantId?: string; + /** + * The subscription ID of the resource. + */ + subscriptionId?: string; + /** + * The resource group of the resource. + */ + resourceGroup?: string; + /** + * The resource provider performing the operation. + */ + resourceProvider?: string; + /** + * The URI of the resource in the operation. + */ + resourceUri?: string; + /** + * The operation that was performed. + */ + operationName?: string; + /** + * The status of the operation. + */ + status?: string; + /** + * The requested authorization for the operation. + */ + authorization?: string; + /** + * The properties of the claims. + */ + claims?: string; + /** + * An operation ID used for troubleshooting. + */ + correlationId?: string; + /** + * The details of the operation. + */ + httpRequest?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceDeleteFailure event. This is raised when a resource delete operation fails. + */ +export interface ResourceDeleteFailureEventData { + /** + * The tenant ID of the resource. + */ + tenantId?: string; + /** + * The subscription ID of the resource. + */ + subscriptionId?: string; + /** + * The resource group of the resource. + */ + resourceGroup?: string; + /** + * The resource provider performing the operation. + */ + resourceProvider?: string; + /** + * The URI of the resource in the operation. + */ + resourceUri?: string; + /** + * The operation that was performed. + */ + operationName?: string; + /** + * The status of the operation. + */ + status?: string; + /** + * The requested authorization for the operation. + */ + authorization?: string; + /** + * The properties of the claims. + */ + claims?: string; + /** + * An operation ID used for troubleshooting. + */ + correlationId?: string; + /** + * The details of the operation. + */ + httpRequest?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Resources.ResourceDeleteCancel event. This is raised when a resource delete operation is canceled. + */ +export interface ResourceDeleteCancelEventData { + /** + * The tenant ID of the resource. + */ + tenantId?: string; + /** + * The subscription ID of the resource. + */ + subscriptionId?: string; + /** + * The resource group of the resource. + */ + resourceGroup?: string; + /** + * The resource provider performing the operation. + */ + resourceProvider?: string; + /** + * The URI of the resource in the operation. + */ + resourceUri?: string; + /** + * The operation that was performed. + */ + operationName?: string; + /** + * The status of the operation. + */ + status?: string; + /** + * The requested authorization for the operation. + */ + authorization?: string; + /** + * The properties of the claims. + */ + claims?: string; + /** + * An operation ID used for troubleshooting. + */ + correlationId?: string; + /** + * The details of the operation. + */ + httpRequest?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceActionSuccess event. This is raised when a resource action operation succeeds. + */ +export interface ResourceActionSuccessEventData { + /** + * The tenant ID of the resource. + */ + tenantId?: string; + /** + * The subscription ID of the resource. + */ + subscriptionId?: string; + /** + * The resource group of the resource. + */ + resourceGroup?: string; + /** + * The resource provider performing the operation. + */ + resourceProvider?: string; + /** + * The URI of the resource in the operation. + */ + resourceUri?: string; + /** + * The operation that was performed. + */ + operationName?: string; + /** + * The status of the operation. + */ + status?: string; + /** + * The requested authorization for the operation. + */ + authorization?: string; + /** + * The properties of the claims. + */ + claims?: string; + /** + * An operation ID used for troubleshooting. + */ + correlationId?: string; + /** + * The details of the operation. + */ + httpRequest?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Resources.ResourceActionFailure event. This is raised when a resource action operation fails. + */ +export interface ResourceActionFailureEventData { + /** + * The tenant ID of the resource. + */ + tenantId?: string; + /** + * The subscription ID of the resource. + */ + subscriptionId?: string; + /** + * The resource group of the resource. + */ + resourceGroup?: string; + /** + * The resource provider performing the operation. + */ + resourceProvider?: string; + /** + * The URI of the resource in the operation. + */ + resourceUri?: string; + /** + * The operation that was performed. + */ + operationName?: string; + /** + * The status of the operation. + */ + status?: string; + /** + * The requested authorization for the operation. + */ + authorization?: string; + /** + * The properties of the claims. + */ + claims?: string; + /** + * An operation ID used for troubleshooting. + */ + correlationId?: string; + /** + * The details of the operation. + */ + httpRequest?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Resources.ResourceActionCancel event. This is raised when a resource action operation is canceled. + */ +export interface ResourceActionCancelEventData { + /** + * The tenant ID of the resource. + */ + tenantId?: string; + /** + * The subscription ID of the resource. + */ + subscriptionId?: string; + /** + * The resource group of the resource. + */ + resourceGroup?: string; + /** + * The resource provider performing the operation. + */ + resourceProvider?: string; + /** + * The URI of the resource in the operation. + */ + resourceUri?: string; + /** + * The operation that was performed. + */ + operationName?: string; + /** + * The status of the operation. + */ + status?: string; + /** + * The requested authorization for the operation. + */ + authorization?: string; + /** + * The properties of the claims. + */ + claims?: string; + /** + * An operation ID used for troubleshooting. + */ + correlationId?: string; + /** + * The details of the operation. + */ + httpRequest?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.EventGrid.SubscriptionValidationEvent. + */ +export interface SubscriptionValidationEventData { + /** + * The validation code sent by Azure Event Grid to validate an event subscription. To complete the validation handshake, the subscriber must either respond with this validation code as part of the validation response, or perform a GET request on the validationUrl (available starting version 2018-05-01-preview). + */ + readonly validationCode?: string; + /** + * The validation URL sent by Azure Event Grid (available starting version 2018-05-01-preview). To complete the validation handshake, the subscriber must either respond with the validationCode as part of the validation response, or perform a GET request on the validationUrl (available starting version 2018-05-01-preview). + */ + readonly validationUrl?: string; +} + +/** + * To complete an event subscription validation handshake, a subscriber can use either the validationCode or the validationUrl received in a SubscriptionValidationEvent. When the validationCode is used, the SubscriptionValidationResponse can be used to build the response. + */ +export interface SubscriptionValidationResponse { + /** + * The validation response sent by the subscriber to Azure Event Grid to complete the validation of an event subscription. + */ + validationResponse?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.EventGrid.SubscriptionDeletedEvent. + */ +export interface SubscriptionDeletedEventData { + /** + * The Azure resource ID of the deleted event subscription. + */ + readonly eventSubscriptionId?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a device life cycle event (DeviceCreated, DeviceDeleted). + */ +export interface DeviceLifeCycleEventProperties { + /** + * The unique identifier of the device. This case-sensitive string can be up to 128 characters long, and supports ASCII 7-bit alphanumeric characters plus the following special characters: - : . + % _ # * ? ! ( ) , = @ ; $ '. + */ + deviceId?: string; + /** + * Name of the IoT Hub where the device was created or deleted. + */ + hubName?: string; + /** + * Information about the device twin, which is the cloud representation of application device metadata. + */ + twin?: DeviceTwinInfo; +} + +/** + * Information about the device twin, which is the cloud representation of application device metadata. + */ +export interface DeviceTwinInfo { + /** + * Authentication type used for this device: either SAS, SelfSigned, or CertificateAuthority. + */ + authenticationType?: string; + /** + * Count of cloud to device messages sent to this device. + */ + cloudToDeviceMessageCount?: number; + /** + * Whether the device is connected or disconnected. + */ + connectionState?: string; + /** + * The unique identifier of the device twin. + */ + deviceId?: string; + /** + * A piece of information that describes the content of the device twin. Each etag is guaranteed to be unique per device twin. + */ + etag?: string; + /** + * The ISO8601 timestamp of the last activity. + */ + lastActivityTime?: string; + /** + * Properties JSON element. + */ + properties?: DeviceTwinInfoProperties; + /** + * Whether the device twin is enabled or disabled. + */ + status?: string; + /** + * The ISO8601 timestamp of the last device twin status update. + */ + statusUpdateTime?: string; + /** + * An integer that is incremented by one each time the device twin is updated. + */ + version?: number; + /** + * The thumbprint is a unique value for the x509 certificate, commonly used to find a particular certificate in a certificate store. The thumbprint is dynamically generated using the SHA1 algorithm, and does not physically exist in the certificate. + */ + x509Thumbprint?: DeviceTwinInfoX509Thumbprint; +} + +/** + * Properties JSON element. + */ +export interface DeviceTwinInfoProperties { + /** + * A portion of the properties that can be written only by the application back-end, and read by the device. + */ + desired?: DeviceTwinProperties; + /** + * A portion of the properties that can be written only by the device, and read by the application back-end. + */ + reported?: DeviceTwinProperties; +} + +/** + * A portion of the properties that can be written only by the application back-end, and read by the device. + */ +export interface DeviceTwinProperties { + /** + * Metadata information for the properties JSON document. + */ + metadata?: DeviceTwinMetadata; + /** + * Version of device twin properties. + */ + version?: number; +} + +/** + * Metadata information for the properties JSON document. + */ +export interface DeviceTwinMetadata { + /** + * The ISO8601 timestamp of the last time the properties were updated. + */ + lastUpdated?: string; +} + +/** + * The thumbprint is a unique value for the x509 certificate, commonly used to find a particular certificate in a certificate store. The thumbprint is dynamically generated using the SHA1 algorithm, and does not physically exist in the certificate. + */ +export interface DeviceTwinInfoX509Thumbprint { + /** + * Primary thumbprint for the x509 certificate. + */ + primaryThumbprint?: string; + /** + * Secondary thumbprint for the x509 certificate. + */ + secondaryThumbprint?: string; +} + +/** + * Event data for Microsoft.Devices.DeviceCreated event. + */ +export type IotHubDeviceCreatedEventData = DeviceLifeCycleEventProperties & {}; + +/** + * Event data for Microsoft.Devices.DeviceDeleted event. + */ +export type IotHubDeviceDeletedEventData = DeviceLifeCycleEventProperties & {}; + +/** + * Schema of the Data property of an EventGridEvent for a device connection state event (DeviceConnected, DeviceDisconnected). + */ +export interface DeviceConnectionStateEventProperties { + /** + * The unique identifier of the device. This case-sensitive string can be up to 128 characters long, and supports ASCII 7-bit alphanumeric characters plus the following special characters: - : . + % _ # * ? ! ( ) , = @ ; $ '. + */ + deviceId?: string; + /** + * The unique identifier of the module. This case-sensitive string can be up to 128 characters long, and supports ASCII 7-bit alphanumeric characters plus the following special characters: - : . + % _ # * ? ! ( ) , = @ ; $ '. + */ + moduleId?: string; + /** + * Name of the IoT Hub where the device was created or deleted. + */ + hubName?: string; + /** + * Information about the device connection state event. + */ + deviceConnectionStateEventInfo?: DeviceConnectionStateEventInfo; +} + +/** + * Information about the device connection state event. + */ +export interface DeviceConnectionStateEventInfo { + /** + * Sequence number is string representation of a hexadecimal number. string compare can be used to identify the larger number because both in ASCII and HEX numbers come after alphabets. If you are converting the string to hex, then the number is a 256 bit number. + */ + sequenceNumber?: string; +} + +/** + * Event data for Microsoft.Devices.DeviceConnected event. + */ +export type IotHubDeviceConnectedEventData = DeviceConnectionStateEventProperties & {}; + +/** + * Event data for Microsoft.Devices.DeviceDisconnected event. + */ +export type IotHubDeviceDisconnectedEventData = DeviceConnectionStateEventProperties & {}; + +/** + * Schema of the Data property of an EventGridEvent for a device telemetry event (DeviceTelemetry). + */ +export interface DeviceTelemetryEventProperties { + /** + * The content of the message from the device. + */ + body?: any; + /** + * Application properties are user-defined strings that can be added to the message. These fields are optional. + */ + properties?: { [propertyName: string]: string }; + /** + * System properties help identify contents and source of the messages. + */ + systemProperties?: { [propertyName: string]: string }; +} + +/** + * Event data for Microsoft.Devices.DeviceTelemetry event. + */ +export type IotHubDeviceTelemetryEventData = DeviceTelemetryEventProperties & {}; + +/** + * The content of the event request message. + */ +export interface ContainerRegistryEventData { + /** + * The event ID. + */ + id?: string; + /** + * The time at which the event occurred. + */ + timestamp?: Date; + /** + * The action that encompasses the provided event. + */ + action?: string; + /** + * The target of the event. + */ + target?: ContainerRegistryEventTarget; + /** + * The request that generated the event. + */ + request?: ContainerRegistryEventRequest; + /** + * The agent that initiated the event. For most situations, this could be from the authorization context of the request. + */ + actor?: ContainerRegistryEventActor; + /** + * The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. + */ + source?: ContainerRegistryEventSource; +} + +/** + * The target of the event. + */ +export interface ContainerRegistryEventTarget { + /** + * The MIME type of the referenced object. + */ + mediaType?: string; + /** + * The number of bytes of the content. Same as Length field. + */ + size?: number; + /** + * The digest of the content, as defined by the Registry V2 HTTP API Specification. + */ + digest?: string; + /** + * The number of bytes of the content. Same as Size field. + */ + length?: number; + /** + * The repository name. + */ + repository?: string; + /** + * The direct URL to the content. + */ + url?: string; + /** + * The tag name. + */ + tag?: string; +} + +/** + * The request that generated the event. + */ +export interface ContainerRegistryEventRequest { + /** + * The ID of the request that initiated the event. + */ + id?: string; + /** + * The IP or hostname and possibly port of the client connection that initiated the event. This is the RemoteAddr from the standard http request. + */ + addr?: string; + /** + * The externally accessible hostname of the registry instance, as specified by the http host header on incoming requests. + */ + host?: string; + /** + * The request method that generated the event. + */ + method?: string; + /** + * The user agent header of the request. + */ + useragent?: string; +} + +/** + * The agent that initiated the event. For most situations, this could be from the authorization context of the request. + */ +export interface ContainerRegistryEventActor { + /** + * The subject or username associated with the request context that generated the event. + */ + name?: string; +} + +/** + * The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. + */ +export interface ContainerRegistryEventSource { + /** + * The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. + */ + addr?: string; + /** + * The running instance of an application. Changes after each restart. + */ + instanceID?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.ContainerRegistry.ImagePushed event. + */ +export type ContainerRegistryImagePushedEventData = ContainerRegistryEventData & {}; + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.ContainerRegistry.ImageDeleted event. + */ +export type ContainerRegistryImageDeletedEventData = ContainerRegistryEventData & {}; + +/** + * The content of the event request message. + */ +export interface ContainerRegistryArtifactEventData { + /** + * The event ID. + */ + id?: string; + /** + * The time at which the event occurred. + */ + timestamp?: Date; + /** + * The action that encompasses the provided event. + */ + action?: string; + /** + * The target of the event. + */ + target?: ContainerRegistryArtifactEventTarget; +} + +/** + * The target of the event. + */ +export interface ContainerRegistryArtifactEventTarget { + /** + * The MIME type of the artifact. + */ + mediaType?: string; + /** + * The size in bytes of the artifact. + */ + size?: number; + /** + * The digest of the artifact. + */ + digest?: string; + /** + * The repository name of the artifact. + */ + repository?: string; + /** + * The tag of the artifact. + */ + tag?: string; + /** + * The name of the artifact. + */ + name?: string; + /** + * The version of the artifact. + */ + version?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.ContainerRegistry.ChartPushed event. + */ +export type ContainerRegistryChartPushedEventData = ContainerRegistryArtifactEventData & {}; + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.ContainerRegistry.ChartDeleted event. + */ +export type ContainerRegistryChartDeletedEventData = ContainerRegistryArtifactEventData & {}; + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners event. + */ +export interface ServiceBusActiveMessagesAvailableWithNoListenersEventData { + /** + * The namespace name of the Microsoft.ServiceBus resource. + */ + namespaceName?: string; + /** + * The endpoint of the Microsoft.ServiceBus resource. + */ + requestUri?: string; + /** + * The entity type of the Microsoft.ServiceBus resource. Could be one of 'queue' or 'subscriber'. + */ + entityType?: string; + /** + * The name of the Microsoft.ServiceBus queue. If the entity type is of type 'subscriber', then this value will be null. + */ + queueName?: string; + /** + * The name of the Microsoft.ServiceBus topic. If the entity type is of type 'queue', then this value will be null. + */ + topicName?: string; + /** + * The name of the Microsoft.ServiceBus topic's subscription. If the entity type is of type 'queue', then this value will be null. + */ + subscriptionName?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListenersEvent event. + */ +export interface ServiceBusDeadletterMessagesAvailableWithNoListenersEventData { + /** + * The namespace name of the Microsoft.ServiceBus resource. + */ + namespaceName?: string; + /** + * The endpoint of the Microsoft.ServiceBus resource. + */ + requestUri?: string; + /** + * The entity type of the Microsoft.ServiceBus resource. Could be one of 'queue' or 'subscriber'. + */ + entityType?: string; + /** + * The name of the Microsoft.ServiceBus queue. If the entity type is of type 'subscriber', then this value will be null. + */ + queueName?: string; + /** + * The name of the Microsoft.ServiceBus topic. If the entity type is of type 'queue', then this value will be null. + */ + topicName?: string; + /** + * The name of the Microsoft.ServiceBus topic's subscription. If the entity type is of type 'queue', then this value will be null. + */ + subscriptionName?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Media.JobStateChange event. + */ +export interface MediaJobStateChangeEventData { + /** + * The previous state of the Job. + */ + readonly previousState?: MediaJobState; + /** + * The new state of the Job. + */ + readonly state?: MediaJobState; + /** + * Gets the Job correlation data. + */ + correlationData?: { [propertyName: string]: string }; +} + +/** + * Details of JobOutput errors. + */ +export interface MediaJobError { + /** + * Error code describing the error. + */ + readonly code?: MediaJobErrorCode; + /** + * A human-readable language-dependent representation of the error. + */ + readonly message?: string; + /** + * Helps with categorization of errors. + */ + readonly category?: MediaJobErrorCategory; + /** + * Indicates that it may be possible to retry the Job. If retry is unsuccessful, please contact Azure support via Azure Portal. + */ + readonly retry?: MediaJobRetry; + /** + * An array of details about specific errors that led to this reported error. + */ + readonly details?: MediaJobErrorDetail[]; +} + +/** + * Details of JobOutput errors. + */ +export interface MediaJobErrorDetail { + /** + * Code describing the error detail. + */ + readonly code?: string; + /** + * A human-readable representation of the error. + */ + readonly message?: string; +} + +/** + * The event data for a Job output. + */ +export interface MediaJobOutput { + /** + * Polymorphic discriminator, which specifies the different types this object can be + */ + "@odata.type": "#Microsoft.Media.JobOutputAsset"; + /** + * The discriminator for derived types. + */ + odataType?: string; + /** + * Gets the Job output error. + */ + error?: MediaJobError; + /** + * Gets the Job output label. + */ + label?: string; + /** + * Gets the Job output progress. + */ + progress: number; + /** + * Gets the Job output state. + */ + state: MediaJobState; +} + +/** + * The event data for a Job output asset. + */ +export type MediaJobOutputAsset = MediaJobOutput & { + /** + * Gets the Job output asset name. + */ + assetName?: string; +}; + +/** + * Job Output Progress Event Data. + */ +export interface MediaJobOutputProgressEventData { + /** + * Gets the Job output label. + */ + label?: string; + /** + * Gets the Job output progress. + */ + progress?: number; + /** + * Gets the Job correlation data. + */ + jobCorrelationData?: { [propertyName: string]: string }; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Media.JobOutputStateChange event. + */ +export interface MediaJobOutputStateChangeEventData { + /** + * The previous state of the Job. + */ + readonly previousState?: MediaJobState; + /** + * Gets the output. + */ + output?: MediaJobOutputUnion; + /** + * Gets the Job correlation data. + */ + jobCorrelationData?: { [propertyName: string]: string }; +} + +/** + * Job scheduled event data + */ +export type MediaJobScheduledEventData = MediaJobStateChangeEventData & {}; + +/** + * Job processing event data + */ +export type MediaJobProcessingEventData = MediaJobStateChangeEventData & {}; + +/** + * Job canceling event data + */ +export type MediaJobCancelingEventData = MediaJobStateChangeEventData & {}; + +/** + * Job finished event data + */ +export type MediaJobFinishedEventData = MediaJobStateChangeEventData & { + /** + * Gets the Job outputs. + */ + outputs?: MediaJobOutputUnion[]; +}; + +/** + * Job canceled event data + */ +export type MediaJobCanceledEventData = MediaJobStateChangeEventData & { + /** + * Gets the Job outputs. + */ + outputs?: MediaJobOutputUnion[]; +}; + +/** + * Job error state event data + */ +export type MediaJobErroredEventData = MediaJobStateChangeEventData & { + /** + * Gets the Job outputs. + */ + outputs?: MediaJobOutputUnion[]; +}; + +/** + * Job output canceled event data + */ +export type MediaJobOutputCanceledEventData = MediaJobOutputStateChangeEventData & {}; + +/** + * Job output canceling event data + */ +export type MediaJobOutputCancelingEventData = MediaJobOutputStateChangeEventData & {}; + +/** + * Job output error event data + */ +export type MediaJobOutputErroredEventData = MediaJobOutputStateChangeEventData & {}; + +/** + * Job output finished event data + */ +export type MediaJobOutputFinishedEventData = MediaJobOutputStateChangeEventData & {}; + +/** + * Job output processing event data + */ +export type MediaJobOutputProcessingEventData = MediaJobOutputStateChangeEventData & {}; + +/** + * Job output scheduled event data + */ +export type MediaJobOutputScheduledEventData = MediaJobOutputStateChangeEventData & {}; + +/** + * Encoder connect event data. + */ +export interface MediaLiveEventEncoderConnectedEventData { + /** + * Gets the ingest URL provided by the live event. + */ + readonly ingestUrl?: string; + /** + * Gets the stream Id. + */ + readonly streamId?: string; + /** + * Gets the remote IP. + */ + readonly encoderIp?: string; + /** + * Gets the remote port. + */ + readonly encoderPort?: string; +} + +/** + * Encoder connection rejected event data. + */ +export interface MediaLiveEventConnectionRejectedEventData { + /** + * Gets the ingest URL provided by the live event. + */ + readonly ingestUrl?: string; + /** + * Gets the stream Id. + */ + readonly streamId?: string; + /** + * Gets the remote IP. + */ + readonly encoderIp?: string; + /** + * Gets the remote port. + */ + readonly encoderPort?: string; + /** + * Gets the result code. + */ + readonly resultCode?: string; +} + +/** + * Encoder disconnected event data. + */ +export interface MediaLiveEventEncoderDisconnectedEventData { + /** + * Gets the ingest URL provided by the live event. + */ + readonly ingestUrl?: string; + /** + * Gets the stream Id. + */ + readonly streamId?: string; + /** + * Gets the remote IP. + */ + readonly encoderIp?: string; + /** + * Gets the remote port. + */ + readonly encoderPort?: string; + /** + * Gets the result code. + */ + readonly resultCode?: string; +} + +/** + * Encoder connect event data. + */ +export interface MediaLiveEventIncomingStreamReceivedEventData { + /** + * Gets the ingest URL provided by the live event. + */ + readonly ingestUrl?: string; + /** + * Gets the type of the track (Audio / Video). + */ + readonly trackType?: string; + /** + * Gets the track name. + */ + readonly trackName?: string; + /** + * Gets the bitrate of the track. + */ + readonly bitrate?: number; + /** + * Gets the remote IP. + */ + readonly encoderIp?: string; + /** + * Gets the remote port. + */ + readonly encoderPort?: string; + /** + * Gets the first timestamp of the data chunk received. + */ + readonly timestamp?: string; + /** + * Gets the duration of the first data chunk. + */ + readonly duration?: string; + /** + * Gets the timescale in which timestamp is represented. + */ + readonly timescale?: string; +} + +/** + * Incoming streams out of sync event data. + */ +export interface MediaLiveEventIncomingStreamsOutOfSyncEventData { + /** + * Gets the minimum last timestamp received. + */ + readonly minLastTimestamp?: string; + /** + * Gets the type of stream with minimum last timestamp. + */ + readonly typeOfStreamWithMinLastTimestamp?: string; + /** + * Gets the maximum timestamp among all the tracks (audio or video). + */ + readonly maxLastTimestamp?: string; + /** + * Gets the type of stream with maximum last timestamp. + */ + readonly typeOfStreamWithMaxLastTimestamp?: string; + /** + * Gets the timescale in which "MinLastTimestamp" is represented. + */ + readonly timescaleOfMinLastTimestamp?: string; + /** + * Gets the timescale in which "MaxLastTimestamp" is represented. + */ + readonly timescaleOfMaxLastTimestamp?: string; +} + +/** + * Incoming video stream out of synch event data. + */ +export interface MediaLiveEventIncomingVideoStreamsOutOfSyncEventData { + /** + * Gets the first timestamp received for one of the quality levels. + */ + readonly firstTimestamp?: string; + /** + * Gets the duration of the data chunk with first timestamp. + */ + readonly firstDuration?: string; + /** + * Gets the timestamp received for some other quality levels. + */ + readonly secondTimestamp?: string; + /** + * Gets the duration of the data chunk with second timestamp. + */ + readonly secondDuration?: string; + /** + * Gets the timescale in which both the timestamps and durations are represented. + */ + readonly timescale?: string; +} + +/** + * Ingest fragment dropped event data. + */ +export interface MediaLiveEventIncomingDataChunkDroppedEventData { + /** + * Gets the timestamp of the data chunk dropped. + */ + readonly timestamp?: string; + /** + * Gets the type of the track (Audio / Video). + */ + readonly trackType?: string; + /** + * Gets the bitrate of the track. + */ + readonly bitrate?: number; + /** + * Gets the timescale of the Timestamp. + */ + readonly timescale?: string; + /** + * Gets the result code for fragment drop operation. + */ + readonly resultCode?: string; + /** + * Gets the name of the track for which fragment is dropped. + */ + readonly trackName?: string; +} + +/** + * Ingest fragment dropped event data. + */ +export interface MediaLiveEventIngestHeartbeatEventData { + /** + * Gets the type of the track (Audio / Video). + */ + readonly trackType?: string; + /** + * Gets the track name. + */ + readonly trackName?: string; + /** + * Gets the bitrate of the track. + */ + readonly bitrate?: number; + /** + * Gets the incoming bitrate. + */ + readonly incomingBitrate?: number; + /** + * Gets the last timestamp. + */ + readonly lastTimestamp?: string; + /** + * Gets the timescale of the last timestamp. + */ + readonly timescale?: string; + /** + * Gets the fragment Overlap count. + */ + readonly overlapCount?: number; + /** + * Gets the fragment Discontinuity count. + */ + readonly discontinuityCount?: number; + /** + * Gets Non increasing count. + */ + readonly nonincreasingCount?: number; + /** + * Gets a value indicating whether unexpected bitrate is present or not. + */ + readonly unexpectedBitrate?: boolean; + /** + * Gets the state of the live event. + */ + readonly state?: string; + /** + * Gets a value indicating whether preview is healthy or not. + */ + readonly healthy?: boolean; +} + +/** + * Ingest track discontinuity detected event data. + */ +export interface MediaLiveEventTrackDiscontinuityDetectedEventData { + /** + * Gets the type of the track (Audio / Video). + */ + readonly trackType?: string; + /** + * Gets the track name. + */ + readonly trackName?: string; + /** + * Gets the bitrate. + */ + readonly bitrate?: number; + /** + * Gets the timestamp of the previous fragment. + */ + readonly previousTimestamp?: string; + /** + * Gets the timestamp of the current fragment. + */ + readonly newTimestamp?: string; + /** + * Gets the timescale in which both timestamps and discontinuity gap are represented. + */ + readonly timescale?: string; + /** + * Gets the discontinuity gap between PreviousTimestamp and NewTimestamp. + */ + readonly discontinuityGap?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Geofence event (GeofenceEntered, GeofenceExited, GeofenceResult). + */ +export interface MapsGeofenceEventProperties { + /** + * Lists of the geometry ID of the geofence which is expired relative to the user time in the request. + */ + expiredGeofenceGeometryId?: string[]; + /** + * Lists the fence geometries that either fully contain the coordinate position or have an overlap with the searchBuffer around the fence. + */ + geometries?: MapsGeofenceGeometry[]; + /** + * Lists of the geometry ID of the geofence which is in invalid period relative to the user time in the request. + */ + invalidPeriodGeofenceGeometryId?: string[]; + /** + * True if at least one event is published to the Azure Maps event subscriber, false if no event is published to the Azure Maps event subscriber. + */ + isEventPublished?: boolean; +} + +/** + * The geofence geometry. + */ +export interface MapsGeofenceGeometry { + /** + * ID of the device. + */ + deviceId?: string; + /** + * Distance from the coordinate to the closest border of the geofence. Positive means the coordinate is outside of the geofence. If the coordinate is outside of the geofence, but more than the value of searchBuffer away from the closest geofence border, then the value is 999. Negative means the coordinate is inside of the geofence. If the coordinate is inside the polygon, but more than the value of searchBuffer away from the closest geofencing border,then the value is -999. A value of 999 means that there is great confidence the coordinate is well outside the geofence. A value of -999 means that there is great confidence the coordinate is well within the geofence. + */ + distance?: number; + /** + * The unique ID for the geofence geometry. + */ + geometryId?: string; + /** + * Latitude of the nearest point of the geometry. + */ + nearestLat?: number; + /** + * Longitude of the nearest point of the geometry. + */ + nearestLon?: number; + /** + * The unique id returned from user upload service when uploading a geofence. Will not be included in geofencing post API. + */ + udId?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Maps.GeofenceEntered event. + */ +export type MapsGeofenceEnteredEventData = MapsGeofenceEventProperties & {}; + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Maps.GeofenceExited event. + */ +export type MapsGeofenceExitedEventData = MapsGeofenceEventProperties & {}; + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.Maps.GeofenceResult event. + */ +export type MapsGeofenceResultEventData = MapsGeofenceEventProperties & {}; + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.AppConfiguration.KeyValueModified event. + */ +export interface AppConfigurationKeyValueModifiedEventData { + /** + * The key used to identify the key-value that was modified. + */ + key?: string; + /** + * The label, if any, used to identify the key-value that was modified. + */ + label?: string; + /** + * The etag representing the new state of the key-value. + */ + etag?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.AppConfiguration.KeyValueDeleted event. + */ +export interface AppConfigurationKeyValueDeletedEventData { + /** + * The key used to identify the key-value that was deleted. + */ + key?: string; + /** + * The label, if any, used to identify the key-value that was deleted. + */ + label?: string; + /** + * The etag representing the key-value that was deleted. + */ + etag?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.SignalRService.ClientConnectionConnected event. + */ +export interface SignalRServiceClientConnectionConnectedEventData { + /** + * The time at which the event occurred. + */ + timestamp?: Date; + /** + * The hub of connected client connection. + */ + hubName?: string; + /** + * The connection Id of connected client connection. + */ + connectionId?: string; + /** + * The user Id of connected client connection. + */ + userId?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for a Microsoft.SignalRService.ClientConnectionDisconnected event. + */ +export interface SignalRServiceClientConnectionDisconnectedEventData { + /** + * The time at which the event occurred. + */ + timestamp?: Date; + /** + * The hub of connected client connection. + */ + hubName?: string; + /** + * The connection Id of connected client connection. + */ + connectionId?: string; + /** + * The user Id of connected client connection. + */ + userId?: string; + /** + * The message of error that cause the client connection disconnected. + */ + errorMessage?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an CertificateNewVersionCreated event. + */ +export interface KeyVaultCertificateNewVersionCreatedEventData { + /** + * The id of the object that triggered this event. + */ + id?: string; + /** + * Key vault name of the object that triggered this event. + */ + vaultName?: string; + /** + * The type of the object that triggered this event + */ + objectType?: string; + /** + * The name of the object that triggered this event + */ + objectName?: string; + /** + * The version of the object that triggered this event + */ + version?: string; + /** + * Not before date of the object that triggered this event + */ + nbf?: number; + /** + * The expiration date of the object that triggered this event + */ + exp?: number; +} + +/** + * Schema of the Data property of an EventGridEvent for an CertificateNearExpiry event. + */ +export interface KeyVaultCertificateNearExpiryEventData { + /** + * The id of the object that triggered this event. + */ + id?: string; + /** + * Key vault name of the object that triggered this event. + */ + vaultName?: string; + /** + * The type of the object that triggered this event + */ + objectType?: string; + /** + * The name of the object that triggered this event + */ + objectName?: string; + /** + * The version of the object that triggered this event + */ + version?: string; + /** + * Not before date of the object that triggered this event + */ + nbf?: number; + /** + * The expiration date of the object that triggered this event + */ + exp?: number; +} + +/** + * Schema of the Data property of an EventGridEvent for an CertificateExpired event. + */ +export interface KeyVaultCertificateExpiredEventData { + /** + * The id of the object that triggered this event. + */ + id?: string; + /** + * Key vault name of the object that triggered this event. + */ + vaultName?: string; + /** + * The type of the object that triggered this event + */ + objectType?: string; + /** + * The name of the object that triggered this event + */ + objectName?: string; + /** + * The version of the object that triggered this event + */ + version?: string; + /** + * Not before date of the object that triggered this event + */ + nbf?: number; + /** + * The expiration date of the object that triggered this event + */ + exp?: number; +} + +/** + * Schema of the Data property of an EventGridEvent for an KeyNewVersionCreated event. + */ +export interface KeyVaultKeyNewVersionCreatedEventData { + /** + * The id of the object that triggered this event. + */ + id?: string; + /** + * Key vault name of the object that triggered this event. + */ + vaultName?: string; + /** + * The type of the object that triggered this event + */ + objectType?: string; + /** + * The name of the object that triggered this event + */ + objectName?: string; + /** + * The version of the object that triggered this event + */ + version?: string; + /** + * Not before date of the object that triggered this event + */ + nbf?: number; + /** + * The expiration date of the object that triggered this event + */ + exp?: number; +} + +/** + * Schema of the Data property of an EventGridEvent for an KeyNearExpiry event. + */ +export interface KeyVaultKeyNearExpiryEventData { + /** + * The id of the object that triggered this event. + */ + id?: string; + /** + * Key vault name of the object that triggered this event. + */ + vaultName?: string; + /** + * The type of the object that triggered this event + */ + objectType?: string; + /** + * The name of the object that triggered this event + */ + objectName?: string; + /** + * The version of the object that triggered this event + */ + version?: string; + /** + * Not before date of the object that triggered this event + */ + nbf?: number; + /** + * The expiration date of the object that triggered this event + */ + exp?: number; +} + +/** + * Schema of the Data property of an EventGridEvent for an KeyExpired event. + */ +export interface KeyVaultKeyExpiredEventData { + /** + * The id of the object that triggered this event. + */ + id?: string; + /** + * Key vault name of the object that triggered this event. + */ + vaultName?: string; + /** + * The type of the object that triggered this event + */ + objectType?: string; + /** + * The name of the object that triggered this event + */ + objectName?: string; + /** + * The version of the object that triggered this event + */ + version?: string; + /** + * Not before date of the object that triggered this event + */ + nbf?: number; + /** + * The expiration date of the object that triggered this event + */ + exp?: number; +} + +/** + * Schema of the Data property of an EventGridEvent for an SecretNewVersionCreated event. + */ +export interface KeyVaultSecretNewVersionCreatedEventData { + /** + * The id of the object that triggered this event. + */ + id?: string; + /** + * Key vault name of the object that triggered this event. + */ + vaultName?: string; + /** + * The type of the object that triggered this event + */ + objectType?: string; + /** + * The name of the object that triggered this event + */ + objectName?: string; + /** + * The version of the object that triggered this event + */ + version?: string; + /** + * Not before date of the object that triggered this event + */ + nbf?: number; + /** + * The expiration date of the object that triggered this event + */ + exp?: number; +} + +/** + * Schema of the Data property of an EventGridEvent for an SecretNearExpiry event. + */ +export interface KeyVaultSecretNearExpiryEventData { + /** + * The id of the object that triggered this event. + */ + id?: string; + /** + * Key vault name of the object that triggered this event. + */ + vaultName?: string; + /** + * The type of the object that triggered this event + */ + objectType?: string; + /** + * The name of the object that triggered this event + */ + objectName?: string; + /** + * The version of the object that triggered this event + */ + version?: string; + /** + * Not before date of the object that triggered this event + */ + nbf?: number; + /** + * The expiration date of the object that triggered this event + */ + exp?: number; +} + +/** + * Schema of the Data property of an EventGridEvent for an SecretExpired event. + */ +export interface KeyVaultSecretExpiredEventData { + /** + * The id of the object that triggered this event. + */ + id?: string; + /** + * Key vault name of the object that triggered this event. + */ + vaultName?: string; + /** + * The type of the object that triggered this event + */ + objectType?: string; + /** + * The name of the object that triggered this event + */ + objectName?: string; + /** + * The version of the object that triggered this event + */ + version?: string; + /** + * Not before date of the object that triggered this event + */ + nbf?: number; + /** + * The expiration date of the object that triggered this event + */ + exp?: number; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.MachineLearningServices.ModelRegistered event. + */ +export interface MachineLearningServicesModelRegisteredEventData { + /** + * The name of the model that was registered. + */ + modelName?: string; + /** + * The version of the model that was registered. + */ + modelVersion?: string; + /** + * The tags of the model that was registered. + */ + modelTags?: any; + /** + * The properties of the model that was registered. + */ + modelProperties?: any; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.MachineLearningServices.ModelDeployed event. + */ +export interface MachineLearningServicesModelDeployedEventData { + /** + * The name of the deployed service. + */ + serviceName?: string; + /** + * The compute type (e.g. ACI, AKS) of the deployed service. + */ + serviceComputeType?: string; + /** + * A common separated list of model IDs. The IDs of the models deployed in the service. + */ + modelIds?: string; + /** + * The tags of the deployed service. + */ + serviceTags?: any; + /** + * The properties of the deployed service. + */ + serviceProperties?: any; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.MachineLearningServices.RunCompleted event. + */ +export interface MachineLearningServicesRunCompletedEventData { + /** + * The ID of the experiment that the run belongs to. + */ + experimentId?: string; + /** + * The name of the experiment that the run belongs to. + */ + experimentName?: string; + /** + * The ID of the Run that was completed. + */ + runId?: string; + /** + * The Run Type of the completed Run. + */ + runType?: string; + /** + * The tags of the completed Run. + */ + runTags?: any; + /** + * The properties of the completed Run. + */ + runProperties?: any; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.MachineLearningServices.DatasetDriftDetected event. + */ +export interface MachineLearningServicesDatasetDriftDetectedEventData { + /** + * The ID of the data drift monitor that triggered the event. + */ + dataDriftId?: string; + /** + * The name of the data drift monitor that triggered the event. + */ + dataDriftName?: string; + /** + * The ID of the Run that detected data drift. + */ + runId?: string; + /** + * The ID of the base Dataset used to detect drift. + */ + baseDatasetId?: string; + /** + * The ID of the target Dataset used to detect drift. + */ + targetDatasetId?: string; + /** + * The coefficient result that triggered the event. + */ + driftCoefficient?: number; + /** + * The start time of the target dataset time series that resulted in drift detection. + */ + startTime?: Date; + /** + * The end time of the target dataset time series that resulted in drift detection. + */ + endTime?: Date; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.MachineLearningServices.RunStatusChanged event. + */ +export interface MachineLearningServicesRunStatusChangedEventData { + /** + * The ID of the experiment that the Machine Learning Run belongs to. + */ + experimentId?: string; + /** + * The name of the experiment that the Machine Learning Run belongs to. + */ + experimentName?: string; + /** + * The ID of the Machine Learning Run. + */ + runId?: string; + /** + * The Run Type of the Machine Learning Run. + */ + runType?: string; + /** + * The tags of the Machine Learning Run. + */ + runTags?: any; + /** + * The properties of the Machine Learning Run. + */ + runProperties?: any; + /** + * The status of the Machine Learning Run. + */ + runStatus?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Cache.PatchingCompleted event. + */ +export interface RedisPatchingCompletedEventData { + /** + * The time at which the event occurred. + */ + timestamp?: Date; + /** + * The name of this event. + */ + name?: string; + /** + * The status of this event. Failed or succeeded + */ + status?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Cache.ScalingCompleted event. + */ +export interface RedisScalingCompletedEventData { + /** + * The time at which the event occurred. + */ + timestamp?: Date; + /** + * The name of this event. + */ + name?: string; + /** + * The status of this event. Failed or succeeded + */ + status?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Cache.ExportRDBCompleted event. + */ +export interface RedisExportRDBCompletedEventData { + /** + * The time at which the event occurred. + */ + timestamp?: Date; + /** + * The name of this event. + */ + name?: string; + /** + * The status of this event. Failed or succeeded + */ + status?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Cache.ImportRDBCompleted event. + */ +export interface RedisImportRDBCompletedEventData { + /** + * The time at which the event occurred. + */ + timestamp?: Date; + /** + * The name of this event. + */ + name?: string; + /** + * The status of this event. Failed or succeeded + */ + status?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.AppUpdated event. + */ +export interface WebAppUpdatedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Detail of action on the app. + */ +export interface AppEventTypeDetail { + /** + * Type of action of the operation. + */ + action?: AppAction; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.BackupOperationStarted event. + */ +export interface WebBackupOperationStartedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.BackupOperationCompleted event. + */ +export interface WebBackupOperationCompletedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.BackupOperationFailed event. + */ +export interface WebBackupOperationFailedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.RestoreOperationStarted event. + */ +export interface WebRestoreOperationStartedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.RestoreOperationCompleted event. + */ +export interface WebRestoreOperationCompletedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.RestoreOperationFailed event. + */ +export interface WebRestoreOperationFailedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.SlotSwapStarted event. + */ +export interface WebSlotSwapStartedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.SlotSwapCompleted event. + */ +export interface WebSlotSwapCompletedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.SlotSwapFailed event. + */ +export interface WebSlotSwapFailedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.SlotSwapWithPreviewStarted event. + */ +export interface WebSlotSwapWithPreviewStartedEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.SlotSwapWithPreviewCancelled event. + */ +export interface WebSlotSwapWithPreviewCancelledEventData { + /** + * Detail of action on the app. + */ + appEventTypeDetail?: AppEventTypeDetail; + /** + * name of the web site that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the site API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the site API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the site API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Web.AppServicePlanUpdated event. + */ +export interface WebAppServicePlanUpdatedEventData { + /** + * Detail of action on the app service plan. + */ + appServicePlanEventTypeDetail?: AppServicePlanEventTypeDetail; + /** + * sku of app service plan. + */ + sku?: WebAppServicePlanUpdatedEventDataSku; + /** + * name of the app service plan that had this event. + */ + name?: string; + /** + * The client request id generated by the app service for the app service plan API operation that triggered this event. + */ + clientRequestId?: string; + /** + * The correlation request id generated by the app service for the app service plan API operation that triggered this event. + */ + correlationRequestId?: string; + /** + * The request id generated by the app service for the app service plan API operation that triggered this event. + */ + requestId?: string; + /** + * HTTP request URL of this operation. + */ + address?: string; + /** + * HTTP verb of this operation. + */ + verb?: string; +} + +/** + * Detail of action on the app service plan. + */ +export interface AppServicePlanEventTypeDetail { + /** + * Kind of environment where app service plan is. + */ + stampKind?: StampKind; + /** + * Type of action on the app service plan. + */ + action?: "Updated"; + /** + * Asynchronous operation status of the operation on the app service plan. + */ + status?: AsyncStatus; +} + +/** + * sku of app service plan. + */ +export interface WebAppServicePlanUpdatedEventDataSku { + /** + * name of app service plan sku. + */ + name?: string; + /** + * tier of app service plan sku. + */ + tier?: string; + /** + * size of app service plan sku. + */ + size?: string; + /** + * family of app service plan sku. + */ + family?: string; + /** + * capacity of app service plan sku. + */ + capacity?: string; +} + +/** + * Defines values for AppAction. + */ +export type AppAction = + | "Restarted" + | "Stopped" + | "ChangedAppSettings" + | "Started" + | "Completed" + | "Failed"; +/** + * Defines values for StampKind. + */ +export type StampKind = "Public" | "AseV1" | "AseV2"; +/** + * Defines values for AsyncStatus. + */ +export type AsyncStatus = "Started" | "Completed" | "Failed"; +/** + * Defines values for MediaJobState. + */ +export type MediaJobState = + | "Canceled" + | "Canceling" + | "Error" + | "Finished" + | "Processing" + | "Queued" + | "Scheduled"; +/** + * Defines values for MediaJobErrorCode. + */ +export type MediaJobErrorCode = + | "ServiceError" + | "ServiceTransientError" + | "DownloadNotAccessible" + | "DownloadTransientError" + | "UploadNotAccessible" + | "UploadTransientError" + | "ConfigurationUnsupported" + | "ContentMalformed" + | "ContentUnsupported"; +/** + * Defines values for MediaJobErrorCategory. + */ +export type MediaJobErrorCategory = + | "Service" + | "Download" + | "Upload" + | "Configuration" + | "Content"; +/** + * Defines values for MediaJobRetry. + */ +export type MediaJobRetry = "DoNotRetry" | "MayRetry"; + +/** + * Optional parameters. + */ +export interface GeneratedClientOptionalParams + extends coreHttp.ServiceClientOptions { + /** + * Api Version + */ + apiVersion?: string; + /** + * Overrides client endpoint. + */ + endpoint?: string; +} diff --git a/sdk/eventgrid/eventgrid/src/generated/models/mappers.ts b/sdk/eventgrid/eventgrid/src/generated/models/mappers.ts new file mode 100644 index 000000000000..f937243b0970 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/generated/models/mappers.ts @@ -0,0 +1,4750 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; + +export const EventGridEvent: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "EventGridEvent", + modelProperties: { + id: { + serializedName: "id", + required: true, + type: { + name: "String" + } + }, + topic: { + serializedName: "topic", + type: { + name: "String" + } + }, + subject: { + serializedName: "subject", + required: true, + type: { + name: "String" + } + }, + data: { + serializedName: "data", + required: true, + type: { + name: "any" + } + }, + eventType: { + serializedName: "eventType", + required: true, + type: { + name: "String" + } + }, + eventTime: { + serializedName: "eventTime", + required: true, + type: { + name: "DateTime" + } + }, + metadataVersion: { + serializedName: "metadataVersion", + readOnly: true, + type: { + name: "String" + } + }, + dataVersion: { + serializedName: "dataVersion", + required: true, + type: { + name: "String" + } + } + } + } +}; + +export const CloudEvent: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "CloudEvent", + additionalProperties: { type: { name: "Object" } }, + modelProperties: { + id: { + serializedName: "id", + required: true, + type: { + name: "String" + } + }, + source: { + serializedName: "source", + required: true, + type: { + name: "String" + } + }, + data: { + serializedName: "data", + type: { + name: "any" + } + }, + dataBase64: { + serializedName: "data_base64", + type: { + name: "String" + } + }, + type: { + serializedName: "type", + required: true, + type: { + name: "String" + } + }, + time: { + serializedName: "time", + type: { + name: "DateTime" + } + }, + specversion: { + serializedName: "specversion", + required: true, + type: { + name: "String" + } + }, + dataschema: { + serializedName: "dataschema", + type: { + name: "String" + } + }, + datacontenttype: { + serializedName: "datacontenttype", + type: { + name: "String" + } + }, + subject: { + serializedName: "subject", + type: { + name: "String" + } + } + } + } +}; + +export const StorageBlobCreatedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "StorageBlobCreatedEventData", + modelProperties: { + api: { + serializedName: "api", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + eTag: { + serializedName: "eTag", + type: { + name: "String" + } + }, + contentType: { + serializedName: "contentType", + type: { + name: "String" + } + }, + contentLength: { + serializedName: "contentLength", + type: { + name: "Number" + } + }, + contentOffset: { + serializedName: "contentOffset", + type: { + name: "Number" + } + }, + blobType: { + serializedName: "blobType", + type: { + name: "String" + } + }, + url: { + serializedName: "url", + type: { + name: "String" + } + }, + sequencer: { + serializedName: "sequencer", + type: { + name: "String" + } + }, + identity: { + serializedName: "identity", + type: { + name: "String" + } + }, + storageDiagnostics: { + serializedName: "storageDiagnostics", + type: { + name: "any" + } + } + } + } +}; + +export const StorageBlobDeletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "StorageBlobDeletedEventData", + modelProperties: { + api: { + serializedName: "api", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + contentType: { + serializedName: "contentType", + type: { + name: "String" + } + }, + blobType: { + serializedName: "blobType", + type: { + name: "String" + } + }, + url: { + serializedName: "url", + type: { + name: "String" + } + }, + sequencer: { + serializedName: "sequencer", + type: { + name: "String" + } + }, + identity: { + serializedName: "identity", + type: { + name: "String" + } + }, + storageDiagnostics: { + serializedName: "storageDiagnostics", + type: { + name: "any" + } + } + } + } +}; + +export const StorageDirectoryCreatedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "StorageDirectoryCreatedEventData", + modelProperties: { + api: { + serializedName: "api", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + eTag: { + serializedName: "eTag", + type: { + name: "String" + } + }, + url: { + serializedName: "url", + type: { + name: "String" + } + }, + sequencer: { + serializedName: "sequencer", + type: { + name: "String" + } + }, + identity: { + serializedName: "identity", + type: { + name: "String" + } + }, + storageDiagnostics: { + serializedName: "storageDiagnostics", + type: { + name: "any" + } + } + } + } +}; + +export const StorageDirectoryDeletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "StorageDirectoryDeletedEventData", + modelProperties: { + api: { + serializedName: "api", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + url: { + serializedName: "url", + type: { + name: "String" + } + }, + recursive: { + serializedName: "recursive", + type: { + name: "Boolean" + } + }, + sequencer: { + serializedName: "sequencer", + type: { + name: "String" + } + }, + identity: { + serializedName: "identity", + type: { + name: "String" + } + }, + storageDiagnostics: { + serializedName: "storageDiagnostics", + type: { + name: "any" + } + } + } + } +}; + +export const StorageBlobRenamedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "StorageBlobRenamedEventData", + modelProperties: { + api: { + serializedName: "api", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + sourceUrl: { + serializedName: "sourceUrl", + type: { + name: "String" + } + }, + destinationUrl: { + serializedName: "destinationUrl", + type: { + name: "String" + } + }, + sequencer: { + serializedName: "sequencer", + type: { + name: "String" + } + }, + identity: { + serializedName: "identity", + type: { + name: "String" + } + }, + storageDiagnostics: { + serializedName: "storageDiagnostics", + type: { + name: "any" + } + } + } + } +}; + +export const StorageDirectoryRenamedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "StorageDirectoryRenamedEventData", + modelProperties: { + api: { + serializedName: "api", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + sourceUrl: { + serializedName: "sourceUrl", + type: { + name: "String" + } + }, + destinationUrl: { + serializedName: "destinationUrl", + type: { + name: "String" + } + }, + sequencer: { + serializedName: "sequencer", + type: { + name: "String" + } + }, + identity: { + serializedName: "identity", + type: { + name: "String" + } + }, + storageDiagnostics: { + serializedName: "storageDiagnostics", + type: { + name: "any" + } + } + } + } +}; + +export const EventHubCaptureFileCreatedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "EventHubCaptureFileCreatedEventData", + modelProperties: { + fileurl: { + serializedName: "fileurl", + type: { + name: "String" + } + }, + fileType: { + serializedName: "fileType", + type: { + name: "String" + } + }, + partitionId: { + serializedName: "partitionId", + type: { + name: "String" + } + }, + sizeInBytes: { + serializedName: "sizeInBytes", + type: { + name: "Number" + } + }, + eventCount: { + serializedName: "eventCount", + type: { + name: "Number" + } + }, + firstSequenceNumber: { + serializedName: "firstSequenceNumber", + type: { + name: "Number" + } + }, + lastSequenceNumber: { + serializedName: "lastSequenceNumber", + type: { + name: "Number" + } + }, + firstEnqueueTime: { + serializedName: "firstEnqueueTime", + type: { + name: "DateTime" + } + }, + lastEnqueueTime: { + serializedName: "lastEnqueueTime", + type: { + name: "DateTime" + } + } + } + } +}; + +export const ResourceWriteSuccessEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceWriteSuccessEventData", + modelProperties: { + tenantId: { + serializedName: "tenantId", + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + resourceGroup: { + serializedName: "resourceGroup", + type: { + name: "String" + } + }, + resourceProvider: { + serializedName: "resourceProvider", + type: { + name: "String" + } + }, + resourceUri: { + serializedName: "resourceUri", + type: { + name: "String" + } + }, + operationName: { + serializedName: "operationName", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + authorization: { + serializedName: "authorization", + type: { + name: "String" + } + }, + claims: { + serializedName: "claims", + type: { + name: "String" + } + }, + correlationId: { + serializedName: "correlationId", + type: { + name: "String" + } + }, + httpRequest: { + serializedName: "httpRequest", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceWriteFailureEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceWriteFailureEventData", + modelProperties: { + tenantId: { + serializedName: "tenantId", + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + resourceGroup: { + serializedName: "resourceGroup", + type: { + name: "String" + } + }, + resourceProvider: { + serializedName: "resourceProvider", + type: { + name: "String" + } + }, + resourceUri: { + serializedName: "resourceUri", + type: { + name: "String" + } + }, + operationName: { + serializedName: "operationName", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + authorization: { + serializedName: "authorization", + type: { + name: "String" + } + }, + claims: { + serializedName: "claims", + type: { + name: "String" + } + }, + correlationId: { + serializedName: "correlationId", + type: { + name: "String" + } + }, + httpRequest: { + serializedName: "httpRequest", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceWriteCancelEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceWriteCancelEventData", + modelProperties: { + tenantId: { + serializedName: "tenantId", + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + resourceGroup: { + serializedName: "resourceGroup", + type: { + name: "String" + } + }, + resourceProvider: { + serializedName: "resourceProvider", + type: { + name: "String" + } + }, + resourceUri: { + serializedName: "resourceUri", + type: { + name: "String" + } + }, + operationName: { + serializedName: "operationName", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + authorization: { + serializedName: "authorization", + type: { + name: "String" + } + }, + claims: { + serializedName: "claims", + type: { + name: "String" + } + }, + correlationId: { + serializedName: "correlationId", + type: { + name: "String" + } + }, + httpRequest: { + serializedName: "httpRequest", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceDeleteSuccessEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceDeleteSuccessEventData", + modelProperties: { + tenantId: { + serializedName: "tenantId", + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + resourceGroup: { + serializedName: "resourceGroup", + type: { + name: "String" + } + }, + resourceProvider: { + serializedName: "resourceProvider", + type: { + name: "String" + } + }, + resourceUri: { + serializedName: "resourceUri", + type: { + name: "String" + } + }, + operationName: { + serializedName: "operationName", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + authorization: { + serializedName: "authorization", + type: { + name: "String" + } + }, + claims: { + serializedName: "claims", + type: { + name: "String" + } + }, + correlationId: { + serializedName: "correlationId", + type: { + name: "String" + } + }, + httpRequest: { + serializedName: "httpRequest", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceDeleteFailureEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceDeleteFailureEventData", + modelProperties: { + tenantId: { + serializedName: "tenantId", + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + resourceGroup: { + serializedName: "resourceGroup", + type: { + name: "String" + } + }, + resourceProvider: { + serializedName: "resourceProvider", + type: { + name: "String" + } + }, + resourceUri: { + serializedName: "resourceUri", + type: { + name: "String" + } + }, + operationName: { + serializedName: "operationName", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + authorization: { + serializedName: "authorization", + type: { + name: "String" + } + }, + claims: { + serializedName: "claims", + type: { + name: "String" + } + }, + correlationId: { + serializedName: "correlationId", + type: { + name: "String" + } + }, + httpRequest: { + serializedName: "httpRequest", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceDeleteCancelEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceDeleteCancelEventData", + modelProperties: { + tenantId: { + serializedName: "tenantId", + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + resourceGroup: { + serializedName: "resourceGroup", + type: { + name: "String" + } + }, + resourceProvider: { + serializedName: "resourceProvider", + type: { + name: "String" + } + }, + resourceUri: { + serializedName: "resourceUri", + type: { + name: "String" + } + }, + operationName: { + serializedName: "operationName", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + authorization: { + serializedName: "authorization", + type: { + name: "String" + } + }, + claims: { + serializedName: "claims", + type: { + name: "String" + } + }, + correlationId: { + serializedName: "correlationId", + type: { + name: "String" + } + }, + httpRequest: { + serializedName: "httpRequest", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceActionSuccessEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceActionSuccessEventData", + modelProperties: { + tenantId: { + serializedName: "tenantId", + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + resourceGroup: { + serializedName: "resourceGroup", + type: { + name: "String" + } + }, + resourceProvider: { + serializedName: "resourceProvider", + type: { + name: "String" + } + }, + resourceUri: { + serializedName: "resourceUri", + type: { + name: "String" + } + }, + operationName: { + serializedName: "operationName", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + authorization: { + serializedName: "authorization", + type: { + name: "String" + } + }, + claims: { + serializedName: "claims", + type: { + name: "String" + } + }, + correlationId: { + serializedName: "correlationId", + type: { + name: "String" + } + }, + httpRequest: { + serializedName: "httpRequest", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceActionFailureEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceActionFailureEventData", + modelProperties: { + tenantId: { + serializedName: "tenantId", + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + resourceGroup: { + serializedName: "resourceGroup", + type: { + name: "String" + } + }, + resourceProvider: { + serializedName: "resourceProvider", + type: { + name: "String" + } + }, + resourceUri: { + serializedName: "resourceUri", + type: { + name: "String" + } + }, + operationName: { + serializedName: "operationName", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + authorization: { + serializedName: "authorization", + type: { + name: "String" + } + }, + claims: { + serializedName: "claims", + type: { + name: "String" + } + }, + correlationId: { + serializedName: "correlationId", + type: { + name: "String" + } + }, + httpRequest: { + serializedName: "httpRequest", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceActionCancelEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceActionCancelEventData", + modelProperties: { + tenantId: { + serializedName: "tenantId", + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + resourceGroup: { + serializedName: "resourceGroup", + type: { + name: "String" + } + }, + resourceProvider: { + serializedName: "resourceProvider", + type: { + name: "String" + } + }, + resourceUri: { + serializedName: "resourceUri", + type: { + name: "String" + } + }, + operationName: { + serializedName: "operationName", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + authorization: { + serializedName: "authorization", + type: { + name: "String" + } + }, + claims: { + serializedName: "claims", + type: { + name: "String" + } + }, + correlationId: { + serializedName: "correlationId", + type: { + name: "String" + } + }, + httpRequest: { + serializedName: "httpRequest", + type: { + name: "String" + } + } + } + } +}; + +export const SubscriptionValidationEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "SubscriptionValidationEventData", + modelProperties: { + validationCode: { + serializedName: "validationCode", + readOnly: true, + type: { + name: "String" + } + }, + validationUrl: { + serializedName: "validationUrl", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const SubscriptionValidationResponse: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "SubscriptionValidationResponse", + modelProperties: { + validationResponse: { + serializedName: "validationResponse", + type: { + name: "String" + } + } + } + } +}; + +export const SubscriptionDeletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "SubscriptionDeletedEventData", + modelProperties: { + eventSubscriptionId: { + serializedName: "eventSubscriptionId", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const DeviceLifeCycleEventProperties: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "DeviceLifeCycleEventProperties", + modelProperties: { + deviceId: { + serializedName: "deviceId", + type: { + name: "String" + } + }, + hubName: { + serializedName: "hubName", + type: { + name: "String" + } + }, + twin: { + serializedName: "twin", + type: { + name: "Composite", + className: "DeviceTwinInfo" + } + } + } + } +}; + +export const DeviceTwinInfo: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "DeviceTwinInfo", + modelProperties: { + authenticationType: { + serializedName: "authenticationType", + type: { + name: "String" + } + }, + cloudToDeviceMessageCount: { + serializedName: "cloudToDeviceMessageCount", + type: { + name: "Number" + } + }, + connectionState: { + serializedName: "connectionState", + type: { + name: "String" + } + }, + deviceId: { + serializedName: "deviceId", + type: { + name: "String" + } + }, + etag: { + serializedName: "etag", + type: { + name: "String" + } + }, + lastActivityTime: { + serializedName: "lastActivityTime", + type: { + name: "String" + } + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "DeviceTwinInfoProperties" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + statusUpdateTime: { + serializedName: "statusUpdateTime", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "Number" + } + }, + x509Thumbprint: { + serializedName: "x509Thumbprint", + type: { + name: "Composite", + className: "DeviceTwinInfoX509Thumbprint" + } + } + } + } +}; + +export const DeviceTwinInfoProperties: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "DeviceTwinInfoProperties", + modelProperties: { + desired: { + serializedName: "desired", + type: { + name: "Composite", + className: "DeviceTwinProperties" + } + }, + reported: { + serializedName: "reported", + type: { + name: "Composite", + className: "DeviceTwinProperties" + } + } + } + } +}; + +export const DeviceTwinProperties: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "DeviceTwinProperties", + modelProperties: { + metadata: { + serializedName: "metadata", + type: { + name: "Composite", + className: "DeviceTwinMetadata" + } + }, + version: { + serializedName: "version", + type: { + name: "Number" + } + } + } + } +}; + +export const DeviceTwinMetadata: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "DeviceTwinMetadata", + modelProperties: { + lastUpdated: { + serializedName: "lastUpdated", + type: { + name: "String" + } + } + } + } +}; + +export const DeviceTwinInfoX509Thumbprint: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "DeviceTwinInfoX509Thumbprint", + modelProperties: { + primaryThumbprint: { + serializedName: "primaryThumbprint", + type: { + name: "String" + } + }, + secondaryThumbprint: { + serializedName: "secondaryThumbprint", + type: { + name: "String" + } + } + } + } +}; + +export const IotHubDeviceCreatedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "IotHubDeviceCreatedEventData", + modelProperties: { + ...DeviceLifeCycleEventProperties.type.modelProperties + } + } +}; + +export const IotHubDeviceDeletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "IotHubDeviceDeletedEventData", + modelProperties: { + ...DeviceLifeCycleEventProperties.type.modelProperties + } + } +}; + +export const DeviceConnectionStateEventProperties: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "DeviceConnectionStateEventProperties", + modelProperties: { + deviceId: { + serializedName: "deviceId", + type: { + name: "String" + } + }, + moduleId: { + serializedName: "moduleId", + type: { + name: "String" + } + }, + hubName: { + serializedName: "hubName", + type: { + name: "String" + } + }, + deviceConnectionStateEventInfo: { + serializedName: "deviceConnectionStateEventInfo", + type: { + name: "Composite", + className: "DeviceConnectionStateEventInfo" + } + } + } + } +}; + +export const DeviceConnectionStateEventInfo: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "DeviceConnectionStateEventInfo", + modelProperties: { + sequenceNumber: { + serializedName: "sequenceNumber", + type: { + name: "String" + } + } + } + } +}; + +export const IotHubDeviceConnectedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "IotHubDeviceConnectedEventData", + modelProperties: { + ...DeviceConnectionStateEventProperties.type.modelProperties + } + } +}; + +export const IotHubDeviceDisconnectedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "IotHubDeviceDisconnectedEventData", + modelProperties: { + ...DeviceConnectionStateEventProperties.type.modelProperties + } + } +}; + +export const DeviceTelemetryEventProperties: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "DeviceTelemetryEventProperties", + modelProperties: { + body: { + serializedName: "body", + type: { + name: "any" + } + }, + properties: { + serializedName: "properties", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + }, + systemProperties: { + serializedName: "systemProperties", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + } + } + } +}; + +export const IotHubDeviceTelemetryEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "IotHubDeviceTelemetryEventData", + modelProperties: { + ...DeviceTelemetryEventProperties.type.modelProperties + } + } +}; + +export const ContainerRegistryEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + timestamp: { + serializedName: "timestamp", + type: { + name: "DateTime" + } + }, + action: { + serializedName: "action", + type: { + name: "String" + } + }, + target: { + serializedName: "target", + type: { + name: "Composite", + className: "ContainerRegistryEventTarget" + } + }, + request: { + serializedName: "request", + type: { + name: "Composite", + className: "ContainerRegistryEventRequest" + } + }, + actor: { + serializedName: "actor", + type: { + name: "Composite", + className: "ContainerRegistryEventActor" + } + }, + source: { + serializedName: "source", + type: { + name: "Composite", + className: "ContainerRegistryEventSource" + } + } + } + } +}; + +export const ContainerRegistryEventTarget: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryEventTarget", + modelProperties: { + mediaType: { + serializedName: "mediaType", + type: { + name: "String" + } + }, + size: { + serializedName: "size", + type: { + name: "Number" + } + }, + digest: { + serializedName: "digest", + type: { + name: "String" + } + }, + length: { + serializedName: "length", + type: { + name: "Number" + } + }, + repository: { + serializedName: "repository", + type: { + name: "String" + } + }, + url: { + serializedName: "url", + type: { + name: "String" + } + }, + tag: { + serializedName: "tag", + type: { + name: "String" + } + } + } + } +}; + +export const ContainerRegistryEventRequest: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryEventRequest", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + addr: { + serializedName: "addr", + type: { + name: "String" + } + }, + host: { + serializedName: "host", + type: { + name: "String" + } + }, + method: { + serializedName: "method", + type: { + name: "String" + } + }, + useragent: { + serializedName: "useragent", + type: { + name: "String" + } + } + } + } +}; + +export const ContainerRegistryEventActor: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryEventActor", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + } + } + } +}; + +export const ContainerRegistryEventSource: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryEventSource", + modelProperties: { + addr: { + serializedName: "addr", + type: { + name: "String" + } + }, + instanceID: { + serializedName: "instanceID", + type: { + name: "String" + } + } + } + } +}; + +export const ContainerRegistryImagePushedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryImagePushedEventData", + modelProperties: { + ...ContainerRegistryEventData.type.modelProperties + } + } +}; + +export const ContainerRegistryImageDeletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryImageDeletedEventData", + modelProperties: { + ...ContainerRegistryEventData.type.modelProperties + } + } +}; + +export const ContainerRegistryArtifactEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryArtifactEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + timestamp: { + serializedName: "timestamp", + type: { + name: "DateTime" + } + }, + action: { + serializedName: "action", + type: { + name: "String" + } + }, + target: { + serializedName: "target", + type: { + name: "Composite", + className: "ContainerRegistryArtifactEventTarget" + } + } + } + } +}; + +export const ContainerRegistryArtifactEventTarget: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryArtifactEventTarget", + modelProperties: { + mediaType: { + serializedName: "mediaType", + type: { + name: "String" + } + }, + size: { + serializedName: "size", + type: { + name: "Number" + } + }, + digest: { + serializedName: "digest", + type: { + name: "String" + } + }, + repository: { + serializedName: "repository", + type: { + name: "String" + } + }, + tag: { + serializedName: "tag", + type: { + name: "String" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + } + } + } +}; + +export const ContainerRegistryChartPushedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryChartPushedEventData", + modelProperties: { + ...ContainerRegistryArtifactEventData.type.modelProperties + } + } +}; + +export const ContainerRegistryChartDeletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ContainerRegistryChartDeletedEventData", + modelProperties: { + ...ContainerRegistryArtifactEventData.type.modelProperties + } + } +}; + +export const ServiceBusActiveMessagesAvailableWithNoListenersEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ServiceBusActiveMessagesAvailableWithNoListenersEventData", + modelProperties: { + namespaceName: { + serializedName: "namespaceName", + type: { + name: "String" + } + }, + requestUri: { + serializedName: "requestUri", + type: { + name: "String" + } + }, + entityType: { + serializedName: "entityType", + type: { + name: "String" + } + }, + queueName: { + serializedName: "queueName", + type: { + name: "String" + } + }, + topicName: { + serializedName: "topicName", + type: { + name: "String" + } + }, + subscriptionName: { + serializedName: "subscriptionName", + type: { + name: "String" + } + } + } + } +}; + +export const ServiceBusDeadletterMessagesAvailableWithNoListenersEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ServiceBusDeadletterMessagesAvailableWithNoListenersEventData", + modelProperties: { + namespaceName: { + serializedName: "namespaceName", + type: { + name: "String" + } + }, + requestUri: { + serializedName: "requestUri", + type: { + name: "String" + } + }, + entityType: { + serializedName: "entityType", + type: { + name: "String" + } + }, + queueName: { + serializedName: "queueName", + type: { + name: "String" + } + }, + topicName: { + serializedName: "topicName", + type: { + name: "String" + } + }, + subscriptionName: { + serializedName: "subscriptionName", + type: { + name: "String" + } + } + } + } +}; + +export const MediaJobStateChangeEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaJobStateChangeEventData", + modelProperties: { + previousState: { + serializedName: "previousState", + readOnly: true, + type: { + name: "Enum", + allowedValues: [ + "Canceled", + "Canceling", + "Error", + "Finished", + "Processing", + "Queued", + "Scheduled" + ] + } + }, + state: { + serializedName: "state", + readOnly: true, + type: { + name: "Enum", + allowedValues: [ + "Canceled", + "Canceling", + "Error", + "Finished", + "Processing", + "Queued", + "Scheduled" + ] + } + }, + correlationData: { + serializedName: "correlationData", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + } + } + } +}; + +export const MediaJobError: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaJobError", + modelProperties: { + code: { + serializedName: "code", + readOnly: true, + type: { + name: "Enum", + allowedValues: [ + "ServiceError", + "ServiceTransientError", + "DownloadNotAccessible", + "DownloadTransientError", + "UploadNotAccessible", + "UploadTransientError", + "ConfigurationUnsupported", + "ContentMalformed", + "ContentUnsupported" + ] + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + }, + category: { + serializedName: "category", + readOnly: true, + type: { + name: "Enum", + allowedValues: [ + "Service", + "Download", + "Upload", + "Configuration", + "Content" + ] + } + }, + retry: { + serializedName: "retry", + readOnly: true, + type: { + name: "Enum", + allowedValues: ["DoNotRetry", "MayRetry"] + } + }, + details: { + serializedName: "details", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { name: "Composite", className: "MediaJobErrorDetail" } + } + } + } + } + } +}; + +export const MediaJobErrorDetail: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaJobErrorDetail", + modelProperties: { + code: { + serializedName: "code", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const MediaJobOutput: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaJobOutput", + uberParent: "MediaJobOutput", + polymorphicDiscriminator: { + serializedName: "@odata\\.type", + clientName: "@odata\\.type" + }, + modelProperties: { + odataType: { + serializedName: "@odata\\.type", + type: { + name: "String" + } + }, + error: { + serializedName: "error", + type: { + name: "Composite", + className: "MediaJobError" + } + }, + label: { + serializedName: "label", + type: { + name: "String" + } + }, + progress: { + serializedName: "progress", + required: true, + type: { + name: "Number" + } + }, + state: { + serializedName: "state", + required: true, + type: { + name: "Enum", + allowedValues: [ + "Canceled", + "Canceling", + "Error", + "Finished", + "Processing", + "Queued", + "Scheduled" + ] + } + } + } + } +}; + +export const MediaJobOutputAsset: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobOutputAsset", + type: { + name: "Composite", + className: "MediaJobOutputAsset", + uberParent: "MediaJobOutput", + polymorphicDiscriminator: MediaJobOutput.type.polymorphicDiscriminator, + modelProperties: { + ...MediaJobOutput.type.modelProperties, + assetName: { + serializedName: "assetName", + type: { + name: "String" + } + } + } + } +}; + +export const MediaJobOutputProgressEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobOutputProgress", + type: { + name: "Composite", + className: "MediaJobOutputProgressEventData", + modelProperties: { + label: { + serializedName: "label", + type: { + name: "String" + } + }, + progress: { + serializedName: "progress", + type: { + name: "Number" + } + }, + jobCorrelationData: { + serializedName: "jobCorrelationData", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + } + } + } +}; + +export const MediaJobOutputStateChangeEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaJobOutputStateChangeEventData", + modelProperties: { + previousState: { + serializedName: "previousState", + readOnly: true, + type: { + name: "Enum", + allowedValues: [ + "Canceled", + "Canceling", + "Error", + "Finished", + "Processing", + "Queued", + "Scheduled" + ] + } + }, + output: { + serializedName: "output", + type: { + name: "Composite", + className: "MediaJobOutput" + } + }, + jobCorrelationData: { + serializedName: "jobCorrelationData", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + } + } + } +}; + +export const MediaJobScheduledEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobScheduled", + type: { + name: "Composite", + className: "MediaJobScheduledEventData", + modelProperties: { + ...MediaJobStateChangeEventData.type.modelProperties + } + } +}; + +export const MediaJobProcessingEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobProcessing", + type: { + name: "Composite", + className: "MediaJobProcessingEventData", + modelProperties: { + ...MediaJobStateChangeEventData.type.modelProperties + } + } +}; + +export const MediaJobCancelingEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobCanceling", + type: { + name: "Composite", + className: "MediaJobCancelingEventData", + modelProperties: { + ...MediaJobStateChangeEventData.type.modelProperties + } + } +}; + +export const MediaJobFinishedEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobFinished", + type: { + name: "Composite", + className: "MediaJobFinishedEventData", + modelProperties: { + ...MediaJobStateChangeEventData.type.modelProperties, + outputs: { + serializedName: "outputs", + type: { + name: "Sequence", + element: { type: { name: "Composite", className: "MediaJobOutput" } } + } + } + } + } +}; + +export const MediaJobCanceledEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobCanceled", + type: { + name: "Composite", + className: "MediaJobCanceledEventData", + modelProperties: { + ...MediaJobStateChangeEventData.type.modelProperties, + outputs: { + serializedName: "outputs", + type: { + name: "Sequence", + element: { type: { name: "Composite", className: "MediaJobOutput" } } + } + } + } + } +}; + +export const MediaJobErroredEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobErrored", + type: { + name: "Composite", + className: "MediaJobErroredEventData", + modelProperties: { + ...MediaJobStateChangeEventData.type.modelProperties, + outputs: { + serializedName: "outputs", + type: { + name: "Sequence", + element: { type: { name: "Composite", className: "MediaJobOutput" } } + } + } + } + } +}; + +export const MediaJobOutputCanceledEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobOutputCanceled", + type: { + name: "Composite", + className: "MediaJobOutputCanceledEventData", + modelProperties: { + ...MediaJobOutputStateChangeEventData.type.modelProperties + } + } +}; + +export const MediaJobOutputCancelingEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobOutputCanceling", + type: { + name: "Composite", + className: "MediaJobOutputCancelingEventData", + modelProperties: { + ...MediaJobOutputStateChangeEventData.type.modelProperties + } + } +}; + +export const MediaJobOutputErroredEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobOutputErrored", + type: { + name: "Composite", + className: "MediaJobOutputErroredEventData", + modelProperties: { + ...MediaJobOutputStateChangeEventData.type.modelProperties + } + } +}; + +export const MediaJobOutputFinishedEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobOutputFinished", + type: { + name: "Composite", + className: "MediaJobOutputFinishedEventData", + modelProperties: { + ...MediaJobOutputStateChangeEventData.type.modelProperties + } + } +}; + +export const MediaJobOutputProcessingEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobOutputProcessing", + type: { + name: "Composite", + className: "MediaJobOutputProcessingEventData", + modelProperties: { + ...MediaJobOutputStateChangeEventData.type.modelProperties + } + } +}; + +export const MediaJobOutputScheduledEventData: coreHttp.CompositeMapper = { + serializedName: "#Microsoft.Media.JobOutputScheduled", + type: { + name: "Composite", + className: "MediaJobOutputScheduledEventData", + modelProperties: { + ...MediaJobOutputStateChangeEventData.type.modelProperties + } + } +}; + +export const MediaLiveEventEncoderConnectedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaLiveEventEncoderConnectedEventData", + modelProperties: { + ingestUrl: { + serializedName: "ingestUrl", + readOnly: true, + type: { + name: "String" + } + }, + streamId: { + serializedName: "streamId", + readOnly: true, + type: { + name: "String" + } + }, + encoderIp: { + serializedName: "encoderIp", + readOnly: true, + type: { + name: "String" + } + }, + encoderPort: { + serializedName: "encoderPort", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const MediaLiveEventConnectionRejectedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaLiveEventConnectionRejectedEventData", + modelProperties: { + ingestUrl: { + serializedName: "ingestUrl", + readOnly: true, + type: { + name: "String" + } + }, + streamId: { + serializedName: "streamId", + readOnly: true, + type: { + name: "String" + } + }, + encoderIp: { + serializedName: "encoderIp", + readOnly: true, + type: { + name: "String" + } + }, + encoderPort: { + serializedName: "encoderPort", + readOnly: true, + type: { + name: "String" + } + }, + resultCode: { + serializedName: "resultCode", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const MediaLiveEventEncoderDisconnectedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaLiveEventEncoderDisconnectedEventData", + modelProperties: { + ingestUrl: { + serializedName: "ingestUrl", + readOnly: true, + type: { + name: "String" + } + }, + streamId: { + serializedName: "streamId", + readOnly: true, + type: { + name: "String" + } + }, + encoderIp: { + serializedName: "encoderIp", + readOnly: true, + type: { + name: "String" + } + }, + encoderPort: { + serializedName: "encoderPort", + readOnly: true, + type: { + name: "String" + } + }, + resultCode: { + serializedName: "resultCode", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const MediaLiveEventIncomingStreamReceivedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaLiveEventIncomingStreamReceivedEventData", + modelProperties: { + ingestUrl: { + serializedName: "ingestUrl", + readOnly: true, + type: { + name: "String" + } + }, + trackType: { + serializedName: "trackType", + readOnly: true, + type: { + name: "String" + } + }, + trackName: { + serializedName: "trackName", + readOnly: true, + type: { + name: "String" + } + }, + bitrate: { + serializedName: "bitrate", + readOnly: true, + type: { + name: "Number" + } + }, + encoderIp: { + serializedName: "encoderIp", + readOnly: true, + type: { + name: "String" + } + }, + encoderPort: { + serializedName: "encoderPort", + readOnly: true, + type: { + name: "String" + } + }, + timestamp: { + serializedName: "timestamp", + readOnly: true, + type: { + name: "String" + } + }, + duration: { + serializedName: "duration", + readOnly: true, + type: { + name: "String" + } + }, + timescale: { + serializedName: "timescale", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const MediaLiveEventIncomingStreamsOutOfSyncEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaLiveEventIncomingStreamsOutOfSyncEventData", + modelProperties: { + minLastTimestamp: { + serializedName: "minLastTimestamp", + readOnly: true, + type: { + name: "String" + } + }, + typeOfStreamWithMinLastTimestamp: { + serializedName: "typeOfStreamWithMinLastTimestamp", + readOnly: true, + type: { + name: "String" + } + }, + maxLastTimestamp: { + serializedName: "maxLastTimestamp", + readOnly: true, + type: { + name: "String" + } + }, + typeOfStreamWithMaxLastTimestamp: { + serializedName: "typeOfStreamWithMaxLastTimestamp", + readOnly: true, + type: { + name: "String" + } + }, + timescaleOfMinLastTimestamp: { + serializedName: "timescaleOfMinLastTimestamp", + readOnly: true, + type: { + name: "String" + } + }, + timescaleOfMaxLastTimestamp: { + serializedName: "timescaleOfMaxLastTimestamp", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const MediaLiveEventIncomingVideoStreamsOutOfSyncEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaLiveEventIncomingVideoStreamsOutOfSyncEventData", + modelProperties: { + firstTimestamp: { + serializedName: "firstTimestamp", + readOnly: true, + type: { + name: "String" + } + }, + firstDuration: { + serializedName: "firstDuration", + readOnly: true, + type: { + name: "String" + } + }, + secondTimestamp: { + serializedName: "secondTimestamp", + readOnly: true, + type: { + name: "String" + } + }, + secondDuration: { + serializedName: "secondDuration", + readOnly: true, + type: { + name: "String" + } + }, + timescale: { + serializedName: "timescale", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const MediaLiveEventIncomingDataChunkDroppedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaLiveEventIncomingDataChunkDroppedEventData", + modelProperties: { + timestamp: { + serializedName: "timestamp", + readOnly: true, + type: { + name: "String" + } + }, + trackType: { + serializedName: "trackType", + readOnly: true, + type: { + name: "String" + } + }, + bitrate: { + serializedName: "bitrate", + readOnly: true, + type: { + name: "Number" + } + }, + timescale: { + serializedName: "timescale", + readOnly: true, + type: { + name: "String" + } + }, + resultCode: { + serializedName: "resultCode", + readOnly: true, + type: { + name: "String" + } + }, + trackName: { + serializedName: "trackName", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const MediaLiveEventIngestHeartbeatEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaLiveEventIngestHeartbeatEventData", + modelProperties: { + trackType: { + serializedName: "trackType", + readOnly: true, + type: { + name: "String" + } + }, + trackName: { + serializedName: "trackName", + readOnly: true, + type: { + name: "String" + } + }, + bitrate: { + serializedName: "bitrate", + readOnly: true, + type: { + name: "Number" + } + }, + incomingBitrate: { + serializedName: "incomingBitrate", + readOnly: true, + type: { + name: "Number" + } + }, + lastTimestamp: { + serializedName: "lastTimestamp", + readOnly: true, + type: { + name: "String" + } + }, + timescale: { + serializedName: "timescale", + readOnly: true, + type: { + name: "String" + } + }, + overlapCount: { + serializedName: "overlapCount", + readOnly: true, + type: { + name: "Number" + } + }, + discontinuityCount: { + serializedName: "discontinuityCount", + readOnly: true, + type: { + name: "Number" + } + }, + nonincreasingCount: { + serializedName: "nonincreasingCount", + readOnly: true, + type: { + name: "Number" + } + }, + unexpectedBitrate: { + serializedName: "unexpectedBitrate", + readOnly: true, + type: { + name: "Boolean" + } + }, + state: { + serializedName: "state", + readOnly: true, + type: { + name: "String" + } + }, + healthy: { + serializedName: "healthy", + readOnly: true, + type: { + name: "Boolean" + } + } + } + } +}; + +export const MediaLiveEventTrackDiscontinuityDetectedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MediaLiveEventTrackDiscontinuityDetectedEventData", + modelProperties: { + trackType: { + serializedName: "trackType", + readOnly: true, + type: { + name: "String" + } + }, + trackName: { + serializedName: "trackName", + readOnly: true, + type: { + name: "String" + } + }, + bitrate: { + serializedName: "bitrate", + readOnly: true, + type: { + name: "Number" + } + }, + previousTimestamp: { + serializedName: "previousTimestamp", + readOnly: true, + type: { + name: "String" + } + }, + newTimestamp: { + serializedName: "newTimestamp", + readOnly: true, + type: { + name: "String" + } + }, + timescale: { + serializedName: "timescale", + readOnly: true, + type: { + name: "String" + } + }, + discontinuityGap: { + serializedName: "discontinuityGap", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const MapsGeofenceEventProperties: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MapsGeofenceEventProperties", + modelProperties: { + expiredGeofenceGeometryId: { + serializedName: "expiredGeofenceGeometryId", + type: { + name: "Sequence", + element: { type: { name: "String" } } + } + }, + geometries: { + serializedName: "geometries", + type: { + name: "Sequence", + element: { + type: { name: "Composite", className: "MapsGeofenceGeometry" } + } + } + }, + invalidPeriodGeofenceGeometryId: { + serializedName: "invalidPeriodGeofenceGeometryId", + type: { + name: "Sequence", + element: { type: { name: "String" } } + } + }, + isEventPublished: { + serializedName: "isEventPublished", + type: { + name: "Boolean" + } + } + } + } +}; + +export const MapsGeofenceGeometry: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MapsGeofenceGeometry", + modelProperties: { + deviceId: { + serializedName: "deviceId", + type: { + name: "String" + } + }, + distance: { + serializedName: "distance", + type: { + name: "Number" + } + }, + geometryId: { + serializedName: "geometryId", + type: { + name: "String" + } + }, + nearestLat: { + serializedName: "nearestLat", + type: { + name: "Number" + } + }, + nearestLon: { + serializedName: "nearestLon", + type: { + name: "Number" + } + }, + udId: { + serializedName: "udId", + type: { + name: "String" + } + } + } + } +}; + +export const MapsGeofenceEnteredEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MapsGeofenceEnteredEventData", + modelProperties: { + ...MapsGeofenceEventProperties.type.modelProperties + } + } +}; + +export const MapsGeofenceExitedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MapsGeofenceExitedEventData", + modelProperties: { + ...MapsGeofenceEventProperties.type.modelProperties + } + } +}; + +export const MapsGeofenceResultEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MapsGeofenceResultEventData", + modelProperties: { + ...MapsGeofenceEventProperties.type.modelProperties + } + } +}; + +export const AppConfigurationKeyValueModifiedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "AppConfigurationKeyValueModifiedEventData", + modelProperties: { + key: { + serializedName: "key", + type: { + name: "String" + } + }, + label: { + serializedName: "label", + type: { + name: "String" + } + }, + etag: { + serializedName: "etag", + type: { + name: "String" + } + } + } + } +}; + +export const AppConfigurationKeyValueDeletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "AppConfigurationKeyValueDeletedEventData", + modelProperties: { + key: { + serializedName: "key", + type: { + name: "String" + } + }, + label: { + serializedName: "label", + type: { + name: "String" + } + }, + etag: { + serializedName: "etag", + type: { + name: "String" + } + } + } + } +}; + +export const SignalRServiceClientConnectionConnectedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "SignalRServiceClientConnectionConnectedEventData", + modelProperties: { + timestamp: { + serializedName: "timestamp", + type: { + name: "DateTime" + } + }, + hubName: { + serializedName: "hubName", + type: { + name: "String" + } + }, + connectionId: { + serializedName: "connectionId", + type: { + name: "String" + } + }, + userId: { + serializedName: "userId", + type: { + name: "String" + } + } + } + } +}; + +export const SignalRServiceClientConnectionDisconnectedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "SignalRServiceClientConnectionDisconnectedEventData", + modelProperties: { + timestamp: { + serializedName: "timestamp", + type: { + name: "DateTime" + } + }, + hubName: { + serializedName: "hubName", + type: { + name: "String" + } + }, + connectionId: { + serializedName: "connectionId", + type: { + name: "String" + } + }, + userId: { + serializedName: "userId", + type: { + name: "String" + } + }, + errorMessage: { + serializedName: "errorMessage", + type: { + name: "String" + } + } + } + } +}; + +export const KeyVaultCertificateNewVersionCreatedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyVaultCertificateNewVersionCreatedEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + vaultName: { + serializedName: "vaultName", + type: { + name: "String" + } + }, + objectType: { + serializedName: "objectType", + type: { + name: "String" + } + }, + objectName: { + serializedName: "objectName", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + }, + nbf: { + serializedName: "nbf", + type: { + name: "Number" + } + }, + exp: { + serializedName: "exp", + type: { + name: "Number" + } + } + } + } +}; + +export const KeyVaultCertificateNearExpiryEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyVaultCertificateNearExpiryEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + vaultName: { + serializedName: "vaultName", + type: { + name: "String" + } + }, + objectType: { + serializedName: "objectType", + type: { + name: "String" + } + }, + objectName: { + serializedName: "objectName", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + }, + nbf: { + serializedName: "nbf", + type: { + name: "Number" + } + }, + exp: { + serializedName: "exp", + type: { + name: "Number" + } + } + } + } +}; + +export const KeyVaultCertificateExpiredEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyVaultCertificateExpiredEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + vaultName: { + serializedName: "vaultName", + type: { + name: "String" + } + }, + objectType: { + serializedName: "objectType", + type: { + name: "String" + } + }, + objectName: { + serializedName: "objectName", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + }, + nbf: { + serializedName: "nbf", + type: { + name: "Number" + } + }, + exp: { + serializedName: "exp", + type: { + name: "Number" + } + } + } + } +}; + +export const KeyVaultKeyNewVersionCreatedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyVaultKeyNewVersionCreatedEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + vaultName: { + serializedName: "vaultName", + type: { + name: "String" + } + }, + objectType: { + serializedName: "objectType", + type: { + name: "String" + } + }, + objectName: { + serializedName: "objectName", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + }, + nbf: { + serializedName: "nbf", + type: { + name: "Number" + } + }, + exp: { + serializedName: "exp", + type: { + name: "Number" + } + } + } + } +}; + +export const KeyVaultKeyNearExpiryEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyVaultKeyNearExpiryEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + vaultName: { + serializedName: "vaultName", + type: { + name: "String" + } + }, + objectType: { + serializedName: "objectType", + type: { + name: "String" + } + }, + objectName: { + serializedName: "objectName", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + }, + nbf: { + serializedName: "nbf", + type: { + name: "Number" + } + }, + exp: { + serializedName: "exp", + type: { + name: "Number" + } + } + } + } +}; + +export const KeyVaultKeyExpiredEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyVaultKeyExpiredEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + vaultName: { + serializedName: "vaultName", + type: { + name: "String" + } + }, + objectType: { + serializedName: "objectType", + type: { + name: "String" + } + }, + objectName: { + serializedName: "objectName", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + }, + nbf: { + serializedName: "nbf", + type: { + name: "Number" + } + }, + exp: { + serializedName: "exp", + type: { + name: "Number" + } + } + } + } +}; + +export const KeyVaultSecretNewVersionCreatedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyVaultSecretNewVersionCreatedEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + vaultName: { + serializedName: "vaultName", + type: { + name: "String" + } + }, + objectType: { + serializedName: "objectType", + type: { + name: "String" + } + }, + objectName: { + serializedName: "objectName", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + }, + nbf: { + serializedName: "nbf", + type: { + name: "Number" + } + }, + exp: { + serializedName: "exp", + type: { + name: "Number" + } + } + } + } +}; + +export const KeyVaultSecretNearExpiryEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyVaultSecretNearExpiryEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + vaultName: { + serializedName: "vaultName", + type: { + name: "String" + } + }, + objectType: { + serializedName: "objectType", + type: { + name: "String" + } + }, + objectName: { + serializedName: "objectName", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + }, + nbf: { + serializedName: "nbf", + type: { + name: "Number" + } + }, + exp: { + serializedName: "exp", + type: { + name: "Number" + } + } + } + } +}; + +export const KeyVaultSecretExpiredEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyVaultSecretExpiredEventData", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + vaultName: { + serializedName: "vaultName", + type: { + name: "String" + } + }, + objectType: { + serializedName: "objectType", + type: { + name: "String" + } + }, + objectName: { + serializedName: "objectName", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + }, + nbf: { + serializedName: "nbf", + type: { + name: "Number" + } + }, + exp: { + serializedName: "exp", + type: { + name: "Number" + } + } + } + } +}; + +export const MachineLearningServicesModelRegisteredEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MachineLearningServicesModelRegisteredEventData", + modelProperties: { + modelName: { + serializedName: "modelName", + type: { + name: "String" + } + }, + modelVersion: { + serializedName: "modelVersion", + type: { + name: "String" + } + }, + modelTags: { + serializedName: "modelTags", + type: { + name: "any" + } + }, + modelProperties: { + serializedName: "modelProperties", + type: { + name: "any" + } + } + } + } +}; + +export const MachineLearningServicesModelDeployedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MachineLearningServicesModelDeployedEventData", + modelProperties: { + serviceName: { + serializedName: "serviceName", + type: { + name: "String" + } + }, + serviceComputeType: { + serializedName: "serviceComputeType", + type: { + name: "String" + } + }, + modelIds: { + serializedName: "modelIds", + type: { + name: "String" + } + }, + serviceTags: { + serializedName: "serviceTags", + type: { + name: "any" + } + }, + serviceProperties: { + serializedName: "serviceProperties", + type: { + name: "any" + } + } + } + } +}; + +export const MachineLearningServicesRunCompletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MachineLearningServicesRunCompletedEventData", + modelProperties: { + experimentId: { + serializedName: "experimentId", + type: { + name: "String" + } + }, + experimentName: { + serializedName: "experimentName", + type: { + name: "String" + } + }, + runId: { + serializedName: "runId", + type: { + name: "String" + } + }, + runType: { + serializedName: "runType", + type: { + name: "String" + } + }, + runTags: { + serializedName: "runTags", + type: { + name: "any" + } + }, + runProperties: { + serializedName: "runProperties", + type: { + name: "any" + } + } + } + } +}; + +export const MachineLearningServicesDatasetDriftDetectedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MachineLearningServicesDatasetDriftDetectedEventData", + modelProperties: { + dataDriftId: { + serializedName: "dataDriftId", + type: { + name: "String" + } + }, + dataDriftName: { + serializedName: "dataDriftName", + type: { + name: "String" + } + }, + runId: { + serializedName: "runId", + type: { + name: "String" + } + }, + baseDatasetId: { + serializedName: "baseDatasetId", + type: { + name: "String" + } + }, + targetDatasetId: { + serializedName: "targetDatasetId", + type: { + name: "String" + } + }, + driftCoefficient: { + serializedName: "driftCoefficient", + type: { + name: "Number" + } + }, + startTime: { + serializedName: "startTime", + type: { + name: "DateTime" + } + }, + endTime: { + serializedName: "endTime", + type: { + name: "DateTime" + } + } + } + } +}; + +export const MachineLearningServicesRunStatusChangedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "MachineLearningServicesRunStatusChangedEventData", + modelProperties: { + experimentId: { + serializedName: "experimentId", + type: { + name: "String" + } + }, + experimentName: { + serializedName: "experimentName", + type: { + name: "String" + } + }, + runId: { + serializedName: "runId", + type: { + name: "String" + } + }, + runType: { + serializedName: "runType", + type: { + name: "String" + } + }, + runTags: { + serializedName: "runTags", + type: { + name: "any" + } + }, + runProperties: { + serializedName: "runProperties", + type: { + name: "any" + } + }, + runStatus: { + serializedName: "runStatus", + type: { + name: "String" + } + } + } + } +}; + +export const RedisPatchingCompletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "RedisPatchingCompletedEventData", + modelProperties: { + timestamp: { + serializedName: "timestamp", + type: { + name: "DateTime" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + } + } + } +}; + +export const RedisScalingCompletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "RedisScalingCompletedEventData", + modelProperties: { + timestamp: { + serializedName: "timestamp", + type: { + name: "DateTime" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + } + } + } +}; + +export const RedisExportRDBCompletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "RedisExportRDBCompletedEventData", + modelProperties: { + timestamp: { + serializedName: "timestamp", + type: { + name: "DateTime" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + } + } + } +}; + +export const RedisImportRDBCompletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "RedisImportRDBCompletedEventData", + modelProperties: { + timestamp: { + serializedName: "timestamp", + type: { + name: "DateTime" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + } + } + } +}; + +export const WebAppUpdatedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebAppUpdatedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const AppEventTypeDetail: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "AppEventTypeDetail", + modelProperties: { + action: { + serializedName: "action", + type: { + name: "String" + } + } + } + } +}; + +export const WebBackupOperationStartedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebBackupOperationStartedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebBackupOperationCompletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebBackupOperationCompletedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebBackupOperationFailedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebBackupOperationFailedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebRestoreOperationStartedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebRestoreOperationStartedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebRestoreOperationCompletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebRestoreOperationCompletedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebRestoreOperationFailedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebRestoreOperationFailedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebSlotSwapStartedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebSlotSwapStartedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebSlotSwapCompletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebSlotSwapCompletedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebSlotSwapFailedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebSlotSwapFailedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebSlotSwapWithPreviewStartedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebSlotSwapWithPreviewStartedEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebSlotSwapWithPreviewCancelledEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebSlotSwapWithPreviewCancelledEventData", + modelProperties: { + appEventTypeDetail: { + serializedName: "appEventTypeDetail", + type: { + name: "Composite", + className: "AppEventTypeDetail" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const WebAppServicePlanUpdatedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebAppServicePlanUpdatedEventData", + modelProperties: { + appServicePlanEventTypeDetail: { + serializedName: "appServicePlanEventTypeDetail", + type: { + name: "Composite", + className: "AppServicePlanEventTypeDetail" + } + }, + sku: { + serializedName: "sku", + type: { + name: "Composite", + className: "WebAppServicePlanUpdatedEventDataSku" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + clientRequestId: { + serializedName: "clientRequestId", + type: { + name: "String" + } + }, + correlationRequestId: { + serializedName: "correlationRequestId", + type: { + name: "String" + } + }, + requestId: { + serializedName: "requestId", + type: { + name: "String" + } + }, + address: { + serializedName: "address", + type: { + name: "String" + } + }, + verb: { + serializedName: "verb", + type: { + name: "String" + } + } + } + } +}; + +export const AppServicePlanEventTypeDetail: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "AppServicePlanEventTypeDetail", + modelProperties: { + stampKind: { + serializedName: "stampKind", + type: { + name: "String" + } + }, + action: { + defaultValue: "Updated", + isConstant: true, + serializedName: "action", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + } + } + } +}; + +export const WebAppServicePlanUpdatedEventDataSku: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "WebAppServicePlanUpdatedEventDataSku", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + tier: { + serializedName: "Tier", + type: { + name: "String" + } + }, + size: { + serializedName: "Size", + type: { + name: "String" + } + }, + family: { + serializedName: "Family", + type: { + name: "String" + } + }, + capacity: { + serializedName: "Capacity", + type: { + name: "String" + } + } + } + } +}; + +export let discriminators = { + MediaJobOutput: MediaJobOutput, + "MediaJobOutput.#Microsoft.Media.JobOutputAsset": MediaJobOutputAsset +}; diff --git a/sdk/eventgrid/eventgrid/src/generated/models/parameters.ts b/sdk/eventgrid/eventgrid/src/generated/models/parameters.ts new file mode 100644 index 000000000000..3c29844c7328 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/generated/models/parameters.ts @@ -0,0 +1,97 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + OperationParameter, + OperationURLParameter, + OperationQueryParameter +} from "@azure/core-http"; + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const events: OperationParameter = { + parameterPath: "events", + mapper: { + serializedName: "events", + required: true, + type: { + name: "Sequence", + element: { type: { name: "Composite", className: "EventGridEvent" } } + } + } +}; + +export const topicHostname: OperationURLParameter = { + parameterPath: "topicHostname", + mapper: { + serializedName: "topicHostname", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2018-01-01", + isConstant: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; + +export const contentType1: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/cloudevents-batch+json; charset=utf-8", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const events1: OperationParameter = { + parameterPath: "events", + mapper: { + serializedName: "events", + required: true, + type: { + name: "Sequence", + element: { type: { name: "Composite", className: "CloudEvent" } } + } + } +}; + +export const events2: OperationParameter = { + parameterPath: "events", + mapper: { + serializedName: "events", + required: true, + type: { + name: "Sequence", + element: { type: { name: "any" } } + } + } +}; diff --git a/sdk/eventgrid/eventgrid/src/index.ts b/sdk/eventgrid/eventgrid/src/index.ts new file mode 100644 index 000000000000..2d86d74c4312 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/index.ts @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +export { AzureKeyCredential } from "@azure/core-auth"; + +export { EventGridEvent, CloudEvent } from "./models"; + +export { + EventGridClient, + EventGridClientOptions, + SendEventsOptions, + SendCloudEventsOptions, + SendCustomSchemaEventsOptions +} from "./eventGridClient"; + +export { + SignatureCredential, + EventGridSharedAccessSignatureCredential +} from "./sharedAccessSignitureCredential"; + +export { EventGridConsumer } from "./consumer"; + +export { + EventHubCaptureFileCreatedEventData, + ContainerRegistryArtifactEventTarget, + ContainerRegistryEventData, + ContainerRegistryImagePushedEventData, + ContainerRegistryImageDeletedEventData, + ContainerRegistryChartDeletedEventData, + ContainerRegistryChartPushedEventData, + ContainerRegistryArtifactEventData, + ContainerRegistryEventActor, + ContainerRegistryEventRequest, + ContainerRegistryEventSource, + ContainerRegistryEventTarget +} from "./generated/models"; + +export { + isEventHubCaptureFileCreatedEvent, + isContainerRegistryChartDeletedEvent, + isContainerRegistryChartPushedEvent, + isContainerRegistryImageDeletedEvent, + isContainerRegistryImagePushedEvent +} from "./predicates"; + +// TODO(matell): Export these from top level when we export the predicates. + +/* +export { + AppConfigurationKeyValueDeletedEventData, + AppConfigurationKeyValueModifiedEventData + AppEventTypeDetail, + AppServicePlanEventTypeDetail, + ContainerRegistryArtifactEventTarget, + ContainerRegistryEventData, + ContainerRegistryImagePushedEventData, + ContainerRegistryImageDeletedEventData, + ContainerRegistryChartDeletedEventData, + ContainerRegistryChartPushedEventData, + DeviceConnectionStateEventInfo, + DeviceTwinInfo, + DeviceTwinInfoProperties, + DeviceTwinInfoX509Thumbprint, + IotHubDeviceCreatedEventData, + IotHubDeviceDeletedEventData, + IotHubDeviceConnectedEventData, + IotHubDeviceDisconnectedEventData, + IotHubDeviceTelemetryEventData, + SubscriptionValidationEventData, + SubscriptionDeletedEventData, + EventHubCaptureFileCreatedEventData, + MachineLearningServicesDatasetDriftDetectedEventData, + MachineLearningServicesModelDeployedEventData, + MachineLearningServicesModelRegisteredEventData, + MachineLearningServicesRunCompletedEventData, + MachineLearningServicesRunStatusChangedEventData, + MapsGeofenceEventProperties, + MapsGeofenceEnteredEventData, + MapsGeofenceExitedEventData, + MapsGeofenceResultEventData, + MediaJobStateChangeEventData, + MediaJobOutputStateChangeEventData, + MediaJobScheduledEventData, + MediaJobProcessingEventData, + MediaJobCancelingEventData, + MediaJobFinishedEventData, + MediaJobCanceledEventData, + MediaJobError, + MediaJobErrorCategory, + MediaJobErrorDetail, + MediaJobErrorCode, + MediaJobRetry, + MediaJobErroredEventData, + MediaJobOutputCanceledEventData, + MediaJobOutputCancelingEventData, + MediaJobOutputErroredEventData, + MediaJobOutputFinishedEventData, + MediaJobOutputProcessingEventData, + MediaJobOutputScheduledEventData, + MediaJobOutputProgressEventData, + MediaJobOutputUnion, + MediaJobState, + MediaLiveEventEncoderConnectedEventData, + MediaLiveEventConnectionRejectedEventData, + MediaLiveEventEncoderDisconnectedEventData, + MediaLiveEventIncomingStreamReceivedEventData, + MediaLiveEventIncomingStreamsOutOfSyncEventData, + MediaLiveEventIncomingVideoStreamsOutOfSyncEventData, + MediaLiveEventIncomingDataChunkDroppedEventData, + MediaLiveEventIngestHeartbeatEventData, + MediaLiveEventTrackDiscontinuityDetectedEventData, + ResourceWriteSuccessEventData, + ResourceWriteFailureEventData, + ResourceWriteCancelEventData, + ResourceDeleteSuccessEventData, + ResourceDeleteFailureEventData, + ResourceDeleteCancelEventData, + ResourceActionSuccessEventData, + ResourceActionFailureEventData, + ResourceActionCancelEventData, + ServiceBusActiveMessagesAvailableWithNoListenersEventData, + ServiceBusDeadletterMessagesAvailableWithNoListenersEventData, + StorageBlobCreatedEventData, + StorageBlobDeletedEventData, + StorageBlobRenamedEventData, + StorageDirectoryCreatedEventData, + StorageDirectoryDeletedEventData, + StorageDirectoryRenamedEventData, + WebAppUpdatedEventData, + WebBackupOperationStartedEventData, + WebBackupOperationCompletedEventData, + WebBackupOperationFailedEventData, + WebRestoreOperationStartedEventData, + WebRestoreOperationCompletedEventData, + WebRestoreOperationFailedEventData, + WebSlotSwapStartedEventData, + WebSlotSwapCompletedEventData, + WebSlotSwapFailedEventData, + WebSlotSwapWithPreviewStartedEventData, + WebSlotSwapWithPreviewCancelledEventData, + WebAppServicePlanUpdatedEventData, + WebAppServicePlanUpdatedEventDataSku, + AppAction, + StampKind, + AsyncStatus, + ContainerRegistryArtifactEventData, + ContainerRegistryEventActor, + ContainerRegistryEventRequest, + ContainerRegistryEventSource, + ContainerRegistryEventTarget, + DeviceConnectionStateEventProperties, + DeviceLifeCycleEventProperties, + DeviceTelemetryEventProperties, + MapsGeofenceGeometry, + MediaJobOutput, + MediaJobOutputAsset, + DeviceTwinProperties, + DeviceTwinMetadata +} from "./generated/modles" +*/ diff --git a/sdk/eventgrid/eventgrid/src/logger.ts b/sdk/eventgrid/eventgrid/src/logger.ts new file mode 100644 index 000000000000..a58275d73374 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/logger.ts @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { createClientLogger } from "@azure/logger"; + +/** + * The @azure/logger configuration for this package. + */ +export const logger = createClientLogger("messaging-eventgrid"); diff --git a/sdk/eventgrid/eventgrid/src/models.ts b/sdk/eventgrid/eventgrid/src/models.ts new file mode 100644 index 000000000000..62a7435892e3 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/models.ts @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * An event in the in the Event Grid Schema. + */ +export interface EventGridEvent { + /** + * The type of the event. + */ + eventType: string; + /** + * The time the event was generated. + */ + eventTime: Date; + /** + * An unique identifier for the event. + */ + id: string; + /** + * The resource path of the event source. + */ + topic?: string; + /** + * A resource path relative to the topic path. + */ + subject: string; + /** + * The schema version of the data object. + */ + dataVersion: string; + /** + * Event data specific to the event type. + */ + data: T; +} + +/** + * An event in the Cloud Event 1.0 schema. + */ +export interface CloudEvent { + /** + * Type of event related to the originating occurrence. + */ + type: string; + /** + * Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. + */ + source: string; + /** + * An identifier for the event. The combination of id and source must be unique for each distinct event. + */ + id: string; + /** + * The time the event was generated. + */ + time?: Date; + /** + * Identifies the schema that data adheres to. + */ + dataschema?: string; + /** + * Content type of data value. + */ + datacontenttype?: string; + /** + * Event data specific to the event type. + */ + + data?: T; + /** + * This describes the subject of the event in the context of the event producer (identified by source). + */ + subject?: string; + /** + * Additional custom properties for the event. + */ + [keyof: string]: any; +} + +export type CustomEventDataDecoder = (o: any) => Promise; diff --git a/sdk/eventgrid/eventgrid/src/predicates.ts b/sdk/eventgrid/eventgrid/src/predicates.ts new file mode 100644 index 000000000000..d6aaaaa88da9 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/predicates.ts @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + ContainerRegistryImagePushedEventData, + ContainerRegistryImageDeletedEventData, + ContainerRegistryChartDeletedEventData, + ContainerRegistryChartPushedEventData, + EventHubCaptureFileCreatedEventData +} from "./generated/models"; + +import { CloudEvent, EventGridEvent } from "./models"; + +// TODO(matell): We need to generate `isXYZEvent`'s for all the known system events and add +// the coresponding mappers. + +/** + * isCloudEventLike returns "true" when the event is a CloudEvent + * + * @param o Either an EventGrid our CloudEvent event. + */ +function isCloudEventLike( + o: EventGridEvent | CloudEvent +): o is CloudEvent { + return (o as any).source !== undefined; +} + +/** isEventHubCaptureFileCreatedEvent returns true if the event is of type "Microsoft.EventHub.CaptureFileCreated" */ +export function isEventHubCaptureFileCreatedEvent( + event: EventGridEvent +): event is EventGridEvent; +/** isEventHubCaptureFileCreatedEvent returns true if the event is of type "Microsoft.EventHub.CaptureFileCreated" */ +export function isEventHubCaptureFileCreatedEvent( + event: CloudEvent +): event is CloudEvent; +export function isEventHubCaptureFileCreatedEvent( + event: EventGridEvent | CloudEvent +): event is + | CloudEvent + | EventGridEvent { + if (isCloudEventLike(event)) { + return event.type === "Microsoft.EventHub.CaptureFileCreated"; + } else { + return event.eventType === "Microsoft.EventHub.CaptureFileCreated"; + } +} + +/** isContainerRegistryImagePushedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ImagePushed" */ +export function isContainerRegistryImagePushedEvent( + event: EventGridEvent +): event is EventGridEvent; +/** isContainerRegistryImagePushedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ImagePushed" */ +export function isContainerRegistryImagePushedEvent( + event: CloudEvent +): event is CloudEvent; +export function isContainerRegistryImagePushedEvent( + event: EventGridEvent | CloudEvent +): event is + | CloudEvent + | EventGridEvent { + if (isCloudEventLike(event)) { + return event.type === "Microsoft.ContainerRegistry.ImagePushed"; + } else { + return event.eventType === "Microsoft.ContainerRegistry.ImagePushed"; + } +} + +/** isContainerRegistryImageDeletedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ImageDeleted" */ +export function isContainerRegistryImageDeletedEvent( + event: EventGridEvent +): event is EventGridEvent; +/** isContainerRegistryImageDeletedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ImageDeleted" */ +export function isContainerRegistryImageDeletedEvent( + event: CloudEvent +): event is CloudEvent; +export function isContainerRegistryImageDeletedEvent( + event: EventGridEvent | CloudEvent +): event is + | CloudEvent + | EventGridEvent { + if (isCloudEventLike(event)) { + return event.type === "Microsoft.ContainerRegistry.ImageDeleted"; + } else { + return event.eventType === "Microsoft.ContainerRegistry.ImageDeleted"; + } +} + +/** isContainerRegistryChartPushedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ChartPushed" */ +export function isContainerRegistryChartPushedEvent( + event: EventGridEvent +): event is EventGridEvent; +/** isContainerRegistryChartPushedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ChartPushed" */ +export function isContainerRegistryChartPushedEvent( + event: CloudEvent +): event is CloudEvent; +export function isContainerRegistryChartPushedEvent( + event: EventGridEvent | CloudEvent +): event is + | CloudEvent + | EventGridEvent { + if (isCloudEventLike(event)) { + return event.type === "Microsoft.ContainerRegistry.ChartPushed"; + } else { + return event.eventType === "Microsoft.ContainerRegistry.ChartPushed"; + } +} + +/** isContainerRegistryChartDeletedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ChartDeleted" */ +export function isContainerRegistryChartDeletedEvent( + event: EventGridEvent +): event is EventGridEvent; +/** isContainerRegistryChartDeletedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ChartDeleted" */ +export function isContainerRegistryChartDeletedEvent( + event: CloudEvent +): event is CloudEvent; +export function isContainerRegistryChartDeletedEvent( + event: EventGridEvent | CloudEvent +): event is + | CloudEvent + | EventGridEvent { + if (isCloudEventLike(event)) { + return event.type === "Microsoft.ContainerRegistry.ChartDeleted"; + } else { + return event.eventType === "Microsoft.ContainerRegistry.ChartDeleted"; + } +} diff --git a/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts b/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts new file mode 100644 index 000000000000..89b4b5cf594d --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * Represents a credential defined by a shared signature. + */ +export interface SignatureCredential { + /** + * The signature to be used in authentication. + */ + signature: string; +} + +/** + * A credential type which allows using a "shared access signature" to authenticate with EventGrid + * when sending events. + * + * A shared access signiture may be generated by using `EventGridClient.generateSharedAccessSignature` + */ +export class EventGridSharedAccessSignatureCredential implements SignatureCredential { + private _signature: string; + + /** + * The value of the signature to be used in authentication + */ + public get signature(): string { + return this._signature; + } + + /** + * Create an instance of an EventGridSharedAccessSignatureCredential for use + * with a service client. + * + * @param {string} signature the signature to use in authentication + */ + constructor(signature: string) { + if (!signature) { + throw new Error("signature must be a non-empty string"); + } + + this._signature = signature; + } + + /** + * Change the value of the signature. + * + * Updates will take effect upon the next request after + * updating the signature value. + * + * @param {string} newSignature the new signature value to be used + */ + public update(newSignature: string): void { + this._signature = newSignature; + } +} diff --git a/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts b/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts new file mode 100644 index 000000000000..9914e592352d --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Mapper, Serializer } from "@azure/core-http"; +import { CustomEventDataDecoder } from "./models"; +import { EventHubCaptureFileCreatedEventData } from "./generated/models/mappers"; +import { + ContainerRegistryEventData, + ContainerRegistryEventTarget, + ContainerRegistryEventRequest, + ContainerRegistryEventActor, + ContainerRegistryEventSource +} from "./generated/models/mappers"; + +const serializer = new Serializer({ + ContainerRegistryEventTarget: ContainerRegistryEventTarget, + ContainerRegistryEventRequest: ContainerRegistryEventRequest, + ContainerRegistryEventActor: ContainerRegistryEventActor, + ContainerRegistryEventSource: ContainerRegistryEventSource +}); + +function makeDecoderFromMapper( + mapper: Mapper, + initialDecoders?: CustomEventDataDecoder[] +): CustomEventDataDecoder { + return async function(o: any): Promise { + if (initialDecoders) { + for (const decoder of initialDecoders) { + o = await decoder(o); + } + } + + return serializer.deserialize(mapper, o, ""); + }; +} + +async function jsonParseDecoder(o: any): Promise { + if (typeof o === "string") { + return JSON.parse(o); + } + + return o; +} + +export const systemDecoders: Record = { + "Microsoft.ContainerRegistry.ChartDeleted": makeDecoderFromMapper(ContainerRegistryEventData, [ + jsonParseDecoder + ]), + "Microsoft.ContainerRegistry.ChartPushed": makeDecoderFromMapper(ContainerRegistryEventData, [ + jsonParseDecoder + ]), + "Microsoft.ContainerRegistry.ImageDeleted": makeDecoderFromMapper(ContainerRegistryEventData, [ + jsonParseDecoder + ]), + "Microsoft.ContainerRegistry.ImagePushed": makeDecoderFromMapper(ContainerRegistryEventData, [ + jsonParseDecoder + ]), + "Microsoft.EventHub.CaptureFileCreated": makeDecoderFromMapper( + EventHubCaptureFileCreatedEventData + ) +}; diff --git a/sdk/eventgrid/eventgrid/src/util.ts b/sdk/eventgrid/eventgrid/src/util.ts new file mode 100644 index 000000000000..48efd19f076d --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/util.ts @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { KeyCredential } from "@azure/core-auth"; + +/** + * Stringifies a Date object in the format expected by the Event Grid service, for use in a Shared Access Signiture. + * + * The service expects this time string to be in the same format as what is returned by the .NET DateTime.ToString + * method, using the "en-US" culture. + * + * This corresponds to the .NET format string: "M/d/yyyy h:mm:ss tt". For example, the date "June 5th, 2020, 12:09:03 PM" + * is represented as the string "6/5/2020 12:09:03 PM" + * + * The service expects a UTC time, so this method returns a string based on the UTC time of the provided Date. + * + * @param d The Date object to convert to a string. + */ +export function dateToServiceTimeString(d: Date): string { + const month = d.getUTCMonth() + 1; // getUTCMonth returns 0-11 not 1-12. + const day = d.getUTCDate(); + const year = d.getUTCFullYear(); + + const hour = d.getUTCHours() === 0 ? 12 : d.getUTCHours() % 12; // getUTCHours returns 0-23, and we want this in 12 hour format. + const minute = d + .getUTCMinutes() + .toString() + .padStart(2, "0"); + const second = d + .getUTCSeconds() + .toString() + .padStart(2, "0"); + const am = d.getUTCHours() >= 13 ? "PM" : "AM"; + + return `${month}/${day}/${year} ${hour}:${minute}:${second} ${am}`; +} + +/** + * Returns `true` if the credential object is like the KeyCredential interface (i.e. it has a + * key property). + * + * @param credential the object to test + */ +export function isKeyCredentialLike(o: any): o is KeyCredential { + return o.key !== undefined; +} + +export function parseAndWrap(jsonStringOrObject: string | object): any[] { + if (typeof jsonStringOrObject === "string") { + const o = JSON.parse(jsonStringOrObject); + if (Array.isArray(o)) { + return o; + } else { + return [o]; + } + } + + if (Array.isArray(jsonStringOrObject)) { + return jsonStringOrObject; + } else { + return [jsonStringOrObject]; + } +} diff --git a/sdk/eventgrid/eventgrid/swagger/README.md b/sdk/eventgrid/eventgrid/swagger/README.md new file mode 100644 index 000000000000..ac601d27e3dd --- /dev/null +++ b/sdk/eventgrid/eventgrid/swagger/README.md @@ -0,0 +1,52 @@ +# Azure Text Analytics TypeScript Protocol Layer + +> see https://aka.ms/autorest + +## Configuration + +```yaml +package-name: "@azure/eventgrid" +title: GeneratedClient +description: EventGrid Client +generate-metadata: false +add-credentials: false +license-header: MICROSOFT_MIT_NO_VERSION +output-folder: ../ +source-code-folder-path: ./src/generated +input-file: +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Storage/stable/2018-01-01/Storage.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.EventHub/stable/2018-01-01/EventHub.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Resources/stable/2018-01-01/Resources.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.EventGrid/stable/2018-01-01/EventGrid.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Devices/stable/2018-01-01/IotHub.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.ContainerRegistry/stable/2018-01-01/ContainerRegistry.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.ServiceBus/stable/2018-01-01/ServiceBus.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Media/stable/2018-01-01/MediaServices.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Maps/stable/2018-01-01/Maps.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.AppConfiguration/stable/2018-01-01/AppConfiguration.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.SignalRService/stable/2018-01-01/SignalRService.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.KeyVault/stable/2018-01-01/KeyVault.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.MachineLearningServices/stable/2018-01-01/MachineLearningServices.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Cache/stable/2018-01-01/RedisCache.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Web/stable/2018-01-01/Web.json +use-extension: + "@autorest/typescript": "6.0.0-dev.20200618.1" +``` + +## Customizations + +### Use the "EventData" suffix on the Azure Resource Manager Event types, instead of just "Data" + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + ["Write", "Delete", "Action"].forEach(action => { + ["Success", "Failure", "Cancel"].forEach(status => { + if ($[`Resource${action}${status}Data`]) { + $[`Resource${action}${status}Data`]["x-ms-client-name"] = `Resource${action}${status}EventData`; + } + }); + }); +``` diff --git a/sdk/eventgrid/eventgrid/test/consumer.spec.ts b/sdk/eventgrid/eventgrid/test/consumer.spec.ts new file mode 100644 index 000000000000..5f4504bc8ec6 --- /dev/null +++ b/sdk/eventgrid/eventgrid/test/consumer.spec.ts @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { assert, use as chaiUse } from "chai"; +import chaiPromises from "chai-as-promised"; + +import { EventGridConsumer } from "../src"; +import * as testData from "./utils/testData"; + +chaiUse(chaiPromises); + +describe("EventGridConsumer", function() { + const consumer = new EventGridConsumer(); + + describe("#decodeEventGridEvents", function() { + it("decodes a single event", async () => { + const events = await consumer.decodeEventGridEvents( + testData.customTestEvent1.eventGridSchema.encodedEvent + ); + + assert.lengthOf(events, 1); + assert.deepStrictEqual(events[0], testData.customTestEvent1.eventGridSchema.expected); + }); + + it("decoded a batch with a single event ", async () => { + const events = await consumer.decodeEventGridEvents( + wrapEncodedEventsInArray([testData.customTestEvent1.eventGridSchema]) + ); + + assert.lengthOf(events, 1); + assert.deepStrictEqual(events[0], testData.customTestEvent1.eventGridSchema.expected); + }); + + it("decodes an batch of multiple events", async () => { + const events = await consumer.decodeEventGridEvents( + wrapEncodedEventsInArray([ + testData.customTestEvent1.eventGridSchema, + testData.customTestEvent2.eventGridSchema + ]) + ); + + assert.lengthOf(events, 2); + assert.deepStrictEqual(events[0], testData.customTestEvent1.eventGridSchema.expected); + assert.deepStrictEqual(events[1], testData.customTestEvent2.eventGridSchema.expected); + }); + + it("decodes system events correctly", async () => { + const events = await consumer.decodeEventGridEvents( + testData.containerRegistryPushedEvent.eventGridSchema.encodedEvent + ); + + assert.lengthOf(events, 1); + assert.deepStrictEqual( + events[0], + testData.containerRegistryPushedEvent.eventGridSchema.expected + ); + }); + + it("fails when a required property is missing", () => { + const o = { ...testData.customTestEvent1.eventGridSchema.expected }; + for (const property of [ + "eventType", + "eventTime", + "id", + "metadataVersion", + "data", + "dataVersion" + ]) { + delete o[property]; + + assert.isRejected( + consumer.decodeEventGridEvents(JSON.stringify(o)), + /missing required property/ + ); + } + }); + + it("fails when metadata version is wrong", () => { + const o = { ...testData.customTestEvent1.eventGridSchema.expected }; + o.metadataVersion = "2"; + + assert.isRejected( + consumer.decodeEventGridEvents(JSON.stringify(o)), + /event is not in the Event Grid schema/ + ); + }); + }); + + describe("#decodeCloudEvents", function() { + it("decodes a single event", async () => { + const events = await consumer.decodeCloudEvents( + testData.customTestEvent1.cloudEventSchema.encodedEvent + ); + + assert.lengthOf(events, 1); + assert.deepStrictEqual(events[0], testData.customTestEvent1.cloudEventSchema.expected); + }); + + it("decoded a batch with a single event ", async () => { + const events = await consumer.decodeCloudEvents( + wrapEncodedEventsInArray([testData.customTestEvent1.cloudEventSchema]) + ); + + assert.lengthOf(events, 1); + assert.deepStrictEqual(events[0], testData.customTestEvent1.cloudEventSchema.expected); + }); + + it("decodes an batch of multiple events", async () => { + const events = await consumer.decodeCloudEvents( + wrapEncodedEventsInArray([ + testData.customTestEvent1.cloudEventSchema, + testData.customTestEvent2.cloudEventSchema + ]) + ); + + assert.lengthOf(events, 2); + assert.deepStrictEqual(events[0], testData.customTestEvent1.cloudEventSchema.expected); + assert.deepStrictEqual(events[1], testData.customTestEvent2.cloudEventSchema.expected); + }); + + it("decodes system events correctly", async () => { + const events = await consumer.decodeCloudEvents( + testData.containerRegistryPushedEvent.cloudEventSchema.encodedEvent + ); + + assert.lengthOf(events, 1); + assert.deepStrictEqual( + events[0], + testData.containerRegistryPushedEvent.cloudEventSchema.expected + ); + }); + + it("fails when a required property is missing", () => { + const o = { ...testData.customTestEvent1.cloudEventSchema.expected }; + for (const property of ["type", "source", "id", "specversion"]) { + delete o[property]; + + assert.isRejected( + consumer.decodeCloudEvents(JSON.stringify(o)), + /missing required property/ + ); + } + }); + + it("fails when spec version is wrong", () => { + const o = { ...testData.customTestEvent1.cloudEventSchema.expected }; + o.specversion = "2.0"; + + assert.isRejected( + consumer.decodeCloudEvents(JSON.stringify(o)), + /event is not in the Cloud Event 1.0 schema/ + ); + }); + }); +}); + +/** + * wrapEncodedEventsInArray takes the encoded events for a set of test cases and returns a string + * which is the JSON encoding of an array containing all the encoded events. + */ +function wrapEncodedEventsInArray(testCases: testData.TestCase[]): string { + const foo = []; + + for (const testCase of testCases) { + foo.push(JSON.parse(testCase.encodedEvent)); + } + + return JSON.stringify(foo); +} diff --git a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts new file mode 100644 index 000000000000..0e9b0f06159d --- /dev/null +++ b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/* eslint-disable no-invalid-this */ + +import { assert } from "chai"; + +import { isNode } from "@azure/core-http"; +import { Recorder } from "@azure/test-utils-recorder"; + +import { createRecordedClient, testEnv } from "./utils/recordedClient"; + +import { + AzureKeyCredential, + EventGridClient, + EventGridSharedAccessSignatureCredential +} from "../src/index"; + +describe("EventGridClient", function() { + let recorder: Recorder; + let client: EventGridClient; + + this.timeout(10000); + + describe("#sendEvents", function() { + beforeEach(function() { + ({ client, recorder } = createRecordedClient( + this, + testEnv.EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT, + new AzureKeyCredential(testEnv.EVENT_GRID_EVENT_GRID_SCHEMA_API_KEY) + )); + }); + + afterEach(() => { + recorder.stop(); + }); + + it("sends a single event", async () => { + const res = await client.sendEvents([ + { + eventTime: recorder.newDate("singleEventDate"), + id: recorder.getUniqueName("singleEventId"), + eventType: "Azure.Sdk.TestEvent1", + subject: "Single 1", + dataVersion: "1.0", + data: { + hello: "world" + } + } + ]); + + assert.equal(res._response.status, 200); + }); + + it("sends multiple events", async () => { + const res = await client.sendEvents([ + { + eventTime: recorder.newDate("multiEventDate1"), + id: recorder.getUniqueName("multiEventId1"), + eventType: "Azure.Sdk.TestEvent1", + subject: "Multiple 1", + dataVersion: "1.0", + data: { + hello: "world" + } + }, + { + eventTime: recorder.newDate("multiEventDate2"), + id: recorder.getUniqueName("multiEventId2"), + eventType: "Azure.Sdk.TestEvent1", + subject: "Multiple 2", + dataVersion: "1.0", + data: { + hello: "world" + } + } + ]); + + assert.equal(res._response.status, 200); + }); + }); + + describe("#sendCloudEventSchemaEvents", function() { + beforeEach(function() { + ({ client, recorder } = createRecordedClient( + this, + testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT, + new AzureKeyCredential(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY) + )); + }); + + afterEach(() => { + recorder.stop(); + }); + + it("sends a single event", async () => { + const res = await client.sendCloudEvents([ + { + type: "Azure.Sdk.TestEvent1", + id: recorder.getUniqueName("cloudSingleEventId"), + time: recorder.newDate("cloudSingleEventDate"), + source: "/earth/unitedstates/washington/kirkland/finnhill", + data: { + hello: "world" + } + } + ]); + + assert.equal(res._response.status, 200); + }); + + it("sends multiple events", async () => { + const res = await client.sendCloudEvents([ + { + type: "Azure.Sdk.TestEvent1", + id: recorder.getUniqueName("cloudMultiEventId1"), + time: recorder.newDate("cloudMultiEventDate1"), + source: "/earth/unitedstates/washington/kirkland/finnhill", + subject: "Multiple 1", + data: { + hello: "world" + } + }, + { + type: "Azure.Sdk.TestEvent1", + id: recorder.getUniqueName("cloudMultiEventId2"), + time: recorder.newDate("cloudMultiEventDate2"), + source: "/earth/unitedstates/washington/kirkland/finnhill", + subject: "Multiple 2", + data: { + hello: "world" + } + } + ]); + + assert.equal(res._response.status, 200); + }); + + // TODO(matell): Write a test that ensures any cloud event extensions are serialized with + // the event itself. + }); + + describe("#sendCustomSchemaEvents", function() { + beforeEach(function() { + ({ client, recorder } = createRecordedClient( + this, + testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT, + new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY) + )); + }); + + afterEach(() => { + recorder.stop(); + }); + + it("sends a single event", async () => { + const res = await client.sendCustomSchemaEvents([ + { + ver: "1.0", + typ: "Azure.Sdk.TestEvent1", + sub: "Single", + payload: { + hello: "world" + } + } + ]); + + assert.equal(res._response.status, 200); + }); + + it("sends multiple events", async () => { + const res = await client.sendCustomSchemaEvents([ + { + ver: "1.0", + typ: "Azure.Sdk.TestEvent1", + sub: "Multiple 1", + payload: { + hello: "world" + } + }, + { + ver: "1.0", + typ: "Azure.Sdk.TestEvent1", + sub: "Multiple 2", + payload: { + hello: "world" + } + } + ]); + + assert.equal(res._response.status, 200); + }); + }); + + // TODO(matell): generateSharedAccessSigniture used `createHmac` which is specific to node. When we get this working in the browser + // we need to enable this test there as well. + if (isNode) { + describe("#generateSharedAccessSigniture", () => { + it("generates the correct signiture", () => { + // This is not a real key, it's the base64 encoding of "this is not a real EventGrid key", which happens to be the same + // number of bytes as an actual EventGrid Access Key. + const key = "dGhpcyBpcyBub3QgYSByZWFsIEV2ZW50R3JpZCBrZXk="; + + const client = new EventGridClient( + "https://eg-topic.westus-2.eventgrid.azure.net/api/events", + new AzureKeyCredential(key) + ); + + const sig = client.generateSharedAccessSignature(new Date(2020, 0, 1, 0, 0, 0)); + assert.equal( + sig, + "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%208%3A00%3A00%20AM&s=PL2XXgj4Fimu3LcgH5aIaYTG3MefvrmcZZ%2BLPBsARrc%3D" + ); + }); + + it("fails when a signature credential was used", () => { + const signature = + "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%208%3A00%3A00%20AM&s=PL2XXgj4Fimu3LcgH5aIaYTG3MefvrmcZZ%2BLPBsARrc%3D"; + + const client = new EventGridClient( + "https://eg-topic.westus-2.eventgrid.azure.net/api/events", + new EventGridSharedAccessSignatureCredential(signature) + ); + + assert.throws( + () => client.generateSharedAccessSignature(new Date(2020, 0, 1, 0, 0, 0)), + /may only be called when the client is constructed with a key credential/ + ); + }); + }); + } +}); diff --git a/sdk/eventgrid/eventgrid/test/util.spec.ts b/sdk/eventgrid/eventgrid/test/util.spec.ts new file mode 100644 index 000000000000..fe0605149c86 --- /dev/null +++ b/sdk/eventgrid/eventgrid/test/util.spec.ts @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { assert } from "chai"; + +import { dateToServiceTimeString } from "../src/util"; + +describe("util", function() { + describe("dateToServiceTimeString", () => { + it("converts dates correctly", () => { + const simpleMorningDate = new Date(Date.UTC(2020, 0, 2, 3, 4, 5)); + assert.equal(dateToServiceTimeString(simpleMorningDate), "1/2/2020 3:04:05 AM"); + + const simpleAfternoonDate = new Date(Date.UTC(2020, 0, 2, 13, 10, 21)); + assert.equal(dateToServiceTimeString(simpleAfternoonDate), "1/2/2020 1:10:21 PM"); + + const slightlyAfterMidnight = new Date(Date.UTC(2020, 0, 2, 0, 10, 21)); + assert.equal(dateToServiceTimeString(slightlyAfterMidnight), "1/2/2020 12:10:21 AM"); + }); + }); +}); diff --git a/sdk/eventgrid/eventgrid/test/utils/recordedClient.ts b/sdk/eventgrid/eventgrid/test/utils/recordedClient.ts new file mode 100644 index 000000000000..235c5461b720 --- /dev/null +++ b/sdk/eventgrid/eventgrid/test/utils/recordedClient.ts @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Context } from "mocha"; +import * as dotenv from "dotenv"; + +import { env, Recorder, record, RecorderEnvironmentSetup } from "@azure/test-utils-recorder"; +import { isNode } from "@azure/core-http"; + +import { EventGridClient } from "../../src/index"; +import { KeyCredential } from "@azure/core-auth"; + +if (isNode) { + dotenv.config(); +} + +export interface RecordedClient { + client: EventGridClient; + recorder: Recorder; +} + +const replaceableVariables: { [k: string]: string } = { + EVENT_GRID_EVENT_GRID_SCHEMA_API_KEY: "api_key", + EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT: "https://endpoint/api/events", + EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY: "api_key", + EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT: "https://endpoint/api/events", + EVENT_GRID_CUSTOM_SCHEMA_API_KEY: "api_key", + EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT: "https://endpoint/api/events" +}; + +export const testEnv = new Proxy(replaceableVariables, { + get: (target, key: string) => { + return env[key] || target[key]; + } +}); + +export const environmentSetup: RecorderEnvironmentSetup = { + replaceableVariables, + customizationsOnRecordings: [ + (recording: string): string => + recording.replace(/"aeg-sas-key"\s?:\s?"[^"]*"/g, `"aeg-sas-key":"aeg-sas-key"`), + (recording: string): string => + recording.replace(/"aeg-sas-token"\s?:\s?"[^"]*"/g, `"aeg-sas-token":"aeg-sas-token"`), + // If we put EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT (or similar) in replaceableVariables above, + // it will not capture the endpoint string used with nock, which will be expanded to + // https://:443/ and therefore will not match, so we have to do + // this instead. + (recording: string): string => { + const replaced = recording.replace("endpoint:443", "endpoint"); + return replaced; + } + ], + queryParametersToSkip: [] +}; + +export function createRecordedClient( + context: Context, + endpoint: string, + credential: KeyCredential +): RecordedClient { + const recorder = record(context, environmentSetup); + + return { + client: new EventGridClient(endpoint, credential), + recorder + }; +} diff --git a/sdk/eventgrid/eventgrid/test/utils/testData.ts b/sdk/eventgrid/eventgrid/test/utils/testData.ts new file mode 100644 index 000000000000..be1727120376 --- /dev/null +++ b/sdk/eventgrid/eventgrid/test/utils/testData.ts @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +export class TestCase { + public expected: any; + public encodedEvent: string; + + constructor(expected: any, encodedEvent?: string) { + this.expected = expected; + this.encodedEvent = encodedEvent ?? JSON.stringify(expected); + } +} + +export interface TestEventInfo { + /** + * A test case of an event in the Event Grid Schema + */ + eventGridSchema: TestCase; + /** + * A test case of an event in the Cloud Event Schema. + */ + cloudEventSchema: TestCase; +} + +export const customTestEvent1: TestEventInfo = { + eventGridSchema: new TestCase({ + id: "5bc888aa-c2f4-11ea-b3de-0242ac130004", + subject: "", + data: { + hello: "world" + }, + eventType: "Azure.Sdk.TestEvent1", + dataVersion: "1.0", + metadataVersion: "1", + eventTime: new Date("2020-07-10T21:27:12.925Z"), + topic: + "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/matell-rg/providers/Microsoft.EventGrid/topics/matell-eg-topic" + }), + cloudEventSchema: new TestCase({ + id: "5bc888aa-c2f4-11ea-b3de-0242ac130004", + source: + "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/matell-rg/providers/Microsoft.EventGrid/topics/matell-eg-topic", + specversion: "1.0", + type: "Azure.Sdk.TestEvent1", + subject: "", + time: new Date("2020-07-10T21:27:12.925Z"), + data: { + hello: "world" + } + }) +}; + +export const customTestEvent2: TestEventInfo = { + eventGridSchema: new TestCase({ + id: "ddf773ae-c2f4-11ea-b3de-0242ac130004", + subject: "", + data: { + goodbye: "everyone" + }, + eventType: "Azure.Sdk.TestEvent2", + dataVersion: "1.0", + metadataVersion: "1", + eventTime: new Date("2020-07-10T21:27:12.925Z"), + topic: + "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/matell-rg/providers/Microsoft.EventGrid/topics/matell-eg-topic" + }), + cloudEventSchema: new TestCase({ + id: "ddf773ae-c2f4-11ea-b3de-0242ac130004", + source: + "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/matell-rg/providers/Microsoft.EventGrid/topics/matell-eg-topic", + specversion: "1.0", + type: "Azure.Sdk.TestEvent2", + subject: "", + time: new Date("2020-07-10T21:27:12.925Z"), + data: { + goodbye: "everyone" + } + }) +}; + +// As of 2020-07-10, the Container Registry service is delivering the `data` object as string instead of a JSON object. This disagrees with +// the documented shape of the event. Our parsers have a special case to deal with this, for these events. +export const containerRegistryPushedEvent: TestEventInfo = { + eventGridSchema: new TestCase( + { + id: "b734f818-f923-472b-aec8-50995013fd7c", + topic: + "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/matell-rg/providers/Microsoft.ContainerRegistry/registries/matellcr", + subject: "ubuntu:18.04", + eventType: "Microsoft.ContainerRegistry.ImagePushed", + data: { + id: "b734f818-f923-472b-aec8-50995013fd7c", + timestamp: new Date("2020-07-09T00:29:38.143428094Z"), + action: "push", + target: { + mediaType: "application/vnd.docker.distribution.manifest.v2+json", + size: 1152, + digest: "sha256:3013b0d761d4bad6ff16dd2805887a2f2c3fc140d6206086698b5c3e44e0f7fe", + length: 1152, + repository: "ubuntu", + tag: "18.04" + }, + request: { + id: "6d472f8e-8366-408a-a248-fb76348c91a0", + host: "matellcr.azurecr.io", + method: "PUT", + useragent: + "docker/19.03.8 go/go1.12.17 git-commit/afacb8b kernel/4.19.104-microsoft-standard os/linux arch/amd64 UpstreamClient(Docker-Client/19.03.8 \\(windows\\))" + } + }, + dataVersion: "1.0", + metadataVersion: "1", + eventTime: new Date("2020-07-09T00:29:38.3640826Z") + }, + JSON.stringify({ + id: "b734f818-f923-472b-aec8-50995013fd7c", + topic: + "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/matell-rg/providers/Microsoft.ContainerRegistry/registries/matellcr", + subject: "ubuntu:18.04", + eventType: "Microsoft.ContainerRegistry.ImagePushed", + data: + '{"id":"b734f818-f923-472b-aec8-50995013fd7c","timestamp":"2020-07-09T00:29:38.143428094Z","action":"push","target":{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","size":1152,"digest":"sha256:3013b0d761d4bad6ff16dd2805887a2f2c3fc140d6206086698b5c3e44e0f7fe","length":1152,"repository":"ubuntu","tag":"18.04"},"request":{"id":"6d472f8e-8366-408a-a248-fb76348c91a0","host":"matellcr.azurecr.io","method":"PUT","useragent":"docker/19.03.8 go/go1.12.17 git-commit/afacb8b kernel/4.19.104-microsoft-standard os/linux arch/amd64 UpstreamClient(Docker-Client/19.03.8 \\\\(windows\\\\))"}}', + dataVersion: "1.0", + metadataVersion: "1", + eventTime: "2020-07-09T00:29:38.3640826Z" + }) + ), + cloudEventSchema: new TestCase( + { + id: "2092c215-d22b-4116-8e56-42dfa856d711", + source: + "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/matell-rg/providers/Microsoft.ContainerRegistry/registries/matellcr", + specversion: "1.0", + type: "Microsoft.ContainerRegistry.ImagePushed", + dataschema: "#1.0", + subject: "alpine:latest", + time: new Date("2020-07-10T20:30:31.3653996Z"), + data: { + id: "2092c215-d22b-4116-8e56-42dfa856d711", + timestamp: new Date("2020-07-10T20:30:30.956083501Z"), + action: "push", + target: { + mediaType: "application/vnd.docker.distribution.manifest.v2+json", + size: 528, + digest: "sha256:a15790640a6690aa1730c38cf0a440e2aa44aaca9b0e8931a9f2b0d7cc90fd65", + length: 528, + repository: "alpine", + tag: "latest" + }, + request: { + id: "1dd0b459-1fc7-43aa-a1a1-c820e996699f", + host: "matellcr.azurecr.io", + method: "PUT", + useragent: + "docker/19.03.8 go/go1.12.17 git-commit/afacb8b kernel/4.19.104-microsoft-standard os/linux arch/amd64 UpstreamClient(Docker-Client/19.03.8 \\(linux\\))" + } + } + }, + JSON.stringify({ + id: "2092c215-d22b-4116-8e56-42dfa856d711", + source: + "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/matell-rg/providers/Microsoft.ContainerRegistry/registries/matellcr", + specversion: "1.0", + type: "Microsoft.ContainerRegistry.ImagePushed", + dataschema: "#1.0", + subject: "alpine:latest", + time: "2020-07-10T20:30:31.3653996Z", + data: + '{"id":"2092c215-d22b-4116-8e56-42dfa856d711","timestamp":"2020-07-10T20:30:30.956083501Z","action":"push","target":{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","size":528,"digest":"sha256:a15790640a6690aa1730c38cf0a440e2aa44aaca9b0e8931a9f2b0d7cc90fd65","length":528,"repository":"alpine","tag":"latest"},"request":{"id":"1dd0b459-1fc7-43aa-a1a1-c820e996699f","host":"matellcr.azurecr.io","method":"PUT","useragent":"docker/19.03.8 go/go1.12.17 git-commit/afacb8b kernel/4.19.104-microsoft-standard os/linux arch/amd64 UpstreamClient(Docker-Client/19.03.8 \\\\(linux\\\\))"}}' + }) + ) +}; diff --git a/sdk/eventgrid/eventgrid/tests.yml b/sdk/eventgrid/eventgrid/tests.yml new file mode 100644 index 000000000000..8b419fc54cb0 --- /dev/null +++ b/sdk/eventgrid/eventgrid/tests.yml @@ -0,0 +1,19 @@ +trigger: none +resources: + repositories: + - repository: azure-sdk-build-tools + type: git + name: internal/azure-sdk-build-tools + - repository: azure-sdk-tools + type: github + name: Azure/azure-sdk-tools + endpoint: azure +jobs: + - template: ../../../eng/pipelines/templates/jobs/archetype-sdk-integration.yml + parameters: + PackageName: "@azure/eventgrid" + ResourceServiceDirectory: eventgrid + EnvVars: + AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id) + AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id) + AZURE_CLIENT_SECRET: $(aad-azure-sdk-test-client-secret) diff --git a/sdk/eventgrid/eventgrid/tsconfig.json b/sdk/eventgrid/eventgrid/tsconfig.json new file mode 100644 index 000000000000..9784ff1f1ed3 --- /dev/null +++ b/sdk/eventgrid/eventgrid/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../tsconfig.package", + "compilerOptions": { + "outDir": "./dist-esm", + "declarationDir": "./types" + }, + "exclude": [ + "node_modules", + "types", + "temp", + "browser", + "dist", + "dist-samples", + "dist-esm", + "./samples/**/*.ts" + ] +} From d92e4eb7c94cca522803a28bebc39953570fe0d6 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Wed, 15 Jul 2020 16:33:38 -0700 Subject: [PATCH 03/34] [EventGrid] Use UTC Date in SAS Token test The test code to generate a date was using `new Date()` which does a local to UTC conversion. When run in CI we have a different local timezone and so the expect data does not match the actual data. Rewrite the test to use `Date.UTC` to construct a time that is in UTC. --- sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts index 0e9b0f06159d..3ab5dfefb00d 100644 --- a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts +++ b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts @@ -205,16 +205,16 @@ describe("EventGridClient", function() { new AzureKeyCredential(key) ); - const sig = client.generateSharedAccessSignature(new Date(2020, 0, 1, 0, 0, 0)); + const sig = client.generateSharedAccessSignature(new Date(Date.UTC(2020, 0, 1, 0, 0, 0))); assert.equal( sig, - "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%208%3A00%3A00%20AM&s=PL2XXgj4Fimu3LcgH5aIaYTG3MefvrmcZZ%2BLPBsARrc%3D" + "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%2012%3A00%3A00%20AM&s=ZzvNAYRyvJwDrOJKYxbNAPNCoSqgOJVLFi4IMXOrW2Q%3D" ); }); it("fails when a signature credential was used", () => { const signature = - "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%208%3A00%3A00%20AM&s=PL2XXgj4Fimu3LcgH5aIaYTG3MefvrmcZZ%2BLPBsARrc%3D"; + "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%2012%3A00%3A00%20AM&s=ZzvNAYRyvJwDrOJKYxbNAPNCoSqgOJVLFi4IMXOrW2Q%3D"; const client = new EventGridClient( "https://eg-topic.westus-2.eventgrid.azure.net/api/events", @@ -222,7 +222,7 @@ describe("EventGridClient", function() { ); assert.throws( - () => client.generateSharedAccessSignature(new Date(2020, 0, 1, 0, 0, 0)), + () => client.generateSharedAccessSignature(new Date(Date.UTC(2020, 0, 1, 0, 0, 0))), /may only be called when the client is constructed with a key credential/ ); }); From 7cd0a2d6ee5a50774c74c1b00579250725b481b8 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Mon, 20 Jul 2020 14:12:50 -0700 Subject: [PATCH 04/34] [EventGrid] Fix typos in README.md --- sdk/eventgrid/eventgrid/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md index 9d327267f6a4..1566e496a0b9 100644 --- a/sdk/eventgrid/eventgrid/README.md +++ b/sdk/eventgrid/eventgrid/README.md @@ -5,7 +5,7 @@ Use the client library to: - Send events to Event Grid using either the Event Grid, Cloud Events 1.0 schemas, or a custom schema -- Decode and process events where were delivered to an Event Grid handler +- Decode and process events which were delivered to an Event Grid handler - Generate Shared Access Signatures for Event Grid topics [Source code](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/eventgrid/eventgrid/) | @@ -94,9 +94,7 @@ const { EventGridClient, AzureKeyCredential } = require("@azure/eventgrid"); const client = new EventGridClient("", new AzureKeyCredential("")); // Create a SAS Token which expires on 2020-01-01 at Midnight. -const token = client.generateSharedAccessSignature( - generateSharedAccessSignature(new Date(2020, 0, 1, 0, 0, 0)) -); +const token = client.generateSharedAccessSignature(new Date(2020, 0, 1, 0, 0, 0)); ``` ## Key concepts From 80ed46541fc1434b417145bddb4489ff69b31c0a Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Mon, 20 Jul 2020 14:13:09 -0700 Subject: [PATCH 05/34] [EventGrid] Don't use getter in credential class This would need to be downleveled for earlier versions of TypeScript. The only reason we followed the pattern of an interface with a member property and then a class with that property as a getter was because that's what we had done with `KeyCredential` and `AzureKeyCredential` but we can just save ourselves the pain by small tweaks to `SignatureCredential` and friends --- sdk/eventgrid/eventgrid/review/eventgrid.api.md | 4 ++-- sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts | 2 +- .../eventgrid/src/sharedAccessSignitureCredential.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index e1d9e0f60717..d2ceef9c1001 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -139,7 +139,7 @@ export interface EventGridEvent { // @public export class EventGridSharedAccessSignatureCredential implements SignatureCredential { constructor(signature: string); - get signature(): string; + signature(): string; update(newSignature: string): void; } @@ -197,7 +197,7 @@ export type SendEventsOptions = OperationOptions; // @public export interface SignatureCredential { - signature: string; + signature(): string; } diff --git a/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts b/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts index 231432e30cc0..4ba9c24fbb4f 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts @@ -62,7 +62,7 @@ class EventGridAzureKeyCredentialPolicy extends BaseRequestPolicy { if (isKeyCredentialLike(this.credential)) { webResource.headers.set(API_KEY_HEADER_NAME, this.credential.key); } else { - webResource.headers.set(SAS_TOKEN_HEAER_NAME, this.credential.signature); + webResource.headers.set(SAS_TOKEN_HEAER_NAME, this.credential.signature()); } return this._nextPolicy.sendRequest(webResource); diff --git a/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts b/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts index 89b4b5cf594d..9d5b7d268565 100644 --- a/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts +++ b/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts @@ -8,7 +8,7 @@ export interface SignatureCredential { /** * The signature to be used in authentication. */ - signature: string; + signature(): string; } /** @@ -23,7 +23,7 @@ export class EventGridSharedAccessSignatureCredential implements SignatureCreden /** * The value of the signature to be used in authentication */ - public get signature(): string { + public signature(): string { return this._signature; } From 9c7758ee319281ecd84c07ced20397372a3f8ea0 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Mon, 20 Jul 2020 14:40:37 -0700 Subject: [PATCH 06/34] [EventGrid] Move extension attributes on model type Move extension attributes to be on a property of the `CloudEvent` object instead of just being defined at top level. This makes the TypeScript experience a little nicer as now you you typo the name of one of the know properties, the compiler will now issue an error. --- .../eventgrid/review/eventgrid.api.md | 2 +- sdk/eventgrid/eventgrid/src/consumer.ts | 59 ++++++++++++++++--- .../eventgrid/src/eventGridClient.ts | 10 +++- sdk/eventgrid/eventgrid/src/models.ts | 4 +- 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index d2ceef9c1001..2347d336b30d 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -14,10 +14,10 @@ export { AzureKeyCredential } // @public export interface CloudEvent { - [keyof: string]: any; data?: T; datacontenttype?: string; dataschema?: string; + extensionAttributes?: Record; id: string; source: string; subject?: string; diff --git a/sdk/eventgrid/eventgrid/src/consumer.ts b/sdk/eventgrid/eventgrid/src/consumer.ts index 523707b5b03a..0d95283adca1 100644 --- a/sdk/eventgrid/eventgrid/src/consumer.ts +++ b/sdk/eventgrid/eventgrid/src/consumer.ts @@ -2,6 +2,7 @@ // Licensed under the MIT license. import { Serializer } from "@azure/core-http"; +import { CloudEvent as WireCloudEvent } from "./generated/models"; import { CloudEvent, EventGridEvent, CustomEventDataDecoder } from "./models"; import { EventGridEvent as EventGridEventMapper, @@ -140,7 +141,33 @@ export class EventGridConsumer { throw new TypeError("event is not in the Cloud Event 1.0 schema"); } - const deserialized: CloudEvent = serializer.deserialize(CloudEventMapper, o, ""); + const deserialized: WireCloudEvent = serializer.deserialize(CloudEventMapper, o, ""); + const modelEvent: Record = { + specversion: deserialized.specversion, + id: deserialized.id, + source: deserialized.source, + type: deserialized.type + }; + + if (deserialized.datacontenttype !== undefined) { + modelEvent.datacontenttype = deserialized.datacontenttype; + } + + if (deserialized.dataschema !== undefined) { + modelEvent.dataschema = deserialized.dataschema; + } + + if (deserialized.subject !== undefined) { + modelEvent.subject = deserialized.subject; + } + + if (deserialized.time !== undefined) { + modelEvent.time = deserialized.time; + } + + if (deserialized.data !== undefined) { + modelEvent.data = deserialized.data; + } // If the data the event represents binary, it is encoded as base64 text in a different property on the event and we need to transform it. if (deserialized.dataBase64 !== undefined) { @@ -152,17 +179,33 @@ export class EventGridConsumer { throw new TypeError("event data_base64 property should be a string"); } - deserialized.data = Buffer.from(deserialized.dataBase64, "base64"); - delete deserialized.dataBase64; + modelEvent.data = Buffer.from(deserialized.dataBase64, "base64"); + } + + // If a decoder is registered, apply it to the data. + if (systemDecoders[modelEvent.type]) { + modelEvent.data = await systemDecoders[modelEvent.type](modelEvent.data); + } else if (this.customDecoders[modelEvent.type]) { + modelEvent.data = await this.customDecoders[modelEvent.type](modelEvent.data); } - if (systemDecoders[deserialized.type]) { - deserialized.data = await systemDecoders[deserialized.type](deserialized.data); - } else if (this.customDecoders[deserialized.type]) { - deserialized.data = await this.customDecoders[deserialized.type](deserialized.data); + // Build the "extensionsAttributes" property bag by removing all known top level properties. + const extensionAttributes = { ...deserialized }; + delete extensionAttributes.specversion; + delete extensionAttributes.id; + delete extensionAttributes.source; + delete extensionAttributes.type; + delete extensionAttributes.datacontenttype; + delete extensionAttributes.dataschema; + delete extensionAttributes.subject; + delete extensionAttributes.time; + delete extensionAttributes.data; + + if (Object.keys(extensionAttributes).length > 0) { + modelEvent.extensionAttributes = extensionAttributes; } - events.push(deserialized as CloudEvent); + events.push(modelEvent as CloudEvent); } return events; diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts index 1bbdc5a3676e..e3652f498af3 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -137,9 +137,15 @@ export class EventGridClient { // TODO(matell): If data is of type `Buffer` or other binary data we should Base64 encoded the data and set // `data_base64` instead. We also need to validate that `datacontenttype` is set in this case. return { - ...msg, specversion: "1.0", - datacontenttype: msg.datacontenttype ?? "application/json" + type: msg.type, + source: msg.source, + id: msg.id, + time: msg.time, + subject: msg.subject, + dataschema: msg.dataschema, + datacontenttype: msg.datacontenttype ?? "application/json", + ...(msg.extensionAttributes ?? []) }; }); diff --git a/sdk/eventgrid/eventgrid/src/models.ts b/sdk/eventgrid/eventgrid/src/models.ts index 62a7435892e3..ecef260733be 100644 --- a/sdk/eventgrid/eventgrid/src/models.ts +++ b/sdk/eventgrid/eventgrid/src/models.ts @@ -73,9 +73,9 @@ export interface CloudEvent { */ subject?: string; /** - * Additional custom properties for the event. + * Additional context attributes for the event. The Cloud Event specification refers to these as "extension attributes". */ - [keyof: string]: any; + extensionAttributes?: Record; } export type CustomEventDataDecoder = (o: any) => Promise; From 66a1e87710524c0f05c52d842f7add98de382f68 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Mon, 20 Jul 2020 15:23:08 -0700 Subject: [PATCH 07/34] [EventGrid] Use options bag pattern This will make evolving the `EventGridConsumer` type more straight forward in the future. --- sdk/eventgrid/eventgrid/review/eventgrid.api.md | 12 +++++++++--- sdk/eventgrid/eventgrid/src/consumer.ts | 17 ++++++++++++++--- sdk/eventgrid/eventgrid/src/index.ts | 4 ++-- sdk/eventgrid/eventgrid/src/models.ts | 3 +++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index 2347d336b30d..fe558ac79744 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -98,6 +98,9 @@ export type ContainerRegistryImageDeletedEventData = ContainerRegistryEventData // @public export type ContainerRegistryImagePushedEventData = ContainerRegistryEventData & {}; +// @public +export type CustomEventDataDecoder = (o: any) => Promise; + // @public export class EventGridClient { constructor(endpointUrl: string, credential: KeyCredential | SignatureCredential, options?: EventGridClientOptions); @@ -114,9 +117,7 @@ export type EventGridClientOptions = PipelineOptions; // @public export class EventGridConsumer { - constructor(decoders?: Record); - // Warning: (ae-forgotten-export) The symbol "CustomEventDataDecoder" needs to be exported by the entry point index.d.ts - // + constructor(options?: EventGridConsumerOptions); // (undocumented) readonly customDecoders: Record; decodeCloudEvents(encodedEvents: string): Promise[]>; @@ -125,6 +126,11 @@ export class EventGridConsumer { decodeEventGridEvents(encodedEvents: object): Promise[]>; } +// @public +export interface EventGridConsumerOptions { + customDecoders: Record; +} + // @public export interface EventGridEvent { data: T; diff --git a/sdk/eventgrid/eventgrid/src/consumer.ts b/sdk/eventgrid/eventgrid/src/consumer.ts index 0d95283adca1..997b5c91647f 100644 --- a/sdk/eventgrid/eventgrid/src/consumer.ts +++ b/sdk/eventgrid/eventgrid/src/consumer.ts @@ -3,7 +3,7 @@ import { Serializer } from "@azure/core-http"; import { CloudEvent as WireCloudEvent } from "./generated/models"; -import { CloudEvent, EventGridEvent, CustomEventDataDecoder } from "./models"; +import { CustomEventDataDecoder, CloudEvent, EventGridEvent } from "./models"; import { EventGridEvent as EventGridEventMapper, CloudEvent as CloudEventMapper @@ -41,13 +41,24 @@ function validateOptionalStringProperty(propertyName: string, o: any): void { } } +/** + * Options for the Event Grid Consumer + */ +export interface EventGridConsumerOptions { + /** + * Custom decoders to use when decoding a specific event's data, based on the type + * field of the event. + */ + customDecoders: Record; +} + /** * TODO(matell): Document this. */ export class EventGridConsumer { readonly customDecoders: Record; - constructor(decoders: Record = {}) { - this.customDecoders = decoders; + constructor(options?: EventGridConsumerOptions) { + this.customDecoders = options?.customDecoders ?? {}; } /** diff --git a/sdk/eventgrid/eventgrid/src/index.ts b/sdk/eventgrid/eventgrid/src/index.ts index 2d86d74c4312..5c2d02b1d623 100644 --- a/sdk/eventgrid/eventgrid/src/index.ts +++ b/sdk/eventgrid/eventgrid/src/index.ts @@ -3,7 +3,7 @@ export { AzureKeyCredential } from "@azure/core-auth"; -export { EventGridEvent, CloudEvent } from "./models"; +export { CustomEventDataDecoder, EventGridEvent, CloudEvent } from "./models"; export { EventGridClient, @@ -18,7 +18,7 @@ export { EventGridSharedAccessSignatureCredential } from "./sharedAccessSignitureCredential"; -export { EventGridConsumer } from "./consumer"; +export { EventGridConsumer, EventGridConsumerOptions } from "./consumer"; export { EventHubCaptureFileCreatedEventData, diff --git a/sdk/eventgrid/eventgrid/src/models.ts b/sdk/eventgrid/eventgrid/src/models.ts index ecef260733be..d25c6d2420fb 100644 --- a/sdk/eventgrid/eventgrid/src/models.ts +++ b/sdk/eventgrid/eventgrid/src/models.ts @@ -78,4 +78,7 @@ export interface CloudEvent { extensionAttributes?: Record; } +/** + * A function which provides custom logic to be used when decoding events. + */ export type CustomEventDataDecoder = (o: any) => Promise; From ee7170e01386f71b41787a22cbc5906f9bc71079 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Mon, 20 Jul 2020 15:37:35 -0700 Subject: [PATCH 08/34] [EventGrid] Refactor validation logic for consumer Move the validation helpers out of `consumer.ts` and into `util.ts` and expose some high level functions for doing the validation. --- sdk/eventgrid/eventgrid/src/consumer.ts | 64 +--------------------- sdk/eventgrid/eventgrid/src/util.ts | 73 +++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 61 deletions(-) diff --git a/sdk/eventgrid/eventgrid/src/consumer.ts b/sdk/eventgrid/eventgrid/src/consumer.ts index 997b5c91647f..27e5518dbb83 100644 --- a/sdk/eventgrid/eventgrid/src/consumer.ts +++ b/sdk/eventgrid/eventgrid/src/consumer.ts @@ -8,39 +8,11 @@ import { EventGridEvent as EventGridEventMapper, CloudEvent as CloudEventMapper } from "./generated/models/mappers"; -import { parseAndWrap } from "./util"; +import { parseAndWrap, validateEventGridEvent, validateCloudEventEvent } from "./util"; import { systemDecoders } from "./systemEventDecoders"; const serializer = new Serializer(); -function validateRequiredStringProperty(o: any, propertyName: string): void { - if (typeof o[propertyName] === "undefined") { - throw new TypeError(`event is missing required property '${propertyName}'`); - } - - if (typeof o[propertyName] !== "string") { - throw new TypeError( - `event property '${propertyName} should be a 'string', but is '${typeof o[propertyName]}'` - ); - } -} - -function validateRequiredAnyProperty(o: any, propertyName: string): void { - if (typeof o[propertyName] === "undefined") { - throw new TypeError(`event is missing required property '${propertyName}'`); - } -} - -function validateOptionalStringProperty(propertyName: string, o: any): void { - if (typeof o[propertyName] !== "undefined" && typeof o[propertyName] !== "string") { - throw new TypeError( - `event property '${propertyName}' should be a 'string' but it is a '${typeof o[ - propertyName - ]}'` - ); - } -} - /** * Options for the Event Grid Consumer */ @@ -82,22 +54,7 @@ export class EventGridConsumer { const events: EventGridEvent[] = []; for (const o of decodedArray) { - if (typeof o !== "object") { - throw new TypeError("event is not an object"); - } - - validateRequiredStringProperty(o, "eventType"); - validateRequiredStringProperty(o, "eventTime"); - validateRequiredStringProperty(o, "id"); - validateRequiredStringProperty(o, "subject"); - validateRequiredStringProperty(o, "topic"); - validateRequiredAnyProperty(o, "data"); - validateRequiredStringProperty(o, "dataVersion"); - validateRequiredStringProperty(o, "metadataVersion"); - - if (o.metadataVersion !== "1") { - throw new TypeError("event is not in the Event Grid schema"); - } + validateEventGridEvent(o); const deserialized: EventGridEvent = serializer.deserialize(EventGridEventMapper, o, ""); @@ -132,26 +89,11 @@ export class EventGridConsumer { const events: CloudEvent[] = []; for (const o of decodedArray) { - if (typeof o !== "object") { - throw new TypeError("encoded event is not an object"); - } + validateCloudEventEvent(o); // Check that the required fields are present and of the correct type and the optional fields are missing // or of the correct type. - validateRequiredStringProperty(o, "type"); - validateRequiredStringProperty(o, "source"); - validateRequiredStringProperty(o, "id"); - validateRequiredStringProperty(o, "specversion"); - validateOptionalStringProperty(o, "time"); - validateOptionalStringProperty(o, "dataschema"); - validateOptionalStringProperty(o, "datacontenttype"); - validateOptionalStringProperty(o, "subject"); - - if (o.specversion !== "1.0") { - throw new TypeError("event is not in the Cloud Event 1.0 schema"); - } - const deserialized: WireCloudEvent = serializer.deserialize(CloudEventMapper, o, ""); const modelEvent: Record = { specversion: deserialized.specversion, diff --git a/sdk/eventgrid/eventgrid/src/util.ts b/sdk/eventgrid/eventgrid/src/util.ts index 48efd19f076d..3726a639aa6c 100644 --- a/sdk/eventgrid/eventgrid/src/util.ts +++ b/sdk/eventgrid/eventgrid/src/util.ts @@ -61,3 +61,76 @@ export function parseAndWrap(jsonStringOrObject: string | object): any[] { return [jsonStringOrObject]; } } + +const EVENT_GRID_SCHEMA_METADATA_VERSION = "1"; + +export function validateEventGridEvent(o: any): void { + if (typeof o !== "object") { + throw new TypeError("event is not an object"); + } + + validateRequiredStringProperties(o, [ + "eventType", + "eventTime", + "id", + "subject", + "topic", + "dataVersion", + "metadataVersion" + ]); + + validateRequiredAnyProperties(o, ["data"]); + + if (o.metadataVersion !== EVENT_GRID_SCHEMA_METADATA_VERSION) { + throw new TypeError("event is not in the Event Grid schema"); + } +} + +const CLOUD_EVENT_1_0_SPEC_VERSION = "1.0"; + +export function validateCloudEventEvent(o: any): void { + validateRequiredStringProperties(o, ["type", "source", "id", "specversion"]); + validateOptionalStringProperties(o, ["time", "dataschema", "datacontenttype", "subject"]); + + if (typeof o !== "object") { + throw new TypeError("event is not an object"); + } + + if (o.specversion !== CLOUD_EVENT_1_0_SPEC_VERSION) { + throw new TypeError("event is not in the Cloud Event 1.0 schema"); + } +} + +function validateRequiredStringProperties(o: any, propertyNames: string[]): void { + for (const propertyName of propertyNames) { + if (typeof o[propertyName] === "undefined") { + throw new TypeError(`event is missing required property '${propertyName}'`); + } + + if (typeof o[propertyName] !== "string") { + throw new TypeError( + `event property '${propertyName} should be a 'string', but is '${typeof o[propertyName]}'` + ); + } + } +} + +function validateRequiredAnyProperties(o: any, propertyNames: string[]): void { + for (const propertyName of propertyNames) { + if (typeof o[propertyName] === "undefined") { + throw new TypeError(`event is missing required property '${propertyName}'`); + } + } +} + +function validateOptionalStringProperties(o: any, propertyNames: string[]): void { + for (const propertyName of propertyNames) { + if (typeof o[propertyName] !== "undefined" && typeof o[propertyName] !== "string") { + throw new TypeError( + `event property '${propertyName}' should be a 'string' but it is a '${typeof o[ + propertyName + ]}'` + ); + } + } +} From 0b7ccd022411e08907cc9cc5771d30b25bdb77ca Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 21 Jul 2020 14:07:12 -0700 Subject: [PATCH 09/34] [EventGrid] Allow creating SAS tokens from browser This change takes some of the utility code from the Cosmos SDK which allows doing an SHA256 HMAC inside the browser (in addition to Node). In order to support this, we need to make `generateSharedAccessSignature` be async, since on the browser side some of the APIs we use are async themselves. --- sdk/eventgrid/eventgrid/README.md | 1 + sdk/eventgrid/eventgrid/package.json | 4 ++ .../eventgrid/review/eventgrid.api.md | 2 +- .../eventgrid/src/eventGridClient.ts | 13 ++-- .../eventgrid/src/utils/atob.browser.ts | 8 +++ sdk/eventgrid/eventgrid/src/utils/atob.ts | 6 ++ sdk/eventgrid/eventgrid/src/utils/encode.ts | 25 +++++++ .../eventgrid/src/utils/globalCrypto.ts | 16 +++++ .../eventgrid/src/utils/hmac.browser.ts | 20 ++++++ sdk/eventgrid/eventgrid/src/utils/hmac.ts | 10 +++ .../eventgrid/test/eventGridClient.spec.ts | 71 +++++++++---------- 11 files changed, 130 insertions(+), 46 deletions(-) create mode 100644 sdk/eventgrid/eventgrid/src/utils/atob.browser.ts create mode 100644 sdk/eventgrid/eventgrid/src/utils/atob.ts create mode 100644 sdk/eventgrid/eventgrid/src/utils/encode.ts create mode 100644 sdk/eventgrid/eventgrid/src/utils/globalCrypto.ts create mode 100644 sdk/eventgrid/eventgrid/src/utils/hmac.browser.ts create mode 100644 sdk/eventgrid/eventgrid/src/utils/hmac.ts diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md index 1566e496a0b9..2c8b0e3bb82e 100644 --- a/sdk/eventgrid/eventgrid/README.md +++ b/sdk/eventgrid/eventgrid/README.md @@ -19,6 +19,7 @@ Use the client library to: ### Currently supported environments - Node.js version 8.x.x or higher +- Browser JavaScript ### Prerequisites diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json index dda932dafbee..003b6d95c929 100644 --- a/sdk/eventgrid/eventgrid/package.json +++ b/sdk/eventgrid/eventgrid/package.json @@ -42,6 +42,10 @@ } ] }, + "browser": { + "./dist-esm/src/utils/hmac.js": "./dist-esm/src/utils/hmac.browser.js", + "./dist-esm/src/utils/atob.js": "./dist-esm/src/utils/atob.browser.js" + }, "scripts": { "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", "build:autorest": "autorest ./swagger/README.md --typescript --v3", diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index fe558ac79744..840930c9905b 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -106,7 +106,7 @@ export class EventGridClient { constructor(endpointUrl: string, credential: KeyCredential | SignatureCredential, options?: EventGridClientOptions); readonly apiVersion: string; readonly endpointUrl: string; - generateSharedAccessSignature(expiresOnUtc: Date): string; + generateSharedAccessSignature(expiresOnUtc: Date): Promise; sendCloudEvents(events: CloudEvent[], options?: SendCloudEventsOptions): Promise; sendCustomSchemaEvents(events: Record[], options?: SendCustomSchemaEventsOptions): Promise; sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise; diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts index e3652f498af3..4c0571b1ffdb 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -9,7 +9,7 @@ import { OperationOptions } from "@azure/core-http"; -import { createHmac } from "crypto"; +import { hmac } from "./utils/hmac"; import { createEventGridCredentialPolicy } from "./eventGridAuthenticationPolicy"; import { SignatureCredential } from "./sharedAccessSignitureCredential"; @@ -170,7 +170,7 @@ export class EventGridClient { * * @param expiresOn The time at which the shared signature is no longer valid. */ - generateSharedAccessSignature(expiresOnUtc: Date): string { + async generateSharedAccessSignature(expiresOnUtc: Date): Promise { if (!this.keyCredential) { throw new Error( "generateSharedAccessSignature may only be called when the client is constructed with a key credential" @@ -181,11 +181,8 @@ export class EventGridClient { const unsignedSas = `r=${encodeURIComponent( `${this.endpointUrl}?apiVersion=${this.apiVersion}` )}&e=${encodeURIComponent(expiresOnString)}`; - const digest = createHmac("sha256", Buffer.from(this.keyCredential?.key, "base64")) - .update(unsignedSas) - .digest() - .toString("base64"); - - return `${unsignedSas}&s=${encodeURIComponent(digest)}`; + return hmac(this.keyCredential!.key, unsignedSas).then( + (digest) => `${unsignedSas}&s=${encodeURIComponent(digest)}` + ); } } diff --git a/sdk/eventgrid/eventgrid/src/utils/atob.browser.ts b/sdk/eventgrid/eventgrid/src/utils/atob.browser.ts new file mode 100644 index 000000000000..766fc839b4ae --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/utils/atob.browser.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +if ("function" !== typeof atob) { + throw new Error("Your browser environment is missing the global `atob` function"); +} + +export default atob; diff --git a/sdk/eventgrid/eventgrid/src/utils/atob.ts b/sdk/eventgrid/eventgrid/src/utils/atob.ts new file mode 100644 index 000000000000..2239926f9ff7 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/utils/atob.ts @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +export default function atob(str: string) { + return Buffer.from(str, "base64").toString("binary"); +} diff --git a/sdk/eventgrid/eventgrid/src/utils/encode.ts b/sdk/eventgrid/eventgrid/src/utils/encode.ts new file mode 100644 index 000000000000..87b35db58e0e --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/utils/encode.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/// + +export function encodeUTF8(str: string): Uint8Array { + const bytes = new Uint8Array(str.length); + for (let i = 0; i < str.length; i++) { + bytes[i] = str.charCodeAt(i); + } + return bytes; +} + +export function encodeBase64(value: ArrayBuffer): string { + if ("function" !== typeof btoa) { + throw new Error("Your browser environment is missing the global `btoa` function"); + } + + let binary = ""; + const bytes = new Uint8Array(value); + const len = bytes.byteLength; + for (let i = 0; i < len; i++) { + binary += String.fromCharCode(bytes[i]); + } + return btoa(binary); +} diff --git a/sdk/eventgrid/eventgrid/src/utils/globalCrypto.ts b/sdk/eventgrid/eventgrid/src/utils/globalCrypto.ts new file mode 100644 index 000000000000..ab7f046745d6 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/utils/globalCrypto.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +const globalRef: any = typeof self === "undefined" ? window : self; + +if (!globalRef) { + throw new Error("Could not find global"); +} + +const globalCrypto: Crypto = globalRef.crypto || globalRef.msCrypto; + +if (!globalCrypto || !globalCrypto.subtle) { + throw new Error("Browser does not support cryptography functions"); +} + +export { globalCrypto }; diff --git a/sdk/eventgrid/eventgrid/src/utils/hmac.browser.ts b/sdk/eventgrid/eventgrid/src/utils/hmac.browser.ts new file mode 100644 index 000000000000..939648ed6c50 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/utils/hmac.browser.ts @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { encodeUTF8, encodeBase64 } from "./encode"; +import atob from "./atob"; +import { globalCrypto } from "./globalCrypto"; + +export async function hmac(key: string, message: string) { + const importParams: HmacImportParams = { name: "HMAC", hash: { name: "SHA-256" } }; + const encodedMessage = new Uint8Array( + [...unescape(encodeURIComponent(message))].map((c) => c.charCodeAt(0)) + ); + const encodedKey = encodeUTF8(atob(key)); + const cryptoKey = await globalCrypto.subtle.importKey("raw", encodedKey, importParams, false, [ + "sign" + ]); + const signature = await globalCrypto.subtle.sign(importParams, cryptoKey, encodedMessage); + + return encodeBase64(signature); +} diff --git a/sdk/eventgrid/eventgrid/src/utils/hmac.ts b/sdk/eventgrid/eventgrid/src/utils/hmac.ts new file mode 100644 index 000000000000..7349e0d5e067 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/utils/hmac.ts @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { createHmac } from "crypto"; + +export async function hmac(key: string, message: string) { + return createHmac("sha256", Buffer.from(key, "base64")) + .update(message) + .digest("base64"); +} diff --git a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts index 3ab5dfefb00d..ca4758012572 100644 --- a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts +++ b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts @@ -4,7 +4,6 @@ import { assert } from "chai"; -import { isNode } from "@azure/core-http"; import { Recorder } from "@azure/test-utils-recorder"; import { createRecordedClient, testEnv } from "./utils/recordedClient"; @@ -191,41 +190,39 @@ describe("EventGridClient", function() { }); }); - // TODO(matell): generateSharedAccessSigniture used `createHmac` which is specific to node. When we get this working in the browser - // we need to enable this test there as well. - if (isNode) { - describe("#generateSharedAccessSigniture", () => { - it("generates the correct signiture", () => { - // This is not a real key, it's the base64 encoding of "this is not a real EventGrid key", which happens to be the same - // number of bytes as an actual EventGrid Access Key. - const key = "dGhpcyBpcyBub3QgYSByZWFsIEV2ZW50R3JpZCBrZXk="; - - const client = new EventGridClient( - "https://eg-topic.westus-2.eventgrid.azure.net/api/events", - new AzureKeyCredential(key) - ); - - const sig = client.generateSharedAccessSignature(new Date(Date.UTC(2020, 0, 1, 0, 0, 0))); - assert.equal( - sig, - "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%2012%3A00%3A00%20AM&s=ZzvNAYRyvJwDrOJKYxbNAPNCoSqgOJVLFi4IMXOrW2Q%3D" - ); - }); - - it("fails when a signature credential was used", () => { - const signature = - "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%2012%3A00%3A00%20AM&s=ZzvNAYRyvJwDrOJKYxbNAPNCoSqgOJVLFi4IMXOrW2Q%3D"; - - const client = new EventGridClient( - "https://eg-topic.westus-2.eventgrid.azure.net/api/events", - new EventGridSharedAccessSignatureCredential(signature) - ); - - assert.throws( - () => client.generateSharedAccessSignature(new Date(Date.UTC(2020, 0, 1, 0, 0, 0))), - /may only be called when the client is constructed with a key credential/ - ); - }); + describe("#generateSharedAccessSigniture", () => { + it("generates the correct signiture", async () => { + // This is not a real key, it's the base64 encoding of "this is not a real EventGrid key", which happens to be the same + // number of bytes as an actual EventGrid Access Key. + const key = "dGhpcyBpcyBub3QgYSByZWFsIEV2ZW50R3JpZCBrZXk="; + + const client = new EventGridClient( + "https://eg-topic.westus-2.eventgrid.azure.net/api/events", + new AzureKeyCredential(key) + ); + + const sig = await client.generateSharedAccessSignature( + new Date(Date.UTC(2020, 0, 1, 0, 0, 0)) + ); + assert.equal( + sig, + "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%2012%3A00%3A00%20AM&s=ZzvNAYRyvJwDrOJKYxbNAPNCoSqgOJVLFi4IMXOrW2Q%3D" + ); }); - } + + it("fails when a signature credential was used", () => { + const signature = + "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%2012%3A00%3A00%20AM&s=ZzvNAYRyvJwDrOJKYxbNAPNCoSqgOJVLFi4IMXOrW2Q%3D"; + + const client = new EventGridClient( + "https://eg-topic.westus-2.eventgrid.azure.net/api/events", + new EventGridSharedAccessSignatureCredential(signature) + ); + + assert.isRejected( + client.generateSharedAccessSignature(new Date(Date.UTC(2020, 0, 1, 0, 0, 0))), + /may only be called when the client is constructed with a key credential/ + ); + }); + }); }); From 88b0ed1f7c729a638c7530c91d8605689b2f7f45 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 21 Jul 2020 14:19:57 -0700 Subject: [PATCH 10/34] [EventGrid] use package name in logger --- sdk/eventgrid/eventgrid/src/logger.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventgrid/eventgrid/src/logger.ts b/sdk/eventgrid/eventgrid/src/logger.ts index a58275d73374..81ab74e89343 100644 --- a/sdk/eventgrid/eventgrid/src/logger.ts +++ b/sdk/eventgrid/eventgrid/src/logger.ts @@ -6,4 +6,4 @@ import { createClientLogger } from "@azure/logger"; /** * The @azure/logger configuration for this package. */ -export const logger = createClientLogger("messaging-eventgrid"); +export const logger = createClientLogger("eventgrid"); From 85cd59f376a2d4fe11d04ec1904ac45035c58f32 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 21 Jul 2020 14:27:06 -0700 Subject: [PATCH 11/34] [EventGrid] Rename `EventGridClient` The feature crew has decided to use `EventGridPublisherClient` as the name for our client. --- sdk/eventgrid/eventgrid/README.md | 33 ++++++++++--------- .../eventgrid/review/eventgrid.api.md | 28 ++++++++-------- .../eventgrid/src/eventGridClient.ts | 16 ++++----- sdk/eventgrid/eventgrid/src/index.ts | 4 +-- .../src/sharedAccessSignitureCredential.ts | 2 +- .../eventgrid/test/eventGridClient.spec.ts | 10 +++--- .../eventgrid/test/utils/recordedClient.ts | 6 ++-- 7 files changed, 51 insertions(+), 48 deletions(-) diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md index 2c8b0e3bb82e..bff044783674 100644 --- a/sdk/eventgrid/eventgrid/README.md +++ b/sdk/eventgrid/eventgrid/README.md @@ -48,7 +48,7 @@ Install the Azure Event Grid client library for JavaScript with `npm`: npm install @azure/eventgrid ``` -### Create and authenticate a `EventGridClient` +### Create and authenticate a `EventGridPublisherClient` To create a client object to access the Event Grid API, you will need the `endpoint` of your Event Grid topic and a `credential`. The Event Grid client can use either an Access Key or Shared Access Signature (SAS) created from an access key. @@ -69,9 +69,9 @@ az eventgrid topic key list --resource-group --name < Once you have an API key and endpoint, you can use the `AzureKeyCredential` class to authenticate the client as follows: ```js -const { EventGridClient, AzureKeyCredential } = require("@azure/eventgrid"); +const { EventGridPublisherClient, AzureKeyCredential } = require("@azure/eventgrid"); -const client = new EventGridClient("", new AzureKeyCredential("")); +const client = new EventGridPublisherClient("", new AzureKeyCredential("")); ``` #### Using a SAS Token @@ -79,20 +79,23 @@ const client = new EventGridClient("", new AzureKeyCredential("", new EventGridSharedAccessSignatureCredential("") ); ``` -You can generate a SAS token by using the `generateSharedAccessSigniture` instance method on the `EventGridClient` type. Because the Topic's Access Key is used as part of generating the SAS token, you need to create the `EventGridClient` using an Access Key: +You can generate a SAS token by using the `generateSharedAccessSigniture` instance method on the `EventGridPublisherClient` type. Because the Topic's Access Key is used as part of generating the SAS token, you need to create the `EventGridPublisherClient` using an Access Key: ```js -const { EventGridClient, AzureKeyCredential } = require("@azure/eventgrid"); +const { EventGridPublisherClient, AzureKeyCredential } = require("@azure/eventgrid"); -const client = new EventGridClient("", new AzureKeyCredential("")); +const client = new EventGridPublisherClient("", new AzureKeyCredential("")); // Create a SAS Token which expires on 2020-01-01 at Midnight. const token = client.generateSharedAccessSignature(new Date(2020, 0, 1, 0, 0, 0)); @@ -100,13 +103,13 @@ const token = client.generateSharedAccessSignature(new Date(2020, 0, 1, 0, 0, 0) ## Key concepts -### EventGridClient +### EventGridPublisherClient -`EventGridClient` is used sending events to an Event Grid Topic or an Event Grid Domain. +`EventGridPublisherClient` is used sending events to an Event Grid Topic or an Event Grid Domain. ### Event Schemas -Event Grid supports multiple schemas for encoding events. When a Custom Topic or Domain is created, you specify the schema that will be used when publishing events. While you may configure your topic to use a _custom schema_ it is more common to use the already defined _Event Grid schema_ or _CloudEvents 1.0 schema_. [CloudEvents](https://cloudevents.io/) is a Cloud Native Computing Foundation project which produces a specification for describing event data in a common way. Regardless of what schmea your topic or domain is configured to use, `EventGridClient` will be used to publish events to it. However, you must use the correct method for publishing: +Event Grid supports multiple schemas for encoding events. When a Custom Topic or Domain is created, you specify the schema that will be used when publishing events. While you may configure your topic to use a _custom schema_ it is more common to use the already defined _Event Grid schema_ or _CloudEvents 1.0 schema_. [CloudEvents](https://cloudevents.io/) is a Cloud Native Computing Foundation project which produces a specification for describing event data in a common way. Regardless of what schmea your topic or domain is configured to use, `EventGridPublisherClient` will be used to publish events to it. However, you must use the correct method for publishing: | Schema | Publishing Method | | ------------ | --------------------- | @@ -126,9 +129,9 @@ TODO ```js const { v4: uuidv4 } = require("uuid"); -const { EventGridClient, AzureKeyCredential } = require("@azure/eventgrid"); +const { EventGridPublisherClient, AzureKeyCredential } = require("@azure/eventgrid"); -const client = new EventGridClient("", new AzureKeyCredential("")); +const client = new EventGridPublisherClient("", new AzureKeyCredential("")); await client.sendEvents([ { @@ -150,9 +153,9 @@ Publishing events to an Event Grid Domain is similar to publish to an Event Grid ```js const { v4: uuidv4 } = require("uuid"); -const { EventGridClient, AzureKeyCredential } = require("@azure/eventgrid"); +const { EventGridPublisherClient, AzureKeyCredential } = require("@azure/eventgrid"); -const client = new EventGridClient("", new AzureKeyCredential("")); +const client = new EventGridPublisherClient("", new AzureKeyCredential("")); await client.sendEvents([ { diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index 840930c9905b..350b8dd78e40 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -101,20 +101,6 @@ export type ContainerRegistryImagePushedEventData = ContainerRegistryEventData & // @public export type CustomEventDataDecoder = (o: any) => Promise; -// @public -export class EventGridClient { - constructor(endpointUrl: string, credential: KeyCredential | SignatureCredential, options?: EventGridClientOptions); - readonly apiVersion: string; - readonly endpointUrl: string; - generateSharedAccessSignature(expiresOnUtc: Date): Promise; - sendCloudEvents(events: CloudEvent[], options?: SendCloudEventsOptions): Promise; - sendCustomSchemaEvents(events: Record[], options?: SendCustomSchemaEventsOptions): Promise; - sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise; -} - -// @public -export type EventGridClientOptions = PipelineOptions; - // @public export class EventGridConsumer { constructor(options?: EventGridConsumerOptions); @@ -142,6 +128,20 @@ export interface EventGridEvent { topic?: string; } +// @public +export class EventGridPublisherClient { + constructor(endpointUrl: string, credential: KeyCredential | SignatureCredential, options?: EventGridPublisherClientOptions); + readonly apiVersion: string; + readonly endpointUrl: string; + generateSharedAccessSignature(expiresOnUtc: Date): Promise; + sendCloudEvents(events: CloudEvent[], options?: SendCloudEventsOptions): Promise; + sendCustomSchemaEvents(events: Record[], options?: SendCustomSchemaEventsOptions): Promise; + sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise; +} + +// @public +export type EventGridPublisherClientOptions = PipelineOptions; + // @public export class EventGridSharedAccessSignatureCredential implements SignatureCredential { constructor(signature: string); diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts index 4c0571b1ffdb..34a56690253b 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -22,7 +22,7 @@ import { dateToServiceTimeString, isKeyCredentialLike } from "./util"; /** * Options for the Event Grid Client. */ -export type EventGridClientOptions = PipelineOptions; +export type EventGridPublisherClientOptions = PipelineOptions; /** * Options for the send events operation. @@ -40,9 +40,9 @@ export type SendCloudEventsOptions = OperationOptions; export type SendCustomSchemaEventsOptions = OperationOptions; /** - * Client class for interacting with the Event Grid Service. + * Client class for publishing events to the Event Grid Service. */ -export class EventGridClient { +export class EventGridPublisherClient { /** * The URL to the Event Grid endpoint. */ @@ -65,13 +65,13 @@ export class EventGridClient { private readonly keyCredential?: KeyCredential; /** - * Creates an instance of EventGridClient. + * Creates an instance of EventGridPublisherClient. * * Example usage: * ```ts - * import { EventGridClient, AzureKeyCredential } from "@azure/eventgrid"; + * import { EventGridPublisherClient, AzureKeyCredential } from "@azure/eventgrid"; * - * const client = new EventGridClient( + * const client = new EventGridPublisherClient( * "", * new AzureKeyCredential("") * ); @@ -84,7 +84,7 @@ export class EventGridClient { constructor( endpointUrl: string, credential: KeyCredential | SignatureCredential, - options: EventGridClientOptions = {} + options: EventGridPublisherClientOptions = {} ) { this.endpointUrl = endpointUrl; @@ -166,7 +166,7 @@ export class EventGridClient { /** * Generate a shared access signature, which allows a client to send events to an Event Grid Topic for a limited period of time. This - * function may only be called when the EventGridClient was constructed with a KeyCredential instance. + * function may only be called when the EventGridPublisherClient was constructed with a KeyCredential instance. * * @param expiresOn The time at which the shared signature is no longer valid. */ diff --git a/sdk/eventgrid/eventgrid/src/index.ts b/sdk/eventgrid/eventgrid/src/index.ts index 5c2d02b1d623..70817b7669bd 100644 --- a/sdk/eventgrid/eventgrid/src/index.ts +++ b/sdk/eventgrid/eventgrid/src/index.ts @@ -6,8 +6,8 @@ export { AzureKeyCredential } from "@azure/core-auth"; export { CustomEventDataDecoder, EventGridEvent, CloudEvent } from "./models"; export { - EventGridClient, - EventGridClientOptions, + EventGridPublisherClient, + EventGridPublisherClientOptions, SendEventsOptions, SendCloudEventsOptions, SendCustomSchemaEventsOptions diff --git a/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts b/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts index 9d5b7d268565..73306480da20 100644 --- a/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts +++ b/sdk/eventgrid/eventgrid/src/sharedAccessSignitureCredential.ts @@ -15,7 +15,7 @@ export interface SignatureCredential { * A credential type which allows using a "shared access signature" to authenticate with EventGrid * when sending events. * - * A shared access signiture may be generated by using `EventGridClient.generateSharedAccessSignature` + * A shared access signiture may be generated by using `EventGridPublisherClient#generateSharedAccessSignature` */ export class EventGridSharedAccessSignatureCredential implements SignatureCredential { private _signature: string; diff --git a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts index ca4758012572..b70bb5f6008f 100644 --- a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts +++ b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts @@ -10,13 +10,13 @@ import { createRecordedClient, testEnv } from "./utils/recordedClient"; import { AzureKeyCredential, - EventGridClient, + EventGridPublisherClient, EventGridSharedAccessSignatureCredential } from "../src/index"; -describe("EventGridClient", function() { +describe("EventGridPublisherClient", function() { let recorder: Recorder; - let client: EventGridClient; + let client: EventGridPublisherClient; this.timeout(10000); @@ -196,7 +196,7 @@ describe("EventGridClient", function() { // number of bytes as an actual EventGrid Access Key. const key = "dGhpcyBpcyBub3QgYSByZWFsIEV2ZW50R3JpZCBrZXk="; - const client = new EventGridClient( + const client = new EventGridPublisherClient( "https://eg-topic.westus-2.eventgrid.azure.net/api/events", new AzureKeyCredential(key) ); @@ -214,7 +214,7 @@ describe("EventGridClient", function() { const signature = "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%2012%3A00%3A00%20AM&s=ZzvNAYRyvJwDrOJKYxbNAPNCoSqgOJVLFi4IMXOrW2Q%3D"; - const client = new EventGridClient( + const client = new EventGridPublisherClient( "https://eg-topic.westus-2.eventgrid.azure.net/api/events", new EventGridSharedAccessSignatureCredential(signature) ); diff --git a/sdk/eventgrid/eventgrid/test/utils/recordedClient.ts b/sdk/eventgrid/eventgrid/test/utils/recordedClient.ts index 235c5461b720..648f93134e7a 100644 --- a/sdk/eventgrid/eventgrid/test/utils/recordedClient.ts +++ b/sdk/eventgrid/eventgrid/test/utils/recordedClient.ts @@ -7,7 +7,7 @@ import * as dotenv from "dotenv"; import { env, Recorder, record, RecorderEnvironmentSetup } from "@azure/test-utils-recorder"; import { isNode } from "@azure/core-http"; -import { EventGridClient } from "../../src/index"; +import { EventGridPublisherClient } from "../../src/index"; import { KeyCredential } from "@azure/core-auth"; if (isNode) { @@ -15,7 +15,7 @@ if (isNode) { } export interface RecordedClient { - client: EventGridClient; + client: EventGridPublisherClient; recorder: Recorder; } @@ -61,7 +61,7 @@ export function createRecordedClient( const recorder = record(context, environmentSetup); return { - client: new EventGridClient(endpoint, credential), + client: new EventGridPublisherClient(endpoint, credential), recorder }; } From 2035b4943af4e580b013605a6963eb77f3c534a7 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 21 Jul 2020 14:38:09 -0700 Subject: [PATCH 12/34] [EventGrid] Rename `decode` family of methods We are using `deserialize` instead of `decode` in other languages. This is a more common name overall. --- .../eventgrid/review/eventgrid.api.md | 14 ++--- sdk/eventgrid/eventgrid/src/consumer.ts | 58 +++++++++++-------- sdk/eventgrid/eventgrid/src/index.ts | 2 +- sdk/eventgrid/eventgrid/src/models.ts | 2 +- .../eventgrid/src/systemEventDecoders.ts | 46 ++++++++------- sdk/eventgrid/eventgrid/test/consumer.spec.ts | 44 +++++++------- 6 files changed, 90 insertions(+), 76 deletions(-) diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index 350b8dd78e40..06901d30db87 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -99,22 +99,22 @@ export type ContainerRegistryImageDeletedEventData = ContainerRegistryEventData export type ContainerRegistryImagePushedEventData = ContainerRegistryEventData & {}; // @public -export type CustomEventDataDecoder = (o: any) => Promise; +export type CustomEventDataDeserializer = (o: any) => Promise; // @public export class EventGridConsumer { constructor(options?: EventGridConsumerOptions); // (undocumented) - readonly customDecoders: Record; - decodeCloudEvents(encodedEvents: string): Promise[]>; - decodeCloudEvents(encodedEvents: object): Promise[]>; - decodeEventGridEvents(encodedEvents: string): Promise[]>; - decodeEventGridEvents(encodedEvents: object): Promise[]>; + readonly customDeserializers: Record; + deserializeCloudEvents(encodedEvents: string): Promise[]>; + deserializeCloudEvents(encodedEvents: object): Promise[]>; + deserializeEventGridEvents(encodedEvents: string): Promise[]>; + deserializeEventGridEvents(encodedEvents: object): Promise[]>; } // @public export interface EventGridConsumerOptions { - customDecoders: Record; + customDeserializers: Record; } // @public diff --git a/sdk/eventgrid/eventgrid/src/consumer.ts b/sdk/eventgrid/eventgrid/src/consumer.ts index 27e5518dbb83..e9e099982676 100644 --- a/sdk/eventgrid/eventgrid/src/consumer.ts +++ b/sdk/eventgrid/eventgrid/src/consumer.ts @@ -3,13 +3,13 @@ import { Serializer } from "@azure/core-http"; import { CloudEvent as WireCloudEvent } from "./generated/models"; -import { CustomEventDataDecoder, CloudEvent, EventGridEvent } from "./models"; +import { CustomEventDataDeserializer, CloudEvent, EventGridEvent } from "./models"; import { EventGridEvent as EventGridEventMapper, CloudEvent as CloudEventMapper } from "./generated/models/mappers"; import { parseAndWrap, validateEventGridEvent, validateCloudEventEvent } from "./util"; -import { systemDecoders } from "./systemEventDecoders"; +import { systemDeserializers } from "./systemEventDecoders"; const serializer = new Serializer(); @@ -18,35 +18,40 @@ const serializer = new Serializer(); */ export interface EventGridConsumerOptions { /** - * Custom decoders to use when decoding a specific event's data, based on the type + * Custom deserializers to use when decoding a specific event's data, based on the type * field of the event. */ - customDecoders: Record; + customDeserializers: Record; } /** * TODO(matell): Document this. */ export class EventGridConsumer { - readonly customDecoders: Record; + readonly customDeserializers: Record; constructor(options?: EventGridConsumerOptions) { - this.customDecoders = options?.customDecoders ?? {}; + this.customDeserializers = options?.customDeserializers ?? {}; } /** - * Decodes events encoded in the Event Grid schema. + * Deserializes events encoded in the Event Grid schema. * * @param encodedEvents the JSON encoded representation of either a single event or an array of * events, encoded in the Event Grid Schema. */ - public async decodeEventGridEvents(encodedEvents: string): Promise[]>; + public async deserializeEventGridEvents( + encodedEvents: string + ): Promise[]>; + /** - * Decodes events encoded in the Event Grid schema. + * Deserializes events encoded in the Event Grid schema. * * @param encodedEvents an object representing a single event, encoded in the Event Grid schema. */ - public async decodeEventGridEvents(encodedEvents: object): Promise[]>; - public async decodeEventGridEvents( + public async deserializeEventGridEvents( + encodedEvents: object + ): Promise[]>; + public async deserializeEventGridEvents( encodedEvents: string | object ): Promise[]> { const decodedArray = parseAndWrap(encodedEvents); @@ -58,10 +63,12 @@ export class EventGridConsumer { const deserialized: EventGridEvent = serializer.deserialize(EventGridEventMapper, o, ""); - if (systemDecoders[deserialized.eventType]) { - deserialized.data = await systemDecoders[deserialized.eventType](deserialized.data); - } else if (this.customDecoders[deserialized.eventType]) { - deserialized.data = await this.customDecoders[deserialized.eventType](deserialized.data); + if (systemDeserializers[deserialized.eventType]) { + deserialized.data = await systemDeserializers[deserialized.eventType](deserialized.data); + } else if (this.customDeserializers[deserialized.eventType]) { + deserialized.data = await this.customDeserializers[deserialized.eventType]( + deserialized.data + ); } events.push(deserialized as EventGridEvent); @@ -71,19 +78,22 @@ export class EventGridConsumer { } /** - * Decodes events encoded in the Cloud Events 1.0 schema. + * Deserializes events encoded in the Cloud Events 1.0 schema. * * @param encodedEvents the JSON encoded representation of either a single event or an array of * events, encoded in the Cloud Events 1.0 Schema. */ - public async decodeCloudEvents(encodedEvents: string): Promise[]>; + public async deserializeCloudEvents(encodedEvents: string): Promise[]>; + /** - * Decodes events encoded in the Cloud Events 1.0 schema. + * Deserializes events encoded in the Cloud Events 1.0 schema. * * @param encodedEvents an object representing a single event, encoded in the Cloud Events 1.0 schema. */ - public async decodeCloudEvents(encodedEvents: object): Promise[]>; - public async decodeCloudEvents(encodedEvents: string | object): Promise[]> { + public async deserializeCloudEvents(encodedEvents: object): Promise[]>; + public async deserializeCloudEvents( + encodedEvents: string | object + ): Promise[]> { const decodedArray = parseAndWrap(encodedEvents); const events: CloudEvent[] = []; @@ -136,10 +146,10 @@ export class EventGridConsumer { } // If a decoder is registered, apply it to the data. - if (systemDecoders[modelEvent.type]) { - modelEvent.data = await systemDecoders[modelEvent.type](modelEvent.data); - } else if (this.customDecoders[modelEvent.type]) { - modelEvent.data = await this.customDecoders[modelEvent.type](modelEvent.data); + if (systemDeserializers[modelEvent.type]) { + modelEvent.data = await systemDeserializers[modelEvent.type](modelEvent.data); + } else if (this.customDeserializers[modelEvent.type]) { + modelEvent.data = await this.customDeserializers[modelEvent.type](modelEvent.data); } // Build the "extensionsAttributes" property bag by removing all known top level properties. diff --git a/sdk/eventgrid/eventgrid/src/index.ts b/sdk/eventgrid/eventgrid/src/index.ts index 70817b7669bd..fd63564b4cbf 100644 --- a/sdk/eventgrid/eventgrid/src/index.ts +++ b/sdk/eventgrid/eventgrid/src/index.ts @@ -3,7 +3,7 @@ export { AzureKeyCredential } from "@azure/core-auth"; -export { CustomEventDataDecoder, EventGridEvent, CloudEvent } from "./models"; +export { CustomEventDataDeserializer, EventGridEvent, CloudEvent } from "./models"; export { EventGridPublisherClient, diff --git a/sdk/eventgrid/eventgrid/src/models.ts b/sdk/eventgrid/eventgrid/src/models.ts index d25c6d2420fb..1f3e6d38caf9 100644 --- a/sdk/eventgrid/eventgrid/src/models.ts +++ b/sdk/eventgrid/eventgrid/src/models.ts @@ -81,4 +81,4 @@ export interface CloudEvent { /** * A function which provides custom logic to be used when decoding events. */ -export type CustomEventDataDecoder = (o: any) => Promise; +export type CustomEventDataDeserializer = (o: any) => Promise; diff --git a/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts b/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts index 9914e592352d..0b1b612c1b46 100644 --- a/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts +++ b/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { Mapper, Serializer } from "@azure/core-http"; -import { CustomEventDataDecoder } from "./models"; +import { CustomEventDataDeserializer } from "./models"; import { EventHubCaptureFileCreatedEventData } from "./generated/models/mappers"; import { ContainerRegistryEventData, @@ -19,13 +19,13 @@ const serializer = new Serializer({ ContainerRegistryEventSource: ContainerRegistryEventSource }); -function makeDecoderFromMapper( +function makeDeserializerFromMapper( mapper: Mapper, - initialDecoders?: CustomEventDataDecoder[] -): CustomEventDataDecoder { + initialDesializers?: CustomEventDataDeserializer[] +): CustomEventDataDeserializer { return async function(o: any): Promise { - if (initialDecoders) { - for (const decoder of initialDecoders) { + if (initialDesializers) { + for (const decoder of initialDesializers) { o = await decoder(o); } } @@ -34,7 +34,7 @@ function makeDecoderFromMapper( }; } -async function jsonParseDecoder(o: any): Promise { +async function jsonParseDeserializer(o: any): Promise { if (typeof o === "string") { return JSON.parse(o); } @@ -42,20 +42,24 @@ async function jsonParseDecoder(o: any): Promise { return o; } -export const systemDecoders: Record = { - "Microsoft.ContainerRegistry.ChartDeleted": makeDecoderFromMapper(ContainerRegistryEventData, [ - jsonParseDecoder - ]), - "Microsoft.ContainerRegistry.ChartPushed": makeDecoderFromMapper(ContainerRegistryEventData, [ - jsonParseDecoder - ]), - "Microsoft.ContainerRegistry.ImageDeleted": makeDecoderFromMapper(ContainerRegistryEventData, [ - jsonParseDecoder - ]), - "Microsoft.ContainerRegistry.ImagePushed": makeDecoderFromMapper(ContainerRegistryEventData, [ - jsonParseDecoder - ]), - "Microsoft.EventHub.CaptureFileCreated": makeDecoderFromMapper( +export const systemDeserializers: Record = { + "Microsoft.ContainerRegistry.ChartDeleted": makeDeserializerFromMapper( + ContainerRegistryEventData, + [jsonParseDeserializer] + ), + "Microsoft.ContainerRegistry.ChartPushed": makeDeserializerFromMapper( + ContainerRegistryEventData, + [jsonParseDeserializer] + ), + "Microsoft.ContainerRegistry.ImageDeleted": makeDeserializerFromMapper( + ContainerRegistryEventData, + [jsonParseDeserializer] + ), + "Microsoft.ContainerRegistry.ImagePushed": makeDeserializerFromMapper( + ContainerRegistryEventData, + [jsonParseDeserializer] + ), + "Microsoft.EventHub.CaptureFileCreated": makeDeserializerFromMapper( EventHubCaptureFileCreatedEventData ) }; diff --git a/sdk/eventgrid/eventgrid/test/consumer.spec.ts b/sdk/eventgrid/eventgrid/test/consumer.spec.ts index 5f4504bc8ec6..0609f9db5c8b 100644 --- a/sdk/eventgrid/eventgrid/test/consumer.spec.ts +++ b/sdk/eventgrid/eventgrid/test/consumer.spec.ts @@ -12,9 +12,9 @@ chaiUse(chaiPromises); describe("EventGridConsumer", function() { const consumer = new EventGridConsumer(); - describe("#decodeEventGridEvents", function() { - it("decodes a single event", async () => { - const events = await consumer.decodeEventGridEvents( + describe("#deserializeEventGridEvents", function() { + it("deserializes a single event", async () => { + const events = await consumer.deserializeEventGridEvents( testData.customTestEvent1.eventGridSchema.encodedEvent ); @@ -22,8 +22,8 @@ describe("EventGridConsumer", function() { assert.deepStrictEqual(events[0], testData.customTestEvent1.eventGridSchema.expected); }); - it("decoded a batch with a single event ", async () => { - const events = await consumer.decodeEventGridEvents( + it("deserialized a batch with a single event ", async () => { + const events = await consumer.deserializeEventGridEvents( wrapEncodedEventsInArray([testData.customTestEvent1.eventGridSchema]) ); @@ -31,8 +31,8 @@ describe("EventGridConsumer", function() { assert.deepStrictEqual(events[0], testData.customTestEvent1.eventGridSchema.expected); }); - it("decodes an batch of multiple events", async () => { - const events = await consumer.decodeEventGridEvents( + it("deserializes an batch of multiple events", async () => { + const events = await consumer.deserializeEventGridEvents( wrapEncodedEventsInArray([ testData.customTestEvent1.eventGridSchema, testData.customTestEvent2.eventGridSchema @@ -44,8 +44,8 @@ describe("EventGridConsumer", function() { assert.deepStrictEqual(events[1], testData.customTestEvent2.eventGridSchema.expected); }); - it("decodes system events correctly", async () => { - const events = await consumer.decodeEventGridEvents( + it("deserializes system events correctly", async () => { + const events = await consumer.deserializeEventGridEvents( testData.containerRegistryPushedEvent.eventGridSchema.encodedEvent ); @@ -69,7 +69,7 @@ describe("EventGridConsumer", function() { delete o[property]; assert.isRejected( - consumer.decodeEventGridEvents(JSON.stringify(o)), + consumer.deserializeEventGridEvents(JSON.stringify(o)), /missing required property/ ); } @@ -80,15 +80,15 @@ describe("EventGridConsumer", function() { o.metadataVersion = "2"; assert.isRejected( - consumer.decodeEventGridEvents(JSON.stringify(o)), + consumer.deserializeEventGridEvents(JSON.stringify(o)), /event is not in the Event Grid schema/ ); }); }); - describe("#decodeCloudEvents", function() { - it("decodes a single event", async () => { - const events = await consumer.decodeCloudEvents( + describe("#deserializeCloudEvents", function() { + it("deserializes a single event", async () => { + const events = await consumer.deserializeCloudEvents( testData.customTestEvent1.cloudEventSchema.encodedEvent ); @@ -96,8 +96,8 @@ describe("EventGridConsumer", function() { assert.deepStrictEqual(events[0], testData.customTestEvent1.cloudEventSchema.expected); }); - it("decoded a batch with a single event ", async () => { - const events = await consumer.decodeCloudEvents( + it("deserialized a batch with a single event ", async () => { + const events = await consumer.deserializeCloudEvents( wrapEncodedEventsInArray([testData.customTestEvent1.cloudEventSchema]) ); @@ -105,8 +105,8 @@ describe("EventGridConsumer", function() { assert.deepStrictEqual(events[0], testData.customTestEvent1.cloudEventSchema.expected); }); - it("decodes an batch of multiple events", async () => { - const events = await consumer.decodeCloudEvents( + it("deserializes an batch of multiple events", async () => { + const events = await consumer.deserializeCloudEvents( wrapEncodedEventsInArray([ testData.customTestEvent1.cloudEventSchema, testData.customTestEvent2.cloudEventSchema @@ -118,8 +118,8 @@ describe("EventGridConsumer", function() { assert.deepStrictEqual(events[1], testData.customTestEvent2.cloudEventSchema.expected); }); - it("decodes system events correctly", async () => { - const events = await consumer.decodeCloudEvents( + it("deserializes system events correctly", async () => { + const events = await consumer.deserializeCloudEvents( testData.containerRegistryPushedEvent.cloudEventSchema.encodedEvent ); @@ -136,7 +136,7 @@ describe("EventGridConsumer", function() { delete o[property]; assert.isRejected( - consumer.decodeCloudEvents(JSON.stringify(o)), + consumer.deserializeCloudEvents(JSON.stringify(o)), /missing required property/ ); } @@ -147,7 +147,7 @@ describe("EventGridConsumer", function() { o.specversion = "2.0"; assert.isRejected( - consumer.decodeCloudEvents(JSON.stringify(o)), + consumer.deserializeCloudEvents(JSON.stringify(o)), /event is not in the Cloud Event 1.0 schema/ ); }); From c21d109d0cf7e67c08b1454a27947d444c787597 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 23 Jul 2020 14:13:59 -0700 Subject: [PATCH 13/34] [EventGrid] Regenerate recordings --- .../recording_sends_a_single_event.json | 32 ----------------- .../recording_sends_multiple_events.json | 34 ------------------- .../recording_sends_a_single_event.json | 32 +++++++++++++++++ .../recording_sends_multiple_events.json | 34 +++++++++++++++++++ .../recording_sends_a_single_event.json | 4 +-- .../recording_sends_multiple_events.json | 28 +++++++++++++++ .../recording_sends_a_single_event.json | 10 +++--- .../recording_sends_multiple_events.json | 14 ++++---- .../recording_sends_multiple_events.js | 23 ------------- .../recording_sends_a_single_event.js | 8 ++--- .../recording_sends_multiple_events.js | 23 +++++++++++++ .../recording_sends_a_single_event.js | 4 +-- .../recording_sends_multiple_events.js | 4 +-- .../recording_sends_a_single_event.js | 8 ++--- .../recording_sends_multiple_events.js | 8 ++--- .../eventgrid/test/eventGridClient.spec.ts | 6 ++-- 16 files changed, 150 insertions(+), 122 deletions(-) delete mode 100644 sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.json delete mode 100644 sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.json create mode 100644 sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.json create mode 100644 sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.json rename sdk/eventgrid/eventgrid/recordings/browsers/{eventgridclient_sendcustomschemaevents => eventgridpublisherclient_sendcustomschemaevents}/recording_sends_a_single_event.json (85%) create mode 100644 sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.json rename sdk/eventgrid/eventgrid/recordings/browsers/{eventgridclient_sendevents => eventgridpublisherclient_sendevents}/recording_sends_a_single_event.json (61%) rename sdk/eventgrid/eventgrid/recordings/browsers/{eventgridclient_sendevents => eventgridpublisherclient_sendevents}/recording_sends_multiple_events.json (51%) delete mode 100644 sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.js rename sdk/eventgrid/eventgrid/recordings/node/{eventgridclient_sendcloudeventschemaevents => eventgridpublisherclient_sendcloudeventschemaevents}/recording_sends_a_single_event.js (50%) create mode 100644 sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.js rename sdk/eventgrid/eventgrid/recordings/node/{eventgridclient_sendcustomschemaevents => eventgridpublisherclient_sendcustomschemaevents}/recording_sends_a_single_event.js (88%) rename sdk/eventgrid/eventgrid/recordings/node/{eventgridclient_sendcustomschemaevents => eventgridpublisherclient_sendcustomschemaevents}/recording_sends_multiple_events.js (89%) rename sdk/eventgrid/eventgrid/recordings/node/{eventgridclient_sendevents => eventgridpublisherclient_sendevents}/recording_sends_a_single_event.js (64%) rename sdk/eventgrid/eventgrid/recordings/node/{eventgridclient_sendevents => eventgridpublisherclient_sendevents}/recording_sends_multiple_events.js (53%) diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.json deleted file mode 100644 index 4e655f55c7e0..000000000000 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "recordings": [ - { - "method": "POST", - "url": "https://endpoint/api/events", - "query": { - "api-version": "2018-01-01" - }, - "requestBody": "[{\"id\":\"cloudSingleEventId159477577224000148\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"data\":{\"hello\":\"world\"},\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-15T01:16:12.240Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\"}]", - "status": 200, - "response": "", - "responseHeaders": { - "api-supported-versions": "2018-01-01", - "content-length": "0", - "date": "Wed, 15 Jul 2020 01:16:13 GMT", - "server": "Microsoft-HTTPAPI/2.0", - "status": "200", - "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "2b8da935-3c99-44f3-9470-e961f69f3824" - } - } - ], - "uniqueTestInfo": { - "uniqueName": { - "cloudSingleEventId": "cloudSingleEventId159477577224000148" - }, - "newDate": { - "cloudSingleEventDate": "2020-07-15T01:16:12.240Z" - } - }, - "hash": "7fe25ee020ac364dae32ce81a81c7c3f" -} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.json deleted file mode 100644 index 80324bc4251b..000000000000 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "recordings": [ - { - "method": "POST", - "url": "https://endpoint/api/events", - "query": { - "api-version": "2018-01-01" - }, - "requestBody": "[{\"id\":\"cloudMultiEventId1159477577228005600\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"data\":{\"hello\":\"world\"},\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-15T01:16:12.281Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"Multiple 1\"},{\"id\":\"cloudMultiEventId2159477577228106649\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"data\":{\"hello\":\"world\"},\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-15T01:16:12.281Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"Multiple 2\"}]", - "status": 200, - "response": "", - "responseHeaders": { - "api-supported-versions": "2018-01-01", - "content-length": "0", - "date": "Wed, 15 Jul 2020 01:16:13 GMT", - "server": "Microsoft-HTTPAPI/2.0", - "status": "200", - "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "6f458132-db81-4cea-824d-f633633fdc48" - } - } - ], - "uniqueTestInfo": { - "uniqueName": { - "cloudMultiEventId1": "cloudMultiEventId1159477577228005600", - "cloudMultiEventId2": "cloudMultiEventId2159477577228106649" - }, - "newDate": { - "cloudMultiEventDate1": "2020-07-15T01:16:12.281Z", - "cloudMultiEventDate2": "2020-07-15T01:16:12.281Z" - } - }, - "hash": "799392d36931d99dc2c24d3db67fcb0b" -} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.json new file mode 100644 index 000000000000..46f8a280c9ba --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.json @@ -0,0 +1,32 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://endpoint/api/events", + "query": { + "api-version": "2018-01-01" + }, + "requestBody": "[{\"id\":\"cloudSingleEventId159545158332308816\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-22T20:59:43.323Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\"}]", + "status": 200, + "response": "", + "responseHeaders": { + "api-supported-versions": "2018-01-01", + "content-length": "0", + "date": "Wed, 22 Jul 2020 20:59:43 GMT", + "server": "Microsoft-HTTPAPI/2.0", + "status": "200", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-request-id": "f6bede6a-c737-4c25-9380-1a50f70f8f1d" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "cloudSingleEventId": "cloudSingleEventId159545158332308816" + }, + "newDate": { + "cloudSingleEventDate": "2020-07-22T20:59:43.323Z" + } + }, + "hash": "7fe25ee020ac364dae32ce81a81c7c3f" +} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.json new file mode 100644 index 000000000000..8b7a7533dd45 --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.json @@ -0,0 +1,34 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://endpoint/api/events", + "query": { + "api-version": "2018-01-01" + }, + "requestBody": "[{\"id\":\"cloudMultiEventId1159545158342200757\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-22T20:59:43.422Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"Multiple 1\"},{\"id\":\"cloudMultiEventId2159545158342208317\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-22T20:59:43.422Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"Multiple 2\"}]", + "status": 200, + "response": "", + "responseHeaders": { + "api-supported-versions": "2018-01-01", + "content-length": "0", + "date": "Wed, 22 Jul 2020 20:59:43 GMT", + "server": "Microsoft-HTTPAPI/2.0", + "status": "200", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-request-id": "2f227ab0-ae70-4ac9-a9d1-fd0914c991bb" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "cloudMultiEventId1": "cloudMultiEventId1159545158342200757", + "cloudMultiEventId2": "cloudMultiEventId2159545158342208317" + }, + "newDate": { + "cloudMultiEventDate1": "2020-07-22T20:59:43.422Z", + "cloudMultiEventDate2": "2020-07-22T20:59:43.422Z" + } + }, + "hash": "799392d36931d99dc2c24d3db67fcb0b" +} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.json similarity index 85% rename from sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.json rename to sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.json index ee7df2bb7a9a..08f2ee161cba 100644 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.json +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.json @@ -12,11 +12,11 @@ "responseHeaders": { "api-supported-versions": "2018-01-01", "content-length": "0", - "date": "Wed, 15 Jul 2020 01:16:13 GMT", + "date": "Wed, 22 Jul 2020 20:59:44 GMT", "server": "Microsoft-HTTPAPI/2.0", "status": "200", "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "569e58b3-97f9-4392-8c4b-a98c29fc9b08" + "x-ms-request-id": "8c7b662e-b4aa-4bb9-a932-d97a40306a2d" } } ], diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.json new file mode 100644 index 000000000000..2c7b8377033e --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.json @@ -0,0 +1,28 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://endpoint/api/events", + "query": { + "api-version": "2018-01-01" + }, + "requestBody": "[{\"ver\":\"1.0\",\"typ\":\"Azure.Sdk.TestEvent1\",\"sub\":\"Multiple 1\",\"payload\":{\"hello\":\"world\"}},{\"ver\":\"1.0\",\"typ\":\"Azure.Sdk.TestEvent1\",\"sub\":\"Multiple 2\",\"payload\":{\"hello\":\"world\"}}]", + "status": 200, + "response": "", + "responseHeaders": { + "api-supported-versions": "2018-01-01", + "content-length": "0", + "date": "Wed, 22 Jul 2020 20:59:44 GMT", + "server": "Microsoft-HTTPAPI/2.0", + "status": "200", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-request-id": "c0ac8526-c3a6-4c10-86a7-24bb9dde79eb" + } + } + ], + "uniqueTestInfo": { + "uniqueName": {}, + "newDate": {} + }, + "hash": "1cfb052616732940934c2dfe9e0f6713" +} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_a_single_event.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_a_single_event.json similarity index 61% rename from sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_a_single_event.json rename to sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_a_single_event.json index 1b1651caee2f..7bf590587c4a 100644 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_a_single_event.json +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_a_single_event.json @@ -6,26 +6,26 @@ "query": { "api-version": "2018-01-01" }, - "requestBody": "[{\"id\":\"singleEventId159477576968000871\",\"subject\":\"Single 1\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-15T01:16:09.680Z\",\"dataVersion\":\"1.0\"}]", + "requestBody": "[{\"id\":\"singleEventId159545158072101217\",\"subject\":\"Single 1\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-22T20:59:40.721Z\",\"dataVersion\":\"1.0\"}]", "status": 200, "response": "", "responseHeaders": { "api-supported-versions": "2018-01-01", "content-length": "0", - "date": "Wed, 15 Jul 2020 01:16:13 GMT", + "date": "Wed, 22 Jul 2020 20:59:43 GMT", "server": "Microsoft-HTTPAPI/2.0", "status": "200", "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "2e8240bd-678e-453c-b63c-31d076f8c3c7" + "x-ms-request-id": "c8da1009-5443-4114-bf7b-a6fd1ee5c76d" } } ], "uniqueTestInfo": { "uniqueName": { - "singleEventId": "singleEventId159477576968000871" + "singleEventId": "singleEventId159545158072101217" }, "newDate": { - "singleEventDate": "2020-07-15T01:16:09.680Z" + "singleEventDate": "2020-07-22T20:59:40.721Z" } }, "hash": "9b44e18369316233af4458904ca8ae09" diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_multiple_events.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_multiple_events.json similarity index 51% rename from sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_multiple_events.json rename to sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_multiple_events.json index f66296c3e8fd..4bcd0f09c0d3 100644 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridclient_sendevents/recording_sends_multiple_events.json +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_multiple_events.json @@ -6,28 +6,28 @@ "query": { "api-version": "2018-01-01" }, - "requestBody": "[{\"id\":\"multiEventId1159477577219008240\",\"subject\":\"Multiple 1\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-15T01:16:12.190Z\",\"dataVersion\":\"1.0\"},{\"id\":\"multiEventId2159477577219001904\",\"subject\":\"Multiple 2\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-15T01:16:12.190Z\",\"dataVersion\":\"1.0\"}]", + "requestBody": "[{\"id\":\"multiEventId1159545158328801784\",\"subject\":\"Multiple 1\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-22T20:59:43.287Z\",\"dataVersion\":\"1.0\"},{\"id\":\"multiEventId2159545158328801964\",\"subject\":\"Multiple 2\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-22T20:59:43.288Z\",\"dataVersion\":\"1.0\"}]", "status": 200, "response": "", "responseHeaders": { "api-supported-versions": "2018-01-01", "content-length": "0", - "date": "Wed, 15 Jul 2020 01:16:13 GMT", + "date": "Wed, 22 Jul 2020 20:59:43 GMT", "server": "Microsoft-HTTPAPI/2.0", "status": "200", "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "9bc216fc-b6e9-468d-a1c1-7f3e4a803d4e" + "x-ms-request-id": "aef68b3b-c708-408e-831b-e08e905c58a2" } } ], "uniqueTestInfo": { "uniqueName": { - "multiEventId1": "multiEventId1159477577219008240", - "multiEventId2": "multiEventId2159477577219001904" + "multiEventId1": "multiEventId1159545158328801784", + "multiEventId2": "multiEventId2159545158328801964" }, "newDate": { - "multiEventDate1": "2020-07-15T01:16:12.190Z", - "multiEventDate2": "2020-07-15T01:16:12.190Z" + "multiEventDate1": "2020-07-22T20:59:43.287Z", + "multiEventDate2": "2020-07-22T20:59:43.288Z" } }, "hash": "a1eefb69b1513dc523f50ee66055787d" diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.js deleted file mode 100644 index 849bd8cdfba1..000000000000 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_multiple_events.js +++ /dev/null @@ -1,23 +0,0 @@ -let nock = require('nock'); - -module.exports.hash = "cefc29910fbb6c53981faf8430a3521b"; - -module.exports.testInfo = {"uniqueName":{"cloudMultiEventId1":"cloudMultiEventId1159477576192000975","cloudMultiEventId2":"cloudMultiEventId2159477576192004669"},"newDate":{"cloudMultiEventDate1":"2020-07-15T01:16:01.920Z","cloudMultiEventDate2":"2020-07-15T01:16:01.920Z"}} - -nock('https://endpoint', {"encodedQueryParams":true}) - .post('/api/events', [{"id":"cloudMultiEventId1159477576192000975","source":"/earth/unitedstates/washington/kirkland/finnhill","data":{"hello":"world"},"type":"Azure.Sdk.TestEvent1","time":"2020-07-15T01:16:01.920Z","specversion":"1.0","datacontenttype":"application/json","subject":"Multiple 1"},{"id":"cloudMultiEventId2159477576192004669","source":"/earth/unitedstates/washington/kirkland/finnhill","data":{"hello":"world"},"type":"Azure.Sdk.TestEvent1","time":"2020-07-15T01:16:01.920Z","specversion":"1.0","datacontenttype":"application/json","subject":"Multiple 2"}]) - .query(true) - .reply(200, "", [ - 'Content-Length', - '0', - 'Server', - 'Microsoft-HTTPAPI/2.0', - 'Strict-Transport-Security', - 'max-age=31536000; includeSubDomains', - 'api-supported-versions', - '2018-01-01', - 'x-ms-request-id', - '5a7beed2-2df1-4d8b-887a-267d7c638fa3', - 'Date', - 'Wed, 15 Jul 2020 01:16:02 GMT' -]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.js similarity index 50% rename from sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.js rename to sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.js index 862865535296..4047c2d58fb4 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcloudeventschemaevents/recording_sends_a_single_event.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.js @@ -2,10 +2,10 @@ let nock = require('nock'); module.exports.hash = "b15b1edb6fd215ff27f66c70053afbb8"; -module.exports.testInfo = {"uniqueName":{"cloudSingleEventId":"cloudSingleEventId159477576171608507"},"newDate":{"cloudSingleEventDate":"2020-07-15T01:16:01.716Z"}} +module.exports.testInfo = {"uniqueName":{"cloudSingleEventId":"cloudSingleEventId159545157148202250"},"newDate":{"cloudSingleEventDate":"2020-07-22T20:59:31.482Z"}} nock('https://endpoint', {"encodedQueryParams":true}) - .post('/api/events', [{"id":"cloudSingleEventId159477576171608507","source":"/earth/unitedstates/washington/kirkland/finnhill","data":{"hello":"world"},"type":"Azure.Sdk.TestEvent1","time":"2020-07-15T01:16:01.716Z","specversion":"1.0","datacontenttype":"application/json"}]) + .post('/api/events', [{"id":"cloudSingleEventId159545157148202250","source":"/earth/unitedstates/washington/kirkland/finnhill","type":"Azure.Sdk.TestEvent1","time":"2020-07-22T20:59:31.482Z","specversion":"1.0","datacontenttype":"application/json"}]) .query(true) .reply(200, "", [ 'Content-Length', @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - '76b94efe-2678-47c5-9874-5bce255ef496', + '304512a3-c189-4094-8e12-55d8727d1f80', 'Date', - 'Wed, 15 Jul 2020 01:16:02 GMT' + 'Wed, 22 Jul 2020 20:59:32 GMT' ]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.js new file mode 100644 index 000000000000..8d2443b675ff --- /dev/null +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.js @@ -0,0 +1,23 @@ +let nock = require('nock'); + +module.exports.hash = "cefc29910fbb6c53981faf8430a3521b"; + +module.exports.testInfo = {"uniqueName":{"cloudMultiEventId1":"cloudMultiEventId1159545157162605520","cloudMultiEventId2":"cloudMultiEventId2159545157162709419"},"newDate":{"cloudMultiEventDate1":"2020-07-22T20:59:31.627Z","cloudMultiEventDate2":"2020-07-22T20:59:31.627Z"}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/api/events', [{"id":"cloudMultiEventId1159545157162605520","source":"/earth/unitedstates/washington/kirkland/finnhill","type":"Azure.Sdk.TestEvent1","time":"2020-07-22T20:59:31.627Z","specversion":"1.0","datacontenttype":"application/json","subject":"Multiple 1"},{"id":"cloudMultiEventId2159545157162709419","source":"/earth/unitedstates/washington/kirkland/finnhill","type":"Azure.Sdk.TestEvent1","time":"2020-07-22T20:59:31.627Z","specversion":"1.0","datacontenttype":"application/json","subject":"Multiple 2"}]) + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Server', + 'Microsoft-HTTPAPI/2.0', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'api-supported-versions', + '2018-01-01', + 'x-ms-request-id', + '5615af32-6bb1-46f4-baa9-ab4034a4b6ae', + 'Date', + 'Wed, 22 Jul 2020 20:59:32 GMT' +]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.js similarity index 88% rename from sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.js rename to sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.js index 2dbbeed00f46..35cd1c93e149 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_a_single_event.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.js @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - '1c2dc6b2-5466-49e4-be00-1238811fe55c', + '04296baf-73a5-4e9a-a17c-14d9ee1235cb', 'Date', - 'Wed, 15 Jul 2020 01:16:02 GMT' + 'Wed, 22 Jul 2020 20:59:31 GMT' ]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_multiple_events.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.js similarity index 89% rename from sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_multiple_events.js rename to sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.js index f8341da1163e..ceb5c05bd1f1 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendcustomschemaevents/recording_sends_multiple_events.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.js @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - 'bf74ae91-2aa5-4373-8c4b-7dc77dcc6617', + '661e2301-f378-441d-878a-a8e7fcfd5be3', 'Date', - 'Wed, 15 Jul 2020 01:16:03 GMT' + 'Wed, 22 Jul 2020 20:59:31 GMT' ]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_a_single_event.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_a_single_event.js similarity index 64% rename from sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_a_single_event.js rename to sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_a_single_event.js index 82571eb58578..58a8702b2d70 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_a_single_event.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_a_single_event.js @@ -2,10 +2,10 @@ let nock = require('nock'); module.exports.hash = "93ae44857b9e0329bc4ac9a07e444214"; -module.exports.testInfo = {"uniqueName":{"singleEventId":"singleEventId159477576134002891"},"newDate":{"singleEventDate":"2020-07-15T01:16:01.340Z"}} +module.exports.testInfo = {"uniqueName":{"singleEventId":"singleEventId159545157109200706"},"newDate":{"singleEventDate":"2020-07-22T20:59:31.092Z"}} nock('https://endpoint', {"encodedQueryParams":true}) - .post('/api/events', [{"id":"singleEventId159477576134002891","subject":"Single 1","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-15T01:16:01.340Z","dataVersion":"1.0"}]) + .post('/api/events', [{"id":"singleEventId159545157109200706","subject":"Single 1","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-22T20:59:31.092Z","dataVersion":"1.0"}]) .query(true) .reply(200, "", [ 'Content-Length', @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - 'b422b307-f041-46ef-a5d2-02ca35ab02be', + '2a44e61e-4e08-4138-a58e-4fc9f08e3fb0', 'Date', - 'Wed, 15 Jul 2020 01:16:02 GMT' + 'Wed, 22 Jul 2020 20:59:31 GMT' ]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_multiple_events.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_multiple_events.js similarity index 53% rename from sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_multiple_events.js rename to sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_multiple_events.js index a38ade6f6182..78039bd1bc96 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridclient_sendevents/recording_sends_multiple_events.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_multiple_events.js @@ -2,10 +2,10 @@ let nock = require('nock'); module.exports.hash = "b8c32c266a21a9129c07d237cc8e3d2b"; -module.exports.testInfo = {"uniqueName":{"multiEventId1":"multiEventId1159477576164006772","multiEventId2":"multiEventId2159477576164007351"},"newDate":{"multiEventDate1":"2020-07-15T01:16:01.640Z","multiEventDate2":"2020-07-15T01:16:01.640Z"}} +module.exports.testInfo = {"uniqueName":{"multiEventId1":"multiEventId1159545157139309466","multiEventId2":"multiEventId2159545157139401284"},"newDate":{"multiEventDate1":"2020-07-22T20:59:31.393Z","multiEventDate2":"2020-07-22T20:59:31.394Z"}} nock('https://endpoint', {"encodedQueryParams":true}) - .post('/api/events', [{"id":"multiEventId1159477576164006772","subject":"Multiple 1","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-15T01:16:01.640Z","dataVersion":"1.0"},{"id":"multiEventId2159477576164007351","subject":"Multiple 2","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-15T01:16:01.640Z","dataVersion":"1.0"}]) + .post('/api/events', [{"id":"multiEventId1159545157139309466","subject":"Multiple 1","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-22T20:59:31.393Z","dataVersion":"1.0"},{"id":"multiEventId2159545157139401284","subject":"Multiple 2","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-22T20:59:31.394Z","dataVersion":"1.0"}]) .query(true) .reply(200, "", [ 'Content-Length', @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - '8dbf7cf8-b65d-4d88-bc45-05cab784986b', + 'b255ebc9-6ad6-48b7-8665-aaa1e6e9d628', 'Date', - 'Wed, 15 Jul 2020 01:16:02 GMT' + 'Wed, 22 Jul 2020 20:59:31 GMT' ]); diff --git a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts index b70bb5f6008f..a2edda7138d5 100644 --- a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts +++ b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts @@ -29,7 +29,7 @@ describe("EventGridPublisherClient", function() { )); }); - afterEach(() => { + afterEach(function() { recorder.stop(); }); @@ -87,7 +87,7 @@ describe("EventGridPublisherClient", function() { )); }); - afterEach(() => { + afterEach(function() { recorder.stop(); }); @@ -147,7 +147,7 @@ describe("EventGridPublisherClient", function() { )); }); - afterEach(() => { + afterEach(function() { recorder.stop(); }); From 3d8259fd178d24fa1ea5db2cb348d44fcc46f173 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 23 Jul 2020 14:46:09 -0700 Subject: [PATCH 14/34] [EventGrid] Make some properties optional We have reasonable defaults for cases where an ID or time are not present when an event is being generated (a new random UUID and the current time, respectively). Make the parameters on the model types optional and apply defaults as we are sending the events. --- sdk/eventgrid/eventgrid/package.json | 4 ++- .../eventgrid/review/eventgrid.api.md | 6 ++-- .../eventgrid/src/eventGridClient.ts | 35 ++++++++++++------- sdk/eventgrid/eventgrid/src/models.ts | 15 ++++---- 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json index 003b6d95c929..55682e950e9e 100644 --- a/sdk/eventgrid/eventgrid/package.json +++ b/sdk/eventgrid/eventgrid/package.json @@ -83,7 +83,8 @@ "@azure/core-tracing": "1.0.0-preview.8", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.6.1", - "tslib": "^2.0.0" + "tslib": "^2.0.0", + "uuid": "^8.1.0" }, "devDependencies": { "@azure/eslint-plugin-azure-sdk": "^3.0.0", @@ -99,6 +100,7 @@ "@types/mocha": "^7.0.2", "@types/node": "^8.0.0", "@types/sinon": "^9.0.4", + "@types/uuid": "^8.0.0", "@typescript-eslint/eslint-plugin": "^2.0.0", "@typescript-eslint/parser": "^2.0.0", "chai": "^4.2.0", diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index 06901d30db87..139a00177e85 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -18,7 +18,7 @@ export interface CloudEvent { datacontenttype?: string; dataschema?: string; extensionAttributes?: Record; - id: string; + id?: string; source: string; subject?: string; time?: Date; @@ -121,9 +121,9 @@ export interface EventGridConsumerOptions { export interface EventGridEvent { data: T; dataVersion: string; - eventTime: Date; + eventTime?: Date; eventType: string; - id: string; + id?: string; subject: string; topic?: string; } diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts index 34a56690253b..cc58cc52e5cb 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -9,11 +9,11 @@ import { OperationOptions } from "@azure/core-http"; -import { hmac } from "./utils/hmac"; +import { v4 as uuidv4 } from "uuid"; +import { hmac } from "./utils/hmac"; import { createEventGridCredentialPolicy } from "./eventGridAuthenticationPolicy"; import { SignatureCredential } from "./sharedAccessSignitureCredential"; - import { SDK_VERSION } from "./constants"; import { GeneratedClient } from "./generated/generatedClient"; import { CloudEvent, EventGridEvent } from "./models"; @@ -120,7 +120,18 @@ export class EventGridPublisherClient { * @param message One or more events to publish */ sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise { - return this.client.publishEvents(this.endpointUrl, events, options); + const toPublish = (events || []).map((evt) => { + return { + eventType: evt.eventType, + eventTime: evt.eventTime ?? new Date(), + id: evt.id ?? uuidv4(), + subject: evt.subject, + topic: evt.topic, + data: evt.data, + dataVersion: evt.dataVersion + }; + }); + return this.client.publishEvents(this.endpointUrl, toPublish, options); } /** @@ -133,19 +144,19 @@ export class EventGridPublisherClient { events: CloudEvent[], options?: SendCloudEventsOptions ): Promise { - const toPublish = events.map((msg) => { + const toPublish = (events || []).map((evt) => { // TODO(matell): If data is of type `Buffer` or other binary data we should Base64 encoded the data and set // `data_base64` instead. We also need to validate that `datacontenttype` is set in this case. return { specversion: "1.0", - type: msg.type, - source: msg.source, - id: msg.id, - time: msg.time, - subject: msg.subject, - dataschema: msg.dataschema, - datacontenttype: msg.datacontenttype ?? "application/json", - ...(msg.extensionAttributes ?? []) + type: evt.type, + source: evt.source, + id: evt.id ?? uuidv4(), + time: evt.time ?? new Date(), + subject: evt.subject, + dataschema: evt.dataschema, + datacontenttype: evt.datacontenttype ?? "application/json", + ...(evt.extensionAttributes ?? []) }; }); diff --git a/sdk/eventgrid/eventgrid/src/models.ts b/sdk/eventgrid/eventgrid/src/models.ts index 1f3e6d38caf9..08f8fa12fcda 100644 --- a/sdk/eventgrid/eventgrid/src/models.ts +++ b/sdk/eventgrid/eventgrid/src/models.ts @@ -10,13 +10,14 @@ export interface EventGridEvent { */ eventType: string; /** - * The time the event was generated. + * The time the event was generated. If not provided, the current time will be used. */ - eventTime: Date; + eventTime?: Date; /** - * An unique identifier for the event. + * An unique identifier for the event. If an ID is not provided, a random UUID will be generated + * and used. */ - id: string; + id?: string; /** * The resource path of the event source. */ @@ -48,9 +49,10 @@ export interface CloudEvent { */ source: string; /** - * An identifier for the event. The combination of id and source must be unique for each distinct event. + * An identifier for the event. The combination of id and source must be unique for each distinct event. If an ID is not provided, + * a random UUID will be generated and used. */ - id: string; + id?: string; /** * The time the event was generated. */ @@ -66,7 +68,6 @@ export interface CloudEvent { /** * Event data specific to the event type. */ - data?: T; /** * This describes the subject of the event in the context of the event producer (identified by source). From 68b2e8578ca62773c406810dbeda53024158c4ee Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 23 Jul 2020 15:40:08 -0700 Subject: [PATCH 15/34] [EventGrid] Move `generateSharedAccessSigniture` Previously this was an instance method on `EventGridClient`. We've decided that we would prefer it to be a top level function (where you explicitly pass the endpoint and key) instead of an instance method that re-uses these properties from the client (and fails when the client was constructed with a shared access signiture itself, instead of a key). --- sdk/eventgrid/eventgrid/README.md | 12 +++--- sdk/eventgrid/eventgrid/src/constants.ts | 1 + .../eventgrid/src/eventGridClient.ts | 36 ---------------- .../src/generateSharedAccessSignature.ts | 39 +++++++++++++++++ sdk/eventgrid/eventgrid/src/index.ts | 5 +++ .../eventgrid/test/eventGridClient.spec.ts | 42 +------------------ .../generateSharedAccessSignature.spec.ts | 25 +++++++++++ 7 files changed, 78 insertions(+), 82 deletions(-) create mode 100644 sdk/eventgrid/eventgrid/src/generateSharedAccessSignature.ts create mode 100644 sdk/eventgrid/eventgrid/test/generateSharedAccessSignature.spec.ts diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md index bff044783674..dc4961170b6d 100644 --- a/sdk/eventgrid/eventgrid/README.md +++ b/sdk/eventgrid/eventgrid/README.md @@ -90,15 +90,17 @@ const client = new EventGridPublisherClient( ); ``` -You can generate a SAS token by using the `generateSharedAccessSigniture` instance method on the `EventGridPublisherClient` type. Because the Topic's Access Key is used as part of generating the SAS token, you need to create the `EventGridPublisherClient` using an Access Key: +You can generate a SAS token by using the `generateSharedAccessSigniture` function. ```js -const { EventGridPublisherClient, AzureKeyCredential } = require("@azure/eventgrid"); - -const client = new EventGridPublisherClient("", new AzureKeyCredential("")); +const { generateSharedAccessSignature, AzureKeyCredential } = require("@azure/eventgrid"); // Create a SAS Token which expires on 2020-01-01 at Midnight. -const token = client.generateSharedAccessSignature(new Date(2020, 0, 1, 0, 0, 0)); +const token = generateSharedAccessSignature( + "", + new AzureKeyCredential(""), + new Date(2020, 0, 1, 0, 0, 0) +); ``` ## Key concepts diff --git a/sdk/eventgrid/eventgrid/src/constants.ts b/sdk/eventgrid/eventgrid/src/constants.ts index a0dfd04fd1ea..d0be2d9e825b 100644 --- a/sdk/eventgrid/eventgrid/src/constants.ts +++ b/sdk/eventgrid/eventgrid/src/constants.ts @@ -2,3 +2,4 @@ // Licensed under the MIT license. export const SDK_VERSION: string = "3.0.0-preview.1"; +export const DEFAULT_API_VERSION = "2018-01-01"; diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts index cc58cc52e5cb..f68aff7daf59 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -11,13 +11,11 @@ import { import { v4 as uuidv4 } from "uuid"; -import { hmac } from "./utils/hmac"; import { createEventGridCredentialPolicy } from "./eventGridAuthenticationPolicy"; import { SignatureCredential } from "./sharedAccessSignitureCredential"; import { SDK_VERSION } from "./constants"; import { GeneratedClient } from "./generated/generatedClient"; import { CloudEvent, EventGridEvent } from "./models"; -import { dateToServiceTimeString, isKeyCredentialLike } from "./util"; /** * Options for the Event Grid Client. @@ -58,12 +56,6 @@ export class EventGridPublisherClient { */ private readonly client: GeneratedClient; - /** - * The credential used to construct the client, when it is constructed with a shared key instead of a - * signature. - */ - private readonly keyCredential?: KeyCredential; - /** * Creates an instance of EventGridPublisherClient. * @@ -88,12 +80,6 @@ export class EventGridPublisherClient { ) { this.endpointUrl = endpointUrl; - // If the user suplied a key credential (instead of a signature credential), save it on the client so we can generate - // SAS tokens with `generateSharedAccessSignature`. - if (isKeyCredentialLike(credential)) { - this.keyCredential = credential; - } - const libInfo = `azsdk-js-eventgrid/${SDK_VERSION}`; const pipelineOptions = { ...options }; @@ -174,26 +160,4 @@ export class EventGridPublisherClient { ): Promise { return this.client.publishCustomEventEvents(this.endpointUrl, events, options); } - - /** - * Generate a shared access signature, which allows a client to send events to an Event Grid Topic for a limited period of time. This - * function may only be called when the EventGridPublisherClient was constructed with a KeyCredential instance. - * - * @param expiresOn The time at which the shared signature is no longer valid. - */ - async generateSharedAccessSignature(expiresOnUtc: Date): Promise { - if (!this.keyCredential) { - throw new Error( - "generateSharedAccessSignature may only be called when the client is constructed with a key credential" - ); - } - - const expiresOnString = dateToServiceTimeString(expiresOnUtc); - const unsignedSas = `r=${encodeURIComponent( - `${this.endpointUrl}?apiVersion=${this.apiVersion}` - )}&e=${encodeURIComponent(expiresOnString)}`; - return hmac(this.keyCredential!.key, unsignedSas).then( - (digest) => `${unsignedSas}&s=${encodeURIComponent(digest)}` - ); - } } diff --git a/sdk/eventgrid/eventgrid/src/generateSharedAccessSignature.ts b/sdk/eventgrid/eventgrid/src/generateSharedAccessSignature.ts new file mode 100644 index 000000000000..643945d7c4da --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/generateSharedAccessSignature.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { KeyCredential } from "@azure/core-auth"; +import { DEFAULT_API_VERSION } from "./constants"; +import { hmac } from "./utils/hmac"; +import { dateToServiceTimeString } from "./util"; + +export interface GenerateSharedAccessSignatureOptions { + /** + * The API Version to include in the signature. If not provided, the default + * API version will be used. + */ + apiVersion?: string; +} + +/** + * Generate a shared access signature, which allows a client to send events to an Event Grid Topic or Domain for a limited period of time. This + * function may only be called when the EventGridPublisherClient was constructed with a KeyCredential instance. + * + * @param endpointUrl The endpoint for the topic or domain you wish to generate a shared access signature for. + * @param credential The credential to use when generating the shared access signatrue. + * @param expiresOn The time at which the shared access signature is no longer valid. + * @param options Options to control how the signature is generated. + */ +export async function generateSharedAccessSignature( + endpointUrl: string, + credential: KeyCredential, + expiresOnUtc: Date, + options?: GenerateSharedAccessSignatureOptions +): Promise { + const expiresOnString = dateToServiceTimeString(expiresOnUtc); + const unsignedSas = `r=${encodeURIComponent( + `${endpointUrl}?apiVersion=${options?.apiVersion || DEFAULT_API_VERSION}` + )}&e=${encodeURIComponent(expiresOnString)}`; + return hmac(credential.key, unsignedSas).then( + (digest) => `${unsignedSas}&s=${encodeURIComponent(digest)}` + ); +} diff --git a/sdk/eventgrid/eventgrid/src/index.ts b/sdk/eventgrid/eventgrid/src/index.ts index fd63564b4cbf..01be65030ef1 100644 --- a/sdk/eventgrid/eventgrid/src/index.ts +++ b/sdk/eventgrid/eventgrid/src/index.ts @@ -20,6 +20,11 @@ export { export { EventGridConsumer, EventGridConsumerOptions } from "./consumer"; +export { + generateSharedAccessSignature, + GenerateSharedAccessSignatureOptions +} from "./generateSharedAccessSignature"; + export { EventHubCaptureFileCreatedEventData, ContainerRegistryArtifactEventTarget, diff --git a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts index a2edda7138d5..47d4e41bea73 100644 --- a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts +++ b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts @@ -8,11 +8,7 @@ import { Recorder } from "@azure/test-utils-recorder"; import { createRecordedClient, testEnv } from "./utils/recordedClient"; -import { - AzureKeyCredential, - EventGridPublisherClient, - EventGridSharedAccessSignatureCredential -} from "../src/index"; +import { AzureKeyCredential, EventGridPublisherClient } from "../src/index"; describe("EventGridPublisherClient", function() { let recorder: Recorder; @@ -189,40 +185,4 @@ describe("EventGridPublisherClient", function() { assert.equal(res._response.status, 200); }); }); - - describe("#generateSharedAccessSigniture", () => { - it("generates the correct signiture", async () => { - // This is not a real key, it's the base64 encoding of "this is not a real EventGrid key", which happens to be the same - // number of bytes as an actual EventGrid Access Key. - const key = "dGhpcyBpcyBub3QgYSByZWFsIEV2ZW50R3JpZCBrZXk="; - - const client = new EventGridPublisherClient( - "https://eg-topic.westus-2.eventgrid.azure.net/api/events", - new AzureKeyCredential(key) - ); - - const sig = await client.generateSharedAccessSignature( - new Date(Date.UTC(2020, 0, 1, 0, 0, 0)) - ); - assert.equal( - sig, - "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%2012%3A00%3A00%20AM&s=ZzvNAYRyvJwDrOJKYxbNAPNCoSqgOJVLFi4IMXOrW2Q%3D" - ); - }); - - it("fails when a signature credential was used", () => { - const signature = - "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%2012%3A00%3A00%20AM&s=ZzvNAYRyvJwDrOJKYxbNAPNCoSqgOJVLFi4IMXOrW2Q%3D"; - - const client = new EventGridPublisherClient( - "https://eg-topic.westus-2.eventgrid.azure.net/api/events", - new EventGridSharedAccessSignatureCredential(signature) - ); - - assert.isRejected( - client.generateSharedAccessSignature(new Date(Date.UTC(2020, 0, 1, 0, 0, 0))), - /may only be called when the client is constructed with a key credential/ - ); - }); - }); }); diff --git a/sdk/eventgrid/eventgrid/test/generateSharedAccessSignature.spec.ts b/sdk/eventgrid/eventgrid/test/generateSharedAccessSignature.spec.ts new file mode 100644 index 000000000000..85821849fb6a --- /dev/null +++ b/sdk/eventgrid/eventgrid/test/generateSharedAccessSignature.spec.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { assert } from "chai"; +import { AzureKeyCredential, generateSharedAccessSignature } from "../src/index"; + +describe("generateSharedAccessSignature", function() { + it("generates the correct signiture", async () => { + // This is not a real key, it's the base64 encoding of "this is not a real EventGrid key", which happens to be the same + // number of bytes as an actual EventGrid Access Key. + const key = "dGhpcyBpcyBub3QgYSByZWFsIEV2ZW50R3JpZCBrZXk="; + const topicUrl = "https://eg-topic.westus-2.eventgrid.azure.net/api/events"; + + const sig = await generateSharedAccessSignature( + topicUrl, + new AzureKeyCredential(key), + new Date(Date.UTC(2020, 0, 1, 0, 0, 0)) + ); + + assert.equal( + sig, + "r=https%3A%2F%2Feg-topic.westus-2.eventgrid.azure.net%2Fapi%2Fevents%3FapiVersion%3D2018-01-01&e=1%2F1%2F2020%2012%3A00%3A00%20AM&s=ZzvNAYRyvJwDrOJKYxbNAPNCoSqgOJVLFi4IMXOrW2Q%3D" + ); + }); +}); From 74d3a3109f2f0016f569208576f5629c618a9ba9 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Fri, 24 Jul 2020 13:01:28 -0700 Subject: [PATCH 16/34] [EventGrid] Tweak the consumer system type design Instead of generating individual type guard methods for every system event (which would lead to a bunch of exported functions which would clutter up the documentation and like), we've adopted a model now where we have a single `isSystemEvent` function. This takes two arguments, the first is a string which represents the type name of a System Event supported by the SDK (and we have an union type with all these strings in it) and the second is the CloudEvent or EventGridEvent object to test. In practice this means instead of: ```typescript if (isContainerRegistryChartPushedEvent(event)) { // ... } else if (isContainerRegistryChartDeletedEvent(event)) { // ... } ``` You now write: ```typescript if (isSystemEvent("Microsoft.ContainerRegistry.ChartPushed", event)) { // ... } else if (isSystemEvent("Microsoft.ContainerRegistry.ChartDeleted", event)) { // ... } ``` The `isSystemEvent` function is authored in such a way that auto completion will show you the set of strings that could be passed into isSystemEvent. --- .../eventgrid/review/eventgrid.api.md | 965 +++++++++++++++++- sdk/eventgrid/eventgrid/src/index.ts | 227 ++-- sdk/eventgrid/eventgrid/src/predicates.ts | 348 +++++-- 3 files changed, 1309 insertions(+), 231 deletions(-) diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index 139a00177e85..938d457437a9 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -10,6 +10,38 @@ import { OperationOptions } from '@azure/core-http'; import { PipelineOptions } from '@azure/core-http'; import { RestResponse } from '@azure/core-http'; +// @public +export type AppAction = "Restarted" | "Stopped" | "ChangedAppSettings" | "Started" | "Completed" | "Failed"; + +// @public +export interface AppConfigurationKeyValueDeletedEventData { + etag?: string; + key?: string; + label?: string; +} + +// @public +export interface AppConfigurationKeyValueModifiedEventData { + etag?: string; + key?: string; + label?: string; +} + +// @public +export interface AppEventTypeDetail { + action?: AppAction; +} + +// @public +export interface AppServicePlanEventTypeDetail { + action?: "Updated"; + stampKind?: StampKind; + status?: AsyncStatus; +} + +// @public +export type AsyncStatus = "Started" | "Completed" | "Failed"; + export { AzureKeyCredential } // @public @@ -101,6 +133,75 @@ export type ContainerRegistryImagePushedEventData = ContainerRegistryEventData & // @public export type CustomEventDataDeserializer = (o: any) => Promise; +// @public +export interface DeviceConnectionStateEventInfo { + sequenceNumber?: string; +} + +// @public +export interface DeviceConnectionStateEventProperties { + deviceConnectionStateEventInfo?: DeviceConnectionStateEventInfo; + deviceId?: string; + hubName?: string; + moduleId?: string; +} + +// @public +export interface DeviceLifeCycleEventProperties { + deviceId?: string; + hubName?: string; + twin?: DeviceTwinInfo; +} + +// @public +export interface DeviceTelemetryEventProperties { + body?: any; + properties?: { + [propertyName: string]: string; + }; + systemProperties?: { + [propertyName: string]: string; + }; +} + +// @public +export interface DeviceTwinInfo { + authenticationType?: string; + cloudToDeviceMessageCount?: number; + connectionState?: string; + deviceId?: string; + etag?: string; + lastActivityTime?: string; + properties?: DeviceTwinInfoProperties; + status?: string; + statusUpdateTime?: string; + version?: number; + x509Thumbprint?: DeviceTwinInfoX509Thumbprint; +} + +// @public +export interface DeviceTwinInfoProperties { + desired?: DeviceTwinProperties; + reported?: DeviceTwinProperties; +} + +// @public +export interface DeviceTwinInfoX509Thumbprint { + primaryThumbprint?: string; + secondaryThumbprint?: string; +} + +// @public +export interface DeviceTwinMetadata { + lastUpdated?: string; +} + +// @public +export interface DeviceTwinProperties { + metadata?: DeviceTwinMetadata; + version?: number; +} + // @public export class EventGridConsumer { constructor(options?: EventGridConsumerOptions); @@ -133,7 +234,6 @@ export class EventGridPublisherClient { constructor(endpointUrl: string, credential: KeyCredential | SignatureCredential, options?: EventGridPublisherClientOptions); readonly apiVersion: string; readonly endpointUrl: string; - generateSharedAccessSignature(expiresOnUtc: Date): Promise; sendCloudEvents(events: CloudEvent[], options?: SendCloudEventsOptions): Promise; sendCustomSchemaEvents(events: Record[], options?: SendCustomSchemaEventsOptions): Promise; sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise; @@ -163,34 +263,457 @@ export interface EventHubCaptureFileCreatedEventData { } // @public -export function isContainerRegistryChartDeletedEvent(event: EventGridEvent): event is EventGridEvent; +export function generateSharedAccessSignature(endpointUrl: string, credential: KeyCredential, expiresOnUtc: Date, options?: GenerateSharedAccessSignatureOptions): Promise; + +// @public (undocumented) +export interface GenerateSharedAccessSignatureOptions { + apiVersion?: string; +} + +// @public +export type IotHubDeviceConnectedEventData = DeviceConnectionStateEventProperties & {}; + +// @public +export type IotHubDeviceCreatedEventData = DeviceLifeCycleEventProperties & {}; + +// @public +export type IotHubDeviceDeletedEventData = DeviceLifeCycleEventProperties & {}; + +// @public +export type IotHubDeviceDisconnectedEventData = DeviceConnectionStateEventProperties & {}; + +// @public +export type IotHubDeviceTelemetryEventData = DeviceTelemetryEventProperties & {}; + +// @public +export function isSystemEvent(eventType: T, event: EventGridEvent): event is EventGridEvent; + +// @public +export function isSystemEvent(eventType: T, event: CloudEvent): event is CloudEvent; + +// @public +export type KnownSystemEventTypes = "Microsoft.AppConfiguration.KeyValueDeleted" | "Microsoft.AppConfiguration.KeyValueModified" | "Microsoft.ContainerRegistry.ImagePushed" | "Microsoft.ContainerRegistry.ImageDeleted" | "Microsoft.ContainerRegistry.ChartDeleted" | "Microsoft.ContainerRegistry.ChartPushed" | "Microsoft.Devices.DeviceCreated" | "Microsoft.Devices.DeviceDeleted" | "Microsoft.Devices.DeviceConnected" | "Microsoft.Devices.DeviceDisconnected" | "Microsoft.Devices.DeviceTelemetry" | "Microsoft.EventGrid.SubscriptionValidationEvent" | "Microsoft.EventGrid.SubscriptionDeletedEvent" | "Microsoft.EventHub.CaptureFileCreated" | "Microsoft.MachineLearningServices.DatasetDriftDetected" | "Microsoft.MachineLearningServices.ModelDeployed" | "Microsoft.MachineLearningServices.ModelRegistered" | "Microsoft.MachineLearningServices.RunCompleted" | "Microsoft.MachineLearningServices.RunStatusChanged" | "Microsoft.Maps.GeofenceEntered" | "Microsoft.Maps.GeofenceExited" | "Microsoft.Maps.GeofenceResult" | "Microsoft.Media.JobStateChange" | "Microsoft.Media.JobOutputStateChange" | "Microsoft.Media.JobScheduled" | "Microsoft.Media.JobProcessing" | "Microsoft.Media.JobCanceling" | "Microsoft.Media.JobFinished" | "Microsoft.Media.JobCanceled" | "Microsoft.Media.JobErrored" | "Microsoft.Media.JobOutputCanceled" | "Microsoft.Media.JobOutputCanceling" | "Microsoft.Media.JobOutputErrored" | "Microsoft.Media.JobOutputFinished" | "Microsoft.Media.JobOutputProcessing" | "Microsoft.Media.JobOutputScheduled" | "Microsoft.Media.JobOutputProgress" | "Microsoft.Media.LiveEventEncoderConnected" | "Microsoft.Media.LiveEventConnectionRejected" | "Microsoft.Media.LiveEventEncoderDisconnected" | "Microsoft.Media.LiveEventIncomingStreamReceived" | "Microsoft.Media.LiveEventIncomingStreamsOutOfSync" | "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync" | "Microsoft.Media.LiveEventIncomingDataChunkDropped" | "Microsoft.Media.LiveEventIngestHeartbeat" | "Microsoft.Media.LiveEventTrackDiscontinuityDetected" | "Microsoft.Resources.ResourceWriteSuccess" | "Microsoft.Resources.ResourceWriteFailure" | "Microsoft.Resources.ResourceWriteCancel" | "Microsoft.Resources.ResourceDeleteSuccess" | "Microsoft.Resources.ResourceDeleteFailure" | "Microsoft.Resources.ResourceDeleteCancel" | "Microsoft.Resources.ResourceActionSuccess" | "Microsoft.Resources.ResourceActionFailure" | "Microsoft.Resources.ResourceActionCancel" | "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners" | "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener" | "Microsoft.Storage.BlobCreated" | "Microsoft.Storage.BlobDeleted" | "Microsoft.Storage.BlobRenamed" | "Microsoft.Storage.DirectoryCreated" | "Microsoft.Storage.DirectoryDeleted" | "Microsoft.Storage.DirectoryRenamed" | "Microsoft.Web.AppUpdated" | "Microsoft.Web.BackupOperationStarted" | "Microsoft.Web.BackupOperationCompleted" | "Microsoft.Web.BackupOperationFailed" | "Microsoft.Web.RestoreOperationStarted" | "Microsoft.Web.RestoreOperationCompleted" | "Microsoft.Web.RestoreOperationFailed" | "Microsoft.Web.SlotSwapStarted" | "Microsoft.Web.SlotSwapCompleted" | "Microsoft.Web.SlotSwapFailed" | "Microsoft.Web.SlotSwapWithPreviewStarted" | "Microsoft.Web.SlotSwapWithPreviewCancelled" | "Microsoft.Web.AppServicePlanUpdated"; + +// @public +export interface MachineLearningServicesDatasetDriftDetectedEventData { + baseDatasetId?: string; + dataDriftId?: string; + dataDriftName?: string; + driftCoefficient?: number; + endTime?: Date; + runId?: string; + startTime?: Date; + targetDatasetId?: string; +} + +// @public +export interface MachineLearningServicesModelDeployedEventData { + modelIds?: string; + serviceComputeType?: string; + serviceName?: string; + serviceProperties?: any; + serviceTags?: any; +} + +// @public +export interface MachineLearningServicesModelRegisteredEventData { + modelName?: string; + modelProperties?: any; + modelTags?: any; + modelVersion?: string; +} + +// @public +export interface MachineLearningServicesRunCompletedEventData { + experimentId?: string; + experimentName?: string; + runId?: string; + runProperties?: any; + runTags?: any; + runType?: string; +} + +// @public +export interface MachineLearningServicesRunStatusChangedEventData { + experimentId?: string; + experimentName?: string; + runId?: string; + runProperties?: any; + runStatus?: string; + runTags?: any; + runType?: string; +} + +// @public +export type MapsGeofenceEnteredEventData = MapsGeofenceEventProperties & {}; + +// @public +export interface MapsGeofenceEventProperties { + expiredGeofenceGeometryId?: string[]; + geometries?: MapsGeofenceGeometry[]; + invalidPeriodGeofenceGeometryId?: string[]; + isEventPublished?: boolean; +} + +// @public +export type MapsGeofenceExitedEventData = MapsGeofenceEventProperties & {}; + +// @public +export interface MapsGeofenceGeometry { + deviceId?: string; + distance?: number; + geometryId?: string; + nearestLat?: number; + nearestLon?: number; + udId?: string; +} + +// @public +export type MapsGeofenceResultEventData = MapsGeofenceEventProperties & {}; + +// @public +export type MediaJobCanceledEventData = MediaJobStateChangeEventData & { + outputs?: MediaJobOutputUnion[]; +}; + +// @public +export type MediaJobCancelingEventData = MediaJobStateChangeEventData & {}; + +// @public +export interface MediaJobError { + readonly category?: MediaJobErrorCategory; + readonly code?: MediaJobErrorCode; + readonly details?: MediaJobErrorDetail[]; + readonly message?: string; + readonly retry?: MediaJobRetry; +} + +// @public +export type MediaJobErrorCategory = "Service" | "Download" | "Upload" | "Configuration" | "Content"; + +// @public +export type MediaJobErrorCode = "ServiceError" | "ServiceTransientError" | "DownloadNotAccessible" | "DownloadTransientError" | "UploadNotAccessible" | "UploadTransientError" | "ConfigurationUnsupported" | "ContentMalformed" | "ContentUnsupported"; + +// @public +export interface MediaJobErrorDetail { + readonly code?: string; + readonly message?: string; +} + +// @public +export type MediaJobErroredEventData = MediaJobStateChangeEventData & { + outputs?: MediaJobOutputUnion[]; +}; + +// @public +export type MediaJobFinishedEventData = MediaJobStateChangeEventData & { + outputs?: MediaJobOutputUnion[]; +}; + +// @public +export interface MediaJobOutput { + "@odata.type": "#Microsoft.Media.JobOutputAsset"; + error?: MediaJobError; + label?: string; + odataType?: string; + progress: number; + state: MediaJobState; +} + +// @public +export type MediaJobOutputAsset = MediaJobOutput & { + assetName?: string; +}; + +// @public +export type MediaJobOutputCanceledEventData = MediaJobOutputStateChangeEventData & {}; + +// @public +export type MediaJobOutputCancelingEventData = MediaJobOutputStateChangeEventData & {}; + +// @public +export type MediaJobOutputErroredEventData = MediaJobOutputStateChangeEventData & {}; + +// @public +export type MediaJobOutputFinishedEventData = MediaJobOutputStateChangeEventData & {}; + +// @public +export type MediaJobOutputProcessingEventData = MediaJobOutputStateChangeEventData & {}; + +// @public +export interface MediaJobOutputProgressEventData { + jobCorrelationData?: { + [propertyName: string]: string; + }; + label?: string; + progress?: number; +} + +// @public +export type MediaJobOutputScheduledEventData = MediaJobOutputStateChangeEventData & {}; // @public -export function isContainerRegistryChartDeletedEvent(event: CloudEvent): event is CloudEvent; +export interface MediaJobOutputStateChangeEventData { + jobCorrelationData?: { + [propertyName: string]: string; + }; + output?: MediaJobOutputUnion; + readonly previousState?: MediaJobState; +} + +// @public (undocumented) +export type MediaJobOutputUnion = MediaJobOutput | MediaJobOutputAsset; // @public -export function isContainerRegistryChartPushedEvent(event: EventGridEvent): event is EventGridEvent; +export type MediaJobProcessingEventData = MediaJobStateChangeEventData & {}; // @public -export function isContainerRegistryChartPushedEvent(event: CloudEvent): event is CloudEvent; +export type MediaJobRetry = "DoNotRetry" | "MayRetry"; // @public -export function isContainerRegistryImageDeletedEvent(event: EventGridEvent): event is EventGridEvent; +export type MediaJobScheduledEventData = MediaJobStateChangeEventData & {}; // @public -export function isContainerRegistryImageDeletedEvent(event: CloudEvent): event is CloudEvent; +export type MediaJobState = "Canceled" | "Canceling" | "Error" | "Finished" | "Processing" | "Queued" | "Scheduled"; + +// @public +export interface MediaJobStateChangeEventData { + correlationData?: { + [propertyName: string]: string; + }; + readonly previousState?: MediaJobState; + readonly state?: MediaJobState; +} // @public -export function isContainerRegistryImagePushedEvent(event: EventGridEvent): event is EventGridEvent; +export interface MediaLiveEventConnectionRejectedEventData { + readonly encoderIp?: string; + readonly encoderPort?: string; + readonly ingestUrl?: string; + readonly resultCode?: string; + readonly streamId?: string; +} + +// @public +export interface MediaLiveEventEncoderConnectedEventData { + readonly encoderIp?: string; + readonly encoderPort?: string; + readonly ingestUrl?: string; + readonly streamId?: string; +} + +// @public +export interface MediaLiveEventEncoderDisconnectedEventData { + readonly encoderIp?: string; + readonly encoderPort?: string; + readonly ingestUrl?: string; + readonly resultCode?: string; + readonly streamId?: string; +} + +// @public +export interface MediaLiveEventIncomingDataChunkDroppedEventData { + readonly bitrate?: number; + readonly resultCode?: string; + readonly timescale?: string; + readonly timestamp?: string; + readonly trackName?: string; + readonly trackType?: string; +} + +// @public +export interface MediaLiveEventIncomingStreamReceivedEventData { + readonly bitrate?: number; + readonly duration?: string; + readonly encoderIp?: string; + readonly encoderPort?: string; + readonly ingestUrl?: string; + readonly timescale?: string; + readonly timestamp?: string; + readonly trackName?: string; + readonly trackType?: string; +} + +// @public +export interface MediaLiveEventIncomingStreamsOutOfSyncEventData { + readonly maxLastTimestamp?: string; + readonly minLastTimestamp?: string; + readonly timescaleOfMaxLastTimestamp?: string; + readonly timescaleOfMinLastTimestamp?: string; + readonly typeOfStreamWithMaxLastTimestamp?: string; + readonly typeOfStreamWithMinLastTimestamp?: string; +} + +// @public +export interface MediaLiveEventIncomingVideoStreamsOutOfSyncEventData { + readonly firstDuration?: string; + readonly firstTimestamp?: string; + readonly secondDuration?: string; + readonly secondTimestamp?: string; + readonly timescale?: string; +} + +// @public +export interface MediaLiveEventIngestHeartbeatEventData { + readonly bitrate?: number; + readonly discontinuityCount?: number; + readonly healthy?: boolean; + readonly incomingBitrate?: number; + readonly lastTimestamp?: string; + readonly nonincreasingCount?: number; + readonly overlapCount?: number; + readonly state?: string; + readonly timescale?: string; + readonly trackName?: string; + readonly trackType?: string; + readonly unexpectedBitrate?: boolean; +} + +// @public +export interface MediaLiveEventTrackDiscontinuityDetectedEventData { + readonly bitrate?: number; + readonly discontinuityGap?: string; + readonly newTimestamp?: string; + readonly previousTimestamp?: string; + readonly timescale?: string; + readonly trackName?: string; + readonly trackType?: string; +} + +// @public +export interface ResourceActionCancelEventData { + authorization?: string; + claims?: string; + correlationId?: string; + httpRequest?: string; + operationName?: string; + resourceGroup?: string; + resourceProvider?: string; + resourceUri?: string; + status?: string; + subscriptionId?: string; + tenantId?: string; +} + +// @public +export interface ResourceActionFailureEventData { + authorization?: string; + claims?: string; + correlationId?: string; + httpRequest?: string; + operationName?: string; + resourceGroup?: string; + resourceProvider?: string; + resourceUri?: string; + status?: string; + subscriptionId?: string; + tenantId?: string; +} + +// @public +export interface ResourceActionSuccessEventData { + authorization?: string; + claims?: string; + correlationId?: string; + httpRequest?: string; + operationName?: string; + resourceGroup?: string; + resourceProvider?: string; + resourceUri?: string; + status?: string; + subscriptionId?: string; + tenantId?: string; +} + +// @public +export interface ResourceDeleteCancelEventData { + authorization?: string; + claims?: string; + correlationId?: string; + httpRequest?: string; + operationName?: string; + resourceGroup?: string; + resourceProvider?: string; + resourceUri?: string; + status?: string; + subscriptionId?: string; + tenantId?: string; +} + +// @public +export interface ResourceDeleteFailureEventData { + authorization?: string; + claims?: string; + correlationId?: string; + httpRequest?: string; + operationName?: string; + resourceGroup?: string; + resourceProvider?: string; + resourceUri?: string; + status?: string; + subscriptionId?: string; + tenantId?: string; +} + +// @public +export interface ResourceDeleteSuccessEventData { + authorization?: string; + claims?: string; + correlationId?: string; + httpRequest?: string; + operationName?: string; + resourceGroup?: string; + resourceProvider?: string; + resourceUri?: string; + status?: string; + subscriptionId?: string; + tenantId?: string; +} // @public -export function isContainerRegistryImagePushedEvent(event: CloudEvent): event is CloudEvent; +export interface ResourceWriteCancelEventData { + authorization?: string; + claims?: string; + correlationId?: string; + httpRequest?: string; + operationName?: string; + resourceGroup?: string; + resourceProvider?: string; + resourceUri?: string; + status?: string; + subscriptionId?: string; + tenantId?: string; +} // @public -export function isEventHubCaptureFileCreatedEvent(event: EventGridEvent): event is EventGridEvent; +export interface ResourceWriteFailureEventData { + authorization?: string; + claims?: string; + correlationId?: string; + httpRequest?: string; + operationName?: string; + resourceGroup?: string; + resourceProvider?: string; + resourceUri?: string; + status?: string; + subscriptionId?: string; + tenantId?: string; +} // @public -export function isEventHubCaptureFileCreatedEvent(event: CloudEvent): event is CloudEvent; +export interface ResourceWriteSuccessEventData { + authorization?: string; + claims?: string; + correlationId?: string; + httpRequest?: string; + operationName?: string; + resourceGroup?: string; + resourceProvider?: string; + resourceUri?: string; + status?: string; + subscriptionId?: string; + tenantId?: string; +} // @public export type SendCloudEventsOptions = OperationOptions; @@ -201,11 +724,431 @@ export type SendCustomSchemaEventsOptions = OperationOptions; // @public export type SendEventsOptions = OperationOptions; +// @public +export interface ServiceBusActiveMessagesAvailableWithNoListenersEventData { + entityType?: string; + namespaceName?: string; + queueName?: string; + requestUri?: string; + subscriptionName?: string; + topicName?: string; +} + +// @public +export interface ServiceBusDeadletterMessagesAvailableWithNoListenersEventData { + entityType?: string; + namespaceName?: string; + queueName?: string; + requestUri?: string; + subscriptionName?: string; + topicName?: string; +} + // @public export interface SignatureCredential { signature(): string; } +// @public +export type StampKind = "Public" | "AseV1" | "AseV2"; + +// @public +export interface StorageBlobCreatedEventData { + api?: string; + blobType?: string; + clientRequestId?: string; + contentLength?: number; + contentOffset?: number; + contentType?: string; + eTag?: string; + identity?: string; + requestId?: string; + sequencer?: string; + storageDiagnostics?: any; + url?: string; +} + +// @public +export interface StorageBlobDeletedEventData { + api?: string; + blobType?: string; + clientRequestId?: string; + contentType?: string; + identity?: string; + requestId?: string; + sequencer?: string; + storageDiagnostics?: any; + url?: string; +} + +// @public +export interface StorageBlobRenamedEventData { + api?: string; + clientRequestId?: string; + destinationUrl?: string; + identity?: string; + requestId?: string; + sequencer?: string; + sourceUrl?: string; + storageDiagnostics?: any; +} + +// @public +export interface StorageDirectoryCreatedEventData { + api?: string; + clientRequestId?: string; + eTag?: string; + identity?: string; + requestId?: string; + sequencer?: string; + storageDiagnostics?: any; + url?: string; +} + +// @public +export interface StorageDirectoryDeletedEventData { + api?: string; + clientRequestId?: string; + identity?: string; + recursive?: boolean; + requestId?: string; + sequencer?: string; + storageDiagnostics?: any; + url?: string; +} + +// @public +export interface StorageDirectoryRenamedEventData { + api?: string; + clientRequestId?: string; + destinationUrl?: string; + identity?: string; + requestId?: string; + sequencer?: string; + sourceUrl?: string; + storageDiagnostics?: any; +} + +// @public +export interface SubscriptionDeletedEventData { + readonly eventSubscriptionId?: string; +} + +// @public +export interface SubscriptionValidationEventData { + readonly validationCode?: string; + readonly validationUrl?: string; +} + +// @public +export interface SystemEventNameToEventData { + // (undocumented) + "Microsoft.AppConfiguration.KeyValueDeleted": AppConfigurationKeyValueDeletedEventData; + // (undocumented) + "Microsoft.AppConfiguration.KeyValueModified": AppConfigurationKeyValueModifiedEventData; + // (undocumented) + "Microsoft.ContainerRegistry.ChartDeleted": ContainerRegistryChartDeletedEventData; + // (undocumented) + "Microsoft.ContainerRegistry.ChartPushed": ContainerRegistryChartPushedEventData; + // (undocumented) + "Microsoft.ContainerRegistry.ImageDeleted": ContainerRegistryImageDeletedEventData; + // (undocumented) + "Microsoft.ContainerRegistry.ImagePushed": ContainerRegistryImagePushedEventData; + // (undocumented) + "Microsoft.Devices.DeviceConnected": IotHubDeviceConnectedEventData; + // (undocumented) + "Microsoft.Devices.DeviceCreated": IotHubDeviceCreatedEventData; + // (undocumented) + "Microsoft.Devices.DeviceDeleted": IotHubDeviceDeletedEventData; + // (undocumented) + "Microsoft.Devices.DeviceDisconnected": IotHubDeviceDisconnectedEventData; + // (undocumented) + "Microsoft.Devices.DeviceTelemetry": IotHubDeviceTelemetryEventData; + // (undocumented) + "Microsoft.EventGrid.SubscriptionDeletedEvent": SubscriptionDeletedEventData; + // (undocumented) + "Microsoft.EventGrid.SubscriptionValidationEvent": SubscriptionValidationEventData; + // (undocumented) + "Microsoft.EventHub.CaptureFileCreated": EventHubCaptureFileCreatedEventData; + // (undocumented) + "Microsoft.MachineLearningServices.DatasetDriftDetected": MachineLearningServicesDatasetDriftDetectedEventData; + // (undocumented) + "Microsoft.MachineLearningServices.ModelDeployed": MachineLearningServicesModelDeployedEventData; + // (undocumented) + "Microsoft.MachineLearningServices.ModelRegistered": MachineLearningServicesModelRegisteredEventData; + // (undocumented) + "Microsoft.MachineLearningServices.RunCompleted": MachineLearningServicesRunCompletedEventData; + // (undocumented) + "Microsoft.MachineLearningServices.RunStatusChanged": MachineLearningServicesRunStatusChangedEventData; + // (undocumented) + "Microsoft.Maps.GeofenceEntered": MapsGeofenceEnteredEventData; + // (undocumented) + "Microsoft.Maps.GeofenceExited": MapsGeofenceExitedEventData; + // (undocumented) + "Microsoft.Maps.GeofenceResult": MapsGeofenceResultEventData; + // (undocumented) + "Microsoft.Media.JobCanceled": MediaJobCanceledEventData; + // (undocumented) + "Microsoft.Media.JobCanceling": MediaJobCancelingEventData; + // (undocumented) + "Microsoft.Media.JobErrored": MediaJobErroredEventData; + // (undocumented) + "Microsoft.Media.JobFinished": MediaJobFinishedEventData; + // (undocumented) + "Microsoft.Media.JobOutputCanceled": MediaJobOutputCanceledEventData; + // (undocumented) + "Microsoft.Media.JobOutputCanceling": MediaJobOutputCancelingEventData; + // (undocumented) + "Microsoft.Media.JobOutputErrored": MediaJobOutputErroredEventData; + // (undocumented) + "Microsoft.Media.JobOutputFinished": MediaJobOutputFinishedEventData; + // (undocumented) + "Microsoft.Media.JobOutputProcessing": MediaJobOutputProcessingEventData; + // (undocumented) + "Microsoft.Media.JobOutputProgress": MediaJobOutputProgressEventData; + // (undocumented) + "Microsoft.Media.JobOutputScheduled": MediaJobOutputScheduledEventData; + // (undocumented) + "Microsoft.Media.JobOutputStateChange": MediaJobOutputStateChangeEventData; + // (undocumented) + "Microsoft.Media.JobProcessing": MediaJobProcessingEventData; + // (undocumented) + "Microsoft.Media.JobScheduled": MediaJobScheduledEventData; + // (undocumented) + "Microsoft.Media.JobStateChange": MediaJobStateChangeEventData; + // (undocumented) + "Microsoft.Media.LiveEventConnectionRejected": MediaLiveEventConnectionRejectedEventData; + // (undocumented) + "Microsoft.Media.LiveEventEncoderConnected": MediaLiveEventEncoderConnectedEventData; + // (undocumented) + "Microsoft.Media.LiveEventEncoderDisconnected": MediaLiveEventEncoderDisconnectedEventData; + // (undocumented) + "Microsoft.Media.LiveEventIncomingDataChunkDropped": MediaLiveEventIncomingDataChunkDroppedEventData; + // (undocumented) + "Microsoft.Media.LiveEventIncomingStreamReceived": MediaLiveEventIncomingStreamReceivedEventData; + // (undocumented) + "Microsoft.Media.LiveEventIncomingStreamsOutOfSync": MediaLiveEventIncomingStreamsOutOfSyncEventData; + // (undocumented) + "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync": MediaLiveEventIncomingVideoStreamsOutOfSyncEventData; + // (undocumented) + "Microsoft.Media.LiveEventIngestHeartbeat": MediaLiveEventIngestHeartbeatEventData; + // (undocumented) + "Microsoft.Media.LiveEventTrackDiscontinuityDetected": MediaLiveEventTrackDiscontinuityDetectedEventData; + // (undocumented) + "Microsoft.Resources.ResourceActionCancel": ResourceActionCancelEventData; + // (undocumented) + "Microsoft.Resources.ResourceActionFailure": ResourceActionFailureEventData; + // (undocumented) + "Microsoft.Resources.ResourceActionSuccess": ResourceActionSuccessEventData; + // (undocumented) + "Microsoft.Resources.ResourceDeleteCancel": ResourceDeleteCancelEventData; + // (undocumented) + "Microsoft.Resources.ResourceDeleteFailure": ResourceDeleteFailureEventData; + // (undocumented) + "Microsoft.Resources.ResourceDeleteSuccess": ResourceDeleteSuccessEventData; + // (undocumented) + "Microsoft.Resources.ResourceWriteCancel": ResourceWriteCancelEventData; + // (undocumented) + "Microsoft.Resources.ResourceWriteFailure": ResourceWriteFailureEventData; + // (undocumented) + "Microsoft.Resources.ResourceWriteSuccess": ResourceWriteSuccessEventData; + // (undocumented) + "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners": ServiceBusActiveMessagesAvailableWithNoListenersEventData; + // (undocumented) + "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener": ServiceBusDeadletterMessagesAvailableWithNoListenersEventData; + // (undocumented) + "Microsoft.Storage.BlobCreated": StorageBlobCreatedEventData; + // (undocumented) + "Microsoft.Storage.BlobDeleted": StorageBlobDeletedEventData; + // (undocumented) + "Microsoft.Storage.BlobRenamed": StorageBlobRenamedEventData; + // (undocumented) + "Microsoft.Storage.DirectoryCreated": StorageDirectoryCreatedEventData; + // (undocumented) + "Microsoft.Storage.DirectoryDeleted": StorageDirectoryDeletedEventData; + // (undocumented) + "Microsoft.Storage.DirectoryRenamed": StorageDirectoryRenamedEventData; + // (undocumented) + "Microsoft.Web.AppServicePlanUpdated": WebAppServicePlanUpdatedEventData; + // (undocumented) + "Microsoft.Web.AppUpdated": WebAppUpdatedEventData; + // (undocumented) + "Microsoft.Web.BackupOperationCompleted": WebBackupOperationCompletedEventData; + // (undocumented) + "Microsoft.Web.BackupOperationFailed": WebBackupOperationFailedEventData; + // (undocumented) + "Microsoft.Web.BackupOperationStarted": WebBackupOperationStartedEventData; + // (undocumented) + "Microsoft.Web.RestoreOperationCompleted": WebRestoreOperationCompletedEventData; + // (undocumented) + "Microsoft.Web.RestoreOperationFailed": WebRestoreOperationFailedEventData; + // (undocumented) + "Microsoft.Web.RestoreOperationStarted": WebRestoreOperationStartedEventData; + // (undocumented) + "Microsoft.Web.SlotSwapCompleted": WebSlotSwapCompletedEventData; + // (undocumented) + "Microsoft.Web.SlotSwapFailed": WebSlotSwapFailedEventData; + // (undocumented) + "Microsoft.Web.SlotSwapStarted": WebSlotSwapStartedEventData; + // (undocumented) + "Microsoft.Web.SlotSwapWithPreviewCancelled": WebSlotSwapWithPreviewCancelledEventData; + // (undocumented) + "Microsoft.Web.SlotSwapWithPreviewStarted": WebSlotSwapWithPreviewStartedEventData; +} + +// @public +export interface WebAppServicePlanUpdatedEventData { + address?: string; + appServicePlanEventTypeDetail?: AppServicePlanEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + sku?: WebAppServicePlanUpdatedEventDataSku; + verb?: string; +} + +// @public +export interface WebAppServicePlanUpdatedEventDataSku { + capacity?: string; + family?: string; + name?: string; + size?: string; + tier?: string; +} + +// @public +export interface WebAppUpdatedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebBackupOperationCompletedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebBackupOperationFailedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebBackupOperationStartedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebRestoreOperationCompletedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebRestoreOperationFailedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebRestoreOperationStartedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebSlotSwapCompletedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebSlotSwapFailedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebSlotSwapStartedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebSlotSwapWithPreviewCancelledEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + +// @public +export interface WebSlotSwapWithPreviewStartedEventData { + address?: string; + appEventTypeDetail?: AppEventTypeDetail; + clientRequestId?: string; + correlationRequestId?: string; + name?: string; + requestId?: string; + verb?: string; +} + // (No @packageDocumentation comment for this package) diff --git a/sdk/eventgrid/eventgrid/src/index.ts b/sdk/eventgrid/eventgrid/src/index.ts index 01be65030ef1..31dd1b09e81a 100644 --- a/sdk/eventgrid/eventgrid/src/index.ts +++ b/sdk/eventgrid/eventgrid/src/index.ts @@ -25,141 +25,116 @@ export { GenerateSharedAccessSignatureOptions } from "./generateSharedAccessSignature"; +export { isSystemEvent, KnownSystemEventTypes, SystemEventNameToEventData } from "./predicates"; + export { - EventHubCaptureFileCreatedEventData, + AppConfigurationKeyValueDeletedEventData, + AppConfigurationKeyValueModifiedEventData, + AppEventTypeDetail, + AppServicePlanEventTypeDetail, ContainerRegistryArtifactEventTarget, ContainerRegistryEventData, ContainerRegistryImagePushedEventData, ContainerRegistryImageDeletedEventData, ContainerRegistryChartDeletedEventData, ContainerRegistryChartPushedEventData, + DeviceConnectionStateEventInfo, + DeviceTwinInfo, + DeviceTwinInfoProperties, + DeviceTwinInfoX509Thumbprint, + IotHubDeviceCreatedEventData, + IotHubDeviceDeletedEventData, + IotHubDeviceConnectedEventData, + IotHubDeviceDisconnectedEventData, + IotHubDeviceTelemetryEventData, + SubscriptionValidationEventData, + SubscriptionDeletedEventData, + EventHubCaptureFileCreatedEventData, + MachineLearningServicesDatasetDriftDetectedEventData, + MachineLearningServicesModelDeployedEventData, + MachineLearningServicesModelRegisteredEventData, + MachineLearningServicesRunCompletedEventData, + MachineLearningServicesRunStatusChangedEventData, + MapsGeofenceEventProperties, + MapsGeofenceEnteredEventData, + MapsGeofenceExitedEventData, + MapsGeofenceResultEventData, + MediaJobStateChangeEventData, + MediaJobOutputStateChangeEventData, + MediaJobScheduledEventData, + MediaJobProcessingEventData, + MediaJobCancelingEventData, + MediaJobFinishedEventData, + MediaJobCanceledEventData, + MediaJobError, + MediaJobErrorCategory, + MediaJobErrorDetail, + MediaJobErrorCode, + MediaJobRetry, + MediaJobErroredEventData, + MediaJobOutputCanceledEventData, + MediaJobOutputCancelingEventData, + MediaJobOutputErroredEventData, + MediaJobOutputFinishedEventData, + MediaJobOutputProcessingEventData, + MediaJobOutputScheduledEventData, + MediaJobOutputProgressEventData, + MediaJobOutputUnion, + MediaJobState, + MediaLiveEventEncoderConnectedEventData, + MediaLiveEventConnectionRejectedEventData, + MediaLiveEventEncoderDisconnectedEventData, + MediaLiveEventIncomingStreamReceivedEventData, + MediaLiveEventIncomingStreamsOutOfSyncEventData, + MediaLiveEventIncomingVideoStreamsOutOfSyncEventData, + MediaLiveEventIncomingDataChunkDroppedEventData, + MediaLiveEventIngestHeartbeatEventData, + MediaLiveEventTrackDiscontinuityDetectedEventData, + ResourceWriteSuccessEventData, + ResourceWriteFailureEventData, + ResourceWriteCancelEventData, + ResourceDeleteSuccessEventData, + ResourceDeleteFailureEventData, + ResourceDeleteCancelEventData, + ResourceActionSuccessEventData, + ResourceActionFailureEventData, + ResourceActionCancelEventData, + ServiceBusActiveMessagesAvailableWithNoListenersEventData, + ServiceBusDeadletterMessagesAvailableWithNoListenersEventData, + StorageBlobCreatedEventData, + StorageBlobDeletedEventData, + StorageBlobRenamedEventData, + StorageDirectoryCreatedEventData, + StorageDirectoryDeletedEventData, + StorageDirectoryRenamedEventData, + WebAppUpdatedEventData, + WebBackupOperationStartedEventData, + WebBackupOperationCompletedEventData, + WebBackupOperationFailedEventData, + WebRestoreOperationStartedEventData, + WebRestoreOperationCompletedEventData, + WebRestoreOperationFailedEventData, + WebSlotSwapStartedEventData, + WebSlotSwapCompletedEventData, + WebSlotSwapFailedEventData, + WebSlotSwapWithPreviewStartedEventData, + WebSlotSwapWithPreviewCancelledEventData, + WebAppServicePlanUpdatedEventData, + WebAppServicePlanUpdatedEventDataSku, + AppAction, + StampKind, + AsyncStatus, ContainerRegistryArtifactEventData, ContainerRegistryEventActor, ContainerRegistryEventRequest, ContainerRegistryEventSource, - ContainerRegistryEventTarget + ContainerRegistryEventTarget, + DeviceConnectionStateEventProperties, + DeviceLifeCycleEventProperties, + DeviceTelemetryEventProperties, + MapsGeofenceGeometry, + MediaJobOutput, + MediaJobOutputAsset, + DeviceTwinProperties, + DeviceTwinMetadata } from "./generated/models"; - -export { - isEventHubCaptureFileCreatedEvent, - isContainerRegistryChartDeletedEvent, - isContainerRegistryChartPushedEvent, - isContainerRegistryImageDeletedEvent, - isContainerRegistryImagePushedEvent -} from "./predicates"; - -// TODO(matell): Export these from top level when we export the predicates. - -/* -export { - AppConfigurationKeyValueDeletedEventData, - AppConfigurationKeyValueModifiedEventData - AppEventTypeDetail, - AppServicePlanEventTypeDetail, - ContainerRegistryArtifactEventTarget, - ContainerRegistryEventData, - ContainerRegistryImagePushedEventData, - ContainerRegistryImageDeletedEventData, - ContainerRegistryChartDeletedEventData, - ContainerRegistryChartPushedEventData, - DeviceConnectionStateEventInfo, - DeviceTwinInfo, - DeviceTwinInfoProperties, - DeviceTwinInfoX509Thumbprint, - IotHubDeviceCreatedEventData, - IotHubDeviceDeletedEventData, - IotHubDeviceConnectedEventData, - IotHubDeviceDisconnectedEventData, - IotHubDeviceTelemetryEventData, - SubscriptionValidationEventData, - SubscriptionDeletedEventData, - EventHubCaptureFileCreatedEventData, - MachineLearningServicesDatasetDriftDetectedEventData, - MachineLearningServicesModelDeployedEventData, - MachineLearningServicesModelRegisteredEventData, - MachineLearningServicesRunCompletedEventData, - MachineLearningServicesRunStatusChangedEventData, - MapsGeofenceEventProperties, - MapsGeofenceEnteredEventData, - MapsGeofenceExitedEventData, - MapsGeofenceResultEventData, - MediaJobStateChangeEventData, - MediaJobOutputStateChangeEventData, - MediaJobScheduledEventData, - MediaJobProcessingEventData, - MediaJobCancelingEventData, - MediaJobFinishedEventData, - MediaJobCanceledEventData, - MediaJobError, - MediaJobErrorCategory, - MediaJobErrorDetail, - MediaJobErrorCode, - MediaJobRetry, - MediaJobErroredEventData, - MediaJobOutputCanceledEventData, - MediaJobOutputCancelingEventData, - MediaJobOutputErroredEventData, - MediaJobOutputFinishedEventData, - MediaJobOutputProcessingEventData, - MediaJobOutputScheduledEventData, - MediaJobOutputProgressEventData, - MediaJobOutputUnion, - MediaJobState, - MediaLiveEventEncoderConnectedEventData, - MediaLiveEventConnectionRejectedEventData, - MediaLiveEventEncoderDisconnectedEventData, - MediaLiveEventIncomingStreamReceivedEventData, - MediaLiveEventIncomingStreamsOutOfSyncEventData, - MediaLiveEventIncomingVideoStreamsOutOfSyncEventData, - MediaLiveEventIncomingDataChunkDroppedEventData, - MediaLiveEventIngestHeartbeatEventData, - MediaLiveEventTrackDiscontinuityDetectedEventData, - ResourceWriteSuccessEventData, - ResourceWriteFailureEventData, - ResourceWriteCancelEventData, - ResourceDeleteSuccessEventData, - ResourceDeleteFailureEventData, - ResourceDeleteCancelEventData, - ResourceActionSuccessEventData, - ResourceActionFailureEventData, - ResourceActionCancelEventData, - ServiceBusActiveMessagesAvailableWithNoListenersEventData, - ServiceBusDeadletterMessagesAvailableWithNoListenersEventData, - StorageBlobCreatedEventData, - StorageBlobDeletedEventData, - StorageBlobRenamedEventData, - StorageDirectoryCreatedEventData, - StorageDirectoryDeletedEventData, - StorageDirectoryRenamedEventData, - WebAppUpdatedEventData, - WebBackupOperationStartedEventData, - WebBackupOperationCompletedEventData, - WebBackupOperationFailedEventData, - WebRestoreOperationStartedEventData, - WebRestoreOperationCompletedEventData, - WebRestoreOperationFailedEventData, - WebSlotSwapStartedEventData, - WebSlotSwapCompletedEventData, - WebSlotSwapFailedEventData, - WebSlotSwapWithPreviewStartedEventData, - WebSlotSwapWithPreviewCancelledEventData, - WebAppServicePlanUpdatedEventData, - WebAppServicePlanUpdatedEventDataSku, - AppAction, - StampKind, - AsyncStatus, - ContainerRegistryArtifactEventData, - ContainerRegistryEventActor, - ContainerRegistryEventRequest, - ContainerRegistryEventSource, - ContainerRegistryEventTarget, - DeviceConnectionStateEventProperties, - DeviceLifeCycleEventProperties, - DeviceTelemetryEventProperties, - MapsGeofenceGeometry, - MediaJobOutput, - MediaJobOutputAsset, - DeviceTwinProperties, - DeviceTwinMetadata -} from "./generated/modles" -*/ diff --git a/sdk/eventgrid/eventgrid/src/predicates.ts b/sdk/eventgrid/eventgrid/src/predicates.ts index d6aaaaa88da9..e5490ff2166c 100644 --- a/sdk/eventgrid/eventgrid/src/predicates.ts +++ b/sdk/eventgrid/eventgrid/src/predicates.ts @@ -2,17 +2,250 @@ // Licensed under the MIT license. import { + AppConfigurationKeyValueDeletedEventData, + AppConfigurationKeyValueModifiedEventData, ContainerRegistryImagePushedEventData, ContainerRegistryImageDeletedEventData, ContainerRegistryChartDeletedEventData, ContainerRegistryChartPushedEventData, - EventHubCaptureFileCreatedEventData + IotHubDeviceCreatedEventData, + IotHubDeviceDeletedEventData, + IotHubDeviceConnectedEventData, + IotHubDeviceDisconnectedEventData, + IotHubDeviceTelemetryEventData, + SubscriptionValidationEventData, + SubscriptionDeletedEventData, + EventHubCaptureFileCreatedEventData, + MachineLearningServicesDatasetDriftDetectedEventData, + MachineLearningServicesModelDeployedEventData, + MachineLearningServicesModelRegisteredEventData, + MachineLearningServicesRunCompletedEventData, + MachineLearningServicesRunStatusChangedEventData, + MapsGeofenceEnteredEventData, + MapsGeofenceExitedEventData, + MapsGeofenceResultEventData, + MediaJobStateChangeEventData, + MediaJobOutputStateChangeEventData, + MediaJobScheduledEventData, + MediaJobProcessingEventData, + MediaJobCancelingEventData, + MediaJobFinishedEventData, + MediaJobCanceledEventData, + MediaJobErroredEventData, + MediaJobOutputCanceledEventData, + MediaJobOutputCancelingEventData, + MediaJobOutputErroredEventData, + MediaJobOutputFinishedEventData, + MediaJobOutputProcessingEventData, + MediaJobOutputScheduledEventData, + MediaJobOutputProgressEventData, + MediaLiveEventEncoderConnectedEventData, + MediaLiveEventConnectionRejectedEventData, + MediaLiveEventEncoderDisconnectedEventData, + MediaLiveEventIncomingStreamReceivedEventData, + MediaLiveEventIncomingStreamsOutOfSyncEventData, + MediaLiveEventIncomingVideoStreamsOutOfSyncEventData, + MediaLiveEventIncomingDataChunkDroppedEventData, + MediaLiveEventIngestHeartbeatEventData, + MediaLiveEventTrackDiscontinuityDetectedEventData, + ResourceWriteSuccessEventData, + ResourceWriteFailureEventData, + ResourceWriteCancelEventData, + ResourceDeleteSuccessEventData, + ResourceDeleteFailureEventData, + ResourceDeleteCancelEventData, + ResourceActionSuccessEventData, + ResourceActionFailureEventData, + ResourceActionCancelEventData, + ServiceBusActiveMessagesAvailableWithNoListenersEventData, + ServiceBusDeadletterMessagesAvailableWithNoListenersEventData, + StorageBlobCreatedEventData, + StorageBlobDeletedEventData, + StorageBlobRenamedEventData, + StorageDirectoryCreatedEventData, + StorageDirectoryDeletedEventData, + StorageDirectoryRenamedEventData, + WebAppUpdatedEventData, + WebBackupOperationStartedEventData, + WebBackupOperationCompletedEventData, + WebBackupOperationFailedEventData, + WebRestoreOperationStartedEventData, + WebRestoreOperationCompletedEventData, + WebRestoreOperationFailedEventData, + WebSlotSwapStartedEventData, + WebSlotSwapCompletedEventData, + WebSlotSwapFailedEventData, + WebSlotSwapWithPreviewStartedEventData, + WebSlotSwapWithPreviewCancelledEventData, + WebAppServicePlanUpdatedEventData } from "./generated/models"; import { CloudEvent, EventGridEvent } from "./models"; -// TODO(matell): We need to generate `isXYZEvent`'s for all the known system events and add -// the coresponding mappers. +/** + * TODO(matell): Write some good prose here. + */ +export type KnownSystemEventTypes = + | "Microsoft.AppConfiguration.KeyValueDeleted" + | "Microsoft.AppConfiguration.KeyValueModified" + | "Microsoft.ContainerRegistry.ImagePushed" + | "Microsoft.ContainerRegistry.ImageDeleted" + | "Microsoft.ContainerRegistry.ChartDeleted" + | "Microsoft.ContainerRegistry.ChartPushed" + | "Microsoft.Devices.DeviceCreated" + | "Microsoft.Devices.DeviceDeleted" + | "Microsoft.Devices.DeviceConnected" + | "Microsoft.Devices.DeviceDisconnected" + | "Microsoft.Devices.DeviceTelemetry" + | "Microsoft.EventGrid.SubscriptionValidationEvent" + | "Microsoft.EventGrid.SubscriptionDeletedEvent" + | "Microsoft.EventHub.CaptureFileCreated" + | "Microsoft.MachineLearningServices.DatasetDriftDetected" + | "Microsoft.MachineLearningServices.ModelDeployed" + | "Microsoft.MachineLearningServices.ModelRegistered" + | "Microsoft.MachineLearningServices.RunCompleted" + | "Microsoft.MachineLearningServices.RunStatusChanged" + | "Microsoft.Maps.GeofenceEntered" + | "Microsoft.Maps.GeofenceExited" + | "Microsoft.Maps.GeofenceResult" + | "Microsoft.Media.JobStateChange" + | "Microsoft.Media.JobOutputStateChange" + | "Microsoft.Media.JobScheduled" + | "Microsoft.Media.JobProcessing" + | "Microsoft.Media.JobCanceling" + | "Microsoft.Media.JobFinished" + | "Microsoft.Media.JobCanceled" + | "Microsoft.Media.JobErrored" + | "Microsoft.Media.JobOutputCanceled" + | "Microsoft.Media.JobOutputCanceling" + | "Microsoft.Media.JobOutputErrored" + | "Microsoft.Media.JobOutputFinished" + | "Microsoft.Media.JobOutputProcessing" + | "Microsoft.Media.JobOutputScheduled" + | "Microsoft.Media.JobOutputProgress" + | "Microsoft.Media.LiveEventEncoderConnected" + | "Microsoft.Media.LiveEventConnectionRejected" + | "Microsoft.Media.LiveEventEncoderDisconnected" + | "Microsoft.Media.LiveEventIncomingStreamReceived" + | "Microsoft.Media.LiveEventIncomingStreamsOutOfSync" + | "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync" + | "Microsoft.Media.LiveEventIncomingDataChunkDropped" + | "Microsoft.Media.LiveEventIngestHeartbeat" + | "Microsoft.Media.LiveEventTrackDiscontinuityDetected" + | "Microsoft.Resources.ResourceWriteSuccess" + | "Microsoft.Resources.ResourceWriteFailure" + | "Microsoft.Resources.ResourceWriteCancel" + | "Microsoft.Resources.ResourceDeleteSuccess" + | "Microsoft.Resources.ResourceDeleteFailure" + | "Microsoft.Resources.ResourceDeleteCancel" + | "Microsoft.Resources.ResourceActionSuccess" + | "Microsoft.Resources.ResourceActionFailure" + | "Microsoft.Resources.ResourceActionCancel" + | "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners" + | "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener" + | "Microsoft.Storage.BlobCreated" + | "Microsoft.Storage.BlobDeleted" + | "Microsoft.Storage.BlobRenamed" + | "Microsoft.Storage.DirectoryCreated" + | "Microsoft.Storage.DirectoryDeleted" + | "Microsoft.Storage.DirectoryRenamed" + | "Microsoft.Web.AppUpdated" + | "Microsoft.Web.BackupOperationStarted" + | "Microsoft.Web.BackupOperationCompleted" + | "Microsoft.Web.BackupOperationFailed" + | "Microsoft.Web.RestoreOperationStarted" + | "Microsoft.Web.RestoreOperationCompleted" + | "Microsoft.Web.RestoreOperationFailed" + | "Microsoft.Web.SlotSwapStarted" + | "Microsoft.Web.SlotSwapCompleted" + | "Microsoft.Web.SlotSwapFailed" + | "Microsoft.Web.SlotSwapWithPreviewStarted" + | "Microsoft.Web.SlotSwapWithPreviewCancelled" + | "Microsoft.Web.AppServicePlanUpdated"; + +/** + * A mapping of event type names to event data type interfaces. + * + * @ignore + */ +export interface SystemEventNameToEventData { + "Microsoft.AppConfiguration.KeyValueDeleted": AppConfigurationKeyValueDeletedEventData; + "Microsoft.AppConfiguration.KeyValueModified": AppConfigurationKeyValueModifiedEventData; + "Microsoft.ContainerRegistry.ImagePushed": ContainerRegistryImagePushedEventData; + "Microsoft.ContainerRegistry.ImageDeleted": ContainerRegistryImageDeletedEventData; + "Microsoft.ContainerRegistry.ChartDeleted": ContainerRegistryChartDeletedEventData; + "Microsoft.ContainerRegistry.ChartPushed": ContainerRegistryChartPushedEventData; + "Microsoft.Devices.DeviceCreated": IotHubDeviceCreatedEventData; + "Microsoft.Devices.DeviceDeleted": IotHubDeviceDeletedEventData; + "Microsoft.Devices.DeviceConnected": IotHubDeviceConnectedEventData; + "Microsoft.Devices.DeviceDisconnected": IotHubDeviceDisconnectedEventData; + "Microsoft.Devices.DeviceTelemetry": IotHubDeviceTelemetryEventData; + "Microsoft.EventGrid.SubscriptionValidationEvent": SubscriptionValidationEventData; + "Microsoft.EventGrid.SubscriptionDeletedEvent": SubscriptionDeletedEventData; + "Microsoft.EventHub.CaptureFileCreated": EventHubCaptureFileCreatedEventData; + "Microsoft.MachineLearningServices.DatasetDriftDetected": MachineLearningServicesDatasetDriftDetectedEventData; + "Microsoft.MachineLearningServices.ModelDeployed": MachineLearningServicesModelDeployedEventData; + "Microsoft.MachineLearningServices.ModelRegistered": MachineLearningServicesModelRegisteredEventData; + "Microsoft.MachineLearningServices.RunCompleted": MachineLearningServicesRunCompletedEventData; + "Microsoft.MachineLearningServices.RunStatusChanged": MachineLearningServicesRunStatusChangedEventData; + "Microsoft.Maps.GeofenceEntered": MapsGeofenceEnteredEventData; + "Microsoft.Maps.GeofenceExited": MapsGeofenceExitedEventData; + "Microsoft.Maps.GeofenceResult": MapsGeofenceResultEventData; + "Microsoft.Media.JobStateChange": MediaJobStateChangeEventData; + "Microsoft.Media.JobOutputStateChange": MediaJobOutputStateChangeEventData; + "Microsoft.Media.JobScheduled": MediaJobScheduledEventData; + "Microsoft.Media.JobProcessing": MediaJobProcessingEventData; + "Microsoft.Media.JobCanceling": MediaJobCancelingEventData; + "Microsoft.Media.JobFinished": MediaJobFinishedEventData; + "Microsoft.Media.JobCanceled": MediaJobCanceledEventData; + "Microsoft.Media.JobErrored": MediaJobErroredEventData; + "Microsoft.Media.JobOutputCanceled": MediaJobOutputCanceledEventData; + "Microsoft.Media.JobOutputCanceling": MediaJobOutputCancelingEventData; + "Microsoft.Media.JobOutputErrored": MediaJobOutputErroredEventData; + "Microsoft.Media.JobOutputFinished": MediaJobOutputFinishedEventData; + "Microsoft.Media.JobOutputProcessing": MediaJobOutputProcessingEventData; + "Microsoft.Media.JobOutputScheduled": MediaJobOutputScheduledEventData; + "Microsoft.Media.JobOutputProgress": MediaJobOutputProgressEventData; + "Microsoft.Media.LiveEventEncoderConnected": MediaLiveEventEncoderConnectedEventData; + "Microsoft.Media.LiveEventConnectionRejected": MediaLiveEventConnectionRejectedEventData; + "Microsoft.Media.LiveEventEncoderDisconnected": MediaLiveEventEncoderDisconnectedEventData; + "Microsoft.Media.LiveEventIncomingStreamReceived": MediaLiveEventIncomingStreamReceivedEventData; + "Microsoft.Media.LiveEventIncomingStreamsOutOfSync": MediaLiveEventIncomingStreamsOutOfSyncEventData; + "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync": MediaLiveEventIncomingVideoStreamsOutOfSyncEventData; + "Microsoft.Media.LiveEventIncomingDataChunkDropped": MediaLiveEventIncomingDataChunkDroppedEventData; + "Microsoft.Media.LiveEventIngestHeartbeat": MediaLiveEventIngestHeartbeatEventData; + "Microsoft.Media.LiveEventTrackDiscontinuityDetected": MediaLiveEventTrackDiscontinuityDetectedEventData; + "Microsoft.Resources.ResourceWriteSuccess": ResourceWriteSuccessEventData; + "Microsoft.Resources.ResourceWriteFailure": ResourceWriteFailureEventData; + "Microsoft.Resources.ResourceWriteCancel": ResourceWriteCancelEventData; + "Microsoft.Resources.ResourceDeleteSuccess": ResourceDeleteSuccessEventData; + "Microsoft.Resources.ResourceDeleteFailure": ResourceDeleteFailureEventData; + "Microsoft.Resources.ResourceDeleteCancel": ResourceDeleteCancelEventData; + "Microsoft.Resources.ResourceActionSuccess": ResourceActionSuccessEventData; + "Microsoft.Resources.ResourceActionFailure": ResourceActionFailureEventData; + "Microsoft.Resources.ResourceActionCancel": ResourceActionCancelEventData; + "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners": ServiceBusActiveMessagesAvailableWithNoListenersEventData; + "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener": ServiceBusDeadletterMessagesAvailableWithNoListenersEventData; + "Microsoft.Storage.BlobCreated": StorageBlobCreatedEventData; + "Microsoft.Storage.BlobDeleted": StorageBlobDeletedEventData; + "Microsoft.Storage.BlobRenamed": StorageBlobRenamedEventData; + "Microsoft.Storage.DirectoryCreated": StorageDirectoryCreatedEventData; + "Microsoft.Storage.DirectoryDeleted": StorageDirectoryDeletedEventData; + "Microsoft.Storage.DirectoryRenamed": StorageDirectoryRenamedEventData; + "Microsoft.Web.AppUpdated": WebAppUpdatedEventData; + "Microsoft.Web.BackupOperationStarted": WebBackupOperationStartedEventData; + "Microsoft.Web.BackupOperationCompleted": WebBackupOperationCompletedEventData; + "Microsoft.Web.BackupOperationFailed": WebBackupOperationFailedEventData; + "Microsoft.Web.RestoreOperationStarted": WebRestoreOperationStartedEventData; + "Microsoft.Web.RestoreOperationCompleted": WebRestoreOperationCompletedEventData; + "Microsoft.Web.RestoreOperationFailed": WebRestoreOperationFailedEventData; + "Microsoft.Web.SlotSwapStarted": WebSlotSwapStartedEventData; + "Microsoft.Web.SlotSwapCompleted": WebSlotSwapCompletedEventData; + "Microsoft.Web.SlotSwapFailed": WebSlotSwapFailedEventData; + "Microsoft.Web.SlotSwapWithPreviewStarted": WebSlotSwapWithPreviewStartedEventData; + "Microsoft.Web.SlotSwapWithPreviewCancelled": WebSlotSwapWithPreviewCancelledEventData; + "Microsoft.Web.AppServicePlanUpdated": WebAppServicePlanUpdatedEventData; +} /** * isCloudEventLike returns "true" when the event is a CloudEvent @@ -25,102 +258,29 @@ function isCloudEventLike( return (o as any).source !== undefined; } -/** isEventHubCaptureFileCreatedEvent returns true if the event is of type "Microsoft.EventHub.CaptureFileCreated" */ -export function isEventHubCaptureFileCreatedEvent( - event: EventGridEvent -): event is EventGridEvent; -/** isEventHubCaptureFileCreatedEvent returns true if the event is of type "Microsoft.EventHub.CaptureFileCreated" */ -export function isEventHubCaptureFileCreatedEvent( - event: CloudEvent -): event is CloudEvent; -export function isEventHubCaptureFileCreatedEvent( - event: EventGridEvent | CloudEvent -): event is - | CloudEvent - | EventGridEvent { - if (isCloudEventLike(event)) { - return event.type === "Microsoft.EventHub.CaptureFileCreated"; - } else { - return event.eventType === "Microsoft.EventHub.CaptureFileCreated"; - } -} - -/** isContainerRegistryImagePushedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ImagePushed" */ -export function isContainerRegistryImagePushedEvent( - event: EventGridEvent -): event is EventGridEvent; -/** isContainerRegistryImagePushedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ImagePushed" */ -export function isContainerRegistryImagePushedEvent( - event: CloudEvent -): event is CloudEvent; -export function isContainerRegistryImagePushedEvent( - event: EventGridEvent | CloudEvent -): event is - | CloudEvent - | EventGridEvent { - if (isCloudEventLike(event)) { - return event.type === "Microsoft.ContainerRegistry.ImagePushed"; - } else { - return event.eventType === "Microsoft.ContainerRegistry.ImagePushed"; - } -} - -/** isContainerRegistryImageDeletedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ImageDeleted" */ -export function isContainerRegistryImageDeletedEvent( - event: EventGridEvent -): event is EventGridEvent; -/** isContainerRegistryImageDeletedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ImageDeleted" */ -export function isContainerRegistryImageDeletedEvent( - event: CloudEvent -): event is CloudEvent; -export function isContainerRegistryImageDeletedEvent( - event: EventGridEvent | CloudEvent -): event is - | CloudEvent - | EventGridEvent { - if (isCloudEventLike(event)) { - return event.type === "Microsoft.ContainerRegistry.ImageDeleted"; - } else { - return event.eventType === "Microsoft.ContainerRegistry.ImageDeleted"; - } -} - -/** isContainerRegistryChartPushedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ChartPushed" */ -export function isContainerRegistryChartPushedEvent( - event: EventGridEvent -): event is EventGridEvent; -/** isContainerRegistryChartPushedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ChartPushed" */ -export function isContainerRegistryChartPushedEvent( - event: CloudEvent -): event is CloudEvent; -export function isContainerRegistryChartPushedEvent( - event: EventGridEvent | CloudEvent -): event is - | CloudEvent - | EventGridEvent { - if (isCloudEventLike(event)) { - return event.type === "Microsoft.ContainerRegistry.ChartPushed"; - } else { - return event.eventType === "Microsoft.ContainerRegistry.ChartPushed"; - } -} - -/** isContainerRegistryChartDeletedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ChartDeleted" */ -export function isContainerRegistryChartDeletedEvent( +/** + * TODO(matell): Document this. + */ +export function isSystemEvent( + eventType: T, event: EventGridEvent -): event is EventGridEvent; -/** isContainerRegistryChartDeletedEvent returns true if the event is of type "Microsoft.ContainerRegistry.ChartDeleted" */ -export function isContainerRegistryChartDeletedEvent( +): event is EventGridEvent; +/** + * TODO(matell): Document this. + */ +export function isSystemEvent( + eventType: T, event: CloudEvent -): event is CloudEvent; -export function isContainerRegistryChartDeletedEvent( +): event is CloudEvent; +export function isSystemEvent( + eventType: T, event: EventGridEvent | CloudEvent ): event is - | CloudEvent - | EventGridEvent { + | EventGridEvent + | CloudEvent { if (isCloudEventLike(event)) { - return event.type === "Microsoft.ContainerRegistry.ChartDeleted"; + return event.type === eventType; } else { - return event.eventType === "Microsoft.ContainerRegistry.ChartDeleted"; + return event.eventType === eventType; } } From d36e4f77d093505e9933ca8bfd0b1e4dfbb802ea Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Fri, 24 Jul 2020 17:32:31 -0700 Subject: [PATCH 17/34] [EventGrid] Improve CloudEvent handling This change does a few things: 1. Correctly handles binary data for a cloud event. The strategy here is that when the data value in the event is an `instanceof` `Uint8Array`, the convinece layer does a base64 encoding of the data and sets the `data_base64` property on the underlying model we send to the generated client. 2. When decoding, we do the opposite transform and set data in the returned model to be an instace of UInt8Array. 3. We now validate that the names of extension attributes are valid according to the cloud events spec and that the names of known attributes are not used as extension attributes. As part of this work a few more tests were written to confirm some of the stuff that we do when encoding events to send over the wire (like the above transformations, but also setting a default id and date). --- sdk/eventgrid/eventgrid/package.json | 3 +- sdk/eventgrid/eventgrid/src/base64.browser.ts | 30 +++ sdk/eventgrid/eventgrid/src/base64.ts | 21 +++ sdk/eventgrid/eventgrid/src/consumer.ts | 24 +-- .../eventgrid/src/eventGridClient.ts | 112 ++++++++---- sdk/eventgrid/eventgrid/src/models.ts | 15 ++ sdk/eventgrid/eventgrid/src/predicates.ts | 2 + sdk/eventgrid/eventgrid/test/consumer.spec.ts | 23 +++ .../eventgrid/test/eventGridClient.spec.ts | 173 +++++++++++++++++- 9 files changed, 356 insertions(+), 47 deletions(-) create mode 100644 sdk/eventgrid/eventgrid/src/base64.browser.ts create mode 100644 sdk/eventgrid/eventgrid/src/base64.ts diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json index 55682e950e9e..693032e9c7d3 100644 --- a/sdk/eventgrid/eventgrid/package.json +++ b/sdk/eventgrid/eventgrid/package.json @@ -44,7 +44,8 @@ }, "browser": { "./dist-esm/src/utils/hmac.js": "./dist-esm/src/utils/hmac.browser.js", - "./dist-esm/src/utils/atob.js": "./dist-esm/src/utils/atob.browser.js" + "./dist-esm/src/utils/atob.js": "./dist-esm/src/utils/atob.browser.js", + "./dist-esm/src/base64.js": "./dist-esm/src/base64.browser.js" }, "scripts": { "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", diff --git a/sdk/eventgrid/eventgrid/src/base64.browser.ts b/sdk/eventgrid/eventgrid/src/base64.browser.ts new file mode 100644 index 000000000000..52370e46e730 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/base64.browser.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/// + +/** + * base64Encode encodes a byte array as a base64 string. + * + * @param value the byte array to be encoded in base64 + */ +export function base64Encode(value: Uint8Array): string { + let str = ""; + for (let i = 0; i < value.length; i++) { + str += String.fromCharCode(value[i]); + } + return btoa(str); +} + +/** + * base64Decode decodes a valid base64 encoded string into a byte array. + * + * @param value the valid base64 string to be decoded + */ +export function base64Decode(value: string): Uint8Array { + const byteString = atob(value); + const byteArray = new Uint8Array(byteString.length); + for (let i = 0; i < byteString.length; i++) { + byteArray[i] = byteString.charCodeAt(i); + } + return byteArray; +} diff --git a/sdk/eventgrid/eventgrid/src/base64.ts b/sdk/eventgrid/eventgrid/src/base64.ts new file mode 100644 index 000000000000..91d29a087de6 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/base64.ts @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * base64Encode encodes a byte array as a base64 string. + * + * @param value the byte array to be encoded in base64 + */ +export function base64Encode(value: Uint8Array): string { + const bufferValue = value instanceof Buffer ? value : Buffer.from(value.buffer); + return bufferValue.toString("base64"); +} + +/** + * base64Decode decodes a valid base64 encoded string into a byte array. + * + * @param value the valid base64 string to be decoded + */ +export function base64Decode(value: string): Uint8Array { + return Buffer.from(value, "base64"); +} diff --git a/sdk/eventgrid/eventgrid/src/consumer.ts b/sdk/eventgrid/eventgrid/src/consumer.ts index e9e099982676..7eb18d56ce31 100644 --- a/sdk/eventgrid/eventgrid/src/consumer.ts +++ b/sdk/eventgrid/eventgrid/src/consumer.ts @@ -3,13 +3,19 @@ import { Serializer } from "@azure/core-http"; import { CloudEvent as WireCloudEvent } from "./generated/models"; -import { CustomEventDataDeserializer, CloudEvent, EventGridEvent } from "./models"; +import { + CustomEventDataDeserializer, + CloudEvent, + EventGridEvent, + cloudEventReservedPropertyNames +} from "./models"; import { EventGridEvent as EventGridEventMapper, CloudEvent as CloudEventMapper } from "./generated/models/mappers"; import { parseAndWrap, validateEventGridEvent, validateCloudEventEvent } from "./util"; import { systemDeserializers } from "./systemEventDecoders"; +import { base64Decode } from "./base64"; const serializer = new Serializer(); @@ -142,7 +148,7 @@ export class EventGridConsumer { throw new TypeError("event data_base64 property should be a string"); } - modelEvent.data = Buffer.from(deserialized.dataBase64, "base64"); + modelEvent.data = base64Decode(deserialized.dataBase64); } // If a decoder is registered, apply it to the data. @@ -154,16 +160,12 @@ export class EventGridConsumer { // Build the "extensionsAttributes" property bag by removing all known top level properties. const extensionAttributes = { ...deserialized }; - delete extensionAttributes.specversion; - delete extensionAttributes.id; - delete extensionAttributes.source; - delete extensionAttributes.type; - delete extensionAttributes.datacontenttype; - delete extensionAttributes.dataschema; - delete extensionAttributes.subject; - delete extensionAttributes.time; - delete extensionAttributes.data; + for (const propName of cloudEventReservedPropertyNames) { + delete extensionAttributes[propName]; + } + delete extensionAttributes.dataBase64; + // If any properties remain, copy them to the model. if (Object.keys(extensionAttributes).length > 0) { modelEvent.extensionAttributes = extensionAttributes; } diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts index f68aff7daf59..9cef4401e00c 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -14,8 +14,13 @@ import { v4 as uuidv4 } from "uuid"; import { createEventGridCredentialPolicy } from "./eventGridAuthenticationPolicy"; import { SignatureCredential } from "./sharedAccessSignitureCredential"; import { SDK_VERSION } from "./constants"; +import { CloudEvent, EventGridEvent, cloudEventReservedPropertyNames } from "./models"; +import { base64Encode } from "./base64"; import { GeneratedClient } from "./generated/generatedClient"; -import { CloudEvent, EventGridEvent } from "./models"; +import { + CloudEvent as CloudEventWireModel, + EventGridEvent as EventGridEventWireModel +} from "./generated/models"; /** * Options for the Event Grid Client. @@ -106,18 +111,11 @@ export class EventGridPublisherClient { * @param message One or more events to publish */ sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise { - const toPublish = (events || []).map((evt) => { - return { - eventType: evt.eventType, - eventTime: evt.eventTime ?? new Date(), - id: evt.id ?? uuidv4(), - subject: evt.subject, - topic: evt.topic, - data: evt.data, - dataVersion: evt.dataVersion - }; - }); - return this.client.publishEvents(this.endpointUrl, toPublish, options); + return this.client.publishEvents( + this.endpointUrl, + (events || []).map(convertEventGridEventToModelType), + options + ); } /** @@ -125,28 +123,15 @@ export class EventGridPublisherClient { * * @param message One or more events to publish */ - sendCloudEvents( events: CloudEvent[], options?: SendCloudEventsOptions ): Promise { - const toPublish = (events || []).map((evt) => { - // TODO(matell): If data is of type `Buffer` or other binary data we should Base64 encoded the data and set - // `data_base64` instead. We also need to validate that `datacontenttype` is set in this case. - return { - specversion: "1.0", - type: evt.type, - source: evt.source, - id: evt.id ?? uuidv4(), - time: evt.time ?? new Date(), - subject: evt.subject, - dataschema: evt.dataschema, - datacontenttype: evt.datacontenttype ?? "application/json", - ...(evt.extensionAttributes ?? []) - }; - }); - - return this.client.publishCloudEventEvents(this.endpointUrl, toPublish, options); + return this.client.publishCloudEventEvents( + this.endpointUrl, + (events || []).map(convertCloudEventToModelType), + options + ); } /** @@ -158,6 +143,69 @@ export class EventGridPublisherClient { events: Record[], options?: SendCustomSchemaEventsOptions ): Promise { - return this.client.publishCustomEventEvents(this.endpointUrl, events, options); + return this.client.publishCustomEventEvents(this.endpointUrl, events || [], options); } } + +/** + * @internal + */ +export function convertEventGridEventToModelType( + event: EventGridEvent +): EventGridEventWireModel { + return { + eventType: event.eventType, + eventTime: event.eventTime ?? new Date(), + id: event.id ?? uuidv4(), + subject: event.subject, + topic: event.topic, + data: event.data, + dataVersion: event.dataVersion + }; +} + +/** + * @internal + */ +export function convertCloudEventToModelType(event: CloudEvent): CloudEventWireModel { + if (event.extensionAttributes) { + for (const propName in event.extensionAttributes) { + // Per the cloud events spec: "CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z') or digits ('0' to '9') from the ASCII character set" + // they also can not match an existing defined property name. + + if ( + !/^[a-z0-9]*$/.test(propName) || + cloudEventReservedPropertyNames.indexOf(propName) !== -1 + ) { + throw new Error(`invalid extension attribute name: ${propName}`); + } + } + } + + const converted: CloudEventWireModel = { + specversion: "1.0", + type: event.type, + source: event.source, + id: event.id ?? uuidv4(), + time: event.time ?? new Date(), + subject: event.subject, + dataschema: event.dataschema, + ...(event.extensionAttributes ?? []) + }; + + if (event.data instanceof Uint8Array) { + if (!event.datacontenttype) { + throw new Error( + "a data content type must be provided when sending an event with binary data" + ); + } + + converted.datacontenttype = event.datacontenttype; + converted.dataBase64 = base64Encode(event.data); + } else { + converted.datacontenttype = event.datacontenttype ?? "application/json"; + converted.data = event.data; + } + + return converted; +} diff --git a/sdk/eventgrid/eventgrid/src/models.ts b/sdk/eventgrid/eventgrid/src/models.ts index 08f8fa12fcda..3ba7ffecf424 100644 --- a/sdk/eventgrid/eventgrid/src/models.ts +++ b/sdk/eventgrid/eventgrid/src/models.ts @@ -79,6 +79,21 @@ export interface CloudEvent { extensionAttributes?: Record; } +/** + * Property names defined by the CloudEvents 1.0 specification, these may not be reused as the names of extension properties. + */ +export const cloudEventReservedPropertyNames = [ + "specversion", + "id", + "source", + "type", + "datacontenttype", + "dataschema", + "subject", + "time", + "data" +]; + /** * A function which provides custom logic to be used when decoding events. */ diff --git a/sdk/eventgrid/eventgrid/src/predicates.ts b/sdk/eventgrid/eventgrid/src/predicates.ts index e5490ff2166c..d0e01b480344 100644 --- a/sdk/eventgrid/eventgrid/src/predicates.ts +++ b/sdk/eventgrid/eventgrid/src/predicates.ts @@ -265,6 +265,7 @@ export function isSystemEvent( eventType: T, event: EventGridEvent ): event is EventGridEvent; + /** * TODO(matell): Document this. */ @@ -272,6 +273,7 @@ export function isSystemEvent( eventType: T, event: CloudEvent ): event is CloudEvent; + export function isSystemEvent( eventType: T, event: EventGridEvent | CloudEvent diff --git a/sdk/eventgrid/eventgrid/test/consumer.spec.ts b/sdk/eventgrid/eventgrid/test/consumer.spec.ts index 0609f9db5c8b..ad21c9785a67 100644 --- a/sdk/eventgrid/eventgrid/test/consumer.spec.ts +++ b/sdk/eventgrid/eventgrid/test/consumer.spec.ts @@ -151,6 +151,29 @@ describe("EventGridConsumer", function() { /event is not in the Cloud Event 1.0 schema/ ); }); + + it("decodes byte arrays for cloud events as expected", async () => { + const events = await consumer.deserializeCloudEvents({ + type: "Azure.Sdk.TestEvent", + id: "a-unique-id", + source: "/azure/sdk/test", + specversion: "1.0", + data_base64: "AAECAwQFBgcICQ==" /* Base 64 encoding of: 0x01 0x02 ... 0x09 */ + }); + + assert.strictEqual(events.length, 1); + + const data = events[0].data; + + assert.instanceOf(data, Uint8Array); + assert.strictEqual((data as Uint8Array).length, 10); + + for (let i = 0; i < 10; i++) { + assert.strictEqual((data as Uint8Array)[i], i); + } + + assert.isUndefined((data as any)["data_base64"]); + }); }); }); diff --git a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts index 47d4e41bea73..9a153547c1e6 100644 --- a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts +++ b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts @@ -10,6 +10,11 @@ import { createRecordedClient, testEnv } from "./utils/recordedClient"; import { AzureKeyCredential, EventGridPublisherClient } from "../src/index"; +import { + convertEventGridEventToModelType, + convertCloudEventToModelType +} from "../src/eventGridClient"; + describe("EventGridPublisherClient", function() { let recorder: Recorder; let client: EventGridPublisherClient; @@ -129,9 +134,6 @@ describe("EventGridPublisherClient", function() { assert.equal(res._response.status, 200); }); - - // TODO(matell): Write a test that ensures any cloud event extensions are serialized with - // the event itself. }); describe("#sendCustomSchemaEvents", function() { @@ -186,3 +188,168 @@ describe("EventGridPublisherClient", function() { }); }); }); + +describe("convertEventGridEventToModelType", function() { + it("sets a default ID if one is not provided", () => { + const convertedEvent = convertEventGridEventToModelType({ + dataVersion: "1.0", + eventType: "Azure.Sdk.TestEvent", + subject: "Test Event", + data: { hello: "world " } + }); + + assert.isDefined(convertedEvent.id); + }); + + it("sets a default event time if one is not provided", () => { + const convertedEvent = convertEventGridEventToModelType({ + dataVersion: "1.0", + eventType: "Azure.Sdk.TestEvent", + subject: "Test Event", + data: { hello: "world " } + }); + + assert.isDefined(convertedEvent.eventTime); + }); + + it("does not change set values", () => { + const time = new Date(); + const id = "272871ba-2496-4750-9a90-bedd1ea10191"; + + const convertedEvent = convertEventGridEventToModelType({ + id: id, + eventTime: time, + dataVersion: "1.0", + eventType: "Azure.Sdk.TestEvent", + subject: "Test Event", + data: { hello: "world " } + }); + + assert.strictEqual(convertedEvent.id, id); + assert.strictEqual(convertedEvent.eventTime, time); + }); +}); + +describe("convertCloudEventToModelType", function() { + it("sets a default ID if one is not provided", () => { + const convertedEvent = convertCloudEventToModelType({ + source: "/azure/sdk/tests", + type: "Azure.Sdk.TestEvent" + }); + + assert.isDefined(convertedEvent.id); + }); + + it("sets a default event time if one is not provided", () => { + const convertedEvent = convertCloudEventToModelType({ + source: "/azure/sdk/tests", + type: "Azure.Sdk.TestEvent" + }); + + assert.isDefined(convertedEvent.time); + }); + + it("does not change set values", () => { + const time = new Date(); + const id = "272871ba-2496-4750-9a90-bedd1ea10191"; + + const convertedEvent = convertCloudEventToModelType({ + id: id, + time: time, + source: "/azure/sdk/tests", + type: "Azure.Sdk.TestEvent" + }); + + assert.strictEqual(convertedEvent.id, id); + assert.strictEqual(convertedEvent.time, time); + }); + + it("promotes extension attributes", () => { + const traceparent = "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"; + const tracestate = + "rojo=00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01,congo=lZWRzIHRoNhcm5hbCBwbGVhc3VyZS4"; + + const convertedEvent = convertCloudEventToModelType({ + source: "/azure/sdk/tests", + type: "Azure.Sdk.TestEvent", + extensionAttributes: { + traceparent, + tracestate + } + }); + + // When converted to a model type to send over the wire, the extension attributes are promoted to be + // properties on the envelope itself. + assert.equal(convertedEvent["traceparent"], traceparent); + assert.equal(convertedEvent["tracestate"], tracestate); + }); + + it("base64 encodes binary data", () => { + const binaryData = new Uint8Array(10); + for (let i = 0; i < binaryData.length; i++) { + binaryData[i] = i; + } + + const convertedEvent = convertCloudEventToModelType({ + source: "/azure/sdk/tests", + type: "Azure.Sdk.TestEvent", + data: binaryData, + datacontenttype: "application/binary" + }); + + assert.isUndefined(convertedEvent.data); + assert.strictEqual(convertedEvent.dataBase64, "AAECAwQFBgcICQ=="); + }); + + it("fails if data content type is missing for binary data", () => { + const binaryData = new Uint8Array(10); + for (let i = 0; i < binaryData.length; i++) { + binaryData[i] = i; + } + + assert.throws(() => { + convertCloudEventToModelType({ + source: "/azure/sdk/tests", + type: "Azure.Sdk.TestEvent", + data: binaryData + }); + }, /data content type/); + }); + + it("fails if extenion attributes are invalid", () => { + const binaryData = new Uint8Array(10); + for (let i = 0; i < binaryData.length; i++) { + binaryData[i] = i; + } + + assert.throws(() => { + convertCloudEventToModelType({ + source: "/azure/sdk/tests", + type: "Azure.Sdk.TestEvent", + extensionAttributes: { + source: "this-is-not-allowed" + } + }); + }, /invalid extension attribute name: source/); + + assert.throws(() => { + convertCloudEventToModelType({ + source: "/azure/sdk/tests", + type: "Azure.Sdk.TestEvent", + extensionAttributes: { + MiXedCasE: "this-is-not-allowed" + } + }); + }, /invalid extension attribute name: MiXedCasE/); + + assert.throws(() => { + convertCloudEventToModelType({ + source: "/azure/sdk/tests", + type: "Azure.Sdk.TestEvent", + extensionAttributes: { + data_base64: "this-is-not-allowed" + } + }); + }, /invalid extension attribute name: data_base64/); + }); +}); From 985386089cb501d0d3d7e8639d43ff8683ed228a Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Mon, 27 Jul 2020 14:34:13 -0700 Subject: [PATCH 18/34] [EventGrid] Regenerate Recordings --- .../recording_sends_a_single_event.json | 10 +++++----- .../recording_sends_multiple_events.json | 14 +++++++------- .../recording_sends_a_single_event.json | 4 ++-- .../recording_sends_multiple_events.json | 4 ++-- .../recording_sends_a_single_event.json | 10 +++++----- .../recording_sends_multiple_events.json | 14 +++++++------- .../recording_sends_a_single_event.js | 8 ++++---- .../recording_sends_multiple_events.js | 8 ++++---- .../recording_sends_a_single_event.js | 4 ++-- .../recording_sends_multiple_events.js | 4 ++-- .../recording_sends_a_single_event.js | 8 ++++---- .../recording_sends_multiple_events.js | 8 ++++---- 12 files changed, 48 insertions(+), 48 deletions(-) diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.json index 46f8a280c9ba..e06cfedfde60 100644 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.json +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.json @@ -6,26 +6,26 @@ "query": { "api-version": "2018-01-01" }, - "requestBody": "[{\"id\":\"cloudSingleEventId159545158332308816\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-22T20:59:43.323Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\"}]", + "requestBody": "[{\"id\":\"cloudSingleEventId159588374669809673\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"data\":{\"hello\":\"world\"},\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-27T21:02:26.698Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\"}]", "status": 200, "response": "", "responseHeaders": { "api-supported-versions": "2018-01-01", "content-length": "0", - "date": "Wed, 22 Jul 2020 20:59:43 GMT", + "date": "Mon, 27 Jul 2020 21:02:26 GMT", "server": "Microsoft-HTTPAPI/2.0", "status": "200", "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "f6bede6a-c737-4c25-9380-1a50f70f8f1d" + "x-ms-request-id": "46a799c7-f453-4894-9b7e-e6fd93259622" } } ], "uniqueTestInfo": { "uniqueName": { - "cloudSingleEventId": "cloudSingleEventId159545158332308816" + "cloudSingleEventId": "cloudSingleEventId159588374669809673" }, "newDate": { - "cloudSingleEventDate": "2020-07-22T20:59:43.323Z" + "cloudSingleEventDate": "2020-07-27T21:02:26.698Z" } }, "hash": "7fe25ee020ac364dae32ce81a81c7c3f" diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.json index 8b7a7533dd45..d4491d390ec3 100644 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.json +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.json @@ -6,28 +6,28 @@ "query": { "api-version": "2018-01-01" }, - "requestBody": "[{\"id\":\"cloudMultiEventId1159545158342200757\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-22T20:59:43.422Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"Multiple 1\"},{\"id\":\"cloudMultiEventId2159545158342208317\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-22T20:59:43.422Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"Multiple 2\"}]", + "requestBody": "[{\"id\":\"cloudMultiEventId1159588374680705635\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"data\":{\"hello\":\"world\"},\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-27T21:02:26.807Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"Multiple 1\"},{\"id\":\"cloudMultiEventId2159588374680700679\",\"source\":\"/earth/unitedstates/washington/kirkland/finnhill\",\"data\":{\"hello\":\"world\"},\"type\":\"Azure.Sdk.TestEvent1\",\"time\":\"2020-07-27T21:02:26.807Z\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"Multiple 2\"}]", "status": 200, "response": "", "responseHeaders": { "api-supported-versions": "2018-01-01", "content-length": "0", - "date": "Wed, 22 Jul 2020 20:59:43 GMT", + "date": "Mon, 27 Jul 2020 21:02:26 GMT", "server": "Microsoft-HTTPAPI/2.0", "status": "200", "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "2f227ab0-ae70-4ac9-a9d1-fd0914c991bb" + "x-ms-request-id": "5883a20b-ce78-4928-afb8-bde068f61fb5" } } ], "uniqueTestInfo": { "uniqueName": { - "cloudMultiEventId1": "cloudMultiEventId1159545158342200757", - "cloudMultiEventId2": "cloudMultiEventId2159545158342208317" + "cloudMultiEventId1": "cloudMultiEventId1159588374680705635", + "cloudMultiEventId2": "cloudMultiEventId2159588374680700679" }, "newDate": { - "cloudMultiEventDate1": "2020-07-22T20:59:43.422Z", - "cloudMultiEventDate2": "2020-07-22T20:59:43.422Z" + "cloudMultiEventDate1": "2020-07-27T21:02:26.807Z", + "cloudMultiEventDate2": "2020-07-27T21:02:26.807Z" } }, "hash": "799392d36931d99dc2c24d3db67fcb0b" diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.json index 08f2ee161cba..4e1ad0aed8ec 100644 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.json +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.json @@ -12,11 +12,11 @@ "responseHeaders": { "api-supported-versions": "2018-01-01", "content-length": "0", - "date": "Wed, 22 Jul 2020 20:59:44 GMT", + "date": "Mon, 27 Jul 2020 21:02:26 GMT", "server": "Microsoft-HTTPAPI/2.0", "status": "200", "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "8c7b662e-b4aa-4bb9-a932-d97a40306a2d" + "x-ms-request-id": "e9595ef6-2387-4362-9573-9a2189e74b7d" } } ], diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.json index 2c7b8377033e..bfcb02399eb2 100644 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.json +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.json @@ -12,11 +12,11 @@ "responseHeaders": { "api-supported-versions": "2018-01-01", "content-length": "0", - "date": "Wed, 22 Jul 2020 20:59:44 GMT", + "date": "Mon, 27 Jul 2020 21:02:26 GMT", "server": "Microsoft-HTTPAPI/2.0", "status": "200", "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "c0ac8526-c3a6-4c10-86a7-24bb9dde79eb" + "x-ms-request-id": "a2b97d35-f1aa-4033-9886-e6907c7d6769" } } ], diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_a_single_event.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_a_single_event.json index 7bf590587c4a..cf64165efb69 100644 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_a_single_event.json +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_a_single_event.json @@ -6,26 +6,26 @@ "query": { "api-version": "2018-01-01" }, - "requestBody": "[{\"id\":\"singleEventId159545158072101217\",\"subject\":\"Single 1\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-22T20:59:40.721Z\",\"dataVersion\":\"1.0\"}]", + "requestBody": "[{\"id\":\"singleEventId159588374414604202\",\"subject\":\"Single 1\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-27T21:02:24.145Z\",\"dataVersion\":\"1.0\"}]", "status": 200, "response": "", "responseHeaders": { "api-supported-versions": "2018-01-01", "content-length": "0", - "date": "Wed, 22 Jul 2020 20:59:43 GMT", + "date": "Mon, 27 Jul 2020 21:02:26 GMT", "server": "Microsoft-HTTPAPI/2.0", "status": "200", "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "c8da1009-5443-4114-bf7b-a6fd1ee5c76d" + "x-ms-request-id": "6b4ec1fb-b123-4406-ba01-4fd7c70f4ac0" } } ], "uniqueTestInfo": { "uniqueName": { - "singleEventId": "singleEventId159545158072101217" + "singleEventId": "singleEventId159588374414604202" }, "newDate": { - "singleEventDate": "2020-07-22T20:59:40.721Z" + "singleEventDate": "2020-07-27T21:02:24.145Z" } }, "hash": "9b44e18369316233af4458904ca8ae09" diff --git a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_multiple_events.json b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_multiple_events.json index 4bcd0f09c0d3..a05ed1e4160b 100644 --- a/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_multiple_events.json +++ b/sdk/eventgrid/eventgrid/recordings/browsers/eventgridpublisherclient_sendevents/recording_sends_multiple_events.json @@ -6,28 +6,28 @@ "query": { "api-version": "2018-01-01" }, - "requestBody": "[{\"id\":\"multiEventId1159545158328801784\",\"subject\":\"Multiple 1\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-22T20:59:43.287Z\",\"dataVersion\":\"1.0\"},{\"id\":\"multiEventId2159545158328801964\",\"subject\":\"Multiple 2\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-22T20:59:43.288Z\",\"dataVersion\":\"1.0\"}]", + "requestBody": "[{\"id\":\"multiEventId1159588374666206734\",\"subject\":\"Multiple 1\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-27T21:02:26.662Z\",\"dataVersion\":\"1.0\"},{\"id\":\"multiEventId2159588374666206405\",\"subject\":\"Multiple 2\",\"data\":{\"hello\":\"world\"},\"eventType\":\"Azure.Sdk.TestEvent1\",\"eventTime\":\"2020-07-27T21:02:26.662Z\",\"dataVersion\":\"1.0\"}]", "status": 200, "response": "", "responseHeaders": { "api-supported-versions": "2018-01-01", "content-length": "0", - "date": "Wed, 22 Jul 2020 20:59:43 GMT", + "date": "Mon, 27 Jul 2020 21:02:26 GMT", "server": "Microsoft-HTTPAPI/2.0", "status": "200", "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "aef68b3b-c708-408e-831b-e08e905c58a2" + "x-ms-request-id": "e8eb4406-e3e9-4f10-9f25-31ebd5c4e48b" } } ], "uniqueTestInfo": { "uniqueName": { - "multiEventId1": "multiEventId1159545158328801784", - "multiEventId2": "multiEventId2159545158328801964" + "multiEventId1": "multiEventId1159588374666206734", + "multiEventId2": "multiEventId2159588374666206405" }, "newDate": { - "multiEventDate1": "2020-07-22T20:59:43.287Z", - "multiEventDate2": "2020-07-22T20:59:43.288Z" + "multiEventDate1": "2020-07-27T21:02:26.662Z", + "multiEventDate2": "2020-07-27T21:02:26.662Z" } }, "hash": "a1eefb69b1513dc523f50ee66055787d" diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.js index 4047c2d58fb4..fcbb53e92b2f 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_a_single_event.js @@ -2,10 +2,10 @@ let nock = require('nock'); module.exports.hash = "b15b1edb6fd215ff27f66c70053afbb8"; -module.exports.testInfo = {"uniqueName":{"cloudSingleEventId":"cloudSingleEventId159545157148202250"},"newDate":{"cloudSingleEventDate":"2020-07-22T20:59:31.482Z"}} +module.exports.testInfo = {"uniqueName":{"cloudSingleEventId":"cloudSingleEventId159588373652209687"},"newDate":{"cloudSingleEventDate":"2020-07-27T21:02:16.522Z"}} nock('https://endpoint', {"encodedQueryParams":true}) - .post('/api/events', [{"id":"cloudSingleEventId159545157148202250","source":"/earth/unitedstates/washington/kirkland/finnhill","type":"Azure.Sdk.TestEvent1","time":"2020-07-22T20:59:31.482Z","specversion":"1.0","datacontenttype":"application/json"}]) + .post('/api/events', [{"id":"cloudSingleEventId159588373652209687","source":"/earth/unitedstates/washington/kirkland/finnhill","data":{"hello":"world"},"type":"Azure.Sdk.TestEvent1","time":"2020-07-27T21:02:16.522Z","specversion":"1.0","datacontenttype":"application/json"}]) .query(true) .reply(200, "", [ 'Content-Length', @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - '304512a3-c189-4094-8e12-55d8727d1f80', + '05f88f8f-bd50-41d7-b56c-394c1eeebe1f', 'Date', - 'Wed, 22 Jul 2020 20:59:32 GMT' + 'Mon, 27 Jul 2020 21:02:16 GMT' ]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.js index 8d2443b675ff..2deaf6208971 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcloudeventschemaevents/recording_sends_multiple_events.js @@ -2,10 +2,10 @@ let nock = require('nock'); module.exports.hash = "cefc29910fbb6c53981faf8430a3521b"; -module.exports.testInfo = {"uniqueName":{"cloudMultiEventId1":"cloudMultiEventId1159545157162605520","cloudMultiEventId2":"cloudMultiEventId2159545157162709419"},"newDate":{"cloudMultiEventDate1":"2020-07-22T20:59:31.627Z","cloudMultiEventDate2":"2020-07-22T20:59:31.627Z"}} +module.exports.testInfo = {"uniqueName":{"cloudMultiEventId1":"cloudMultiEventId1159588373674007628","cloudMultiEventId2":"cloudMultiEventId2159588373674005416"},"newDate":{"cloudMultiEventDate1":"2020-07-27T21:02:16.740Z","cloudMultiEventDate2":"2020-07-27T21:02:16.740Z"}} nock('https://endpoint', {"encodedQueryParams":true}) - .post('/api/events', [{"id":"cloudMultiEventId1159545157162605520","source":"/earth/unitedstates/washington/kirkland/finnhill","type":"Azure.Sdk.TestEvent1","time":"2020-07-22T20:59:31.627Z","specversion":"1.0","datacontenttype":"application/json","subject":"Multiple 1"},{"id":"cloudMultiEventId2159545157162709419","source":"/earth/unitedstates/washington/kirkland/finnhill","type":"Azure.Sdk.TestEvent1","time":"2020-07-22T20:59:31.627Z","specversion":"1.0","datacontenttype":"application/json","subject":"Multiple 2"}]) + .post('/api/events', [{"id":"cloudMultiEventId1159588373674007628","source":"/earth/unitedstates/washington/kirkland/finnhill","data":{"hello":"world"},"type":"Azure.Sdk.TestEvent1","time":"2020-07-27T21:02:16.740Z","specversion":"1.0","datacontenttype":"application/json","subject":"Multiple 1"},{"id":"cloudMultiEventId2159588373674005416","source":"/earth/unitedstates/washington/kirkland/finnhill","data":{"hello":"world"},"type":"Azure.Sdk.TestEvent1","time":"2020-07-27T21:02:16.740Z","specversion":"1.0","datacontenttype":"application/json","subject":"Multiple 2"}]) .query(true) .reply(200, "", [ 'Content-Length', @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - '5615af32-6bb1-46f4-baa9-ab4034a4b6ae', + '9ff2a9d4-8089-4ac2-9c2d-1d184abf00e5', 'Date', - 'Wed, 22 Jul 2020 20:59:32 GMT' + 'Mon, 27 Jul 2020 21:02:16 GMT' ]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.js index 35cd1c93e149..a8611e922173 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_a_single_event.js @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - '04296baf-73a5-4e9a-a17c-14d9ee1235cb', + 'fbdc8574-3c20-4bc9-af6b-0d5e454611f6', 'Date', - 'Wed, 22 Jul 2020 20:59:31 GMT' + 'Mon, 27 Jul 2020 21:02:16 GMT' ]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.js index ceb5c05bd1f1..1735dfe3ec3f 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendcustomschemaevents/recording_sends_multiple_events.js @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - '661e2301-f378-441d-878a-a8e7fcfd5be3', + '3461b247-63cd-4940-8cfd-61ada2073c7f', 'Date', - 'Wed, 22 Jul 2020 20:59:31 GMT' + 'Mon, 27 Jul 2020 21:02:17 GMT' ]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_a_single_event.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_a_single_event.js index 58a8702b2d70..ffd251f0e8ea 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_a_single_event.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_a_single_event.js @@ -2,10 +2,10 @@ let nock = require('nock'); module.exports.hash = "93ae44857b9e0329bc4ac9a07e444214"; -module.exports.testInfo = {"uniqueName":{"singleEventId":"singleEventId159545157109200706"},"newDate":{"singleEventDate":"2020-07-22T20:59:31.092Z"}} +module.exports.testInfo = {"uniqueName":{"singleEventId":"singleEventId159588373611301458"},"newDate":{"singleEventDate":"2020-07-27T21:02:16.113Z"}} nock('https://endpoint', {"encodedQueryParams":true}) - .post('/api/events', [{"id":"singleEventId159545157109200706","subject":"Single 1","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-22T20:59:31.092Z","dataVersion":"1.0"}]) + .post('/api/events', [{"id":"singleEventId159588373611301458","subject":"Single 1","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-27T21:02:16.113Z","dataVersion":"1.0"}]) .query(true) .reply(200, "", [ 'Content-Length', @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - '2a44e61e-4e08-4138-a58e-4fc9f08e3fb0', + 'ef70f7ba-868c-4cee-8c9b-e27e2c01409b', 'Date', - 'Wed, 22 Jul 2020 20:59:31 GMT' + 'Mon, 27 Jul 2020 21:02:16 GMT' ]); diff --git a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_multiple_events.js b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_multiple_events.js index 78039bd1bc96..7f892aba5190 100644 --- a/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_multiple_events.js +++ b/sdk/eventgrid/eventgrid/recordings/node/eventgridpublisherclient_sendevents/recording_sends_multiple_events.js @@ -2,10 +2,10 @@ let nock = require('nock'); module.exports.hash = "b8c32c266a21a9129c07d237cc8e3d2b"; -module.exports.testInfo = {"uniqueName":{"multiEventId1":"multiEventId1159545157139309466","multiEventId2":"multiEventId2159545157139401284"},"newDate":{"multiEventDate1":"2020-07-22T20:59:31.393Z","multiEventDate2":"2020-07-22T20:59:31.394Z"}} +module.exports.testInfo = {"uniqueName":{"multiEventId1":"multiEventId1159588373643900701","multiEventId2":"multiEventId2159588373643900216"},"newDate":{"multiEventDate1":"2020-07-27T21:02:16.439Z","multiEventDate2":"2020-07-27T21:02:16.439Z"}} nock('https://endpoint', {"encodedQueryParams":true}) - .post('/api/events', [{"id":"multiEventId1159545157139309466","subject":"Multiple 1","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-22T20:59:31.393Z","dataVersion":"1.0"},{"id":"multiEventId2159545157139401284","subject":"Multiple 2","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-22T20:59:31.394Z","dataVersion":"1.0"}]) + .post('/api/events', [{"id":"multiEventId1159588373643900701","subject":"Multiple 1","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-27T21:02:16.439Z","dataVersion":"1.0"},{"id":"multiEventId2159588373643900216","subject":"Multiple 2","data":{"hello":"world"},"eventType":"Azure.Sdk.TestEvent1","eventTime":"2020-07-27T21:02:16.439Z","dataVersion":"1.0"}]) .query(true) .reply(200, "", [ 'Content-Length', @@ -17,7 +17,7 @@ nock('https://endpoint', {"encodedQueryParams":true}) 'api-supported-versions', '2018-01-01', 'x-ms-request-id', - 'b255ebc9-6ad6-48b7-8665-aaa1e6e9d628', + '2ea7f5e7-f8cf-4051-8b39-353aaa531c12', 'Date', - 'Wed, 22 Jul 2020 20:59:31 GMT' + 'Mon, 27 Jul 2020 21:02:16 GMT' ]); From b0e83e9265d99e63e48ce882f96e9c25a2a7963f Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Mon, 27 Jul 2020 15:34:58 -0700 Subject: [PATCH 19/34] [EventGrid] Slim down HMAC APIs Take some code from AppConfiguration which simplifies the amount of code we need to do HMACs across Node/Browser. Hopefully this can all be removed in favor of a core library in the nearish future --- sdk/eventgrid/eventgrid/package.json | 3 +- .../eventgrid/src/cryptoHelpers.browser.ts | 31 +++++++++++++++++++ sdk/eventgrid/eventgrid/src/cryptoHelpers.ts | 16 ++++++++++ .../src/generateSharedAccessSignature.ts | 4 +-- .../eventgrid/src/utils/atob.browser.ts | 8 ----- sdk/eventgrid/eventgrid/src/utils/atob.ts | 6 ---- sdk/eventgrid/eventgrid/src/utils/encode.ts | 25 --------------- .../eventgrid/src/utils/globalCrypto.ts | 16 ---------- .../eventgrid/src/utils/hmac.browser.ts | 20 ------------ sdk/eventgrid/eventgrid/src/utils/hmac.ts | 10 ------ 10 files changed, 50 insertions(+), 89 deletions(-) create mode 100644 sdk/eventgrid/eventgrid/src/cryptoHelpers.browser.ts create mode 100644 sdk/eventgrid/eventgrid/src/cryptoHelpers.ts delete mode 100644 sdk/eventgrid/eventgrid/src/utils/atob.browser.ts delete mode 100644 sdk/eventgrid/eventgrid/src/utils/atob.ts delete mode 100644 sdk/eventgrid/eventgrid/src/utils/encode.ts delete mode 100644 sdk/eventgrid/eventgrid/src/utils/globalCrypto.ts delete mode 100644 sdk/eventgrid/eventgrid/src/utils/hmac.browser.ts delete mode 100644 sdk/eventgrid/eventgrid/src/utils/hmac.ts diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json index 693032e9c7d3..4a4dc84253a9 100644 --- a/sdk/eventgrid/eventgrid/package.json +++ b/sdk/eventgrid/eventgrid/package.json @@ -43,8 +43,7 @@ ] }, "browser": { - "./dist-esm/src/utils/hmac.js": "./dist-esm/src/utils/hmac.browser.js", - "./dist-esm/src/utils/atob.js": "./dist-esm/src/utils/atob.browser.js", + "./dist-esm/src/cryptoHelpers.js": "./dist-esm/src/cryptoHelpers.browser.js", "./dist-esm/src/base64.js": "./dist-esm/src/base64.browser.js" }, "scripts": { diff --git a/sdk/eventgrid/eventgrid/src/cryptoHelpers.browser.ts b/sdk/eventgrid/eventgrid/src/cryptoHelpers.browser.ts new file mode 100644 index 000000000000..e9c2986d66a0 --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/cryptoHelpers.browser.ts @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/// + +/** + * @internal + * @ignore + */ +export async function sha256Hmac(secret: string, stringToSign: string): Promise { + const key = await self.crypto.subtle.importKey( + "raw", + Uint8Array.from(atob(secret), (c) => c.charCodeAt(0)), + { + name: "HMAC", + hash: "SHA-256" + }, + false, + ["sign"] + ); + + const sigArray = await self.crypto.subtle.sign( + "HMAC", + key, + new TextEncoder().encode(stringToSign) + ); + + // The conversions here are a bit odd but necessary (see "Unicode strings" in the link below) + // https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/btoa + return btoa(String.fromCharCode(...new Uint8Array(sigArray))); +} diff --git a/sdk/eventgrid/eventgrid/src/cryptoHelpers.ts b/sdk/eventgrid/eventgrid/src/cryptoHelpers.ts new file mode 100644 index 000000000000..85f2feb312ee --- /dev/null +++ b/sdk/eventgrid/eventgrid/src/cryptoHelpers.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { createHmac } from "crypto"; + +/** + * @internal + * @ignore + */ +export async function sha256Hmac(secret: string, stringToSign: string): Promise { + const decodedSecret = Buffer.from(secret, "base64"); + + return createHmac("sha256", decodedSecret) + .update(stringToSign) + .digest("base64"); +} diff --git a/sdk/eventgrid/eventgrid/src/generateSharedAccessSignature.ts b/sdk/eventgrid/eventgrid/src/generateSharedAccessSignature.ts index 643945d7c4da..ee9b2d381ed4 100644 --- a/sdk/eventgrid/eventgrid/src/generateSharedAccessSignature.ts +++ b/sdk/eventgrid/eventgrid/src/generateSharedAccessSignature.ts @@ -3,7 +3,7 @@ import { KeyCredential } from "@azure/core-auth"; import { DEFAULT_API_VERSION } from "./constants"; -import { hmac } from "./utils/hmac"; +import { sha256Hmac } from "./cryptoHelpers"; import { dateToServiceTimeString } from "./util"; export interface GenerateSharedAccessSignatureOptions { @@ -33,7 +33,7 @@ export async function generateSharedAccessSignature( const unsignedSas = `r=${encodeURIComponent( `${endpointUrl}?apiVersion=${options?.apiVersion || DEFAULT_API_VERSION}` )}&e=${encodeURIComponent(expiresOnString)}`; - return hmac(credential.key, unsignedSas).then( + return sha256Hmac(credential.key, unsignedSas).then( (digest) => `${unsignedSas}&s=${encodeURIComponent(digest)}` ); } diff --git a/sdk/eventgrid/eventgrid/src/utils/atob.browser.ts b/sdk/eventgrid/eventgrid/src/utils/atob.browser.ts deleted file mode 100644 index 766fc839b4ae..000000000000 --- a/sdk/eventgrid/eventgrid/src/utils/atob.browser.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -if ("function" !== typeof atob) { - throw new Error("Your browser environment is missing the global `atob` function"); -} - -export default atob; diff --git a/sdk/eventgrid/eventgrid/src/utils/atob.ts b/sdk/eventgrid/eventgrid/src/utils/atob.ts deleted file mode 100644 index 2239926f9ff7..000000000000 --- a/sdk/eventgrid/eventgrid/src/utils/atob.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -export default function atob(str: string) { - return Buffer.from(str, "base64").toString("binary"); -} diff --git a/sdk/eventgrid/eventgrid/src/utils/encode.ts b/sdk/eventgrid/eventgrid/src/utils/encode.ts deleted file mode 100644 index 87b35db58e0e..000000000000 --- a/sdk/eventgrid/eventgrid/src/utils/encode.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -/// - -export function encodeUTF8(str: string): Uint8Array { - const bytes = new Uint8Array(str.length); - for (let i = 0; i < str.length; i++) { - bytes[i] = str.charCodeAt(i); - } - return bytes; -} - -export function encodeBase64(value: ArrayBuffer): string { - if ("function" !== typeof btoa) { - throw new Error("Your browser environment is missing the global `btoa` function"); - } - - let binary = ""; - const bytes = new Uint8Array(value); - const len = bytes.byteLength; - for (let i = 0; i < len; i++) { - binary += String.fromCharCode(bytes[i]); - } - return btoa(binary); -} diff --git a/sdk/eventgrid/eventgrid/src/utils/globalCrypto.ts b/sdk/eventgrid/eventgrid/src/utils/globalCrypto.ts deleted file mode 100644 index ab7f046745d6..000000000000 --- a/sdk/eventgrid/eventgrid/src/utils/globalCrypto.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -const globalRef: any = typeof self === "undefined" ? window : self; - -if (!globalRef) { - throw new Error("Could not find global"); -} - -const globalCrypto: Crypto = globalRef.crypto || globalRef.msCrypto; - -if (!globalCrypto || !globalCrypto.subtle) { - throw new Error("Browser does not support cryptography functions"); -} - -export { globalCrypto }; diff --git a/sdk/eventgrid/eventgrid/src/utils/hmac.browser.ts b/sdk/eventgrid/eventgrid/src/utils/hmac.browser.ts deleted file mode 100644 index 939648ed6c50..000000000000 --- a/sdk/eventgrid/eventgrid/src/utils/hmac.browser.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { encodeUTF8, encodeBase64 } from "./encode"; -import atob from "./atob"; -import { globalCrypto } from "./globalCrypto"; - -export async function hmac(key: string, message: string) { - const importParams: HmacImportParams = { name: "HMAC", hash: { name: "SHA-256" } }; - const encodedMessage = new Uint8Array( - [...unescape(encodeURIComponent(message))].map((c) => c.charCodeAt(0)) - ); - const encodedKey = encodeUTF8(atob(key)); - const cryptoKey = await globalCrypto.subtle.importKey("raw", encodedKey, importParams, false, [ - "sign" - ]); - const signature = await globalCrypto.subtle.sign(importParams, cryptoKey, encodedMessage); - - return encodeBase64(signature); -} diff --git a/sdk/eventgrid/eventgrid/src/utils/hmac.ts b/sdk/eventgrid/eventgrid/src/utils/hmac.ts deleted file mode 100644 index 7349e0d5e067..000000000000 --- a/sdk/eventgrid/eventgrid/src/utils/hmac.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { createHmac } from "crypto"; - -export async function hmac(key: string, message: string) { - return createHmac("sha256", Buffer.from(key, "base64")) - .update(message) - .digest("base64"); -} From 0bd440ed7324bba8db55b27dd9806c1f17b5627f Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 28 Jul 2020 15:38:55 -0700 Subject: [PATCH 20/34] [EventGrid] Change the type of some errors --- sdk/eventgrid/eventgrid/src/util.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/eventgrid/eventgrid/src/util.ts b/sdk/eventgrid/eventgrid/src/util.ts index 3726a639aa6c..0df40763a42d 100644 --- a/sdk/eventgrid/eventgrid/src/util.ts +++ b/sdk/eventgrid/eventgrid/src/util.ts @@ -97,14 +97,14 @@ export function validateCloudEventEvent(o: any): void { } if (o.specversion !== CLOUD_EVENT_1_0_SPEC_VERSION) { - throw new TypeError("event is not in the Cloud Event 1.0 schema"); + throw new Error("event is not in the Cloud Event 1.0 schema"); } } function validateRequiredStringProperties(o: any, propertyNames: string[]): void { for (const propertyName of propertyNames) { if (typeof o[propertyName] === "undefined") { - throw new TypeError(`event is missing required property '${propertyName}'`); + throw new Error(`event is missing required property '${propertyName}'`); } if (typeof o[propertyName] !== "string") { @@ -118,7 +118,7 @@ function validateRequiredStringProperties(o: any, propertyNames: string[]): void function validateRequiredAnyProperties(o: any, propertyNames: string[]): void { for (const propertyName of propertyNames) { if (typeof o[propertyName] === "undefined") { - throw new TypeError(`event is missing required property '${propertyName}'`); + throw new Error(`event is missing required property '${propertyName}'`); } } } From 77c2ca819fb525841939b7ed119df4beb04649cd Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 28 Jul 2020 15:39:17 -0700 Subject: [PATCH 21/34] [EventGrid] Improve documentation --- sdk/eventgrid/eventgrid/README.md | 60 +++++++++++++++++++---- sdk/eventgrid/eventgrid/src/consumer.ts | 15 +++++- sdk/eventgrid/eventgrid/src/predicates.ts | 17 +++++-- 3 files changed, 79 insertions(+), 13 deletions(-) diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md index dc4961170b6d..40d17de2ebf6 100644 --- a/sdk/eventgrid/eventgrid/README.md +++ b/sdk/eventgrid/eventgrid/README.md @@ -123,22 +123,28 @@ Using the wrong method will result in an error from the service and your events ### EventGridConsumer -TODO +Events delivered to consumers by Event Grid are delivered as JSON. Depending on the type of consumer being delivered to, the Event Grid service may deliver one or more events as part of a single payload. While these events may be decoded using normal JavaScript methods like `JSON.parse`, this library offers a helper type for deserializing events, called `EventGridConsumer`. + +Compared with using `JSON.parse` directly, `EventGridConsumer` does some additional conversions while deserializng events: + +1. `EventGridConsumer` validates that the required properties of an event are present and are the right types. +2. `EventGridConsumer` converts the event time property into a JavaScript `Date` object. +3. When using Cloud Events, binary data may be used for an event's data property (by using `Uint8Array`). When the event is sent through Event Grid, it is encoded in Base 64. `EventGridConsumer` will decode this data back into an instance of `Uint8Array`. +4. When deserilizing a _System Event_ (an event generated by another Azure service), `EventGridConsumer` will do additional conversions so that the `data` object matches the corresponding interface which describes its data. When using TypeScript, these interfaces ensure you have strong typing when access properties of the data object for a system event. + +When creating an instance of `EventGridConsumer` you may supply custom deserializers that are used to further convert the `data` object. ## Examples ### Publish a Custom Event to an Event Grid Topic ```js -const { v4: uuidv4 } = require("uuid"); const { EventGridPublisherClient, AzureKeyCredential } = require("@azure/eventgrid"); const client = new EventGridPublisherClient("", new AzureKeyCredential("")); await client.sendEvents([ { - id: uuidv4(), - eventTime: new Date(), eventType: "Azure.Sdk.SampleEvent", subject: "Event Subject", dataVersion: "1.0", @@ -154,15 +160,12 @@ await client.sendEvents([ Publishing events to an Event Grid Domain is similar to publish to an Event Grid Topic, except that when using the Event Grid schema for events, you must include the `topic` property. When publishing events in the Cloud Events 1.0 schema, the required `source` property is used as the name of the topic in the domain to publish to ```js -const { v4: uuidv4 } = require("uuid"); const { EventGridPublisherClient, AzureKeyCredential } = require("@azure/eventgrid"); const client = new EventGridPublisherClient("", new AzureKeyCredential("")); await client.sendEvents([ { - id: uuidv4(), - eventTime: new Date(), topic: "my-sample-topic", eventType: "Azure.Sdk.SampleEvent", subject: "Event Subject", @@ -174,9 +177,48 @@ await client.sendEvents([ ]); ``` -### Decoding an Event +### Deserialzing an Event + +`EventGridConsumer` can be used to deserialize events delivered by Event Grid. When deserlizing an event, you need to know the schema used to deliver the event. In this example we have events being delivered to an Azure Service Bus Topic in the Cloud Events schema. Using the Service Bus SDK we can recieve these events from the Service Bus Topic and then deserialize them using `EventGridConsumer` and use `isSystemEvent` to detect what type of events they are. + +```js +const { ServiceBusClient } = require("@azure/service-bus"); +const { DefaultAzureCredential } = require("@azure/identity"); +const { EventGridConsumer, isSystemEvent } = require("@azure/eventgrid"); + +const client = new ServiceBusClient("", new DefaultAzureCredential()); + +const receiver = client.createReceiver("", "peekLock"); -TODO +const consumer = new EventGridConsumer(); + +async function processMessage(message) { + // When delivering to a Service Bus Queue or Topic, EventGrid delivers a single event per message. + // so we just pluck the first one. + const event = (await consumer.decodeCloudEvents(message.body))[0]; + + if (isSystemEvent("Microsoft.ContainerRegistry.ImagePushed", event)) { + console.log( + `${event.time}: Container Registry Image Pushed event for image ${event.data.target.repository}:${event.data.target.tag}` + ); + } else if (isSystemEvent("Microsoft.ContainerRegistry.ImageDeleted", event)) { + console.log( + `${event.time}: Container Registry Image Deleted event for repository ${event.data.target.repository}` + ); + } + + await message.complete(); +} + +console.log("starting receiver"); + +receiver.subscribe({ + processError: async (err) => { + console.error(err); + }, + processMessage: processMessage +}); +``` ## Troubleshooting diff --git a/sdk/eventgrid/eventgrid/src/consumer.ts b/sdk/eventgrid/eventgrid/src/consumer.ts index 7eb18d56ce31..0c17e1eb0e1e 100644 --- a/sdk/eventgrid/eventgrid/src/consumer.ts +++ b/sdk/eventgrid/eventgrid/src/consumer.ts @@ -31,7 +31,20 @@ export interface EventGridConsumerOptions { } /** - * TODO(matell): Document this. + * EventGridConsumer is used to aid in processing events delivered by EventGrid. It can deserialize a JSON encoded payload + * of either a single event or batch of events as well as be used to convert the result of `JSON.parse` into an + * `EventGridEvent` or `CloudEvent` like object. + * + * Unlike normal JSON deseralization, EventGridConsumer does some additional conversions: + * + * - The consumer parses the event time property into a `Date` object, for ease of use. + * - When deserializing an event in the CloudEvent schema, if the event contains binary data, it is base64 decoded + * and returned as an instance of the `Uint8Array` type. + * - The `data` payload from system events is converted to match the interfaces this library defines. + * + * When constructing an `EventGridConsumer`, a map of event types to custom deserializers may be provided. When + * deserializing, if a custom deserializer has been registered for a given event type, it will be called with the + * data object. The object this deserializer returns will replace the existing data object. */ export class EventGridConsumer { readonly customDeserializers: Record; diff --git a/sdk/eventgrid/eventgrid/src/predicates.ts b/sdk/eventgrid/eventgrid/src/predicates.ts index d0e01b480344..3cb6e03dd284 100644 --- a/sdk/eventgrid/eventgrid/src/predicates.ts +++ b/sdk/eventgrid/eventgrid/src/predicates.ts @@ -83,7 +83,8 @@ import { import { CloudEvent, EventGridEvent } from "./models"; /** - * TODO(matell): Write some good prose here. + * The Event Types for all System Events. These may be used with `isSystemEvent` to determine if an + * event is a system event of a given type. */ export type KnownSystemEventTypes = | "Microsoft.AppConfiguration.KeyValueDeleted" @@ -259,7 +260,12 @@ function isCloudEventLike( } /** - * TODO(matell): Document this. + * iSystemEvent returns "true" when a given event is a system event of a given type. When using + * TypeScript, this function acts as a custom type guard and allows the TypeScript compiler to + * identify the underlying data + * + * @param eventType The type of system event to check for, e.g., "Microsoft.AppConfiguration.KeyValueDeleted" + * @param event The event to test. */ export function isSystemEvent( eventType: T, @@ -267,7 +273,12 @@ export function isSystemEvent( ): event is EventGridEvent; /** - * TODO(matell): Document this. + * iSystemEvent returns "true" when a given event is a system event of a given type. When using + * TypeScript, this function acts as a custom type guard and allows the TypeScript compiler to + * identify the underlying data + * + * @param eventType The type of system event to check for, e.g., "Microsoft.AppConfiguration.KeyValueDeleted" + * @param event The event to test. */ export function isSystemEvent( eventType: T, From 0f5de7bc52e3e6bf47fc2b97dc13cceadd3a943e Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Fri, 7 Aug 2020 15:45:53 -0700 Subject: [PATCH 22/34] Update sdk/eventgrid/eventgrid/README.md Co-authored-by: Laurent Mazuel --- sdk/eventgrid/eventgrid/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md index 40d17de2ebf6..1f5678a3977d 100644 --- a/sdk/eventgrid/eventgrid/README.md +++ b/sdk/eventgrid/eventgrid/README.md @@ -177,7 +177,7 @@ await client.sendEvents([ ]); ``` -### Deserialzing an Event +### Deserializing an Event `EventGridConsumer` can be used to deserialize events delivered by Event Grid. When deserlizing an event, you need to know the schema used to deliver the event. In this example we have events being delivered to an Azure Service Bus Topic in the Cloud Events schema. Using the Service Bus SDK we can recieve these events from the Service Bus Topic and then deserialize them using `EventGridConsumer` and use `isSystemEvent` to detect what type of events they are. From 5ec4e5cdcbe219ac4350dd2e0d9567796d18e67a Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Wed, 12 Aug 2020 12:42:07 -0700 Subject: [PATCH 23/34] Consume swagger updates --- sdk/eventgrid/eventgrid/package.json | 3 +- .../eventgrid/review/eventgrid.api.md | 13 +++- sdk/eventgrid/eventgrid/src/base64.browser.ts | 30 --------- sdk/eventgrid/eventgrid/src/base64.ts | 21 ------ sdk/eventgrid/eventgrid/src/consumer.ts | 7 +- .../eventgrid/src/eventGridClient.ts | 3 +- .../eventgrid/src/generated/models/index.ts | 42 +++++++++++- .../eventgrid/src/generated/models/mappers.ts | 65 ++++++++++++++++++- sdk/eventgrid/eventgrid/src/index.ts | 1 + sdk/eventgrid/eventgrid/src/predicates.ts | 5 +- sdk/eventgrid/eventgrid/swagger/README.md | 30 ++++----- .../eventgrid/test/eventGridClient.spec.ts | 2 +- 12 files changed, 143 insertions(+), 79 deletions(-) delete mode 100644 sdk/eventgrid/eventgrid/src/base64.browser.ts delete mode 100644 sdk/eventgrid/eventgrid/src/base64.ts diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json index fc2d38d9296f..cd5a8d5775ed 100644 --- a/sdk/eventgrid/eventgrid/package.json +++ b/sdk/eventgrid/eventgrid/package.json @@ -43,8 +43,7 @@ ] }, "browser": { - "./dist-esm/src/cryptoHelpers.js": "./dist-esm/src/cryptoHelpers.browser.js", - "./dist-esm/src/base64.js": "./dist-esm/src/base64.browser.js" + "./dist-esm/src/cryptoHelpers.js": "./dist-esm/src/cryptoHelpers.browser.js" }, "scripts": { "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index 938d457437a9..64b02369ab0c 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -292,7 +292,7 @@ export function isSystemEvent(eventType: T, eve export function isSystemEvent(eventType: T, event: CloudEvent): event is CloudEvent; // @public -export type KnownSystemEventTypes = "Microsoft.AppConfiguration.KeyValueDeleted" | "Microsoft.AppConfiguration.KeyValueModified" | "Microsoft.ContainerRegistry.ImagePushed" | "Microsoft.ContainerRegistry.ImageDeleted" | "Microsoft.ContainerRegistry.ChartDeleted" | "Microsoft.ContainerRegistry.ChartPushed" | "Microsoft.Devices.DeviceCreated" | "Microsoft.Devices.DeviceDeleted" | "Microsoft.Devices.DeviceConnected" | "Microsoft.Devices.DeviceDisconnected" | "Microsoft.Devices.DeviceTelemetry" | "Microsoft.EventGrid.SubscriptionValidationEvent" | "Microsoft.EventGrid.SubscriptionDeletedEvent" | "Microsoft.EventHub.CaptureFileCreated" | "Microsoft.MachineLearningServices.DatasetDriftDetected" | "Microsoft.MachineLearningServices.ModelDeployed" | "Microsoft.MachineLearningServices.ModelRegistered" | "Microsoft.MachineLearningServices.RunCompleted" | "Microsoft.MachineLearningServices.RunStatusChanged" | "Microsoft.Maps.GeofenceEntered" | "Microsoft.Maps.GeofenceExited" | "Microsoft.Maps.GeofenceResult" | "Microsoft.Media.JobStateChange" | "Microsoft.Media.JobOutputStateChange" | "Microsoft.Media.JobScheduled" | "Microsoft.Media.JobProcessing" | "Microsoft.Media.JobCanceling" | "Microsoft.Media.JobFinished" | "Microsoft.Media.JobCanceled" | "Microsoft.Media.JobErrored" | "Microsoft.Media.JobOutputCanceled" | "Microsoft.Media.JobOutputCanceling" | "Microsoft.Media.JobOutputErrored" | "Microsoft.Media.JobOutputFinished" | "Microsoft.Media.JobOutputProcessing" | "Microsoft.Media.JobOutputScheduled" | "Microsoft.Media.JobOutputProgress" | "Microsoft.Media.LiveEventEncoderConnected" | "Microsoft.Media.LiveEventConnectionRejected" | "Microsoft.Media.LiveEventEncoderDisconnected" | "Microsoft.Media.LiveEventIncomingStreamReceived" | "Microsoft.Media.LiveEventIncomingStreamsOutOfSync" | "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync" | "Microsoft.Media.LiveEventIncomingDataChunkDropped" | "Microsoft.Media.LiveEventIngestHeartbeat" | "Microsoft.Media.LiveEventTrackDiscontinuityDetected" | "Microsoft.Resources.ResourceWriteSuccess" | "Microsoft.Resources.ResourceWriteFailure" | "Microsoft.Resources.ResourceWriteCancel" | "Microsoft.Resources.ResourceDeleteSuccess" | "Microsoft.Resources.ResourceDeleteFailure" | "Microsoft.Resources.ResourceDeleteCancel" | "Microsoft.Resources.ResourceActionSuccess" | "Microsoft.Resources.ResourceActionFailure" | "Microsoft.Resources.ResourceActionCancel" | "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners" | "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener" | "Microsoft.Storage.BlobCreated" | "Microsoft.Storage.BlobDeleted" | "Microsoft.Storage.BlobRenamed" | "Microsoft.Storage.DirectoryCreated" | "Microsoft.Storage.DirectoryDeleted" | "Microsoft.Storage.DirectoryRenamed" | "Microsoft.Web.AppUpdated" | "Microsoft.Web.BackupOperationStarted" | "Microsoft.Web.BackupOperationCompleted" | "Microsoft.Web.BackupOperationFailed" | "Microsoft.Web.RestoreOperationStarted" | "Microsoft.Web.RestoreOperationCompleted" | "Microsoft.Web.RestoreOperationFailed" | "Microsoft.Web.SlotSwapStarted" | "Microsoft.Web.SlotSwapCompleted" | "Microsoft.Web.SlotSwapFailed" | "Microsoft.Web.SlotSwapWithPreviewStarted" | "Microsoft.Web.SlotSwapWithPreviewCancelled" | "Microsoft.Web.AppServicePlanUpdated"; +export type KnownSystemEventTypes = "Microsoft.AppConfiguration.KeyValueDeleted" | "Microsoft.AppConfiguration.KeyValueModified" | "Microsoft.ContainerRegistry.ImagePushed" | "Microsoft.ContainerRegistry.ImageDeleted" | "Microsoft.ContainerRegistry.ChartDeleted" | "Microsoft.ContainerRegistry.ChartPushed" | "Microsoft.Devices.DeviceCreated" | "Microsoft.Devices.DeviceDeleted" | "Microsoft.Devices.DeviceConnected" | "Microsoft.Devices.DeviceDisconnected" | "Microsoft.Devices.DeviceTelemetry" | "Microsoft.EventGrid.SubscriptionValidationEvent" | "Microsoft.EventGrid.SubscriptionDeletedEvent" | "Microsoft.EventHub.CaptureFileCreated" | "Microsoft.MachineLearningServices.DatasetDriftDetected" | "Microsoft.MachineLearningServices.ModelDeployed" | "Microsoft.MachineLearningServices.ModelRegistered" | "Microsoft.MachineLearningServices.RunCompleted" | "Microsoft.MachineLearningServices.RunStatusChanged" | "Microsoft.Maps.GeofenceEntered" | "Microsoft.Maps.GeofenceExited" | "Microsoft.Maps.GeofenceResult" | "Microsoft.Media.JobStateChange" | "Microsoft.Media.JobOutputStateChange" | "Microsoft.Media.JobScheduled" | "Microsoft.Media.JobProcessing" | "Microsoft.Media.JobCanceling" | "Microsoft.Media.JobFinished" | "Microsoft.Media.JobCanceled" | "Microsoft.Media.JobErrored" | "Microsoft.Media.JobOutputCanceled" | "Microsoft.Media.JobOutputCanceling" | "Microsoft.Media.JobOutputErrored" | "Microsoft.Media.JobOutputFinished" | "Microsoft.Media.JobOutputProcessing" | "Microsoft.Media.JobOutputScheduled" | "Microsoft.Media.JobOutputProgress" | "Microsoft.Media.LiveEventEncoderConnected" | "Microsoft.Media.LiveEventConnectionRejected" | "Microsoft.Media.LiveEventEncoderDisconnected" | "Microsoft.Media.LiveEventIncomingStreamReceived" | "Microsoft.Media.LiveEventIncomingStreamsOutOfSync" | "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync" | "Microsoft.Media.LiveEventIncomingDataChunkDropped" | "Microsoft.Media.LiveEventIngestHeartbeat" | "Microsoft.Media.LiveEventTrackDiscontinuityDetected" | "Microsoft.Resources.ResourceWriteSuccess" | "Microsoft.Resources.ResourceWriteFailure" | "Microsoft.Resources.ResourceWriteCancel" | "Microsoft.Resources.ResourceDeleteSuccess" | "Microsoft.Resources.ResourceDeleteFailure" | "Microsoft.Resources.ResourceDeleteCancel" | "Microsoft.Resources.ResourceActionSuccess" | "Microsoft.Resources.ResourceActionFailure" | "Microsoft.Resources.ResourceActionCancel" | "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners" | "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener" | "Microsoft.Storage.BlobCreated" | "Microsoft.Storage.BlobDeleted" | "Microsoft.Storage.BlobRenamed" | "Microsoft.Storage.DirectoryCreated" | "Microsoft.Storage.DirectoryDeleted" | "Microsoft.Storage.DirectoryRenamed" | "Microsoft.Storage.LifecyclePolicyCompleted" | "Microsoft.Web.AppUpdated" | "Microsoft.Web.BackupOperationStarted" | "Microsoft.Web.BackupOperationCompleted" | "Microsoft.Web.BackupOperationFailed" | "Microsoft.Web.RestoreOperationStarted" | "Microsoft.Web.RestoreOperationCompleted" | "Microsoft.Web.RestoreOperationFailed" | "Microsoft.Web.SlotSwapStarted" | "Microsoft.Web.SlotSwapCompleted" | "Microsoft.Web.SlotSwapFailed" | "Microsoft.Web.SlotSwapWithPreviewStarted" | "Microsoft.Web.SlotSwapWithPreviewCancelled" | "Microsoft.Web.AppServicePlanUpdated"; // @public export interface MachineLearningServicesDatasetDriftDetectedEventData { @@ -829,6 +829,15 @@ export interface StorageDirectoryRenamedEventData { storageDiagnostics?: any; } +// @public +export interface StorageLifecyclePolicyCompletedEventData { + // Warning: (ae-forgotten-export) The symbol "StorageLifecyclePolicyActionSummaryDetail" needs to be exported by the entry point index.d.ts + deleteSummary?: StorageLifecyclePolicyActionSummaryDetail; + scheduleTime?: string; + tierToArchiveSummary?: StorageLifecyclePolicyActionSummaryDetail; + tierToCoolSummary?: StorageLifecyclePolicyActionSummaryDetail; +} + // @public export interface SubscriptionDeletedEventData { readonly eventSubscriptionId?: string; @@ -969,6 +978,8 @@ export interface SystemEventNameToEventData { // (undocumented) "Microsoft.Storage.DirectoryRenamed": StorageDirectoryRenamedEventData; // (undocumented) + "Microsoft.Storage.LifecyclePolicyCompleted": StorageLifecyclePolicyCompletedEventData; + // (undocumented) "Microsoft.Web.AppServicePlanUpdated": WebAppServicePlanUpdatedEventData; // (undocumented) "Microsoft.Web.AppUpdated": WebAppUpdatedEventData; diff --git a/sdk/eventgrid/eventgrid/src/base64.browser.ts b/sdk/eventgrid/eventgrid/src/base64.browser.ts deleted file mode 100644 index 52370e46e730..000000000000 --- a/sdk/eventgrid/eventgrid/src/base64.browser.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -/// - -/** - * base64Encode encodes a byte array as a base64 string. - * - * @param value the byte array to be encoded in base64 - */ -export function base64Encode(value: Uint8Array): string { - let str = ""; - for (let i = 0; i < value.length; i++) { - str += String.fromCharCode(value[i]); - } - return btoa(str); -} - -/** - * base64Decode decodes a valid base64 encoded string into a byte array. - * - * @param value the valid base64 string to be decoded - */ -export function base64Decode(value: string): Uint8Array { - const byteString = atob(value); - const byteArray = new Uint8Array(byteString.length); - for (let i = 0; i < byteString.length; i++) { - byteArray[i] = byteString.charCodeAt(i); - } - return byteArray; -} diff --git a/sdk/eventgrid/eventgrid/src/base64.ts b/sdk/eventgrid/eventgrid/src/base64.ts deleted file mode 100644 index 91d29a087de6..000000000000 --- a/sdk/eventgrid/eventgrid/src/base64.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -/** - * base64Encode encodes a byte array as a base64 string. - * - * @param value the byte array to be encoded in base64 - */ -export function base64Encode(value: Uint8Array): string { - const bufferValue = value instanceof Buffer ? value : Buffer.from(value.buffer); - return bufferValue.toString("base64"); -} - -/** - * base64Decode decodes a valid base64 encoded string into a byte array. - * - * @param value the valid base64 string to be decoded - */ -export function base64Decode(value: string): Uint8Array { - return Buffer.from(value, "base64"); -} diff --git a/sdk/eventgrid/eventgrid/src/consumer.ts b/sdk/eventgrid/eventgrid/src/consumer.ts index 0c17e1eb0e1e..dcb69aafd1fa 100644 --- a/sdk/eventgrid/eventgrid/src/consumer.ts +++ b/sdk/eventgrid/eventgrid/src/consumer.ts @@ -15,7 +15,6 @@ import { } from "./generated/models/mappers"; import { parseAndWrap, validateEventGridEvent, validateCloudEventEvent } from "./util"; import { systemDeserializers } from "./systemEventDecoders"; -import { base64Decode } from "./base64"; const serializer = new Serializer(); @@ -157,11 +156,11 @@ export class EventGridConsumer { throw new TypeError("event contains both a data and data_base64 field"); } - if (typeof deserialized.dataBase64 !== "string") { - throw new TypeError("event data_base64 property should be a string"); + if (!(deserialized.dataBase64 instanceof Uint8Array)) { + throw new TypeError("event data_base64 property is invalid"); } - modelEvent.data = base64Decode(deserialized.dataBase64); + modelEvent.data = deserialized.dataBase64; } // If a decoder is registered, apply it to the data. diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts index 9cef4401e00c..8794cdb5d966 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -15,7 +15,6 @@ import { createEventGridCredentialPolicy } from "./eventGridAuthenticationPolicy import { SignatureCredential } from "./sharedAccessSignitureCredential"; import { SDK_VERSION } from "./constants"; import { CloudEvent, EventGridEvent, cloudEventReservedPropertyNames } from "./models"; -import { base64Encode } from "./base64"; import { GeneratedClient } from "./generated/generatedClient"; import { CloudEvent as CloudEventWireModel, @@ -201,7 +200,7 @@ export function convertCloudEventToModelType(event: CloudEvent): CloudEvent } converted.datacontenttype = event.datacontenttype; - converted.dataBase64 = base64Encode(event.data); + converted.dataBase64 = event.data; } else { converted.datacontenttype = event.datacontenttype ?? "application/json"; converted.data = event.data; diff --git a/sdk/eventgrid/eventgrid/src/generated/models/index.ts b/sdk/eventgrid/eventgrid/src/generated/models/index.ts index 3d54535bd959..386fbe28d891 100644 --- a/sdk/eventgrid/eventgrid/src/generated/models/index.ts +++ b/sdk/eventgrid/eventgrid/src/generated/models/index.ts @@ -71,7 +71,7 @@ export interface CloudEvent { /** * Event data specific to the event type, encoded as a base64 string. */ - dataBase64?: string; + dataBase64?: Uint8Array; /** * Type of event related to the originating occurrence. */ @@ -346,6 +346,46 @@ export interface StorageDirectoryRenamedEventData { storageDiagnostics?: any; } +/** + * Schema of the Data property of an EventGridEvent for an Microsoft.Storage.LifecyclePolicyCompleted event. + */ +export interface StorageLifecyclePolicyCompletedEventData { + /** + * The time the policy task was scheduled. + */ + scheduleTime?: string; + /** + * Execution statistics of a specific policy action in a Blob Management cycle. + */ + deleteSummary?: StorageLifecyclePolicyActionSummaryDetail; + /** + * Execution statistics of a specific policy action in a Blob Management cycle. + */ + tierToCoolSummary?: StorageLifecyclePolicyActionSummaryDetail; + /** + * Execution statistics of a specific policy action in a Blob Management cycle. + */ + tierToArchiveSummary?: StorageLifecyclePolicyActionSummaryDetail; +} + +/** + * Execution statistics of a specific policy action in a Blob Management cycle. + */ +export interface StorageLifecyclePolicyActionSummaryDetail { + /** + * Total number of objects to be acted on by this action. + */ + totalObjectsCount?: number; + /** + * Number of success operations of this action. + */ + successCount?: number; + /** + * Error messages of this action if any. + */ + errorList?: string; +} + /** * Schema of the Data property of an EventGridEvent for an Microsoft.EventHub.CaptureFileCreated event. */ diff --git a/sdk/eventgrid/eventgrid/src/generated/models/mappers.ts b/sdk/eventgrid/eventgrid/src/generated/models/mappers.ts index f937243b0970..d28a0c5687f2 100644 --- a/sdk/eventgrid/eventgrid/src/generated/models/mappers.ts +++ b/sdk/eventgrid/eventgrid/src/generated/models/mappers.ts @@ -101,7 +101,7 @@ export const CloudEvent: coreHttp.CompositeMapper = { dataBase64: { serializedName: "data_base64", type: { - name: "String" + name: "ByteArray" } }, type: { @@ -518,6 +518,69 @@ export const StorageDirectoryRenamedEventData: coreHttp.CompositeMapper = { } }; +export const StorageLifecyclePolicyCompletedEventData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "StorageLifecyclePolicyCompletedEventData", + modelProperties: { + scheduleTime: { + serializedName: "scheduleTime", + type: { + name: "String" + } + }, + deleteSummary: { + serializedName: "deleteSummary", + type: { + name: "Composite", + className: "StorageLifecyclePolicyActionSummaryDetail" + } + }, + tierToCoolSummary: { + serializedName: "tierToCoolSummary", + type: { + name: "Composite", + className: "StorageLifecyclePolicyActionSummaryDetail" + } + }, + tierToArchiveSummary: { + serializedName: "tierToArchiveSummary", + type: { + name: "Composite", + className: "StorageLifecyclePolicyActionSummaryDetail" + } + } + } + } +}; + +export const StorageLifecyclePolicyActionSummaryDetail: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "StorageLifecyclePolicyActionSummaryDetail", + modelProperties: { + totalObjectsCount: { + serializedName: "totalObjectsCount", + type: { + name: "Number" + } + }, + successCount: { + serializedName: "successCount", + type: { + name: "Number" + } + }, + errorList: { + serializedName: "errorList", + type: { + name: "String" + } + } + } + } +}; + export const EventHubCaptureFileCreatedEventData: coreHttp.CompositeMapper = { type: { name: "Composite", diff --git a/sdk/eventgrid/eventgrid/src/index.ts b/sdk/eventgrid/eventgrid/src/index.ts index 31dd1b09e81a..a52716573038 100644 --- a/sdk/eventgrid/eventgrid/src/index.ts +++ b/sdk/eventgrid/eventgrid/src/index.ts @@ -107,6 +107,7 @@ export { StorageDirectoryCreatedEventData, StorageDirectoryDeletedEventData, StorageDirectoryRenamedEventData, + StorageLifecyclePolicyCompletedEventData, WebAppUpdatedEventData, WebBackupOperationStartedEventData, WebBackupOperationCompletedEventData, diff --git a/sdk/eventgrid/eventgrid/src/predicates.ts b/sdk/eventgrid/eventgrid/src/predicates.ts index 3cb6e03dd284..44c69df61a08 100644 --- a/sdk/eventgrid/eventgrid/src/predicates.ts +++ b/sdk/eventgrid/eventgrid/src/predicates.ts @@ -77,7 +77,8 @@ import { WebSlotSwapFailedEventData, WebSlotSwapWithPreviewStartedEventData, WebSlotSwapWithPreviewCancelledEventData, - WebAppServicePlanUpdatedEventData + WebAppServicePlanUpdatedEventData, + StorageLifecyclePolicyCompletedEventData } from "./generated/models"; import { CloudEvent, EventGridEvent } from "./models"; @@ -150,6 +151,7 @@ export type KnownSystemEventTypes = | "Microsoft.Storage.DirectoryCreated" | "Microsoft.Storage.DirectoryDeleted" | "Microsoft.Storage.DirectoryRenamed" + | "Microsoft.Storage.LifecyclePolicyCompleted" | "Microsoft.Web.AppUpdated" | "Microsoft.Web.BackupOperationStarted" | "Microsoft.Web.BackupOperationCompleted" @@ -233,6 +235,7 @@ export interface SystemEventNameToEventData { "Microsoft.Storage.DirectoryCreated": StorageDirectoryCreatedEventData; "Microsoft.Storage.DirectoryDeleted": StorageDirectoryDeletedEventData; "Microsoft.Storage.DirectoryRenamed": StorageDirectoryRenamedEventData; + "Microsoft.Storage.LifecyclePolicyCompleted": StorageLifecyclePolicyCompletedEventData; "Microsoft.Web.AppUpdated": WebAppUpdatedEventData; "Microsoft.Web.BackupOperationStarted": WebBackupOperationStartedEventData; "Microsoft.Web.BackupOperationCompleted": WebBackupOperationCompletedEventData; diff --git a/sdk/eventgrid/eventgrid/swagger/README.md b/sdk/eventgrid/eventgrid/swagger/README.md index ac601d27e3dd..e7715dff4dd6 100644 --- a/sdk/eventgrid/eventgrid/swagger/README.md +++ b/sdk/eventgrid/eventgrid/swagger/README.md @@ -14,21 +14,21 @@ license-header: MICROSOFT_MIT_NO_VERSION output-folder: ../ source-code-folder-path: ./src/generated input-file: -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Storage/stable/2018-01-01/Storage.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.EventHub/stable/2018-01-01/EventHub.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Resources/stable/2018-01-01/Resources.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.EventGrid/stable/2018-01-01/EventGrid.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Devices/stable/2018-01-01/IotHub.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.ContainerRegistry/stable/2018-01-01/ContainerRegistry.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.ServiceBus/stable/2018-01-01/ServiceBus.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Media/stable/2018-01-01/MediaServices.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Maps/stable/2018-01-01/Maps.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.AppConfiguration/stable/2018-01-01/AppConfiguration.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.SignalRService/stable/2018-01-01/SignalRService.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.KeyVault/stable/2018-01-01/KeyVault.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.MachineLearningServices/stable/2018-01-01/MachineLearningServices.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Cache/stable/2018-01-01/RedisCache.json -- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/ellismg/add-cloud-event-publish-to-event-grid/specification/eventgrid/data-plane/Microsoft.Web/stable/2018-01-01/Web.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.Storage/stable/2018-01-01/Storage.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.EventHub/stable/2018-01-01/EventHub.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.Resources/stable/2018-01-01/Resources.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.EventGrid/stable/2018-01-01/EventGrid.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.Devices/stable/2018-01-01/IotHub.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.ContainerRegistry/stable/2018-01-01/ContainerRegistry.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.ServiceBus/stable/2018-01-01/ServiceBus.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.Media/stable/2018-01-01/MediaServices.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.Maps/stable/2018-01-01/Maps.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.AppConfiguration/stable/2018-01-01/AppConfiguration.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.SignalRService/stable/2018-01-01/SignalRService.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.KeyVault/stable/2018-01-01/KeyVault.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.MachineLearningServices/stable/2018-01-01/MachineLearningServices.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.Cache/stable/2018-01-01/RedisCache.json +- https://raw.githubusercontent.com/ellismg/azure-rest-api-specs/dev-eventgrid-Microsoft.EventGrid-2018-01-01/specification/eventgrid/data-plane/Microsoft.Web/stable/2018-01-01/Web.json use-extension: "@autorest/typescript": "6.0.0-dev.20200618.1" ``` diff --git a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts index 9a153547c1e6..4960cc10be96 100644 --- a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts +++ b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts @@ -298,7 +298,7 @@ describe("convertCloudEventToModelType", function() { }); assert.isUndefined(convertedEvent.data); - assert.strictEqual(convertedEvent.dataBase64, "AAECAwQFBgcICQ=="); + assert.strictEqual(convertedEvent.dataBase64, binaryData); }); it("fails if data content type is missing for binary data", () => { From 7b39d6b0dc086af43a03724841bb3edde49c9e58 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 1 Sep 2020 14:22:56 -0700 Subject: [PATCH 24/34] README.md tweaks --- sdk/eventgrid/eventgrid/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md index 1f5678a3977d..2791da50052d 100644 --- a/sdk/eventgrid/eventgrid/README.md +++ b/sdk/eventgrid/eventgrid/README.md @@ -26,7 +26,7 @@ Use the client library to: - An [Azure subscription][azure_sub]. - An existing [Event Grid][event_grid] Topic or Domain. If you need to create the resource, you can use the [Azure Portal][azure_portal] or [Azure CLI][azure_cli]. -If you use the Azure CLI, replace `` and `` with your own unique names and `` with an +If you use the Azure CLI, replace `` and `` with your own unique names: #### Create an Event Grid Topic @@ -60,7 +60,7 @@ az eventgrid topic show --name --resource-group --name @@ -71,7 +71,7 @@ Once you have an API key and endpoint, you can use the `AzureKeyCredential` clas ```js const { EventGridPublisherClient, AzureKeyCredential } = require("@azure/eventgrid"); -const client = new EventGridPublisherClient("", new AzureKeyCredential("")); +const client = new EventGridPublisherClient("", new AzureKeyCredential("")); ``` #### Using a SAS Token @@ -123,7 +123,7 @@ Using the wrong method will result in an error from the service and your events ### EventGridConsumer -Events delivered to consumers by Event Grid are delivered as JSON. Depending on the type of consumer being delivered to, the Event Grid service may deliver one or more events as part of a single payload. While these events may be decoded using normal JavaScript methods like `JSON.parse`, this library offers a helper type for deserializing events, called `EventGridConsumer`. +Events delivered to consumers by Event Grid are delivered as JSON. Depending on the type of consumer being delivered to, the Event Grid service may deliver one or more events as part of a single payload. While these events may be deserialized using normal JavaScript methods like `JSON.parse`, this library offers a helper type for deserializing events, called `EventGridConsumer`. Compared with using `JSON.parse` directly, `EventGridConsumer` does some additional conversions while deserializng events: @@ -157,7 +157,7 @@ await client.sendEvents([ ### Publish a Custom Event to a Topic in an Event Grid Domain -Publishing events to an Event Grid Domain is similar to publish to an Event Grid Topic, except that when using the Event Grid schema for events, you must include the `topic` property. When publishing events in the Cloud Events 1.0 schema, the required `source` property is used as the name of the topic in the domain to publish to +Publishing events to an Event Grid Domain is similar to publish to an Event Grid Topic, except that when using the Event Grid schema for events, you must include the `topic` property. When publishing events in the Cloud Events 1.0 schema, the required `source` property is used as the name of the topic in the domain to publish to: ```js const { EventGridPublisherClient, AzureKeyCredential } = require("@azure/eventgrid"); From 31efa0dc7a4ac68023f566950381644749e5fb28 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 1 Sep 2020 18:29:37 -0700 Subject: [PATCH 25/34] [EventGrid] Add decoders for all system events --- .../eventgrid/review/eventgrid.api.md | 77 ---- sdk/eventgrid/eventgrid/src/predicates.ts | 77 ++++ .../eventgrid/src/systemEventDecoders.ts | 420 +++++++++++++++++- 3 files changed, 486 insertions(+), 88 deletions(-) diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index 64b02369ab0c..ee4fe218caf1 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -851,159 +851,82 @@ export interface SubscriptionValidationEventData { // @public export interface SystemEventNameToEventData { - // (undocumented) "Microsoft.AppConfiguration.KeyValueDeleted": AppConfigurationKeyValueDeletedEventData; - // (undocumented) "Microsoft.AppConfiguration.KeyValueModified": AppConfigurationKeyValueModifiedEventData; - // (undocumented) "Microsoft.ContainerRegistry.ChartDeleted": ContainerRegistryChartDeletedEventData; - // (undocumented) "Microsoft.ContainerRegistry.ChartPushed": ContainerRegistryChartPushedEventData; - // (undocumented) "Microsoft.ContainerRegistry.ImageDeleted": ContainerRegistryImageDeletedEventData; - // (undocumented) "Microsoft.ContainerRegistry.ImagePushed": ContainerRegistryImagePushedEventData; - // (undocumented) "Microsoft.Devices.DeviceConnected": IotHubDeviceConnectedEventData; - // (undocumented) "Microsoft.Devices.DeviceCreated": IotHubDeviceCreatedEventData; - // (undocumented) "Microsoft.Devices.DeviceDeleted": IotHubDeviceDeletedEventData; - // (undocumented) "Microsoft.Devices.DeviceDisconnected": IotHubDeviceDisconnectedEventData; - // (undocumented) "Microsoft.Devices.DeviceTelemetry": IotHubDeviceTelemetryEventData; - // (undocumented) "Microsoft.EventGrid.SubscriptionDeletedEvent": SubscriptionDeletedEventData; - // (undocumented) "Microsoft.EventGrid.SubscriptionValidationEvent": SubscriptionValidationEventData; - // (undocumented) "Microsoft.EventHub.CaptureFileCreated": EventHubCaptureFileCreatedEventData; - // (undocumented) "Microsoft.MachineLearningServices.DatasetDriftDetected": MachineLearningServicesDatasetDriftDetectedEventData; - // (undocumented) "Microsoft.MachineLearningServices.ModelDeployed": MachineLearningServicesModelDeployedEventData; - // (undocumented) "Microsoft.MachineLearningServices.ModelRegistered": MachineLearningServicesModelRegisteredEventData; - // (undocumented) "Microsoft.MachineLearningServices.RunCompleted": MachineLearningServicesRunCompletedEventData; - // (undocumented) "Microsoft.MachineLearningServices.RunStatusChanged": MachineLearningServicesRunStatusChangedEventData; - // (undocumented) "Microsoft.Maps.GeofenceEntered": MapsGeofenceEnteredEventData; - // (undocumented) "Microsoft.Maps.GeofenceExited": MapsGeofenceExitedEventData; - // (undocumented) "Microsoft.Maps.GeofenceResult": MapsGeofenceResultEventData; - // (undocumented) "Microsoft.Media.JobCanceled": MediaJobCanceledEventData; - // (undocumented) "Microsoft.Media.JobCanceling": MediaJobCancelingEventData; - // (undocumented) "Microsoft.Media.JobErrored": MediaJobErroredEventData; - // (undocumented) "Microsoft.Media.JobFinished": MediaJobFinishedEventData; - // (undocumented) "Microsoft.Media.JobOutputCanceled": MediaJobOutputCanceledEventData; - // (undocumented) "Microsoft.Media.JobOutputCanceling": MediaJobOutputCancelingEventData; - // (undocumented) "Microsoft.Media.JobOutputErrored": MediaJobOutputErroredEventData; - // (undocumented) "Microsoft.Media.JobOutputFinished": MediaJobOutputFinishedEventData; - // (undocumented) "Microsoft.Media.JobOutputProcessing": MediaJobOutputProcessingEventData; - // (undocumented) "Microsoft.Media.JobOutputProgress": MediaJobOutputProgressEventData; - // (undocumented) "Microsoft.Media.JobOutputScheduled": MediaJobOutputScheduledEventData; - // (undocumented) "Microsoft.Media.JobOutputStateChange": MediaJobOutputStateChangeEventData; - // (undocumented) "Microsoft.Media.JobProcessing": MediaJobProcessingEventData; - // (undocumented) "Microsoft.Media.JobScheduled": MediaJobScheduledEventData; - // (undocumented) "Microsoft.Media.JobStateChange": MediaJobStateChangeEventData; - // (undocumented) "Microsoft.Media.LiveEventConnectionRejected": MediaLiveEventConnectionRejectedEventData; - // (undocumented) "Microsoft.Media.LiveEventEncoderConnected": MediaLiveEventEncoderConnectedEventData; - // (undocumented) "Microsoft.Media.LiveEventEncoderDisconnected": MediaLiveEventEncoderDisconnectedEventData; - // (undocumented) "Microsoft.Media.LiveEventIncomingDataChunkDropped": MediaLiveEventIncomingDataChunkDroppedEventData; - // (undocumented) "Microsoft.Media.LiveEventIncomingStreamReceived": MediaLiveEventIncomingStreamReceivedEventData; - // (undocumented) "Microsoft.Media.LiveEventIncomingStreamsOutOfSync": MediaLiveEventIncomingStreamsOutOfSyncEventData; - // (undocumented) "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync": MediaLiveEventIncomingVideoStreamsOutOfSyncEventData; - // (undocumented) "Microsoft.Media.LiveEventIngestHeartbeat": MediaLiveEventIngestHeartbeatEventData; - // (undocumented) "Microsoft.Media.LiveEventTrackDiscontinuityDetected": MediaLiveEventTrackDiscontinuityDetectedEventData; - // (undocumented) "Microsoft.Resources.ResourceActionCancel": ResourceActionCancelEventData; - // (undocumented) "Microsoft.Resources.ResourceActionFailure": ResourceActionFailureEventData; - // (undocumented) "Microsoft.Resources.ResourceActionSuccess": ResourceActionSuccessEventData; - // (undocumented) "Microsoft.Resources.ResourceDeleteCancel": ResourceDeleteCancelEventData; - // (undocumented) "Microsoft.Resources.ResourceDeleteFailure": ResourceDeleteFailureEventData; - // (undocumented) "Microsoft.Resources.ResourceDeleteSuccess": ResourceDeleteSuccessEventData; - // (undocumented) "Microsoft.Resources.ResourceWriteCancel": ResourceWriteCancelEventData; - // (undocumented) "Microsoft.Resources.ResourceWriteFailure": ResourceWriteFailureEventData; - // (undocumented) "Microsoft.Resources.ResourceWriteSuccess": ResourceWriteSuccessEventData; - // (undocumented) "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners": ServiceBusActiveMessagesAvailableWithNoListenersEventData; - // (undocumented) "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener": ServiceBusDeadletterMessagesAvailableWithNoListenersEventData; - // (undocumented) "Microsoft.Storage.BlobCreated": StorageBlobCreatedEventData; - // (undocumented) "Microsoft.Storage.BlobDeleted": StorageBlobDeletedEventData; - // (undocumented) "Microsoft.Storage.BlobRenamed": StorageBlobRenamedEventData; - // (undocumented) "Microsoft.Storage.DirectoryCreated": StorageDirectoryCreatedEventData; - // (undocumented) "Microsoft.Storage.DirectoryDeleted": StorageDirectoryDeletedEventData; - // (undocumented) "Microsoft.Storage.DirectoryRenamed": StorageDirectoryRenamedEventData; - // (undocumented) "Microsoft.Storage.LifecyclePolicyCompleted": StorageLifecyclePolicyCompletedEventData; - // (undocumented) "Microsoft.Web.AppServicePlanUpdated": WebAppServicePlanUpdatedEventData; - // (undocumented) "Microsoft.Web.AppUpdated": WebAppUpdatedEventData; - // (undocumented) "Microsoft.Web.BackupOperationCompleted": WebBackupOperationCompletedEventData; - // (undocumented) "Microsoft.Web.BackupOperationFailed": WebBackupOperationFailedEventData; - // (undocumented) "Microsoft.Web.BackupOperationStarted": WebBackupOperationStartedEventData; - // (undocumented) "Microsoft.Web.RestoreOperationCompleted": WebRestoreOperationCompletedEventData; - // (undocumented) "Microsoft.Web.RestoreOperationFailed": WebRestoreOperationFailedEventData; - // (undocumented) "Microsoft.Web.RestoreOperationStarted": WebRestoreOperationStartedEventData; - // (undocumented) "Microsoft.Web.SlotSwapCompleted": WebSlotSwapCompletedEventData; - // (undocumented) "Microsoft.Web.SlotSwapFailed": WebSlotSwapFailedEventData; - // (undocumented) "Microsoft.Web.SlotSwapStarted": WebSlotSwapStartedEventData; - // (undocumented) "Microsoft.Web.SlotSwapWithPreviewCancelled": WebSlotSwapWithPreviewCancelledEventData; - // (undocumented) "Microsoft.Web.SlotSwapWithPreviewStarted": WebSlotSwapWithPreviewStartedEventData; } diff --git a/sdk/eventgrid/eventgrid/src/predicates.ts b/sdk/eventgrid/eventgrid/src/predicates.ts index 44c69df61a08..805e9844e910 100644 --- a/sdk/eventgrid/eventgrid/src/predicates.ts +++ b/sdk/eventgrid/eventgrid/src/predicates.ts @@ -172,82 +172,159 @@ export type KnownSystemEventTypes = * @ignore */ export interface SystemEventNameToEventData { + /** An interface for the event data of a "Microsoft.AppConfiguration.KeyValueDeleted" event. */ "Microsoft.AppConfiguration.KeyValueDeleted": AppConfigurationKeyValueDeletedEventData; + /** An interface for the event data of a "Microsoft.AppConfiguration.KeyValueModified" event. */ "Microsoft.AppConfiguration.KeyValueModified": AppConfigurationKeyValueModifiedEventData; + /** An interface for the event data of a "Microsoft.ContainerRegistry.ImagePushed" event. */ "Microsoft.ContainerRegistry.ImagePushed": ContainerRegistryImagePushedEventData; + /** An interface for the event data of a "Microsoft.ContainerRegistry.ImageDeleted" event. */ "Microsoft.ContainerRegistry.ImageDeleted": ContainerRegistryImageDeletedEventData; + /** An interface for the event data of a "Microsoft.ContainerRegistry.ChartDeleted" event. */ "Microsoft.ContainerRegistry.ChartDeleted": ContainerRegistryChartDeletedEventData; + /** An interface for the event data of a "Microsoft.ContainerRegistry.ChartPushed" event. */ "Microsoft.ContainerRegistry.ChartPushed": ContainerRegistryChartPushedEventData; + /** An interface for the event data of a "Microsoft.Devices.DeviceCreated" event. */ "Microsoft.Devices.DeviceCreated": IotHubDeviceCreatedEventData; + /** An interface for the event data of a "Microsoft.Devices.DeviceDeleted" event. */ "Microsoft.Devices.DeviceDeleted": IotHubDeviceDeletedEventData; + /** An interface for the event data of a "Microsoft.Devices.DeviceConnected" event. */ "Microsoft.Devices.DeviceConnected": IotHubDeviceConnectedEventData; + /** An interface for the event data of a "Microsoft.Devices.DeviceDisconnected" event. */ "Microsoft.Devices.DeviceDisconnected": IotHubDeviceDisconnectedEventData; + /** An interface for the event data of a "Microsoft.Devices.DeviceTelemetry" event. */ "Microsoft.Devices.DeviceTelemetry": IotHubDeviceTelemetryEventData; + /** An interface for the event data of a "Microsoft.EventGrid.SubscriptionValidationEvent" event. */ "Microsoft.EventGrid.SubscriptionValidationEvent": SubscriptionValidationEventData; + /** An interface for the event data of a "Microsoft.EventGrid.SubscriptionDeletedEvent" event. */ "Microsoft.EventGrid.SubscriptionDeletedEvent": SubscriptionDeletedEventData; + /** An interface for the event data of a "Microsoft.EventHub.CaptureFileCreated" event. */ "Microsoft.EventHub.CaptureFileCreated": EventHubCaptureFileCreatedEventData; + /** An interface for the event data of a "Microsoft.MachineLearningServices.DatasetDriftDetected" event. */ "Microsoft.MachineLearningServices.DatasetDriftDetected": MachineLearningServicesDatasetDriftDetectedEventData; + /** An interface for the event data of a "Microsoft.MachineLearningServices.ModelDeployed" event. */ "Microsoft.MachineLearningServices.ModelDeployed": MachineLearningServicesModelDeployedEventData; + /** An interface for the event data of a "Microsoft.MachineLearningServices.ModelRegistered" event. */ "Microsoft.MachineLearningServices.ModelRegistered": MachineLearningServicesModelRegisteredEventData; + /** An interface for the event data of a "Microsoft.MachineLearningServices.RunCompleted" event. */ "Microsoft.MachineLearningServices.RunCompleted": MachineLearningServicesRunCompletedEventData; + /** An interface for the event data of a "Microsoft.MachineLearningServices.RunStatusChanged" event. */ "Microsoft.MachineLearningServices.RunStatusChanged": MachineLearningServicesRunStatusChangedEventData; + /** An interface for the event data of a "Microsoft.Maps.GeofenceEntered" event. */ "Microsoft.Maps.GeofenceEntered": MapsGeofenceEnteredEventData; + /** An interface for the event data of a "Microsoft.Maps.GeofenceExited" event. */ "Microsoft.Maps.GeofenceExited": MapsGeofenceExitedEventData; + /** An interface for the event data of a "Microsoft.Maps.GeofenceResult" event. */ "Microsoft.Maps.GeofenceResult": MapsGeofenceResultEventData; + /** An interface for the event data of a "Microsoft.Media.JobStateChange" event. */ "Microsoft.Media.JobStateChange": MediaJobStateChangeEventData; + /** An interface for the event data of a "Microsoft.Media.JobOutputStateChange" event. */ "Microsoft.Media.JobOutputStateChange": MediaJobOutputStateChangeEventData; + /** An interface for the event data of a "Microsoft.Media.JobScheduled" event. */ "Microsoft.Media.JobScheduled": MediaJobScheduledEventData; + /** An interface for the event data of a "Microsoft.Media.JobProcessing" event. */ "Microsoft.Media.JobProcessing": MediaJobProcessingEventData; + /** An interface for the event data of a "Microsoft.Media.JobCanceling" event. */ "Microsoft.Media.JobCanceling": MediaJobCancelingEventData; + /** An interface for the event data of a "Microsoft.Media.JobFinished" event. */ "Microsoft.Media.JobFinished": MediaJobFinishedEventData; + /** An interface for the event data of a "Microsoft.Media.JobCanceled" event. */ "Microsoft.Media.JobCanceled": MediaJobCanceledEventData; + /** An interface for the event data of a "Microsoft.Media.JobErrored" event. */ "Microsoft.Media.JobErrored": MediaJobErroredEventData; + /** An interface for the event data of a "Microsoft.Media.JobOutputCanceled" event. */ "Microsoft.Media.JobOutputCanceled": MediaJobOutputCanceledEventData; + /** An interface for the event data of a "Microsoft.Media.JobOutputCanceling" event. */ "Microsoft.Media.JobOutputCanceling": MediaJobOutputCancelingEventData; + /** An interface for the event data of a "Microsoft.Media.JobOutputErrored" event. */ "Microsoft.Media.JobOutputErrored": MediaJobOutputErroredEventData; + /** An interface for the event data of a "Microsoft.Media.JobOutputFinished" event. */ "Microsoft.Media.JobOutputFinished": MediaJobOutputFinishedEventData; + /** An interface for the event data of a "Microsoft.Media.JobOutputProcessing" event. */ "Microsoft.Media.JobOutputProcessing": MediaJobOutputProcessingEventData; + /** An interface for the event data of a "Microsoft.Media.JobOutputScheduled" event. */ "Microsoft.Media.JobOutputScheduled": MediaJobOutputScheduledEventData; + /** An interface for the event data of a "Microsoft.Media.JobOutputProgress" event. */ "Microsoft.Media.JobOutputProgress": MediaJobOutputProgressEventData; + /** An interface for the event data of a "Microsoft.Media.LiveEventEncoderConnected" event. */ "Microsoft.Media.LiveEventEncoderConnected": MediaLiveEventEncoderConnectedEventData; + /** An interface for the event data of a "Microsoft.Media.LiveEventConnectionRejected" event. */ "Microsoft.Media.LiveEventConnectionRejected": MediaLiveEventConnectionRejectedEventData; + /** An interface for the event data of a "Microsoft.Media.LiveEventEncoderDisconnected" event. */ "Microsoft.Media.LiveEventEncoderDisconnected": MediaLiveEventEncoderDisconnectedEventData; + /** An interface for the event data of a "Microsoft.Media.LiveEventIncomingStreamReceived" event. */ "Microsoft.Media.LiveEventIncomingStreamReceived": MediaLiveEventIncomingStreamReceivedEventData; + /** An interface for the event data of a "Microsoft.Media.LiveEventIncomingStreamsOutOfSync" event. */ "Microsoft.Media.LiveEventIncomingStreamsOutOfSync": MediaLiveEventIncomingStreamsOutOfSyncEventData; + /** An interface for the event data of a "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync" event. */ "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync": MediaLiveEventIncomingVideoStreamsOutOfSyncEventData; + /** An interface for the event data of a "Microsoft.Media.LiveEventIncomingDataChunkDropped" event. */ "Microsoft.Media.LiveEventIncomingDataChunkDropped": MediaLiveEventIncomingDataChunkDroppedEventData; + /** An interface for the event data of a "Microsoft.Media.LiveEventIngestHeartbeat" event. */ "Microsoft.Media.LiveEventIngestHeartbeat": MediaLiveEventIngestHeartbeatEventData; + /** An interface for the event data of a "Microsoft.Media.LiveEventTrackDiscontinuityDetected" event. */ "Microsoft.Media.LiveEventTrackDiscontinuityDetected": MediaLiveEventTrackDiscontinuityDetectedEventData; + /** An interface for the event data of a "Microsoft.Resources.ResourceWriteSuccess" event. */ "Microsoft.Resources.ResourceWriteSuccess": ResourceWriteSuccessEventData; + /** An interface for the event data of a "Microsoft.Resources.ResourceWriteFailure" event. */ "Microsoft.Resources.ResourceWriteFailure": ResourceWriteFailureEventData; + /** An interface for the event data of a "Microsoft.Resources.ResourceWriteCancel" event. */ "Microsoft.Resources.ResourceWriteCancel": ResourceWriteCancelEventData; + /** An interface for the event data of a "Microsoft.Resources.ResourceDeleteSuccess" event. */ "Microsoft.Resources.ResourceDeleteSuccess": ResourceDeleteSuccessEventData; + /** An interface for the event data of a "Microsoft.Resources.ResourceDeleteFailure" event. */ "Microsoft.Resources.ResourceDeleteFailure": ResourceDeleteFailureEventData; + /** An interface for the event data of a "Microsoft.Resources.ResourceDeleteCancel" event. */ "Microsoft.Resources.ResourceDeleteCancel": ResourceDeleteCancelEventData; + /** An interface for the event data of a "Microsoft.Resources.ResourceActionSuccess" event. */ "Microsoft.Resources.ResourceActionSuccess": ResourceActionSuccessEventData; + /** An interface for the event data of a "Microsoft.Resources.ResourceActionFailure" event. */ "Microsoft.Resources.ResourceActionFailure": ResourceActionFailureEventData; + /** An interface for the event data of a "Microsoft.Resources.ResourceActionCancel" event. */ "Microsoft.Resources.ResourceActionCancel": ResourceActionCancelEventData; + /** An interface for the event data of a "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners" event. */ "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners": ServiceBusActiveMessagesAvailableWithNoListenersEventData; + /** An interface for the event data of a "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener" event. */ "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener": ServiceBusDeadletterMessagesAvailableWithNoListenersEventData; + /** An interface for the event data of a "Microsoft.Storage.BlobCreated" event. */ "Microsoft.Storage.BlobCreated": StorageBlobCreatedEventData; + /** An interface for the event data of a "Microsoft.Storage.BlobDeleted" event. */ "Microsoft.Storage.BlobDeleted": StorageBlobDeletedEventData; + /** An interface for the event data of a "Microsoft.Storage.BlobRenamed" event. */ "Microsoft.Storage.BlobRenamed": StorageBlobRenamedEventData; + /** An interface for the event data of a "Microsoft.Storage.DirectoryCreated" event. */ "Microsoft.Storage.DirectoryCreated": StorageDirectoryCreatedEventData; + /** An interface for the event data of a "Microsoft.Storage.DirectoryDeleted" event. */ "Microsoft.Storage.DirectoryDeleted": StorageDirectoryDeletedEventData; + /** An interface for the event data of a "Microsoft.Storage.DirectoryRenamed" event. */ "Microsoft.Storage.DirectoryRenamed": StorageDirectoryRenamedEventData; + /** An interface for the event data of a "Microsoft.Storage.LifecyclePolicyCompleted" event. */ "Microsoft.Storage.LifecyclePolicyCompleted": StorageLifecyclePolicyCompletedEventData; + /** An interface for the event data of a "Microsoft.Web.AppUpdated" event. */ "Microsoft.Web.AppUpdated": WebAppUpdatedEventData; + /** An interface for the event data of a "Microsoft.Web.BackupOperationStarted" event. */ "Microsoft.Web.BackupOperationStarted": WebBackupOperationStartedEventData; + /** An interface for the event data of a "Microsoft.Web.BackupOperationCompleted" event. */ "Microsoft.Web.BackupOperationCompleted": WebBackupOperationCompletedEventData; + /** An interface for the event data of a "Microsoft.Web.BackupOperationFailed" event. */ "Microsoft.Web.BackupOperationFailed": WebBackupOperationFailedEventData; + /** An interface for the event data of a "Microsoft.Web.RestoreOperationStarted" event. */ "Microsoft.Web.RestoreOperationStarted": WebRestoreOperationStartedEventData; + /** An interface for the event data of a "Microsoft.Web.RestoreOperationCompleted" event. */ "Microsoft.Web.RestoreOperationCompleted": WebRestoreOperationCompletedEventData; + /** An interface for the event data of a "Microsoft.Web.RestoreOperationFailed" event. */ "Microsoft.Web.RestoreOperationFailed": WebRestoreOperationFailedEventData; + /** An interface for the event data of a "Microsoft.Web.SlotSwapStarted" event. */ "Microsoft.Web.SlotSwapStarted": WebSlotSwapStartedEventData; + /** An interface for the event data of a "Microsoft.Web.SlotSwapCompleted" event. */ "Microsoft.Web.SlotSwapCompleted": WebSlotSwapCompletedEventData; + /** An interface for the event data of a "Microsoft.Web.SlotSwapFailed" event. */ "Microsoft.Web.SlotSwapFailed": WebSlotSwapFailedEventData; + /** An interface for the event data of a "Microsoft.Web.SlotSwapWithPreviewStarted" event. */ "Microsoft.Web.SlotSwapWithPreviewStarted": WebSlotSwapWithPreviewStartedEventData; + /** An interface for the event data of a "Microsoft.Web.SlotSwapWithPreviewCancelled" event. */ "Microsoft.Web.SlotSwapWithPreviewCancelled": WebSlotSwapWithPreviewCancelledEventData; + /** An interface for the event data of a "Microsoft.Web.AppServicePlanUpdated" event. */ "Microsoft.Web.AppServicePlanUpdated": WebAppServicePlanUpdatedEventData; } diff --git a/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts b/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts index 0b1b612c1b46..73e25ef0a48d 100644 --- a/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts +++ b/sdk/eventgrid/eventgrid/src/systemEventDecoders.ts @@ -3,30 +3,258 @@ import { Mapper, Serializer } from "@azure/core-http"; import { CustomEventDataDeserializer } from "./models"; -import { EventHubCaptureFileCreatedEventData } from "./generated/models/mappers"; import { + AppConfigurationKeyValueDeletedEventData, + AppConfigurationKeyValueModifiedEventData, + AppEventTypeDetail, + AppServicePlanEventTypeDetail, + ContainerRegistryArtifactEventData, + ContainerRegistryArtifactEventTarget, + ContainerRegistryChartDeletedEventData, + ContainerRegistryChartPushedEventData, + ContainerRegistryEventActor, ContainerRegistryEventData, - ContainerRegistryEventTarget, ContainerRegistryEventRequest, - ContainerRegistryEventActor, - ContainerRegistryEventSource + ContainerRegistryEventSource, + ContainerRegistryEventTarget, + ContainerRegistryImageDeletedEventData, + ContainerRegistryImagePushedEventData, + DeviceConnectionStateEventInfo, + DeviceConnectionStateEventProperties, + DeviceLifeCycleEventProperties, + DeviceTelemetryEventProperties, + DeviceTwinInfo, + DeviceTwinInfoProperties, + DeviceTwinInfoX509Thumbprint, + DeviceTwinMetadata, + DeviceTwinProperties, + EventHubCaptureFileCreatedEventData, + IotHubDeviceConnectedEventData, + IotHubDeviceCreatedEventData, + IotHubDeviceDeletedEventData, + IotHubDeviceDisconnectedEventData, + IotHubDeviceTelemetryEventData, + KeyVaultCertificateExpiredEventData, + KeyVaultCertificateNearExpiryEventData, + KeyVaultCertificateNewVersionCreatedEventData, + KeyVaultKeyExpiredEventData, + KeyVaultKeyNearExpiryEventData, + KeyVaultKeyNewVersionCreatedEventData, + KeyVaultSecretExpiredEventData, + KeyVaultSecretNearExpiryEventData, + KeyVaultSecretNewVersionCreatedEventData, + MachineLearningServicesDatasetDriftDetectedEventData, + MachineLearningServicesModelDeployedEventData, + MachineLearningServicesModelRegisteredEventData, + MachineLearningServicesRunCompletedEventData, + MachineLearningServicesRunStatusChangedEventData, + MapsGeofenceEnteredEventData, + MapsGeofenceEventProperties, + MapsGeofenceExitedEventData, + MapsGeofenceGeometry, + MapsGeofenceResultEventData, + MediaJobCanceledEventData, + MediaJobCancelingEventData, + MediaJobError, + MediaJobErrorDetail, + MediaJobErroredEventData, + MediaJobFinishedEventData, + MediaJobOutput, + MediaJobOutputAsset, + MediaJobOutputCanceledEventData, + MediaJobOutputCancelingEventData, + MediaJobOutputErroredEventData, + MediaJobOutputFinishedEventData, + MediaJobOutputProcessingEventData, + MediaJobOutputProgressEventData, + MediaJobOutputScheduledEventData, + MediaJobOutputStateChangeEventData, + MediaJobProcessingEventData, + MediaJobScheduledEventData, + MediaJobStateChangeEventData, + MediaLiveEventConnectionRejectedEventData, + MediaLiveEventEncoderConnectedEventData, + MediaLiveEventEncoderDisconnectedEventData, + MediaLiveEventIncomingDataChunkDroppedEventData, + MediaLiveEventIncomingStreamReceivedEventData, + MediaLiveEventIncomingStreamsOutOfSyncEventData, + MediaLiveEventIncomingVideoStreamsOutOfSyncEventData, + MediaLiveEventIngestHeartbeatEventData, + MediaLiveEventTrackDiscontinuityDetectedEventData, + RedisExportRDBCompletedEventData, + RedisImportRDBCompletedEventData, + RedisPatchingCompletedEventData, + RedisScalingCompletedEventData, + ResourceActionCancelEventData, + ResourceActionFailureEventData, + ResourceActionSuccessEventData, + ResourceDeleteCancelEventData, + ResourceDeleteFailureEventData, + ResourceDeleteSuccessEventData, + ResourceWriteCancelEventData, + ResourceWriteFailureEventData, + ResourceWriteSuccessEventData, + ServiceBusActiveMessagesAvailableWithNoListenersEventData, + ServiceBusDeadletterMessagesAvailableWithNoListenersEventData, + SignalRServiceClientConnectionConnectedEventData, + SignalRServiceClientConnectionDisconnectedEventData, + StorageBlobCreatedEventData, + StorageBlobDeletedEventData, + StorageBlobRenamedEventData, + StorageDirectoryCreatedEventData, + StorageDirectoryDeletedEventData, + StorageDirectoryRenamedEventData, + StorageLifecyclePolicyActionSummaryDetail, + StorageLifecyclePolicyCompletedEventData, + SubscriptionDeletedEventData, + SubscriptionValidationEventData, + SubscriptionValidationResponse, + WebAppServicePlanUpdatedEventData, + WebAppServicePlanUpdatedEventDataSku, + WebAppUpdatedEventData, + WebBackupOperationCompletedEventData, + WebBackupOperationFailedEventData, + WebBackupOperationStartedEventData, + WebRestoreOperationCompletedEventData, + WebRestoreOperationFailedEventData, + WebRestoreOperationStartedEventData, + WebSlotSwapCompletedEventData, + WebSlotSwapFailedEventData, + WebSlotSwapStartedEventData, + WebSlotSwapWithPreviewCancelledEventData, + WebSlotSwapWithPreviewStartedEventData } from "./generated/models/mappers"; const serializer = new Serializer({ - ContainerRegistryEventTarget: ContainerRegistryEventTarget, - ContainerRegistryEventRequest: ContainerRegistryEventRequest, + AppConfigurationKeyValueDeletedEventData: AppConfigurationKeyValueDeletedEventData, + AppConfigurationKeyValueModifiedEventData: AppConfigurationKeyValueModifiedEventData, + AppEventTypeDetail: AppEventTypeDetail, + AppServicePlanEventTypeDetail: AppServicePlanEventTypeDetail, + ContainerRegistryArtifactEventData: ContainerRegistryArtifactEventData, + ContainerRegistryArtifactEventTarget: ContainerRegistryArtifactEventTarget, + ContainerRegistryChartDeletedEventData: ContainerRegistryChartDeletedEventData, + ContainerRegistryChartPushedEventData: ContainerRegistryChartPushedEventData, ContainerRegistryEventActor: ContainerRegistryEventActor, - ContainerRegistryEventSource: ContainerRegistryEventSource + ContainerRegistryEventData: ContainerRegistryEventData, + ContainerRegistryEventRequest: ContainerRegistryEventRequest, + ContainerRegistryEventSource: ContainerRegistryEventSource, + ContainerRegistryEventTarget: ContainerRegistryEventTarget, + ContainerRegistryImageDeletedEventData: ContainerRegistryImageDeletedEventData, + ContainerRegistryImagePushedEventData: ContainerRegistryImagePushedEventData, + DeviceConnectionStateEventInfo: DeviceConnectionStateEventInfo, + DeviceConnectionStateEventProperties: DeviceConnectionStateEventProperties, + DeviceLifeCycleEventProperties: DeviceLifeCycleEventProperties, + DeviceTelemetryEventProperties: DeviceTelemetryEventProperties, + DeviceTwinInfo: DeviceTwinInfo, + DeviceTwinInfoProperties: DeviceTwinInfoProperties, + DeviceTwinInfoX509Thumbprint: DeviceTwinInfoX509Thumbprint, + DeviceTwinMetadata: DeviceTwinMetadata, + DeviceTwinProperties: DeviceTwinProperties, + EventHubCaptureFileCreatedEventData: EventHubCaptureFileCreatedEventData, + IotHubDeviceConnectedEventData: IotHubDeviceConnectedEventData, + IotHubDeviceCreatedEventData: IotHubDeviceCreatedEventData, + IotHubDeviceDeletedEventData: IotHubDeviceDeletedEventData, + IotHubDeviceDisconnectedEventData: IotHubDeviceDisconnectedEventData, + IotHubDeviceTelemetryEventData: IotHubDeviceTelemetryEventData, + KeyVaultCertificateExpiredEventData: KeyVaultCertificateExpiredEventData, + KeyVaultCertificateNearExpiryEventData: KeyVaultCertificateNearExpiryEventData, + KeyVaultCertificateNewVersionCreatedEventData: KeyVaultCertificateNewVersionCreatedEventData, + KeyVaultKeyExpiredEventData: KeyVaultKeyExpiredEventData, + KeyVaultKeyNearExpiryEventData: KeyVaultKeyNearExpiryEventData, + KeyVaultKeyNewVersionCreatedEventData: KeyVaultKeyNewVersionCreatedEventData, + KeyVaultSecretExpiredEventData: KeyVaultSecretExpiredEventData, + KeyVaultSecretNearExpiryEventData: KeyVaultSecretNearExpiryEventData, + KeyVaultSecretNewVersionCreatedEventData: KeyVaultSecretNewVersionCreatedEventData, + MachineLearningServicesDatasetDriftDetectedEventData: MachineLearningServicesDatasetDriftDetectedEventData, + MachineLearningServicesModelDeployedEventData: MachineLearningServicesModelDeployedEventData, + MachineLearningServicesModelRegisteredEventData: MachineLearningServicesModelRegisteredEventData, + MachineLearningServicesRunCompletedEventData: MachineLearningServicesRunCompletedEventData, + MachineLearningServicesRunStatusChangedEventData: MachineLearningServicesRunStatusChangedEventData, + MapsGeofenceEnteredEventData: MapsGeofenceEnteredEventData, + MapsGeofenceEventProperties: MapsGeofenceEventProperties, + MapsGeofenceExitedEventData: MapsGeofenceExitedEventData, + MapsGeofenceGeometry: MapsGeofenceGeometry, + MapsGeofenceResultEventData: MapsGeofenceResultEventData, + MediaJobCanceledEventData: MediaJobCanceledEventData, + MediaJobCancelingEventData: MediaJobCancelingEventData, + MediaJobError: MediaJobError, + MediaJobErrorDetail: MediaJobErrorDetail, + MediaJobErroredEventData: MediaJobErroredEventData, + MediaJobFinishedEventData: MediaJobFinishedEventData, + MediaJobOutput: MediaJobOutput, + MediaJobOutputAsset: MediaJobOutputAsset, + MediaJobOutputCanceledEventData: MediaJobOutputCanceledEventData, + MediaJobOutputCancelingEventData: MediaJobOutputCancelingEventData, + MediaJobOutputErroredEventData: MediaJobOutputErroredEventData, + MediaJobOutputFinishedEventData: MediaJobOutputFinishedEventData, + MediaJobOutputProcessingEventData: MediaJobOutputProcessingEventData, + MediaJobOutputProgressEventData: MediaJobOutputProgressEventData, + MediaJobOutputScheduledEventData: MediaJobOutputScheduledEventData, + MediaJobOutputStateChangeEventData: MediaJobOutputStateChangeEventData, + MediaJobProcessingEventData: MediaJobProcessingEventData, + MediaJobScheduledEventData: MediaJobScheduledEventData, + MediaJobStateChangeEventData: MediaJobStateChangeEventData, + MediaLiveEventConnectionRejectedEventData: MediaLiveEventConnectionRejectedEventData, + MediaLiveEventEncoderConnectedEventData: MediaLiveEventEncoderConnectedEventData, + MediaLiveEventEncoderDisconnectedEventData: MediaLiveEventEncoderDisconnectedEventData, + MediaLiveEventIncomingDataChunkDroppedEventData: MediaLiveEventIncomingDataChunkDroppedEventData, + MediaLiveEventIncomingStreamReceivedEventData: MediaLiveEventIncomingStreamReceivedEventData, + MediaLiveEventIncomingStreamsOutOfSyncEventData: MediaLiveEventIncomingStreamsOutOfSyncEventData, + MediaLiveEventIncomingVideoStreamsOutOfSyncEventData: MediaLiveEventIncomingVideoStreamsOutOfSyncEventData, + MediaLiveEventIngestHeartbeatEventData: MediaLiveEventIngestHeartbeatEventData, + MediaLiveEventTrackDiscontinuityDetectedEventData: MediaLiveEventTrackDiscontinuityDetectedEventData, + RedisExportRDBCompletedEventData: RedisExportRDBCompletedEventData, + RedisImportRDBCompletedEventData: RedisImportRDBCompletedEventData, + RedisPatchingCompletedEventData: RedisPatchingCompletedEventData, + RedisScalingCompletedEventData: RedisScalingCompletedEventData, + ResourceActionCancelEventData: ResourceActionCancelEventData, + ResourceActionFailureEventData: ResourceActionFailureEventData, + ResourceActionSuccessEventData: ResourceActionSuccessEventData, + ResourceDeleteCancelEventData: ResourceDeleteCancelEventData, + ResourceDeleteFailureEventData: ResourceDeleteFailureEventData, + ResourceDeleteSuccessEventData: ResourceDeleteSuccessEventData, + ResourceWriteCancelEventData: ResourceWriteCancelEventData, + ResourceWriteFailureEventData: ResourceWriteFailureEventData, + ResourceWriteSuccessEventData: ResourceWriteSuccessEventData, + ServiceBusActiveMessagesAvailableWithNoListenersEventData: ServiceBusActiveMessagesAvailableWithNoListenersEventData, + ServiceBusDeadletterMessagesAvailableWithNoListenersEventData: ServiceBusDeadletterMessagesAvailableWithNoListenersEventData, + SignalRServiceClientConnectionConnectedEventData: SignalRServiceClientConnectionConnectedEventData, + SignalRServiceClientConnectionDisconnectedEventData: SignalRServiceClientConnectionDisconnectedEventData, + StorageBlobCreatedEventData: StorageBlobCreatedEventData, + StorageBlobDeletedEventData: StorageBlobDeletedEventData, + StorageBlobRenamedEventData: StorageBlobRenamedEventData, + StorageDirectoryCreatedEventData: StorageDirectoryCreatedEventData, + StorageDirectoryDeletedEventData: StorageDirectoryDeletedEventData, + StorageDirectoryRenamedEventData: StorageDirectoryRenamedEventData, + StorageLifecyclePolicyActionSummaryDetail: StorageLifecyclePolicyActionSummaryDetail, + StorageLifecyclePolicyCompletedEventData: StorageLifecyclePolicyCompletedEventData, + SubscriptionDeletedEventData: SubscriptionDeletedEventData, + SubscriptionValidationEventData: SubscriptionValidationEventData, + SubscriptionValidationResponse: SubscriptionValidationResponse, + WebAppServicePlanUpdatedEventData: WebAppServicePlanUpdatedEventData, + WebAppServicePlanUpdatedEventDataSku: WebAppServicePlanUpdatedEventDataSku, + WebAppUpdatedEventData: WebAppUpdatedEventData, + WebBackupOperationCompletedEventData: WebBackupOperationCompletedEventData, + WebBackupOperationFailedEventData: WebBackupOperationFailedEventData, + WebBackupOperationStartedEventData: WebBackupOperationStartedEventData, + WebRestoreOperationCompletedEventData: WebRestoreOperationCompletedEventData, + WebRestoreOperationFailedEventData: WebRestoreOperationFailedEventData, + WebRestoreOperationStartedEventData: WebRestoreOperationStartedEventData, + WebSlotSwapCompletedEventData: WebSlotSwapCompletedEventData, + WebSlotSwapFailedEventData: WebSlotSwapFailedEventData, + WebSlotSwapStartedEventData: WebSlotSwapStartedEventData, + WebSlotSwapWithPreviewCancelledEventData: WebSlotSwapWithPreviewCancelledEventData, + WebSlotSwapWithPreviewStartedEventData: WebSlotSwapWithPreviewStartedEventData }); function makeDeserializerFromMapper( mapper: Mapper, - initialDesializers?: CustomEventDataDeserializer[] + initialDeserializers?: CustomEventDataDeserializer[] ): CustomEventDataDeserializer { return async function(o: any): Promise { - if (initialDesializers) { - for (const decoder of initialDesializers) { - o = await decoder(o); + if (initialDeserializers) { + for (const deserializer of initialDeserializers) { + o = await deserializer(o); } } @@ -34,6 +262,10 @@ function makeDeserializerFromMapper( }; } +// Some system events are published in a format that does not match the schema they publish. In these cases, the "event data" +// field is actually a string with the event data encoded as JSON. For the few system events we know of that are incorrect we +// use this deserializer to convert from the string to an object. This function is written such that it is a no-op when a non +// string value is provided (i.e. when the system events are corrected to publish the data as an actual object, we will not break). async function jsonParseDeserializer(o: any): Promise { if (typeof o === "string") { return JSON.parse(o); @@ -43,6 +275,12 @@ async function jsonParseDeserializer(o: any): Promise { } export const systemDeserializers: Record = { + "Microsoft.AppConfiguration.KeyValueDeleted": makeDeserializerFromMapper( + AppConfigurationKeyValueDeletedEventData + ), + "Microsoft.AppConfiguration.KeyValueModified": makeDeserializerFromMapper( + AppConfigurationKeyValueModifiedEventData + ), "Microsoft.ContainerRegistry.ChartDeleted": makeDeserializerFromMapper( ContainerRegistryEventData, [jsonParseDeserializer] @@ -59,7 +297,167 @@ export const systemDeserializers: Record = ContainerRegistryEventData, [jsonParseDeserializer] ), + "Microsoft.Devices.DeviceCreated": makeDeserializerFromMapper(IotHubDeviceCreatedEventData), + "Microsoft.Devices.DeviceDeleted": makeDeserializerFromMapper(IotHubDeviceDeletedEventData), + "Microsoft.Devices.DeviceConnected": makeDeserializerFromMapper(IotHubDeviceConnectedEventData), + "Microsoft.Devices.DeviceDisconnected": makeDeserializerFromMapper( + IotHubDeviceDisconnectedEventData + ), + "Microsoft.Devices.DeviceTelemetry": makeDeserializerFromMapper(IotHubDeviceTelemetryEventData), + "Microsoft.EventGrid.SubscriptionValidationEvent": makeDeserializerFromMapper( + SubscriptionValidationEventData + ), + "Microsoft.EventGrid.SubscriptionDeletedEvent": makeDeserializerFromMapper( + SubscriptionDeletedEventData + ), "Microsoft.EventHub.CaptureFileCreated": makeDeserializerFromMapper( EventHubCaptureFileCreatedEventData + ), + "Microsoft.MachineLearningServices.DatasetDriftDetected": makeDeserializerFromMapper( + MachineLearningServicesDatasetDriftDetectedEventData + ), + "Microsoft.MachineLearningServices.ModelDeployed": makeDeserializerFromMapper( + MachineLearningServicesModelDeployedEventData + ), + "Microsoft.MachineLearningServices.ModelRegistered": makeDeserializerFromMapper( + MachineLearningServicesModelRegisteredEventData + ), + "Microsoft.MachineLearningServices.RunCompleted": makeDeserializerFromMapper( + MachineLearningServicesRunCompletedEventData + ), + "Microsoft.MachineLearningServices.RunStatusChanged": makeDeserializerFromMapper( + MachineLearningServicesRunStatusChangedEventData + ), + "Microsoft.Maps.GeofenceEntered": makeDeserializerFromMapper(MapsGeofenceEnteredEventData), + "Microsoft.Maps.GeofenceExited": makeDeserializerFromMapper(MapsGeofenceExitedEventData), + "Microsoft.Maps.GeofenceResult": makeDeserializerFromMapper(MapsGeofenceResultEventData), + "Microsoft.Media.JobStateChange": makeDeserializerFromMapper(MediaJobStateChangeEventData), + "Microsoft.Media.JobOutputStateChange": makeDeserializerFromMapper( + MediaJobOutputStateChangeEventData + ), + "Microsoft.Media.JobScheduled": makeDeserializerFromMapper(MediaJobScheduledEventData), + "Microsoft.Media.JobProcessing": makeDeserializerFromMapper(MediaJobProcessingEventData), + "Microsoft.Media.JobCanceling": makeDeserializerFromMapper(MediaJobCancelingEventData), + "Microsoft.Media.JobFinished": makeDeserializerFromMapper(MediaJobFinishedEventData), + "Microsoft.Media.JobCanceled": makeDeserializerFromMapper(MediaJobCanceledEventData), + "Microsoft.Media.JobErrored": makeDeserializerFromMapper(MediaJobErroredEventData), + "Microsoft.Media.JobOutputCanceled": makeDeserializerFromMapper(MediaJobOutputCanceledEventData), + "Microsoft.Media.JobOutputCanceling": makeDeserializerFromMapper( + MediaJobOutputCancelingEventData + ), + "Microsoft.Media.JobOutputErrored": makeDeserializerFromMapper(MediaJobOutputErroredEventData), + "Microsoft.Media.JobOutputFinished": makeDeserializerFromMapper(MediaJobOutputFinishedEventData), + "Microsoft.Media.JobOutputProcessing": makeDeserializerFromMapper( + MediaJobOutputProcessingEventData + ), + "Microsoft.Media.JobOutputScheduled": makeDeserializerFromMapper( + MediaJobOutputScheduledEventData + ), + "Microsoft.Media.JobOutputProgress": makeDeserializerFromMapper(MediaJobOutputProgressEventData), + "Microsoft.Media.LiveEventEncoderConnected": makeDeserializerFromMapper( + MediaLiveEventEncoderConnectedEventData + ), + "Microsoft.Media.LiveEventConnectionRejected": makeDeserializerFromMapper( + MediaLiveEventConnectionRejectedEventData + ), + "Microsoft.Media.LiveEventEncoderDisconnected": makeDeserializerFromMapper( + MediaLiveEventEncoderDisconnectedEventData + ), + "Microsoft.Media.LiveEventIncomingStreamReceived": makeDeserializerFromMapper( + MediaLiveEventIncomingStreamReceivedEventData + ), + "Microsoft.Media.LiveEventIncomingStreamsOutOfSync": makeDeserializerFromMapper( + MediaLiveEventIncomingStreamsOutOfSyncEventData + ), + "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync": makeDeserializerFromMapper( + MediaLiveEventIncomingVideoStreamsOutOfSyncEventData + ), + "Microsoft.Media.LiveEventIncomingDataChunkDropped": makeDeserializerFromMapper( + MediaLiveEventIncomingDataChunkDroppedEventData + ), + "Microsoft.Media.LiveEventIngestHeartbeat": makeDeserializerFromMapper( + MediaLiveEventIngestHeartbeatEventData + ), + "Microsoft.Media.LiveEventTrackDiscontinuityDetected": makeDeserializerFromMapper( + MediaLiveEventTrackDiscontinuityDetectedEventData + ), + "Microsoft.Resources.ResourceWriteSuccess": makeDeserializerFromMapper( + ResourceWriteSuccessEventData + ), + "Microsoft.Resources.ResourceWriteFailure": makeDeserializerFromMapper( + ResourceWriteFailureEventData + ), + "Microsoft.Resources.ResourceWriteCancel": makeDeserializerFromMapper( + ResourceWriteCancelEventData + ), + "Microsoft.Resources.ResourceDeleteSuccess": makeDeserializerFromMapper( + ResourceDeleteSuccessEventData + ), + "Microsoft.Resources.ResourceDeleteFailure": makeDeserializerFromMapper( + ResourceDeleteFailureEventData + ), + "Microsoft.Resources.ResourceDeleteCancel": makeDeserializerFromMapper( + ResourceDeleteCancelEventData + ), + "Microsoft.Resources.ResourceActionSuccess": makeDeserializerFromMapper( + ResourceActionSuccessEventData + ), + "Microsoft.Resources.ResourceActionFailure": makeDeserializerFromMapper( + ResourceActionFailureEventData + ), + "Microsoft.Resources.ResourceActionCancel": makeDeserializerFromMapper( + ResourceActionCancelEventData + ), + "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners": makeDeserializerFromMapper( + ServiceBusActiveMessagesAvailableWithNoListenersEventData + ), + "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener": makeDeserializerFromMapper( + ServiceBusDeadletterMessagesAvailableWithNoListenersEventData + ), + "Microsoft.Storage.BlobCreated": makeDeserializerFromMapper(StorageBlobCreatedEventData), + "Microsoft.Storage.BlobDeleted": makeDeserializerFromMapper(StorageBlobDeletedEventData), + "Microsoft.Storage.BlobRenamed": makeDeserializerFromMapper(StorageBlobRenamedEventData), + "Microsoft.Storage.DirectoryCreated": makeDeserializerFromMapper( + StorageDirectoryCreatedEventData + ), + "Microsoft.Storage.DirectoryDeleted": makeDeserializerFromMapper( + StorageDirectoryDeletedEventData + ), + "Microsoft.Storage.DirectoryRenamed": makeDeserializerFromMapper( + StorageDirectoryRenamedEventData + ), + "Microsoft.Storage.LifecyclePolicyCompleted": makeDeserializerFromMapper( + StorageLifecyclePolicyCompletedEventData + ), + "Microsoft.Web.AppUpdated": makeDeserializerFromMapper(WebAppUpdatedEventData), + "Microsoft.Web.BackupOperationStarted": makeDeserializerFromMapper( + WebBackupOperationStartedEventData + ), + "Microsoft.Web.BackupOperationCompleted": makeDeserializerFromMapper( + WebBackupOperationCompletedEventData + ), + "Microsoft.Web.BackupOperationFailed": makeDeserializerFromMapper( + WebBackupOperationFailedEventData + ), + "Microsoft.Web.RestoreOperationStarted": makeDeserializerFromMapper( + WebRestoreOperationStartedEventData + ), + "Microsoft.Web.RestoreOperationCompleted": makeDeserializerFromMapper( + WebRestoreOperationCompletedEventData + ), + "Microsoft.Web.RestoreOperationFailed": makeDeserializerFromMapper( + WebRestoreOperationFailedEventData + ), + "Microsoft.Web.SlotSwapStarted": makeDeserializerFromMapper(WebSlotSwapStartedEventData), + "Microsoft.Web.SlotSwapCompleted": makeDeserializerFromMapper(WebSlotSwapCompletedEventData), + "Microsoft.Web.SlotSwapFailed": makeDeserializerFromMapper(WebSlotSwapFailedEventData), + "Microsoft.Web.SlotSwapWithPreviewStarted": makeDeserializerFromMapper( + WebSlotSwapWithPreviewStartedEventData + ), + "Microsoft.Web.SlotSwapWithPreviewCancelled": makeDeserializerFromMapper( + WebSlotSwapWithPreviewCancelledEventData + ), + "Microsoft.Web.AppServicePlanUpdated": makeDeserializerFromMapper( + WebAppServicePlanUpdatedEventData ) }; From 35dba842a61696a722c8f891b434fdb8a4ae8553 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Wed, 2 Sep 2020 17:57:23 -0700 Subject: [PATCH 26/34] Respond to PR feedback --- sdk/eventgrid/eventgrid/README.md | 4 ++-- sdk/eventgrid/eventgrid/package.json | 3 +-- .../eventgrid/src/eventGridAuthenticationPolicy.ts | 4 ++-- sdk/eventgrid/eventgrid/src/eventGridClient.ts | 9 ++++----- sdk/eventgrid/eventgrid/src/models.ts | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md index 2791da50052d..759259eb2bf5 100644 --- a/sdk/eventgrid/eventgrid/README.md +++ b/sdk/eventgrid/eventgrid/README.md @@ -179,7 +179,7 @@ await client.sendEvents([ ### Deserializing an Event -`EventGridConsumer` can be used to deserialize events delivered by Event Grid. When deserlizing an event, you need to know the schema used to deliver the event. In this example we have events being delivered to an Azure Service Bus Topic in the Cloud Events schema. Using the Service Bus SDK we can recieve these events from the Service Bus Topic and then deserialize them using `EventGridConsumer` and use `isSystemEvent` to detect what type of events they are. +`EventGridConsumer` can be used to deserialize events delivered by Event Grid. When deserializing an event, you need to know the schema used to deliver the event. In this example we have events being delivered to an Azure Service Bus Topic in the Cloud Events schema. Using the Service Bus SDK we can recieve these events from the Service Bus Topic and then deserialize them using `EventGridConsumer` and use `isSystemEvent` to detect what type of events they are. ```js const { ServiceBusClient } = require("@azure/service-bus"); @@ -216,7 +216,7 @@ receiver.subscribe({ processError: async (err) => { console.error(err); }, - processMessage: processMessage + processMessage }); ``` diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json index cd5a8d5775ed..22da89771afd 100644 --- a/sdk/eventgrid/eventgrid/package.json +++ b/sdk/eventgrid/eventgrid/package.json @@ -82,8 +82,7 @@ "@azure/core-tracing": "1.0.0-preview.9", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", - "tslib": "^2.0.0", - "uuid": "^8.1.0" + "tslib": "^2.0.0" }, "devDependencies": { "@azure/eslint-plugin-azure-sdk": "^3.0.0", diff --git a/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts b/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts index 4ba9c24fbb4f..95896bb83492 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridAuthenticationPolicy.ts @@ -22,7 +22,7 @@ const API_KEY_HEADER_NAME = "aeg-sas-key"; /** * The name of the header to include when Shared Access Signature is used for authentication. */ -const SAS_TOKEN_HEAER_NAME = "aeg-sas-token"; +const SAS_TOKEN_HEADER_NAME = "aeg-sas-token"; /** * Create an HTTP pipeline policy to authenticate a request @@ -62,7 +62,7 @@ class EventGridAzureKeyCredentialPolicy extends BaseRequestPolicy { if (isKeyCredentialLike(this.credential)) { webResource.headers.set(API_KEY_HEADER_NAME, this.credential.key); } else { - webResource.headers.set(SAS_TOKEN_HEAER_NAME, this.credential.signature()); + webResource.headers.set(SAS_TOKEN_HEADER_NAME, this.credential.signature()); } return this._nextPolicy.sendRequest(webResource); diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts index 8794cdb5d966..b22fe7bdedc1 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -6,11 +6,10 @@ import { PipelineOptions, createPipelineFromOptions, RestResponse, - OperationOptions + OperationOptions, + generateUuid } from "@azure/core-http"; -import { v4 as uuidv4 } from "uuid"; - import { createEventGridCredentialPolicy } from "./eventGridAuthenticationPolicy"; import { SignatureCredential } from "./sharedAccessSignitureCredential"; import { SDK_VERSION } from "./constants"; @@ -155,7 +154,7 @@ export function convertEventGridEventToModelType( return { eventType: event.eventType, eventTime: event.eventTime ?? new Date(), - id: event.id ?? uuidv4(), + id: event.id ?? generateUuid(), subject: event.subject, topic: event.topic, data: event.data, @@ -185,7 +184,7 @@ export function convertCloudEventToModelType(event: CloudEvent): CloudEvent specversion: "1.0", type: event.type, source: event.source, - id: event.id ?? uuidv4(), + id: event.id ?? generateUuid(), time: event.time ?? new Date(), subject: event.subject, dataschema: event.dataschema, diff --git a/sdk/eventgrid/eventgrid/src/models.ts b/sdk/eventgrid/eventgrid/src/models.ts index 3ba7ffecf424..b124d4d8a81a 100644 --- a/sdk/eventgrid/eventgrid/src/models.ts +++ b/sdk/eventgrid/eventgrid/src/models.ts @@ -54,7 +54,7 @@ export interface CloudEvent { */ id?: string; /** - * The time the event was generated. + * The time the event was generated. If not provided, the current time will be used. */ time?: Date; /** From 2f425c1cf8df9355bf1cb227d2ee6cc193bd5371 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 3 Sep 2020 11:06:33 -0700 Subject: [PATCH 27/34] [Event Grid] use 'beta' instead of 'preview' --- sdk/eventgrid/eventgrid/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json index 22da89771afd..18596ac13389 100644 --- a/sdk/eventgrid/eventgrid/package.json +++ b/sdk/eventgrid/eventgrid/package.json @@ -3,7 +3,7 @@ "sdk-type": "client", "author": "Microsoft Corporation", "description": "An isomorphic client library for the Azure Event Grid service.", - "version": "3.0.0-preview.1", + "version": "3.0.0-beta.1", "keywords": [ "node", "azure", From e5d79600564ea1d02f949a4387f3d98f8fe564f4 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 3 Sep 2020 11:15:18 -0700 Subject: [PATCH 28/34] [Event Grid] Don't return RestResponse directly Instead, we return a custom interface that has the `_response` property (as is our current pattern). This will allow us to return additional information in the future if we want to, in a compatible way --- .../eventgrid/review/eventgrid.api.md | 9 +-- .../eventgrid/src/eventGridClient.ts | 60 ++++++++++++++----- 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index ee4fe218caf1..ca589bdf8387 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -5,10 +5,10 @@ ```ts import { AzureKeyCredential } from '@azure/core-auth'; +import { HttpResponse } from '@azure/core-http'; import { KeyCredential } from '@azure/core-auth'; import { OperationOptions } from '@azure/core-http'; import { PipelineOptions } from '@azure/core-http'; -import { RestResponse } from '@azure/core-http'; // @public export type AppAction = "Restarted" | "Stopped" | "ChangedAppSettings" | "Started" | "Completed" | "Failed"; @@ -234,9 +234,10 @@ export class EventGridPublisherClient { constructor(endpointUrl: string, credential: KeyCredential | SignatureCredential, options?: EventGridPublisherClientOptions); readonly apiVersion: string; readonly endpointUrl: string; - sendCloudEvents(events: CloudEvent[], options?: SendCloudEventsOptions): Promise; - sendCustomSchemaEvents(events: Record[], options?: SendCustomSchemaEventsOptions): Promise; - sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise; + sendCloudEvents(events: CloudEvent[], options?: SendCloudEventsOptions): Promise; + sendCustomSchemaEvents(events: Record[], options?: SendCustomSchemaEventsOptions): Promise; + // Warning: (ae-forgotten-export) The symbol "SendEventsResponse" needs to be exported by the entry point index.d.ts + sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise; } // @public diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts index b22fe7bdedc1..64f7c6d27b03 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -5,9 +5,9 @@ import { KeyCredential } from "@azure/core-auth"; import { PipelineOptions, createPipelineFromOptions, - RestResponse, OperationOptions, - generateUuid + generateUuid, + HttpResponse } from "@azure/core-http"; import { createEventGridCredentialPolicy } from "./eventGridAuthenticationPolicy"; @@ -40,6 +40,13 @@ export type SendCloudEventsOptions = OperationOptions; */ export type SendCustomSchemaEventsOptions = OperationOptions; +/** + * The response when sending events to the Event Grid service. + */ +export interface SendEventsResponse { + _response: HttpResponse; +} + /** * Client class for publishing events to the Event Grid Service. */ @@ -108,12 +115,21 @@ export class EventGridPublisherClient { * * @param message One or more events to publish */ - sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise { - return this.client.publishEvents( - this.endpointUrl, - (events || []).map(convertEventGridEventToModelType), - options - ); + sendEvents( + events: EventGridEvent[], + options?: SendEventsOptions + ): Promise { + return this.client + .publishEvents( + this.endpointUrl, + (events || []).map(convertEventGridEventToModelType), + options + ) + .then((r) => { + return { + _response: r._response + }; + }); } /** @@ -124,12 +140,18 @@ export class EventGridPublisherClient { sendCloudEvents( events: CloudEvent[], options?: SendCloudEventsOptions - ): Promise { - return this.client.publishCloudEventEvents( - this.endpointUrl, - (events || []).map(convertCloudEventToModelType), - options - ); + ): Promise { + return this.client + .publishCloudEventEvents( + this.endpointUrl, + (events || []).map(convertCloudEventToModelType), + options + ) + .then((r) => { + return { + _response: r._response + }; + }); } /** @@ -140,8 +162,14 @@ export class EventGridPublisherClient { sendCustomSchemaEvents( events: Record[], options?: SendCustomSchemaEventsOptions - ): Promise { - return this.client.publishCustomEventEvents(this.endpointUrl, events || [], options); + ): Promise { + return this.client + .publishCustomEventEvents(this.endpointUrl, events || [], options) + .then((r) => { + return { + _response: r._response + }; + }); } } From 13ece2e7c32443ce93d1aa64ccf5889b6ab0f3c4 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 3 Sep 2020 11:20:48 -0700 Subject: [PATCH 29/34] [Event Grid] Add ci.yml --- sdk/eventgrid/ci.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 sdk/eventgrid/ci.yml diff --git a/sdk/eventgrid/ci.yml b/sdk/eventgrid/ci.yml new file mode 100644 index 000000000000..650c163c8de9 --- /dev/null +++ b/sdk/eventgrid/ci.yml @@ -0,0 +1,30 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - master + - release/* + - hotfix/* + paths: + include: + - sdk/eventgrid/ + +pr: + branches: + include: + - master + - feature/* + - release/* + - hotfix/* + paths: + include: + - sdk/eventgrid/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: eventgrid + Artifacts: + - name: azure-eventgrid + safeName: azureeventgrid From 701cca5bd057e4173f72be96981d762c8767c747 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 3 Sep 2020 11:26:31 -0700 Subject: [PATCH 30/34] [Event Grid] List supported browsers This list matches our general guidence, from https://azure.github.io/azure-sdk/typescript_design.html#ts-platform-support --- sdk/eventgrid/eventgrid/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md index 759259eb2bf5..12c028dbdf9d 100644 --- a/sdk/eventgrid/eventgrid/README.md +++ b/sdk/eventgrid/eventgrid/README.md @@ -20,6 +20,10 @@ Use the client library to: - Node.js version 8.x.x or higher - Browser JavaScript + - Apple Safari: latest two versions + - Google Chrome: latest two versions + - Microsoft Edge: all supported versions + - Mozilla FireFox: latest two versions ### Prerequisites From bf1f87cb4bf8ecc30c715b5d7ee7617c2b452059 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 3 Sep 2020 18:58:40 -0700 Subject: [PATCH 31/34] [Event Grid] Update CHANGELOG.md --- sdk/eventgrid/eventgrid/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventgrid/eventgrid/CHANGELOG.md b/sdk/eventgrid/eventgrid/CHANGELOG.md index 15d4ae13e495..7d00c8b9cae8 100644 --- a/sdk/eventgrid/eventgrid/CHANGELOG.md +++ b/sdk/eventgrid/eventgrid/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 3.0.0-preview.1 (Unreleased) +## 3.0.0-beta.1 (Unreleased) - This release is a preview of our efforts to create a client library that is user friendly and idiomatic to the JavaScript ecosystem. The reasons for most of the changes in this update can be found in the From 519d453bfb9e5c2ed5d731756966e2897880404d Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Fri, 4 Sep 2020 10:59:54 -0700 Subject: [PATCH 32/34] [Event Grid] Add release date to CHANGELOG.md --- sdk/eventgrid/eventgrid/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventgrid/eventgrid/CHANGELOG.md b/sdk/eventgrid/eventgrid/CHANGELOG.md index 7d00c8b9cae8..c534f4049eff 100644 --- a/sdk/eventgrid/eventgrid/CHANGELOG.md +++ b/sdk/eventgrid/eventgrid/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 3.0.0-beta.1 (Unreleased) +## 3.0.0-beta.1 (2020-09-08) - This release is a preview of our efforts to create a client library that is user friendly and idiomatic to the JavaScript ecosystem. The reasons for most of the changes in this update can be found in the From 6f3e5e65482cbc5f514061c96373ae42c2dc427d Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Fri, 4 Sep 2020 13:13:58 -0700 Subject: [PATCH 33/34] [Event Grid] Update sample --- sdk/eventgrid/eventgrid/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventgrid/eventgrid/README.md b/sdk/eventgrid/eventgrid/README.md index 12c028dbdf9d..d6e5a0474a10 100644 --- a/sdk/eventgrid/eventgrid/README.md +++ b/sdk/eventgrid/eventgrid/README.md @@ -103,7 +103,7 @@ const { generateSharedAccessSignature, AzureKeyCredential } = require("@azure/ev const token = generateSharedAccessSignature( "", new AzureKeyCredential(""), - new Date(2020, 0, 1, 0, 0, 0) + new Date("2020-01-01T00:00:00") ); ``` From c9f1ce81efedbe5d06b51e678cecee32ae94e67e Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Fri, 4 Sep 2020 13:56:03 -0700 Subject: [PATCH 34/34] [Event Grid] Improve typings Split the input and output shapes for CloudEvent and EventGridEvent. On input, we don't require either `id` or `eventTime` for EventGridEvent or CloudEvent (since the client will use default values of a new UUID and the current time), where as the outputs correctly reflect what properties will always be set when consuming these events. --- .../eventgrid/review/eventgrid.api.md | 34 ++++++-- .../eventgrid/src/eventGridClient.ts | 14 ++-- sdk/eventgrid/eventgrid/src/index.ts | 8 +- sdk/eventgrid/eventgrid/src/models.ts | 84 ++++++++++++++++++- 4 files changed, 125 insertions(+), 15 deletions(-) diff --git a/sdk/eventgrid/eventgrid/review/eventgrid.api.md b/sdk/eventgrid/eventgrid/review/eventgrid.api.md index ca589bdf8387..8455b7ee664b 100644 --- a/sdk/eventgrid/eventgrid/review/eventgrid.api.md +++ b/sdk/eventgrid/eventgrid/review/eventgrid.api.md @@ -50,7 +50,7 @@ export interface CloudEvent { datacontenttype?: string; dataschema?: string; extensionAttributes?: Record; - id?: string; + id: string; source: string; subject?: string; time?: Date; @@ -222,9 +222,9 @@ export interface EventGridConsumerOptions { export interface EventGridEvent { data: T; dataVersion: string; - eventTime?: Date; + eventTime: Date; eventType: string; - id?: string; + id: string; subject: string; topic?: string; } @@ -234,10 +234,10 @@ export class EventGridPublisherClient { constructor(endpointUrl: string, credential: KeyCredential | SignatureCredential, options?: EventGridPublisherClientOptions); readonly apiVersion: string; readonly endpointUrl: string; - sendCloudEvents(events: CloudEvent[], options?: SendCloudEventsOptions): Promise; + sendCloudEvents(events: SendCloudEventInput[], options?: SendCloudEventsOptions): Promise; sendCustomSchemaEvents(events: Record[], options?: SendCustomSchemaEventsOptions): Promise; // Warning: (ae-forgotten-export) The symbol "SendEventsResponse" needs to be exported by the entry point index.d.ts - sendEvents(events: EventGridEvent[], options?: SendEventsOptions): Promise; + sendEvents(events: SendEventGridEventInput[], options?: SendEventsOptions): Promise; } // @public @@ -716,12 +716,36 @@ export interface ResourceWriteSuccessEventData { tenantId?: string; } +// @public +export interface SendCloudEventInput { + data?: T; + datacontenttype?: string; + dataschema?: string; + extensionAttributes?: Record; + id?: string; + source: string; + subject?: string; + time?: Date; + type: string; +} + // @public export type SendCloudEventsOptions = OperationOptions; // @public export type SendCustomSchemaEventsOptions = OperationOptions; +// @public +export interface SendEventGridEventInput { + data: T; + dataVersion: string; + eventTime?: Date; + eventType: string; + id?: string; + subject: string; + topic?: string; +} + // @public export type SendEventsOptions = OperationOptions; diff --git a/sdk/eventgrid/eventgrid/src/eventGridClient.ts b/sdk/eventgrid/eventgrid/src/eventGridClient.ts index 64f7c6d27b03..04992c0421e3 100644 --- a/sdk/eventgrid/eventgrid/src/eventGridClient.ts +++ b/sdk/eventgrid/eventgrid/src/eventGridClient.ts @@ -13,7 +13,11 @@ import { import { createEventGridCredentialPolicy } from "./eventGridAuthenticationPolicy"; import { SignatureCredential } from "./sharedAccessSignitureCredential"; import { SDK_VERSION } from "./constants"; -import { CloudEvent, EventGridEvent, cloudEventReservedPropertyNames } from "./models"; +import { + SendCloudEventInput, + SendEventGridEventInput, + cloudEventReservedPropertyNames +} from "./models"; import { GeneratedClient } from "./generated/generatedClient"; import { CloudEvent as CloudEventWireModel, @@ -116,7 +120,7 @@ export class EventGridPublisherClient { * @param message One or more events to publish */ sendEvents( - events: EventGridEvent[], + events: SendEventGridEventInput[], options?: SendEventsOptions ): Promise { return this.client @@ -138,7 +142,7 @@ export class EventGridPublisherClient { * @param message One or more events to publish */ sendCloudEvents( - events: CloudEvent[], + events: SendCloudEventInput[], options?: SendCloudEventsOptions ): Promise { return this.client @@ -177,7 +181,7 @@ export class EventGridPublisherClient { * @internal */ export function convertEventGridEventToModelType( - event: EventGridEvent + event: SendEventGridEventInput ): EventGridEventWireModel { return { eventType: event.eventType, @@ -193,7 +197,7 @@ export function convertEventGridEventToModelType( /** * @internal */ -export function convertCloudEventToModelType(event: CloudEvent): CloudEventWireModel { +export function convertCloudEventToModelType(event: SendCloudEventInput): CloudEventWireModel { if (event.extensionAttributes) { for (const propName in event.extensionAttributes) { // Per the cloud events spec: "CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z') or digits ('0' to '9') from the ASCII character set" diff --git a/sdk/eventgrid/eventgrid/src/index.ts b/sdk/eventgrid/eventgrid/src/index.ts index a52716573038..0b9eb253d07b 100644 --- a/sdk/eventgrid/eventgrid/src/index.ts +++ b/sdk/eventgrid/eventgrid/src/index.ts @@ -3,7 +3,13 @@ export { AzureKeyCredential } from "@azure/core-auth"; -export { CustomEventDataDeserializer, EventGridEvent, CloudEvent } from "./models"; +export { + CloudEvent, + CustomEventDataDeserializer, + EventGridEvent, + SendCloudEventInput, + SendEventGridEventInput +} from "./models"; export { EventGridPublisherClient, diff --git a/sdk/eventgrid/eventgrid/src/models.ts b/sdk/eventgrid/eventgrid/src/models.ts index b124d4d8a81a..161da86ccd6f 100644 --- a/sdk/eventgrid/eventgrid/src/models.ts +++ b/sdk/eventgrid/eventgrid/src/models.ts @@ -2,9 +2,9 @@ // Licensed under the MIT license. /** - * An event in the in the Event Grid Schema. + * The shape of the input for EventGridProducerClient#sendEvents */ -export interface EventGridEvent { +export interface SendEventGridEventInput { /** * The type of the event. */ @@ -37,9 +37,43 @@ export interface EventGridEvent { } /** - * An event in the Cloud Event 1.0 schema. + * An event in the in the Event Grid Schema. */ -export interface CloudEvent { +export interface EventGridEvent { + /** + * The type of the event. + */ + eventType: string; + /** + * The time the event was generated. + */ + eventTime: Date; + /** + * An unique identifier for the event. + */ + id: string; + /** + * The resource path of the event source. + */ + topic?: string; + /** + * A resource path relative to the topic path. + */ + subject: string; + /** + * The schema version of the data object. + */ + dataVersion: string; + /** + * Event data specific to the event type. + */ + data: T; +} + +/** + * * The shape of the input for EventGridProducerClient#sendCloudEvents + */ +export interface SendCloudEventInput { /** * Type of event related to the originating occurrence. */ @@ -79,6 +113,48 @@ export interface CloudEvent { extensionAttributes?: Record; } +/** + * An event in the Cloud Event 1.0 schema. + */ +export interface CloudEvent { + /** + * Type of event related to the originating occurrence. + */ + type: string; + /** + * Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. + */ + source: string; + /** + * An identifier for the event. The combination of id and source must be unique for each distinct event. + */ + id: string; + /** + * The time the event was generated. + */ + time?: Date; + /** + * Identifies the schema that data adheres to. + */ + dataschema?: string; + /** + * Content type of data value. + */ + datacontenttype?: string; + /** + * Event data specific to the event type. + */ + data?: T; + /** + * This describes the subject of the event in the context of the event producer (identified by source). + */ + subject?: string; + /** + * Additional context attributes for the event. The Cloud Event specification refers to these as "extension attributes". + */ + extensionAttributes?: Record; +} + /** * Property names defined by the CloudEvents 1.0 specification, these may not be reused as the names of extension properties. */