diff --git a/sdk/messaging/eventgrid/azsystemevents/CHANGELOG.md b/sdk/messaging/eventgrid/azsystemevents/CHANGELOG.md new file mode 100644 index 000000000000..e5621553164a --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/CHANGELOG.md @@ -0,0 +1,5 @@ +## 0.1.0 (TBD) + +### Features Added + +- Initial preview for Event Grid system events. diff --git a/sdk/messaging/eventgrid/azsystemevents/LICENSE.txt b/sdk/messaging/eventgrid/azsystemevents/LICENSE.txt new file mode 100644 index 000000000000..22aed37e650b --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. + +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/messaging/eventgrid/azsystemevents/README.md b/sdk/messaging/eventgrid/azsystemevents/README.md new file mode 100644 index 000000000000..887101b38f18 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/README.md @@ -0,0 +1,103 @@ +# Azure Event Grid System Events Module for Go + +Azure Event Grid system events are published by Azure services to system topics. The models in this package map to events sent by various Azure services. + +Key links: +- [Source code][source] +- [API Reference Documentation][godoc] +- [Product documentation][product_docs] +- [Samples][godoc_examples] + +## Getting started + +### Install the package + +Install the Azure Event Grid system events module for Go with `go get`: + +```bash +go get github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azsystemevents +``` + +### Prerequisites + +- Go, version 1.18 or higher + +# Key concepts + +Event subscriptions can be used to forward events from an [Event Grid system topic][system_topics] to a data source, like [Azure Storage Queues][event_handler_storage_queues]. The payload will be formatted as an array of events, using the event envelope (Cloud Event Schema or Event Grid Schema) configured within the subscription. + +To consume events, use the client package for that service. For example, if the Event Grid subscription uses an an Azure Storage Queue, we would use the [azqeueue](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue) package to consume it. + +# Examples + +Examples for deserializing system events can be found on [pkg.go.dev][godoc_examples] or in the example*_test.go files in our GitHub repo for [azsystemevents][source]. + +# Troubleshooting + +### Logging + +This module uses the classification-based logging implementation in `azcore`. To enable console logging for all SDK modules, set the environment variable `AZURE_SDK_GO_LOGGING` to `all`. + +Use the `azcore/log` package to control log event output. + +```go +import ( + "fmt" + azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log" +) + +// print log output to stdout +azlog.SetListener(func(event azlog.Event, s string) { + fmt.Printf("[%s] %s\n", event, s) +}) +``` + +# Next steps + +More sample code should go here, along with links out to the appropriate example tests. + +## Contributing +For details on contributing to this repository, see the [contributing guide][azure_sdk_for_go_contributing]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a +Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us +the rights to use your contribution. For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide +a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions +provided by the bot. You will only need to do this once across all repos using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or +contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. + +### Additional Helpful Links for Contributors +Many people all over the world have helped make this project better. You'll want to check out: + +* [What are some good first issues for new contributors to the repo?](https://github.com/azure/azure-sdk-for-go/issues?q=is%3Aopen+is%3Aissue+label%3A%22up+for+grabs%22) +* [How to build and test your change][azure_sdk_for_go_contributing_developer_guide] +* [How you can make a change happen!][azure_sdk_for_go_contributing_pull_requests] +* Frequently Asked Questions (FAQ) and Conceptual Topics in the detailed [Azure SDK for Go wiki](https://github.com/azure/azure-sdk-for-go/wiki). + + +### Reporting security issues and security bugs + +Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) . You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the [Security TechCenter](https://www.microsoft.com/msrc/faqs-report-an-issue). + +### License + +Azure SDK for Go is licensed under the [MIT](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/template/aztemplate/LICENSE.txt) license. + + +[azure_sdk_for_go_contributing]: https://github.com/Azure/azure-sdk-for-go/blob/main/CONTRIBUTING.md +[azure_sdk_for_go_contributing_developer_guide]: https://github.com/Azure/azure-sdk-for-go/blob/main/CONTRIBUTING.md#developer-guide +[azure_sdk_for_go_contributing_pull_requests]: https://github.com/Azure/azure-sdk-for-go/blob/main/CONTRIBUTING.md#pull-requests +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_portal]: https://portal.azure.com +[azure_sub]: https://azure.microsoft.com/free/ +[event_handler_storage_queues]: https://learn.microsoft.com/azure/event-grid/handler-storage-queues +[event_handlers]: https://learn.microsoft.com/azure/event-grid/overview#event-handlers +[product_docs]: https://learn.microsoft.com/azure/event-grid/overview +[system_topics]: https://learn.microsoft.com/azure/event-grid/system-topics + [source]: https://azsdk/go/systemevents/src + [godoc_examples]: https://azsdk/go/systemevents/pkg#pkg-examples diff --git a/sdk/messaging/eventgrid/azsystemevents/autorest.md b/sdk/messaging/eventgrid/azsystemevents/autorest.md new file mode 100644 index 000000000000..a9a27c699fe4 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/autorest.md @@ -0,0 +1,123 @@ +## Go + +``` yaml +title: AzureEventGridSystemEvents +description: Azure Event Grid system events +generated-metadata: false +clear-output-folder: false +go: true +require: https://github.com/Azure/azure-rest-api-specs/blob/11bbc2b1df2e915a2227a6a1a48a27b9e67c3311/specification/eventgrid/data-plane/readme.md +license-header: MICROSOFT_MIT_NO_VERSION +openapi-type: "data-plane" +output-folder: ../azsystemevents +override-client-name: ClientDeleteMe +security: "AADToken" +use: "@autorest/go@4.0.0-preview.63" +version: "^3.0.0" +module: github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azsystemevents +slice-elements-byval: true +remove-non-reference-schema: true +batch: + - tag: package-2018-01 +directive: + - from: swagger-document + where: $ + transform: $['paths'] = {}; return $; + - from: swagger-document + where: $.definitions.MediaJobOutput + transform: > + $.required.push("@odata.type"); + $["x-csharp-usage"] = "model,output"; + - from: swagger-document + where: $.definitions.CloudEventEvent + transform: $["x-ms-external"] = true + - from: + - models.go + - models_serde.go + where: $ + transform: | + return $.replace(/ResourceActionCancelData/g, 'ResourceActionCancelEventData') + .replace(/ResourceActionFailureData/g, 'ResourceActionFailureEventData') + .replace(/ResourceActionSuccessData/g, 'ResourceActionSuccessEventData') + .replace(/ResourceDeleteCancelData/g, 'ResourceDeleteCancelEventData') + .replace(/ResourceDeleteFailureData/g, 'ResourceDeleteFailureEventData') + .replace(/ResourceDeleteSuccessData/g, 'ResourceDeleteSuccessEventData') + .replace(/ResourceWriteCancelData/g, 'ResourceWriteCancelEventData') + .replace(/ResourceWriteFailureData/g, 'ResourceWriteFailureEventData') + .replace(/ResourceWriteSuccessData/g, 'ResourceWriteSuccessEventData') +``` + +```yaml +directive: + - from: + - models.go + - responses.go + - options.go + where: $ + transform: return $.replace(/CloudEventEvent/g, "CloudEvent"); + - from: + - models.go + - models_serde.go + - responses.go + - options.go + where: $ + transform: return $.replace(/Schema of the Data property of an EventGridEvent/g, "Schema of the Data property of an CloudEvent/EventGridEvent"); +``` + +```yaml +directive: + - from: + - models.go + - models_serde.go + where: $ + transform: | + return $ + .replace(/ChannelLatencyMs \*string/g, "ChannelLatencyMS *string") + .replace(/m.ChannelLatencyMs/g, "m.ChannelLatencyMS"); +``` + +```yaml +directive: + - from: constants.go + where: $ + transform: return $.replace(/EventGridMqttClientDisconnectionReason/g, "EventGridMQTTClientDisconnectionReason") + - from: models.go + where: $ + transform: return $.replace(/DisconnectionReason \*EventGridMqttClientDisconnectionReason/, "DisconnectionReason *EventGridMQTTClientDisconnectionReason") +``` + +Manually map n/a to the zero value for the type for `MediaLiveEventChannelArchiveHeartbeatEventData` and `MediaLiveEventIngestHeartbeatEventData` + +```yaml +directive: + - from: models_serde.go + where: $ + transform: | + return $ + .replace(/(\s+err = unpopulate\(val, "IngestDriftValue", &m.IngestDriftValue\))/, "$1\nfixNAValue(&m.IngestDriftValue)") + .replace(/(\s+err = unpopulate\(val, "ChannelLatencyMs", &m.ChannelLatencyMS\))/, "$1\nfixNAValue(&m.ChannelLatencyMS)"); +``` + +Rename `AcsRouterWorkerSelector.TTLSeconds` to `TimeToLive` + +```yaml +directive: + - from: + - models.go + where: $ + transform: return $.replace(/TTLSeconds \*float32/g, "TimeToLive *float32"); + - from: + - models_serde.go + where: $ + transform: return $.replace(/a\.TTLSeconds/g, "a.TimeToLive"); +``` + +Fix the EventGridEvent deserialization to work similar to CloudEvent. + +```yaml +directive: + - from: models_serde.go + where: $ + transform: | + return $.replace(/err = unpopulate\(val, "Data", &e.Data\)/, "e.Data = []byte(val)") +``` diff --git a/sdk/messaging/eventgrid/azsystemevents/build.go b/sdk/messaging/eventgrid/azsystemevents/build.go new file mode 100644 index 000000000000..d970c45fcfa1 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/build.go @@ -0,0 +1,12 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +//go:generate autorest ./autorest.md +//go:generate goimports -w ./.. +//go:generate go run ./internal/generate generate +//go:generate goimports -w ./.. + +package azsystemevents diff --git a/sdk/messaging/eventgrid/azsystemevents/ci.yml b/sdk/messaging/eventgrid/azsystemevents/ci.yml new file mode 100644 index 000000000000..da5c792dc65f --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/messaging/eventgrid/azsystemevents + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/messaging/eventgrid/azsystemevents + +stages: + - template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: "messaging/eventgrid/azsystemevents" + RunLiveTests: true + UsePipelineProxy: false + Location: westus2 + EnvVars: + AZURE_CLIENT_ID: $(AZSYSTEMEVENTS_CLIENT_ID) + AZURE_TENANT_ID: $(AZSYSTEMEVENTS_TENANT_ID) + AZURE_CLIENT_SECRET: $(AZSYSTEMEVENTS_CLIENT_SECRET) + AZURE_SUBSCRIPTION_ID: $(AZSYSTEMEVENTS_SUBSCRIPTION_ID) diff --git a/sdk/messaging/eventgrid/azsystemevents/constants.go b/sdk/messaging/eventgrid/azsystemevents/constants.go new file mode 100644 index 000000000000..ffe93a0338a0 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/constants.go @@ -0,0 +1,1031 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package azsystemevents + +// AcsEmailDeliveryReportStatus - The status of the email. Any value other than Delivered is considered failed. +type AcsEmailDeliveryReportStatus string + +const ( + // AcsEmailDeliveryReportStatusBounced - Hard bounce detected while sending the email + AcsEmailDeliveryReportStatusBounced AcsEmailDeliveryReportStatus = "Bounced" + // AcsEmailDeliveryReportStatusDelivered - The email was delivered + AcsEmailDeliveryReportStatusDelivered AcsEmailDeliveryReportStatus = "Delivered" + // AcsEmailDeliveryReportStatusFailed - The email failed to be delivered + AcsEmailDeliveryReportStatusFailed AcsEmailDeliveryReportStatus = "Failed" + // AcsEmailDeliveryReportStatusFilteredSpam - The message was identified spam and was rejected or blocked (not quarantined). + AcsEmailDeliveryReportStatusFilteredSpam AcsEmailDeliveryReportStatus = "FilteredSpam" + // AcsEmailDeliveryReportStatusQuarantined - The message was quarantined (as spam, bulk mail, or phishing). For more information, + // see Quarantined email messages in EOP (EXCHANGE ONLINE PROTECTION). + AcsEmailDeliveryReportStatusQuarantined AcsEmailDeliveryReportStatus = "Quarantined" + // AcsEmailDeliveryReportStatusSuppressed - The email was suppressed + AcsEmailDeliveryReportStatusSuppressed AcsEmailDeliveryReportStatus = "Suppressed" +) + +// PossibleAcsEmailDeliveryReportStatusValues returns the possible values for the AcsEmailDeliveryReportStatus const type. +func PossibleAcsEmailDeliveryReportStatusValues() []AcsEmailDeliveryReportStatus { + return []AcsEmailDeliveryReportStatus{ + AcsEmailDeliveryReportStatusBounced, + AcsEmailDeliveryReportStatusDelivered, + AcsEmailDeliveryReportStatusFailed, + AcsEmailDeliveryReportStatusFilteredSpam, + AcsEmailDeliveryReportStatusQuarantined, + AcsEmailDeliveryReportStatusSuppressed, + } +} + +// AcsRouterJobStatus - Router Job Received Job Status +type AcsRouterJobStatus string + +const ( + AcsRouterJobStatusAssigned AcsRouterJobStatus = "Assigned" + AcsRouterJobStatusCancelled AcsRouterJobStatus = "Cancelled" + AcsRouterJobStatusClassificationFailed AcsRouterJobStatus = "ClassificationFailed" + AcsRouterJobStatusClosed AcsRouterJobStatus = "Closed" + AcsRouterJobStatusCompleted AcsRouterJobStatus = "Completed" + AcsRouterJobStatusCreated AcsRouterJobStatus = "Created" + AcsRouterJobStatusPendingClassification AcsRouterJobStatus = "PendingClassification" + AcsRouterJobStatusPendingSchedule AcsRouterJobStatus = "PendingSchedule" + AcsRouterJobStatusQueued AcsRouterJobStatus = "Queued" + AcsRouterJobStatusScheduleFailed AcsRouterJobStatus = "ScheduleFailed" + AcsRouterJobStatusScheduled AcsRouterJobStatus = "Scheduled" + AcsRouterJobStatusWaitingForActivation AcsRouterJobStatus = "WaitingForActivation" +) + +// PossibleAcsRouterJobStatusValues returns the possible values for the AcsRouterJobStatus const type. +func PossibleAcsRouterJobStatusValues() []AcsRouterJobStatus { + return []AcsRouterJobStatus{ + AcsRouterJobStatusAssigned, + AcsRouterJobStatusCancelled, + AcsRouterJobStatusClassificationFailed, + AcsRouterJobStatusClosed, + AcsRouterJobStatusCompleted, + AcsRouterJobStatusCreated, + AcsRouterJobStatusPendingClassification, + AcsRouterJobStatusPendingSchedule, + AcsRouterJobStatusQueued, + AcsRouterJobStatusScheduleFailed, + AcsRouterJobStatusScheduled, + AcsRouterJobStatusWaitingForActivation, + } +} + +// AcsRouterLabelOperator - Router Job Worker Selector Label Operator +type AcsRouterLabelOperator string + +const ( + // AcsRouterLabelOperatorEqual - = + AcsRouterLabelOperatorEqual AcsRouterLabelOperator = "Equal" + // AcsRouterLabelOperatorGreater - > + AcsRouterLabelOperatorGreater AcsRouterLabelOperator = "Greater" + // AcsRouterLabelOperatorGreaterThanOrEqual - >= + AcsRouterLabelOperatorGreaterThanOrEqual AcsRouterLabelOperator = "GreaterThanOrEqual" + // AcsRouterLabelOperatorLess - < + AcsRouterLabelOperatorLess AcsRouterLabelOperator = "Less" + // AcsRouterLabelOperatorLessThanOrEqual - <= + AcsRouterLabelOperatorLessThanOrEqual AcsRouterLabelOperator = "LessThanOrEqual" + // AcsRouterLabelOperatorNotEqual - != + AcsRouterLabelOperatorNotEqual AcsRouterLabelOperator = "NotEqual" +) + +// PossibleAcsRouterLabelOperatorValues returns the possible values for the AcsRouterLabelOperator const type. +func PossibleAcsRouterLabelOperatorValues() []AcsRouterLabelOperator { + return []AcsRouterLabelOperator{ + AcsRouterLabelOperatorEqual, + AcsRouterLabelOperatorGreater, + AcsRouterLabelOperatorGreaterThanOrEqual, + AcsRouterLabelOperatorLess, + AcsRouterLabelOperatorLessThanOrEqual, + AcsRouterLabelOperatorNotEqual, + } +} + +// AcsRouterWorkerSelectorState - Router Job Worker Selector State +type AcsRouterWorkerSelectorState string + +const ( + // AcsRouterWorkerSelectorStateActive - Router Job Worker Selector is Active + AcsRouterWorkerSelectorStateActive AcsRouterWorkerSelectorState = "active" + // AcsRouterWorkerSelectorStateExpired - Router Job Worker Selector has Expire + AcsRouterWorkerSelectorStateExpired AcsRouterWorkerSelectorState = "expired" +) + +// PossibleAcsRouterWorkerSelectorStateValues returns the possible values for the AcsRouterWorkerSelectorState const type. +func PossibleAcsRouterWorkerSelectorStateValues() []AcsRouterWorkerSelectorState { + return []AcsRouterWorkerSelectorState{ + AcsRouterWorkerSelectorStateActive, + AcsRouterWorkerSelectorStateExpired, + } +} + +// AcsUserEngagement - The type of engagement user have with email +type AcsUserEngagement string + +const ( + AcsUserEngagementClick AcsUserEngagement = "click" + AcsUserEngagementView AcsUserEngagement = "view" +) + +// PossibleAcsUserEngagementValues returns the possible values for the AcsUserEngagement const type. +func PossibleAcsUserEngagementValues() []AcsUserEngagement { + return []AcsUserEngagement{ + AcsUserEngagementClick, + AcsUserEngagementView, + } +} + +// AppAction - Type of action of the operation. +type AppAction string + +const ( + // AppActionChangedAppSettings - There was an operation to change app setting on the web app. + AppActionChangedAppSettings AppAction = "ChangedAppSettings" + // AppActionCompleted - The job has completed. + AppActionCompleted AppAction = "Completed" + // AppActionFailed - The job has failed to complete. + AppActionFailed AppAction = "Failed" + // AppActionRestarted - Web app was restarted. + AppActionRestarted AppAction = "Restarted" + // AppActionStarted - The job has started. + AppActionStarted AppAction = "Started" + // AppActionStopped - Web app was stopped. + AppActionStopped AppAction = "Stopped" +) + +// PossibleAppActionValues returns the possible values for the AppAction const type. +func PossibleAppActionValues() []AppAction { + return []AppAction{ + AppActionChangedAppSettings, + AppActionCompleted, + AppActionFailed, + AppActionRestarted, + AppActionStarted, + AppActionStopped, + } +} + +// AppServicePlanAction - Type of action on the app service plan. +type AppServicePlanAction string + +const ( + // AppServicePlanActionUpdated - App Service plan is being updated. + AppServicePlanActionUpdated AppServicePlanAction = "Updated" +) + +// PossibleAppServicePlanActionValues returns the possible values for the AppServicePlanAction const type. +func PossibleAppServicePlanActionValues() []AppServicePlanAction { + return []AppServicePlanAction{ + AppServicePlanActionUpdated, + } +} + +// AsyncStatus - Asynchronous operation status of the operation on the app service plan. +type AsyncStatus string + +const ( + // AsyncStatusCompleted - Async operation has completed. + AsyncStatusCompleted AsyncStatus = "Completed" + // AsyncStatusFailed - Async operation failed to complete. + AsyncStatusFailed AsyncStatus = "Failed" + // AsyncStatusStarted - Async operation has started. + AsyncStatusStarted AsyncStatus = "Started" +) + +// PossibleAsyncStatusValues returns the possible values for the AsyncStatus const type. +func PossibleAsyncStatusValues() []AsyncStatus { + return []AsyncStatus{ + AsyncStatusCompleted, + AsyncStatusFailed, + AsyncStatusStarted, + } +} + +// CommunicationCloudEnvironmentModel - The cloud that the identifier belongs to. +type CommunicationCloudEnvironmentModel string + +const ( + CommunicationCloudEnvironmentModelDod CommunicationCloudEnvironmentModel = "dod" + CommunicationCloudEnvironmentModelGcch CommunicationCloudEnvironmentModel = "gcch" + CommunicationCloudEnvironmentModelPublic CommunicationCloudEnvironmentModel = "public" +) + +// PossibleCommunicationCloudEnvironmentModelValues returns the possible values for the CommunicationCloudEnvironmentModel const type. +func PossibleCommunicationCloudEnvironmentModelValues() []CommunicationCloudEnvironmentModel { + return []CommunicationCloudEnvironmentModel{ + CommunicationCloudEnvironmentModelDod, + CommunicationCloudEnvironmentModelGcch, + CommunicationCloudEnvironmentModelPublic, + } +} + +// DataBoxStageName - Schema of DataBox Stage Name enumeration. +type DataBoxStageName string + +const ( + // DataBoxStageNameCopyCompleted - Copy has completed + DataBoxStageNameCopyCompleted DataBoxStageName = "CopyCompleted" + // DataBoxStageNameCopyStarted - Copy has started + DataBoxStageNameCopyStarted DataBoxStageName = "CopyStarted" + // DataBoxStageNameOrderCompleted - Order has been completed + DataBoxStageNameOrderCompleted DataBoxStageName = "OrderCompleted" +) + +// PossibleDataBoxStageNameValues returns the possible values for the DataBoxStageName const type. +func PossibleDataBoxStageNameValues() []DataBoxStageName { + return []DataBoxStageName{ + DataBoxStageNameCopyCompleted, + DataBoxStageNameCopyStarted, + DataBoxStageNameOrderCompleted, + } +} + +// EventGridMQTTClientDisconnectionReason - Reason for the disconnection of the MQTT client's session. The value could be +// one of the values in the disconnection reasons table. +type EventGridMQTTClientDisconnectionReason string + +const ( + // EventGridMQTTClientDisconnectionReasonClientAuthenticationError - The client got disconnected for any authentication reasons + // (for example, certificate expired, client got disabled, or client configuration changed). + EventGridMQTTClientDisconnectionReasonClientAuthenticationError EventGridMQTTClientDisconnectionReason = "ClientAuthenticationError" + // EventGridMQTTClientDisconnectionReasonClientAuthorizationError - The client got disconnected for any authorization reasons + // (for example, because of a change in the configuration of topic spaces, permission bindings, or client groups). + EventGridMQTTClientDisconnectionReasonClientAuthorizationError EventGridMQTTClientDisconnectionReason = "ClientAuthorizationError" + // EventGridMQTTClientDisconnectionReasonClientError - The client sent a bad request or used one of the unsupported features + // that resulted in a connection termination by the service. + EventGridMQTTClientDisconnectionReasonClientError EventGridMQTTClientDisconnectionReason = "ClientError" + // EventGridMQTTClientDisconnectionReasonClientInitiatedDisconnect - The client initiates a graceful disconnect through a + // DISCONNECT packet for MQTT or a close frame for MQTT over WebSocket. + EventGridMQTTClientDisconnectionReasonClientInitiatedDisconnect EventGridMQTTClientDisconnectionReason = "ClientInitiatedDisconnect" + // EventGridMQTTClientDisconnectionReasonConnectionLost - The client-server connection is lost. (EXCHANGE ONLINE PROTECTION). + EventGridMQTTClientDisconnectionReasonConnectionLost EventGridMQTTClientDisconnectionReason = "ConnectionLost" + // EventGridMQTTClientDisconnectionReasonIPForbidden - The client's IP address is blocked by IP filter or Private links configuration. + EventGridMQTTClientDisconnectionReasonIPForbidden EventGridMQTTClientDisconnectionReason = "IpForbidden" + // EventGridMQTTClientDisconnectionReasonQuotaExceeded - The client exceeded one or more of the throttling limits that resulted + // in a connection termination by the service. + EventGridMQTTClientDisconnectionReasonQuotaExceeded EventGridMQTTClientDisconnectionReason = "QuotaExceeded" + // EventGridMQTTClientDisconnectionReasonServerError - The connection got terminated due to an unexpected server error. + EventGridMQTTClientDisconnectionReasonServerError EventGridMQTTClientDisconnectionReason = "ServerError" + // EventGridMQTTClientDisconnectionReasonServerInitiatedDisconnect - The server initiates a graceful disconnect for any operational + // reason. + EventGridMQTTClientDisconnectionReasonServerInitiatedDisconnect EventGridMQTTClientDisconnectionReason = "ServerInitiatedDisconnect" + // EventGridMQTTClientDisconnectionReasonSessionOverflow - The client's queue for unacknowledged QoS1 messages reached its + // limit, which resulted in a connection termination by the server. + EventGridMQTTClientDisconnectionReasonSessionOverflow EventGridMQTTClientDisconnectionReason = "SessionOverflow" + // EventGridMQTTClientDisconnectionReasonSessionTakenOver - The client reconnected with the same authentication name, which + // resulted in the termination of the previous connection. + EventGridMQTTClientDisconnectionReasonSessionTakenOver EventGridMQTTClientDisconnectionReason = "SessionTakenOver" +) + +// PossibleEventGridMQTTClientDisconnectionReasonValues returns the possible values for the EventGridMQTTClientDisconnectionReason const type. +func PossibleEventGridMQTTClientDisconnectionReasonValues() []EventGridMQTTClientDisconnectionReason { + return []EventGridMQTTClientDisconnectionReason{ + EventGridMQTTClientDisconnectionReasonClientAuthenticationError, + EventGridMQTTClientDisconnectionReasonClientAuthorizationError, + EventGridMQTTClientDisconnectionReasonClientError, + EventGridMQTTClientDisconnectionReasonClientInitiatedDisconnect, + EventGridMQTTClientDisconnectionReasonConnectionLost, + EventGridMQTTClientDisconnectionReasonIPForbidden, + EventGridMQTTClientDisconnectionReasonQuotaExceeded, + EventGridMQTTClientDisconnectionReasonServerError, + EventGridMQTTClientDisconnectionReasonServerInitiatedDisconnect, + EventGridMQTTClientDisconnectionReasonSessionOverflow, + EventGridMQTTClientDisconnectionReasonSessionTakenOver, + } +} + +// EventGridMqttClientState - Configured state of the client. The value could be Enabled or Disabled +type EventGridMqttClientState string + +const ( + EventGridMqttClientStateDisabled EventGridMqttClientState = "Disabled" + EventGridMqttClientStateEnabled EventGridMqttClientState = "Enabled" +) + +// PossibleEventGridMqttClientStateValues returns the possible values for the EventGridMqttClientState const type. +func PossibleEventGridMqttClientStateValues() []EventGridMqttClientState { + return []EventGridMqttClientState{ + EventGridMqttClientStateDisabled, + EventGridMqttClientStateEnabled, + } +} + +// HealthcareFhirResourceType - Schema of FHIR resource type enumeration. +type HealthcareFhirResourceType string + +const ( + // HealthcareFhirResourceTypeAccount - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeAccount HealthcareFhirResourceType = "Account" + // HealthcareFhirResourceTypeActivityDefinition - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeActivityDefinition HealthcareFhirResourceType = "ActivityDefinition" + // HealthcareFhirResourceTypeAdverseEvent - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeAdverseEvent HealthcareFhirResourceType = "AdverseEvent" + // HealthcareFhirResourceTypeAllergyIntolerance - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeAllergyIntolerance HealthcareFhirResourceType = "AllergyIntolerance" + // HealthcareFhirResourceTypeAppointment - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeAppointment HealthcareFhirResourceType = "Appointment" + // HealthcareFhirResourceTypeAppointmentResponse - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeAppointmentResponse HealthcareFhirResourceType = "AppointmentResponse" + // HealthcareFhirResourceTypeAuditEvent - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeAuditEvent HealthcareFhirResourceType = "AuditEvent" + // HealthcareFhirResourceTypeBasic - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeBasic HealthcareFhirResourceType = "Basic" + // HealthcareFhirResourceTypeBinary - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeBinary HealthcareFhirResourceType = "Binary" + // HealthcareFhirResourceTypeBiologicallyDerivedProduct - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeBiologicallyDerivedProduct HealthcareFhirResourceType = "BiologicallyDerivedProduct" + // HealthcareFhirResourceTypeBodySite - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeBodySite HealthcareFhirResourceType = "BodySite" + // HealthcareFhirResourceTypeBodyStructure - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeBodyStructure HealthcareFhirResourceType = "BodyStructure" + // HealthcareFhirResourceTypeBundle - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeBundle HealthcareFhirResourceType = "Bundle" + // HealthcareFhirResourceTypeCapabilityStatement - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeCapabilityStatement HealthcareFhirResourceType = "CapabilityStatement" + // HealthcareFhirResourceTypeCarePlan - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeCarePlan HealthcareFhirResourceType = "CarePlan" + // HealthcareFhirResourceTypeCareTeam - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeCareTeam HealthcareFhirResourceType = "CareTeam" + // HealthcareFhirResourceTypeCatalogEntry - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeCatalogEntry HealthcareFhirResourceType = "CatalogEntry" + // HealthcareFhirResourceTypeChargeItem - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeChargeItem HealthcareFhirResourceType = "ChargeItem" + // HealthcareFhirResourceTypeChargeItemDefinition - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeChargeItemDefinition HealthcareFhirResourceType = "ChargeItemDefinition" + // HealthcareFhirResourceTypeClaim - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeClaim HealthcareFhirResourceType = "Claim" + // HealthcareFhirResourceTypeClaimResponse - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeClaimResponse HealthcareFhirResourceType = "ClaimResponse" + // HealthcareFhirResourceTypeClinicalImpression - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeClinicalImpression HealthcareFhirResourceType = "ClinicalImpression" + // HealthcareFhirResourceTypeCodeSystem - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeCodeSystem HealthcareFhirResourceType = "CodeSystem" + // HealthcareFhirResourceTypeCommunication - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeCommunication HealthcareFhirResourceType = "Communication" + // HealthcareFhirResourceTypeCommunicationRequest - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeCommunicationRequest HealthcareFhirResourceType = "CommunicationRequest" + // HealthcareFhirResourceTypeCompartmentDefinition - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeCompartmentDefinition HealthcareFhirResourceType = "CompartmentDefinition" + // HealthcareFhirResourceTypeComposition - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeComposition HealthcareFhirResourceType = "Composition" + // HealthcareFhirResourceTypeConceptMap - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeConceptMap HealthcareFhirResourceType = "ConceptMap" + // HealthcareFhirResourceTypeCondition - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeCondition HealthcareFhirResourceType = "Condition" + // HealthcareFhirResourceTypeConsent - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeConsent HealthcareFhirResourceType = "Consent" + // HealthcareFhirResourceTypeContract - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeContract HealthcareFhirResourceType = "Contract" + // HealthcareFhirResourceTypeCoverage - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeCoverage HealthcareFhirResourceType = "Coverage" + // HealthcareFhirResourceTypeCoverageEligibilityRequest - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeCoverageEligibilityRequest HealthcareFhirResourceType = "CoverageEligibilityRequest" + // HealthcareFhirResourceTypeCoverageEligibilityResponse - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeCoverageEligibilityResponse HealthcareFhirResourceType = "CoverageEligibilityResponse" + // HealthcareFhirResourceTypeDataElement - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeDataElement HealthcareFhirResourceType = "DataElement" + // HealthcareFhirResourceTypeDetectedIssue - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeDetectedIssue HealthcareFhirResourceType = "DetectedIssue" + // HealthcareFhirResourceTypeDevice - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeDevice HealthcareFhirResourceType = "Device" + // HealthcareFhirResourceTypeDeviceComponent - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeDeviceComponent HealthcareFhirResourceType = "DeviceComponent" + // HealthcareFhirResourceTypeDeviceDefinition - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeDeviceDefinition HealthcareFhirResourceType = "DeviceDefinition" + // HealthcareFhirResourceTypeDeviceMetric - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeDeviceMetric HealthcareFhirResourceType = "DeviceMetric" + // HealthcareFhirResourceTypeDeviceRequest - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeDeviceRequest HealthcareFhirResourceType = "DeviceRequest" + // HealthcareFhirResourceTypeDeviceUseStatement - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeDeviceUseStatement HealthcareFhirResourceType = "DeviceUseStatement" + // HealthcareFhirResourceTypeDiagnosticReport - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeDiagnosticReport HealthcareFhirResourceType = "DiagnosticReport" + // HealthcareFhirResourceTypeDocumentManifest - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeDocumentManifest HealthcareFhirResourceType = "DocumentManifest" + // HealthcareFhirResourceTypeDocumentReference - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeDocumentReference HealthcareFhirResourceType = "DocumentReference" + // HealthcareFhirResourceTypeDomainResource - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeDomainResource HealthcareFhirResourceType = "DomainResource" + // HealthcareFhirResourceTypeEffectEvidenceSynthesis - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeEffectEvidenceSynthesis HealthcareFhirResourceType = "EffectEvidenceSynthesis" + // HealthcareFhirResourceTypeEligibilityRequest - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeEligibilityRequest HealthcareFhirResourceType = "EligibilityRequest" + // HealthcareFhirResourceTypeEligibilityResponse - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeEligibilityResponse HealthcareFhirResourceType = "EligibilityResponse" + // HealthcareFhirResourceTypeEncounter - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeEncounter HealthcareFhirResourceType = "Encounter" + // HealthcareFhirResourceTypeEndpoint - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeEndpoint HealthcareFhirResourceType = "Endpoint" + // HealthcareFhirResourceTypeEnrollmentRequest - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeEnrollmentRequest HealthcareFhirResourceType = "EnrollmentRequest" + // HealthcareFhirResourceTypeEnrollmentResponse - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeEnrollmentResponse HealthcareFhirResourceType = "EnrollmentResponse" + // HealthcareFhirResourceTypeEpisodeOfCare - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeEpisodeOfCare HealthcareFhirResourceType = "EpisodeOfCare" + // HealthcareFhirResourceTypeEventDefinition - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeEventDefinition HealthcareFhirResourceType = "EventDefinition" + // HealthcareFhirResourceTypeEvidence - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeEvidence HealthcareFhirResourceType = "Evidence" + // HealthcareFhirResourceTypeEvidenceVariable - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeEvidenceVariable HealthcareFhirResourceType = "EvidenceVariable" + // HealthcareFhirResourceTypeExampleScenario - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeExampleScenario HealthcareFhirResourceType = "ExampleScenario" + // HealthcareFhirResourceTypeExpansionProfile - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeExpansionProfile HealthcareFhirResourceType = "ExpansionProfile" + // HealthcareFhirResourceTypeExplanationOfBenefit - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeExplanationOfBenefit HealthcareFhirResourceType = "ExplanationOfBenefit" + // HealthcareFhirResourceTypeFamilyMemberHistory - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeFamilyMemberHistory HealthcareFhirResourceType = "FamilyMemberHistory" + // HealthcareFhirResourceTypeFlag - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeFlag HealthcareFhirResourceType = "Flag" + // HealthcareFhirResourceTypeGoal - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeGoal HealthcareFhirResourceType = "Goal" + // HealthcareFhirResourceTypeGraphDefinition - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeGraphDefinition HealthcareFhirResourceType = "GraphDefinition" + // HealthcareFhirResourceTypeGroup - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeGroup HealthcareFhirResourceType = "Group" + // HealthcareFhirResourceTypeGuidanceResponse - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeGuidanceResponse HealthcareFhirResourceType = "GuidanceResponse" + // HealthcareFhirResourceTypeHealthcareService - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeHealthcareService HealthcareFhirResourceType = "HealthcareService" + // HealthcareFhirResourceTypeImagingManifest - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeImagingManifest HealthcareFhirResourceType = "ImagingManifest" + // HealthcareFhirResourceTypeImagingStudy - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeImagingStudy HealthcareFhirResourceType = "ImagingStudy" + // HealthcareFhirResourceTypeImmunization - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeImmunization HealthcareFhirResourceType = "Immunization" + // HealthcareFhirResourceTypeImmunizationEvaluation - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeImmunizationEvaluation HealthcareFhirResourceType = "ImmunizationEvaluation" + // HealthcareFhirResourceTypeImmunizationRecommendation - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeImmunizationRecommendation HealthcareFhirResourceType = "ImmunizationRecommendation" + // HealthcareFhirResourceTypeImplementationGuide - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeImplementationGuide HealthcareFhirResourceType = "ImplementationGuide" + // HealthcareFhirResourceTypeInsurancePlan - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeInsurancePlan HealthcareFhirResourceType = "InsurancePlan" + // HealthcareFhirResourceTypeInvoice - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeInvoice HealthcareFhirResourceType = "Invoice" + // HealthcareFhirResourceTypeLibrary - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeLibrary HealthcareFhirResourceType = "Library" + // HealthcareFhirResourceTypeLinkage - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeLinkage HealthcareFhirResourceType = "Linkage" + // HealthcareFhirResourceTypeList - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeList HealthcareFhirResourceType = "List" + // HealthcareFhirResourceTypeLocation - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeLocation HealthcareFhirResourceType = "Location" + // HealthcareFhirResourceTypeMeasure - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeMeasure HealthcareFhirResourceType = "Measure" + // HealthcareFhirResourceTypeMeasureReport - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeMeasureReport HealthcareFhirResourceType = "MeasureReport" + // HealthcareFhirResourceTypeMedia - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeMedia HealthcareFhirResourceType = "Media" + // HealthcareFhirResourceTypeMedication - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeMedication HealthcareFhirResourceType = "Medication" + // HealthcareFhirResourceTypeMedicationAdministration - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeMedicationAdministration HealthcareFhirResourceType = "MedicationAdministration" + // HealthcareFhirResourceTypeMedicationDispense - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeMedicationDispense HealthcareFhirResourceType = "MedicationDispense" + // HealthcareFhirResourceTypeMedicationKnowledge - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicationKnowledge HealthcareFhirResourceType = "MedicationKnowledge" + // HealthcareFhirResourceTypeMedicationRequest - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeMedicationRequest HealthcareFhirResourceType = "MedicationRequest" + // HealthcareFhirResourceTypeMedicationStatement - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeMedicationStatement HealthcareFhirResourceType = "MedicationStatement" + // HealthcareFhirResourceTypeMedicinalProduct - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicinalProduct HealthcareFhirResourceType = "MedicinalProduct" + // HealthcareFhirResourceTypeMedicinalProductAuthorization - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicinalProductAuthorization HealthcareFhirResourceType = "MedicinalProductAuthorization" + // HealthcareFhirResourceTypeMedicinalProductContraindication - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicinalProductContraindication HealthcareFhirResourceType = "MedicinalProductContraindication" + // HealthcareFhirResourceTypeMedicinalProductIndication - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicinalProductIndication HealthcareFhirResourceType = "MedicinalProductIndication" + // HealthcareFhirResourceTypeMedicinalProductIngredient - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicinalProductIngredient HealthcareFhirResourceType = "MedicinalProductIngredient" + // HealthcareFhirResourceTypeMedicinalProductInteraction - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicinalProductInteraction HealthcareFhirResourceType = "MedicinalProductInteraction" + // HealthcareFhirResourceTypeMedicinalProductManufactured - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicinalProductManufactured HealthcareFhirResourceType = "MedicinalProductManufactured" + // HealthcareFhirResourceTypeMedicinalProductPackaged - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicinalProductPackaged HealthcareFhirResourceType = "MedicinalProductPackaged" + // HealthcareFhirResourceTypeMedicinalProductPharmaceutical - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicinalProductPharmaceutical HealthcareFhirResourceType = "MedicinalProductPharmaceutical" + // HealthcareFhirResourceTypeMedicinalProductUndesirableEffect - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMedicinalProductUndesirableEffect HealthcareFhirResourceType = "MedicinalProductUndesirableEffect" + // HealthcareFhirResourceTypeMessageDefinition - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeMessageDefinition HealthcareFhirResourceType = "MessageDefinition" + // HealthcareFhirResourceTypeMessageHeader - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeMessageHeader HealthcareFhirResourceType = "MessageHeader" + // HealthcareFhirResourceTypeMolecularSequence - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeMolecularSequence HealthcareFhirResourceType = "MolecularSequence" + // HealthcareFhirResourceTypeNamingSystem - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeNamingSystem HealthcareFhirResourceType = "NamingSystem" + // HealthcareFhirResourceTypeNutritionOrder - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeNutritionOrder HealthcareFhirResourceType = "NutritionOrder" + // HealthcareFhirResourceTypeObservation - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeObservation HealthcareFhirResourceType = "Observation" + // HealthcareFhirResourceTypeObservationDefinition - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeObservationDefinition HealthcareFhirResourceType = "ObservationDefinition" + // HealthcareFhirResourceTypeOperationDefinition - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeOperationDefinition HealthcareFhirResourceType = "OperationDefinition" + // HealthcareFhirResourceTypeOperationOutcome - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeOperationOutcome HealthcareFhirResourceType = "OperationOutcome" + // HealthcareFhirResourceTypeOrganization - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeOrganization HealthcareFhirResourceType = "Organization" + // HealthcareFhirResourceTypeOrganizationAffiliation - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeOrganizationAffiliation HealthcareFhirResourceType = "OrganizationAffiliation" + // HealthcareFhirResourceTypeParameters - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeParameters HealthcareFhirResourceType = "Parameters" + // HealthcareFhirResourceTypePatient - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypePatient HealthcareFhirResourceType = "Patient" + // HealthcareFhirResourceTypePaymentNotice - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypePaymentNotice HealthcareFhirResourceType = "PaymentNotice" + // HealthcareFhirResourceTypePaymentReconciliation - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypePaymentReconciliation HealthcareFhirResourceType = "PaymentReconciliation" + // HealthcareFhirResourceTypePerson - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypePerson HealthcareFhirResourceType = "Person" + // HealthcareFhirResourceTypePlanDefinition - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypePlanDefinition HealthcareFhirResourceType = "PlanDefinition" + // HealthcareFhirResourceTypePractitioner - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypePractitioner HealthcareFhirResourceType = "Practitioner" + // HealthcareFhirResourceTypePractitionerRole - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypePractitionerRole HealthcareFhirResourceType = "PractitionerRole" + // HealthcareFhirResourceTypeProcedure - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeProcedure HealthcareFhirResourceType = "Procedure" + // HealthcareFhirResourceTypeProcedureRequest - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeProcedureRequest HealthcareFhirResourceType = "ProcedureRequest" + // HealthcareFhirResourceTypeProcessRequest - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeProcessRequest HealthcareFhirResourceType = "ProcessRequest" + // HealthcareFhirResourceTypeProcessResponse - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeProcessResponse HealthcareFhirResourceType = "ProcessResponse" + // HealthcareFhirResourceTypeProvenance - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeProvenance HealthcareFhirResourceType = "Provenance" + // HealthcareFhirResourceTypeQuestionnaire - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeQuestionnaire HealthcareFhirResourceType = "Questionnaire" + // HealthcareFhirResourceTypeQuestionnaireResponse - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeQuestionnaireResponse HealthcareFhirResourceType = "QuestionnaireResponse" + // HealthcareFhirResourceTypeReferralRequest - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeReferralRequest HealthcareFhirResourceType = "ReferralRequest" + // HealthcareFhirResourceTypeRelatedPerson - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeRelatedPerson HealthcareFhirResourceType = "RelatedPerson" + // HealthcareFhirResourceTypeRequestGroup - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeRequestGroup HealthcareFhirResourceType = "RequestGroup" + // HealthcareFhirResourceTypeResearchDefinition - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeResearchDefinition HealthcareFhirResourceType = "ResearchDefinition" + // HealthcareFhirResourceTypeResearchElementDefinition - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeResearchElementDefinition HealthcareFhirResourceType = "ResearchElementDefinition" + // HealthcareFhirResourceTypeResearchStudy - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeResearchStudy HealthcareFhirResourceType = "ResearchStudy" + // HealthcareFhirResourceTypeResearchSubject - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeResearchSubject HealthcareFhirResourceType = "ResearchSubject" + // HealthcareFhirResourceTypeResource - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeResource HealthcareFhirResourceType = "Resource" + // HealthcareFhirResourceTypeRiskAssessment - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeRiskAssessment HealthcareFhirResourceType = "RiskAssessment" + // HealthcareFhirResourceTypeRiskEvidenceSynthesis - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeRiskEvidenceSynthesis HealthcareFhirResourceType = "RiskEvidenceSynthesis" + // HealthcareFhirResourceTypeSchedule - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeSchedule HealthcareFhirResourceType = "Schedule" + // HealthcareFhirResourceTypeSearchParameter - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeSearchParameter HealthcareFhirResourceType = "SearchParameter" + // HealthcareFhirResourceTypeSequence - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeSequence HealthcareFhirResourceType = "Sequence" + // HealthcareFhirResourceTypeServiceDefinition - The FHIR resource type defined in STU3. + HealthcareFhirResourceTypeServiceDefinition HealthcareFhirResourceType = "ServiceDefinition" + // HealthcareFhirResourceTypeServiceRequest - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeServiceRequest HealthcareFhirResourceType = "ServiceRequest" + // HealthcareFhirResourceTypeSlot - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeSlot HealthcareFhirResourceType = "Slot" + // HealthcareFhirResourceTypeSpecimen - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeSpecimen HealthcareFhirResourceType = "Specimen" + // HealthcareFhirResourceTypeSpecimenDefinition - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeSpecimenDefinition HealthcareFhirResourceType = "SpecimenDefinition" + // HealthcareFhirResourceTypeStructureDefinition - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeStructureDefinition HealthcareFhirResourceType = "StructureDefinition" + // HealthcareFhirResourceTypeStructureMap - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeStructureMap HealthcareFhirResourceType = "StructureMap" + // HealthcareFhirResourceTypeSubscription - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeSubscription HealthcareFhirResourceType = "Subscription" + // HealthcareFhirResourceTypeSubstance - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeSubstance HealthcareFhirResourceType = "Substance" + // HealthcareFhirResourceTypeSubstanceNucleicAcid - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeSubstanceNucleicAcid HealthcareFhirResourceType = "SubstanceNucleicAcid" + // HealthcareFhirResourceTypeSubstancePolymer - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeSubstancePolymer HealthcareFhirResourceType = "SubstancePolymer" + // HealthcareFhirResourceTypeSubstanceProtein - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeSubstanceProtein HealthcareFhirResourceType = "SubstanceProtein" + // HealthcareFhirResourceTypeSubstanceReferenceInformation - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeSubstanceReferenceInformation HealthcareFhirResourceType = "SubstanceReferenceInformation" + // HealthcareFhirResourceTypeSubstanceSourceMaterial - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeSubstanceSourceMaterial HealthcareFhirResourceType = "SubstanceSourceMaterial" + // HealthcareFhirResourceTypeSubstanceSpecification - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeSubstanceSpecification HealthcareFhirResourceType = "SubstanceSpecification" + // HealthcareFhirResourceTypeSupplyDelivery - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeSupplyDelivery HealthcareFhirResourceType = "SupplyDelivery" + // HealthcareFhirResourceTypeSupplyRequest - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeSupplyRequest HealthcareFhirResourceType = "SupplyRequest" + // HealthcareFhirResourceTypeTask - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeTask HealthcareFhirResourceType = "Task" + // HealthcareFhirResourceTypeTerminologyCapabilities - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeTerminologyCapabilities HealthcareFhirResourceType = "TerminologyCapabilities" + // HealthcareFhirResourceTypeTestReport - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeTestReport HealthcareFhirResourceType = "TestReport" + // HealthcareFhirResourceTypeTestScript - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeTestScript HealthcareFhirResourceType = "TestScript" + // HealthcareFhirResourceTypeValueSet - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeValueSet HealthcareFhirResourceType = "ValueSet" + // HealthcareFhirResourceTypeVerificationResult - The FHIR resource type defined in R4. + HealthcareFhirResourceTypeVerificationResult HealthcareFhirResourceType = "VerificationResult" + // HealthcareFhirResourceTypeVisionPrescription - The FHIR resource type defined in STU3 and R4. + HealthcareFhirResourceTypeVisionPrescription HealthcareFhirResourceType = "VisionPrescription" +) + +// PossibleHealthcareFhirResourceTypeValues returns the possible values for the HealthcareFhirResourceType const type. +func PossibleHealthcareFhirResourceTypeValues() []HealthcareFhirResourceType { + return []HealthcareFhirResourceType{ + HealthcareFhirResourceTypeAccount, + HealthcareFhirResourceTypeActivityDefinition, + HealthcareFhirResourceTypeAdverseEvent, + HealthcareFhirResourceTypeAllergyIntolerance, + HealthcareFhirResourceTypeAppointment, + HealthcareFhirResourceTypeAppointmentResponse, + HealthcareFhirResourceTypeAuditEvent, + HealthcareFhirResourceTypeBasic, + HealthcareFhirResourceTypeBinary, + HealthcareFhirResourceTypeBiologicallyDerivedProduct, + HealthcareFhirResourceTypeBodySite, + HealthcareFhirResourceTypeBodyStructure, + HealthcareFhirResourceTypeBundle, + HealthcareFhirResourceTypeCapabilityStatement, + HealthcareFhirResourceTypeCarePlan, + HealthcareFhirResourceTypeCareTeam, + HealthcareFhirResourceTypeCatalogEntry, + HealthcareFhirResourceTypeChargeItem, + HealthcareFhirResourceTypeChargeItemDefinition, + HealthcareFhirResourceTypeClaim, + HealthcareFhirResourceTypeClaimResponse, + HealthcareFhirResourceTypeClinicalImpression, + HealthcareFhirResourceTypeCodeSystem, + HealthcareFhirResourceTypeCommunication, + HealthcareFhirResourceTypeCommunicationRequest, + HealthcareFhirResourceTypeCompartmentDefinition, + HealthcareFhirResourceTypeComposition, + HealthcareFhirResourceTypeConceptMap, + HealthcareFhirResourceTypeCondition, + HealthcareFhirResourceTypeConsent, + HealthcareFhirResourceTypeContract, + HealthcareFhirResourceTypeCoverage, + HealthcareFhirResourceTypeCoverageEligibilityRequest, + HealthcareFhirResourceTypeCoverageEligibilityResponse, + HealthcareFhirResourceTypeDataElement, + HealthcareFhirResourceTypeDetectedIssue, + HealthcareFhirResourceTypeDevice, + HealthcareFhirResourceTypeDeviceComponent, + HealthcareFhirResourceTypeDeviceDefinition, + HealthcareFhirResourceTypeDeviceMetric, + HealthcareFhirResourceTypeDeviceRequest, + HealthcareFhirResourceTypeDeviceUseStatement, + HealthcareFhirResourceTypeDiagnosticReport, + HealthcareFhirResourceTypeDocumentManifest, + HealthcareFhirResourceTypeDocumentReference, + HealthcareFhirResourceTypeDomainResource, + HealthcareFhirResourceTypeEffectEvidenceSynthesis, + HealthcareFhirResourceTypeEligibilityRequest, + HealthcareFhirResourceTypeEligibilityResponse, + HealthcareFhirResourceTypeEncounter, + HealthcareFhirResourceTypeEndpoint, + HealthcareFhirResourceTypeEnrollmentRequest, + HealthcareFhirResourceTypeEnrollmentResponse, + HealthcareFhirResourceTypeEpisodeOfCare, + HealthcareFhirResourceTypeEventDefinition, + HealthcareFhirResourceTypeEvidence, + HealthcareFhirResourceTypeEvidenceVariable, + HealthcareFhirResourceTypeExampleScenario, + HealthcareFhirResourceTypeExpansionProfile, + HealthcareFhirResourceTypeExplanationOfBenefit, + HealthcareFhirResourceTypeFamilyMemberHistory, + HealthcareFhirResourceTypeFlag, + HealthcareFhirResourceTypeGoal, + HealthcareFhirResourceTypeGraphDefinition, + HealthcareFhirResourceTypeGroup, + HealthcareFhirResourceTypeGuidanceResponse, + HealthcareFhirResourceTypeHealthcareService, + HealthcareFhirResourceTypeImagingManifest, + HealthcareFhirResourceTypeImagingStudy, + HealthcareFhirResourceTypeImmunization, + HealthcareFhirResourceTypeImmunizationEvaluation, + HealthcareFhirResourceTypeImmunizationRecommendation, + HealthcareFhirResourceTypeImplementationGuide, + HealthcareFhirResourceTypeInsurancePlan, + HealthcareFhirResourceTypeInvoice, + HealthcareFhirResourceTypeLibrary, + HealthcareFhirResourceTypeLinkage, + HealthcareFhirResourceTypeList, + HealthcareFhirResourceTypeLocation, + HealthcareFhirResourceTypeMeasure, + HealthcareFhirResourceTypeMeasureReport, + HealthcareFhirResourceTypeMedia, + HealthcareFhirResourceTypeMedication, + HealthcareFhirResourceTypeMedicationAdministration, + HealthcareFhirResourceTypeMedicationDispense, + HealthcareFhirResourceTypeMedicationKnowledge, + HealthcareFhirResourceTypeMedicationRequest, + HealthcareFhirResourceTypeMedicationStatement, + HealthcareFhirResourceTypeMedicinalProduct, + HealthcareFhirResourceTypeMedicinalProductAuthorization, + HealthcareFhirResourceTypeMedicinalProductContraindication, + HealthcareFhirResourceTypeMedicinalProductIndication, + HealthcareFhirResourceTypeMedicinalProductIngredient, + HealthcareFhirResourceTypeMedicinalProductInteraction, + HealthcareFhirResourceTypeMedicinalProductManufactured, + HealthcareFhirResourceTypeMedicinalProductPackaged, + HealthcareFhirResourceTypeMedicinalProductPharmaceutical, + HealthcareFhirResourceTypeMedicinalProductUndesirableEffect, + HealthcareFhirResourceTypeMessageDefinition, + HealthcareFhirResourceTypeMessageHeader, + HealthcareFhirResourceTypeMolecularSequence, + HealthcareFhirResourceTypeNamingSystem, + HealthcareFhirResourceTypeNutritionOrder, + HealthcareFhirResourceTypeObservation, + HealthcareFhirResourceTypeObservationDefinition, + HealthcareFhirResourceTypeOperationDefinition, + HealthcareFhirResourceTypeOperationOutcome, + HealthcareFhirResourceTypeOrganization, + HealthcareFhirResourceTypeOrganizationAffiliation, + HealthcareFhirResourceTypeParameters, + HealthcareFhirResourceTypePatient, + HealthcareFhirResourceTypePaymentNotice, + HealthcareFhirResourceTypePaymentReconciliation, + HealthcareFhirResourceTypePerson, + HealthcareFhirResourceTypePlanDefinition, + HealthcareFhirResourceTypePractitioner, + HealthcareFhirResourceTypePractitionerRole, + HealthcareFhirResourceTypeProcedure, + HealthcareFhirResourceTypeProcedureRequest, + HealthcareFhirResourceTypeProcessRequest, + HealthcareFhirResourceTypeProcessResponse, + HealthcareFhirResourceTypeProvenance, + HealthcareFhirResourceTypeQuestionnaire, + HealthcareFhirResourceTypeQuestionnaireResponse, + HealthcareFhirResourceTypeReferralRequest, + HealthcareFhirResourceTypeRelatedPerson, + HealthcareFhirResourceTypeRequestGroup, + HealthcareFhirResourceTypeResearchDefinition, + HealthcareFhirResourceTypeResearchElementDefinition, + HealthcareFhirResourceTypeResearchStudy, + HealthcareFhirResourceTypeResearchSubject, + HealthcareFhirResourceTypeResource, + HealthcareFhirResourceTypeRiskAssessment, + HealthcareFhirResourceTypeRiskEvidenceSynthesis, + HealthcareFhirResourceTypeSchedule, + HealthcareFhirResourceTypeSearchParameter, + HealthcareFhirResourceTypeSequence, + HealthcareFhirResourceTypeServiceDefinition, + HealthcareFhirResourceTypeServiceRequest, + HealthcareFhirResourceTypeSlot, + HealthcareFhirResourceTypeSpecimen, + HealthcareFhirResourceTypeSpecimenDefinition, + HealthcareFhirResourceTypeStructureDefinition, + HealthcareFhirResourceTypeStructureMap, + HealthcareFhirResourceTypeSubscription, + HealthcareFhirResourceTypeSubstance, + HealthcareFhirResourceTypeSubstanceNucleicAcid, + HealthcareFhirResourceTypeSubstancePolymer, + HealthcareFhirResourceTypeSubstanceProtein, + HealthcareFhirResourceTypeSubstanceReferenceInformation, + HealthcareFhirResourceTypeSubstanceSourceMaterial, + HealthcareFhirResourceTypeSubstanceSpecification, + HealthcareFhirResourceTypeSupplyDelivery, + HealthcareFhirResourceTypeSupplyRequest, + HealthcareFhirResourceTypeTask, + HealthcareFhirResourceTypeTerminologyCapabilities, + HealthcareFhirResourceTypeTestReport, + HealthcareFhirResourceTypeTestScript, + HealthcareFhirResourceTypeValueSet, + HealthcareFhirResourceTypeVerificationResult, + HealthcareFhirResourceTypeVisionPrescription, + } +} + +// MediaJobErrorCategory - Helps with categorization of errors. +type MediaJobErrorCategory string + +const ( + // MediaJobErrorCategoryAccount - The error is related to account information. + MediaJobErrorCategoryAccount MediaJobErrorCategory = "Account" + // MediaJobErrorCategoryConfiguration - The error is configuration related. + MediaJobErrorCategoryConfiguration MediaJobErrorCategory = "Configuration" + // MediaJobErrorCategoryContent - The error is related to data in the input files. + MediaJobErrorCategoryContent MediaJobErrorCategory = "Content" + // MediaJobErrorCategoryDownload - The error is download related. + MediaJobErrorCategoryDownload MediaJobErrorCategory = "Download" + // MediaJobErrorCategoryService - The error is service related. + MediaJobErrorCategoryService MediaJobErrorCategory = "Service" + // MediaJobErrorCategoryUpload - The error is upload related. + MediaJobErrorCategoryUpload MediaJobErrorCategory = "Upload" +) + +// PossibleMediaJobErrorCategoryValues returns the possible values for the MediaJobErrorCategory const type. +func PossibleMediaJobErrorCategoryValues() []MediaJobErrorCategory { + return []MediaJobErrorCategory{ + MediaJobErrorCategoryAccount, + MediaJobErrorCategoryConfiguration, + MediaJobErrorCategoryContent, + MediaJobErrorCategoryDownload, + MediaJobErrorCategoryService, + MediaJobErrorCategoryUpload, + } +} + +// MediaJobErrorCode - Error code describing the error. +type MediaJobErrorCode string + +const ( + // MediaJobErrorCodeConfigurationUnsupported - There was a problem with the combination of input files and the configuration + // settings applied, fix the configuration settings and retry with the same input, or change input to match the configuration. + MediaJobErrorCodeConfigurationUnsupported MediaJobErrorCode = "ConfigurationUnsupported" + // MediaJobErrorCodeContentMalformed - There was a problem with the input content (for example: zero byte files, or corrupt/non-decodable + // files), check the input files. + MediaJobErrorCodeContentMalformed MediaJobErrorCode = "ContentMalformed" + // MediaJobErrorCodeContentUnsupported - There was a problem with the format of the input (not valid media file, or an unsupported + // file/codec), check the validity of the input files. + MediaJobErrorCodeContentUnsupported MediaJobErrorCode = "ContentUnsupported" + // MediaJobErrorCodeDownloadNotAccessible - While trying to download the input files, the files were not accessible, please + // check the availability of the source. + MediaJobErrorCodeDownloadNotAccessible MediaJobErrorCode = "DownloadNotAccessible" + // MediaJobErrorCodeDownloadTransientError - While trying to download the input files, there was an issue during transfer + // (storage service, network errors), see details and check your source. + MediaJobErrorCodeDownloadTransientError MediaJobErrorCode = "DownloadTransientError" + // MediaJobErrorCodeIdentityUnsupported - There is an error verifying to the account identity. Check and fix the identity + // configurations and retry. If unsuccessful, please contact support. + MediaJobErrorCodeIdentityUnsupported MediaJobErrorCode = "IdentityUnsupported" + // MediaJobErrorCodeServiceError - Fatal service error, please contact support. + MediaJobErrorCodeServiceError MediaJobErrorCode = "ServiceError" + // MediaJobErrorCodeServiceTransientError - Transient error, please retry, if retry is unsuccessful, please contact support. + MediaJobErrorCodeServiceTransientError MediaJobErrorCode = "ServiceTransientError" + // MediaJobErrorCodeUploadNotAccessible - While trying to upload the output files, the destination was not reachable, please + // check the availability of the destination. + MediaJobErrorCodeUploadNotAccessible MediaJobErrorCode = "UploadNotAccessible" + // MediaJobErrorCodeUploadTransientError - While trying to upload the output files, there was an issue during transfer (storage + // service, network errors), see details and check your destination. + MediaJobErrorCodeUploadTransientError MediaJobErrorCode = "UploadTransientError" +) + +// PossibleMediaJobErrorCodeValues returns the possible values for the MediaJobErrorCode const type. +func PossibleMediaJobErrorCodeValues() []MediaJobErrorCode { + return []MediaJobErrorCode{ + MediaJobErrorCodeConfigurationUnsupported, + MediaJobErrorCodeContentMalformed, + MediaJobErrorCodeContentUnsupported, + MediaJobErrorCodeDownloadNotAccessible, + MediaJobErrorCodeDownloadTransientError, + MediaJobErrorCodeIdentityUnsupported, + MediaJobErrorCodeServiceError, + MediaJobErrorCodeServiceTransientError, + MediaJobErrorCodeUploadNotAccessible, + MediaJobErrorCodeUploadTransientError, + } +} + +// MediaJobRetry - Indicates that it may be possible to retry the Job. If retry is unsuccessful, please contact Azure support +// via Azure Portal. +type MediaJobRetry string + +const ( + // MediaJobRetryDoNotRetry - Issue needs to be investigated and then the job resubmitted with corrections or retried once + // the underlying issue has been corrected. + MediaJobRetryDoNotRetry MediaJobRetry = "DoNotRetry" + // MediaJobRetryMayRetry - Issue may be resolved after waiting for a period of time and resubmitting the same Job. + MediaJobRetryMayRetry MediaJobRetry = "MayRetry" +) + +// PossibleMediaJobRetryValues returns the possible values for the MediaJobRetry const type. +func PossibleMediaJobRetryValues() []MediaJobRetry { + return []MediaJobRetry{ + MediaJobRetryDoNotRetry, + MediaJobRetryMayRetry, + } +} + +// MediaJobState - The previous state of the Job. +type MediaJobState string + +const ( + // MediaJobStateCanceled - The job was canceled. This is a final state for the job. + MediaJobStateCanceled MediaJobState = "Canceled" + // MediaJobStateCanceling - The job is in the process of being canceled. This is a transient state for the job. + MediaJobStateCanceling MediaJobState = "Canceling" + // MediaJobStateError - The job has encountered an error. This is a final state for the job. + MediaJobStateError MediaJobState = "Error" + // MediaJobStateFinished - The job is finished. This is a final state for the job. + MediaJobStateFinished MediaJobState = "Finished" + // MediaJobStateProcessing - The job is processing. This is a transient state for the job. + MediaJobStateProcessing MediaJobState = "Processing" + // MediaJobStateQueued - The job is in a queued state, waiting for resources to become available. This is a transient state. + MediaJobStateQueued MediaJobState = "Queued" + // MediaJobStateScheduled - The job is being scheduled to run on an available resource. This is a transient state, between + // queued and processing states. + MediaJobStateScheduled MediaJobState = "Scheduled" +) + +// PossibleMediaJobStateValues returns the possible values for the MediaJobState const type. +func PossibleMediaJobStateValues() []MediaJobState { + return []MediaJobState{ + MediaJobStateCanceled, + MediaJobStateCanceling, + MediaJobStateError, + MediaJobStateFinished, + MediaJobStateProcessing, + MediaJobStateQueued, + MediaJobStateScheduled, + } +} + +// RecordingChannelType - The recording channel type - Mixed, Unmixed +type RecordingChannelType string + +const ( + RecordingChannelTypeMixed RecordingChannelType = "Mixed" + RecordingChannelTypeUnmixed RecordingChannelType = "Unmixed" +) + +// PossibleRecordingChannelTypeValues returns the possible values for the RecordingChannelType const type. +func PossibleRecordingChannelTypeValues() []RecordingChannelType { + return []RecordingChannelType{ + RecordingChannelTypeMixed, + RecordingChannelTypeUnmixed, + } +} + +// RecordingContentType - The recording content type- AudioVideo, or Audio +type RecordingContentType string + +const ( + RecordingContentTypeAudio RecordingContentType = "Audio" + RecordingContentTypeAudioVideo RecordingContentType = "AudioVideo" +) + +// PossibleRecordingContentTypeValues returns the possible values for the RecordingContentType const type. +func PossibleRecordingContentTypeValues() []RecordingContentType { + return []RecordingContentType{ + RecordingContentTypeAudio, + RecordingContentTypeAudioVideo, + } +} + +// RecordingFormatType - The recording format type - Mp4, Mp3, Wav +type RecordingFormatType string + +const ( + RecordingFormatTypeMp3 RecordingFormatType = "Mp3" + RecordingFormatTypeMp4 RecordingFormatType = "Mp4" + RecordingFormatTypeWav RecordingFormatType = "Wav" +) + +// PossibleRecordingFormatTypeValues returns the possible values for the RecordingFormatType const type. +func PossibleRecordingFormatTypeValues() []RecordingFormatType { + return []RecordingFormatType{ + RecordingFormatTypeMp3, + RecordingFormatTypeMp4, + RecordingFormatTypeWav, + } +} + +// StampKind - Kind of environment where app service plan is. +type StampKind string + +const ( + // StampKindAseV1 - App Service Plan is running on an App Service Environment V1. + StampKindAseV1 StampKind = "AseV1" + // StampKindAseV2 - App Service Plan is running on an App Service Environment V2. + StampKindAseV2 StampKind = "AseV2" + // StampKindPublic - App Service Plan is running on a public stamp. + StampKindPublic StampKind = "Public" +) + +// PossibleStampKindValues returns the possible values for the StampKind const type. +func PossibleStampKindValues() []StampKind { + return []StampKind{ + StampKindAseV1, + StampKindAseV2, + StampKindPublic, + } +} + +// StorageTaskCompletedStatus - The status for a storage task. +type StorageTaskCompletedStatus string + +const ( + StorageTaskCompletedStatusFailed StorageTaskCompletedStatus = "Failed" + StorageTaskCompletedStatusSucceeded StorageTaskCompletedStatus = "Succeeded" +) + +// PossibleStorageTaskCompletedStatusValues returns the possible values for the StorageTaskCompletedStatus const type. +func PossibleStorageTaskCompletedStatusValues() []StorageTaskCompletedStatus { + return []StorageTaskCompletedStatus{ + StorageTaskCompletedStatusFailed, + StorageTaskCompletedStatusSucceeded, + } +} diff --git a/sdk/messaging/eventgrid/azsystemevents/custom_events.go b/sdk/messaging/eventgrid/azsystemevents/custom_events.go new file mode 100644 index 000000000000..08226522b65f --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/custom_events.go @@ -0,0 +1,15 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azsystemevents + +//type IotHubDeviceConnectedEventData DeviceConnectionStateEventProperties + +func fixNAValue(s **string) { + if *s != nil && **s == "n/a" { + *s = nil + } +} diff --git a/sdk/messaging/eventgrid/azsystemevents/example_test.go b/sdk/messaging/eventgrid/azsystemevents/example_test.go new file mode 100644 index 000000000000..309da667baaa --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/example_test.go @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azsystemevents_test + +import ( + "encoding/json" + "fmt" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/messaging" + "github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azsystemevents" +) + +func Example_deserializingEventGridSchema() { + // The method for extracting the payload will be different, depending on which data store you configured + // as a data handler. For instance, if you used Service Bus, the payload would be in the azservicebus.Message.Body + // field, as a []byte. + + // This particular payload is in the Event Grid Schema format, so we'll use the EventGridEvent to deserialize it. + payload := []byte(`[ + { + "id": "2d1781af-3a4c-4d7c-bd0c-e34b19da4e66", + "topic": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + "subject": "mySubject", + "data": { + "validationCode": "512d38b6-c7b8-40c8-89fe-f46f9e9622b6", + "validationUrl": "https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=B2E34264-7D71-453A-B5FB-B62D0FDC85EE&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1BNqCxBBSSE9OnNSfZM4%2b5H9zDegKMY6uJ%2fO2DFRkwQ%3d" + }, + "eventType": "Microsoft.EventGrid.SubscriptionValidationEvent", + "eventTime": "2018-01-25T22:12:19.4556811Z", + "metadataVersion": "1", + "dataVersion": "1" + } + ]`) + + var eventGridEvents []azsystemevents.EventGridEvent + + err := json.Unmarshal(payload, &eventGridEvents) + + if err != nil { + // TODO: Update the following line with your application specific error handling logic + log.Fatalf("ERROR: %s", err) + } + + for _, envelope := range eventGridEvents { + switch *envelope.EventType { + case string(azsystemevents.TypeSubscriptionValidation): + var eventData *azsystemevents.SubscriptionValidationEventData + + if err := json.Unmarshal(envelope.Data.([]byte), &eventData); err != nil { + // TODO: Update the following line with your application specific error handling logic + log.Fatalf("ERROR: %s", err) + } + + // print a field out from the event, showing what data is there. + fmt.Printf("Validation code: %s\n", *eventData.ValidationCode) + fmt.Printf("Validation URL: %s\n", *eventData.ValidationURL) + default: + // TODO: Update the following line with your application specific error handling logic + log.Fatalf("ERROR: event type %s isn't handled", *envelope.EventType) + } + } + + // Output: + // Validation code: 512d38b6-c7b8-40c8-89fe-f46f9e9622b6 + // Validation URL: https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=B2E34264-7D71-453A-B5FB-B62D0FDC85EE&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1BNqCxBBSSE9OnNSfZM4%2b5H9zDegKMY6uJ%2fO2DFRkwQ%3d +} + +func Example_deserializingCloudEventSchema() { + // The method for extracting the payload will be different, depending on which data store you configured + // as a data handler. For instance, if you used Service Bus, the payload would be in the azservicebus.Message.Body + // field, as a []byte. + + // This particular payload is in the Cloud Event Schema format, so we'll use the messaging.CloudEvent, which comes from the `azcore` package, to deserialize it. + payload := []byte(`[ + { + "specversion": "1.0", + "id": "2d1781af-3a4c-4d7c-bd0c-e34b19da4e66", + "source": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + "subject": "", + "data": { + "validationCode": "512d38b6-c7b8-40c8-89fe-f46f9e9622b6", + "validationUrl": "https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=B2E34264-7D71-453A-B5FB-B62D0FDC85EE&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1BNqCxBBSSE9OnNSfZM4%2b5H9zDegKMY6uJ%2fO2DFRkwQ%3d" + }, + "type": "Microsoft.EventGrid.SubscriptionValidationEvent", + "time": "2018-01-25T22:12:19.4556811Z", + "specversion": "1.0" + } + ]`) + + var cloudEvents []messaging.CloudEvent + + err := json.Unmarshal(payload, &cloudEvents) + + if err != nil { + // TODO: Update the following line with your application specific error handling logic + log.Fatalf("ERROR: %s", err) + } + + for _, envelope := range cloudEvents { + switch envelope.Type { + case string(azsystemevents.TypeSubscriptionValidation): + var eventData *azsystemevents.SubscriptionValidationEventData + + if err := json.Unmarshal(envelope.Data.([]byte), &eventData); err != nil { + // TODO: Update the following line with your application specific error handling logic + log.Fatalf("ERROR: %s", err) + } + + // print a field out from the event, showing what data is there. + fmt.Printf("Validation code: %s\n", *eventData.ValidationCode) + fmt.Printf("Validation URL: %s\n", *eventData.ValidationURL) + default: + // TODO: Update the following line with your application specific error handling logic + log.Fatalf("ERROR: event type %s isn't handled", envelope.Type) + } + } + + // Output: + // Validation code: 512d38b6-c7b8-40c8-89fe-f46f9e9622b6 + // Validation URL: https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=B2E34264-7D71-453A-B5FB-B62D0FDC85EE&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1BNqCxBBSSE9OnNSfZM4%2b5H9zDegKMY6uJ%2fO2DFRkwQ%3d +} diff --git a/sdk/messaging/eventgrid/azsystemevents/go.mod b/sdk/messaging/eventgrid/azsystemevents/go.mod new file mode 100644 index 000000000000..f721109f6dd9 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/go.mod @@ -0,0 +1,19 @@ +module github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azsystemevents + +go 1.18 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 + github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue v1.0.0 + github.com/joho/godotenv v1.5.1 + github.com/stretchr/testify v1.8.4 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/text v0.14.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/sdk/messaging/eventgrid/azsystemevents/go.sum b/sdk/messaging/eventgrid/azsystemevents/go.sum new file mode 100644 index 000000000000..fb050d89d732 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/go.sum @@ -0,0 +1,32 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= +github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue v1.0.0 h1:lJwNFV+xYjHREUTHJKx/ZF6CJSt9znxmLw9DqSTvyRU= +github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue v1.0.0/go.mod h1:GfT0aGew8Qj5yiQVqOO5v7N8fanbJGyUoHqXg56qcVY= +github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/messaging/eventgrid/azsystemevents/interfaces.go b/sdk/messaging/eventgrid/azsystemevents/interfaces.go new file mode 100644 index 000000000000..d4a03aa3d847 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/interfaces.go @@ -0,0 +1,18 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package azsystemevents + +// MediaJobOutputClassification provides polymorphic access to related types. +// Call the interface's GetMediaJobOutput() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *MediaJobOutput, *MediaJobOutputAsset +type MediaJobOutputClassification interface { + // GetMediaJobOutput returns the MediaJobOutput content of the underlying type. + GetMediaJobOutput() *MediaJobOutput +} diff --git a/sdk/messaging/eventgrid/azsystemevents/internal/generate/generate_enum.go b/sdk/messaging/eventgrid/azsystemevents/internal/generate/generate_enum.go new file mode 100644 index 000000000000..e57d1369e0ed --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/internal/generate/generate_enum.go @@ -0,0 +1,404 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package main + +import ( + "bufio" + "bytes" + "errors" + "fmt" + "io" + "log" + "net/http" + "os" + "regexp" + "sort" + "strings" +) + +var filesToDelete = []string{ + "options.go", + "responses.go", + "clientdeleteme_client.go", +} + +const systemEventsPath = "system_events.go" +const goModelsFile = "models.go" + +const tsOutputPath = "./internal/generate/testdata/tsevents.txt" +const javaOutputPath = "./internal/generate/testdata/javaevents.txt" +const pyOutputPath = "./internal/generate/testdata/pyevents.txt" +const goOutputPath = "./internal/generate/testdata/goevents.txt" + +const header = `//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azsystemevents + +// Type represents the value set in EventData.EventType or messaging.CloudEvent.Type +// for system events. +type Type string + +const ( +` + +const footer = `)` + +func main() { + if len(os.Args) < 2 { + fmt.Printf("Usage: generate_system_events (generate|validate|download)") + os.Exit(1) + } + + var err error + switch os.Args[1] { + case "download": + err = writeEventFiles() + case "generate": + err = generateConstants() + case "validate": + var m map[string]bool + m, err = readLines(pyOutputPath) + + if err != nil { + break + } + + err = validateAgainstAnotherLang(m) + default: + err = errors.New(os.Args[1] + " is not a valid command") + } + + if err != nil { + log.Fatalf("Failed with error: %s", err) + } +} + +func downloadEventTypes(url string, lineRE *regexp.Regexp, outputFile string) error { + resp, err := http.Get(url) + + if err != nil { + return err + } + + defer resp.Body.Close() + + return writeEvents(resp.Body, lineRE, outputFile) +} + +func writeEvents(reader io.Reader, lineRE *regexp.Regexp, outputPath string) error { + scanner := bufio.NewScanner(reader) + + allMatches := map[string]bool{} + + for scanner.Scan() { + matches := lineRE.FindStringSubmatch(scanner.Text()) + + if len(matches) == 0 { + continue + } + allMatches[matches[1]] = true + } + + writer, err := os.Create(outputPath) + + if err != nil { + return err + } + + defer writer.Close() + + for _, key := range sortedKeys(allMatches) { + if _, err := writer.WriteString(fmt.Sprintf("%s\n", key)); err != nil { + return err + } + } + + return nil +} + +func writeEventFiles() error { + err := downloadEventTypes("https://raw.githubusercontent.com/Azure/azure-sdk-for-js/main/sdk/eventgrid/eventgrid/src/predicates.ts", regexp.MustCompile(`^\s+"([^"]+)"`), tsOutputPath) + + if err != nil { + return err + } + + err = downloadEventTypes("https://raw.githubusercontent.com/Azure/azure-sdk-for-java/main/sdk/eventgrid/azure-messaging-eventgrid/src/main/java/com/azure/messaging/eventgrid/SystemEventNames.java", regexp.MustCompile(`"([^"]+?)"`), javaOutputPath) + + if err != nil { + return err + } + + err = downloadEventTypes("https://raw.githubusercontent.com/Azure/azure-sdk-for-python/main/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py", regexp.MustCompile(`^.+ = '([^']+)'`), pyOutputPath) + + if err != nil { + return err + } + + reader, err := os.Open(goModelsFile) + + if err != nil { + return err + } + + defer reader.Close() + + err = writeEvents(reader, regexp.MustCompile(`([A-Za-z0-9]+(?:\.[A-Za-z0-9]+){2,3})`), goOutputPath) + + if err != nil { + return err + } + + return nil +} + +func generateConstants() error { + reader, err := os.Open(goModelsFile) + + if err != nil { + return fmt.Errorf("Failed to open %s: %w", goModelsFile, err) + } + + defer reader.Close() + + constants, err := getConstantValues(reader) + + if err != nil { + return fmt.Errorf("Failed to get constant values from file: %w", err) + } + + if err := writeConstantsFile(systemEventsPath, constants); err != nil { + log.Fatalf("Failed to write constants file %s: %s", systemEventsPath, err) + } + + // we don't need these files since we're (intentionally) not exporting a Client from this + // package. + for _, file := range filesToDelete { + log.Printf("Deleting %s since it only has client types", file) + if _, err := os.Stat(file); err == nil { + if err := os.Remove(file); err != nil { + return err + } + } + } + + return nil +} + +func validateAgainstAnotherLang(otherLang map[string]bool) error { + reader, err := os.Open(goModelsFile) + + if err != nil { + return err + } + + defer reader.Close() + + consts, err := getConstantValues(reader) + + if err != nil { + return err + } + + constsMap := map[string]constant{} + + for _, c := range consts { + constsMap[c.ConstantValue] = c + } + + var missingConstants []string + + // now cross-check our generated models against the models that we _should_ have + // if we are caught up to the latest production Event Grid package for Java. + for value := range otherLang { + if _, ok := constsMap[value]; !ok { + + // there are some events that were deprecated + if value == "Microsoft.Communication.ChatMemberAddedToThreadWithUser" || value == "Microsoft.Communication.ChatMemberRemovedFromThreadWithUser" { + continue + } + + // we're missing a value! + missingConstants = append(missingConstants, value) + } + } + + if len(missingConstants) > 0 { + sort.Strings(missingConstants) + return errors.New("Missing constants:\n" + strings.Join(missingConstants, "\n")) + } + + return nil +} + +type constant struct { + ConstantName string + GoType string + ConstantValue string +} + +func getConstantValues(reader io.ReadCloser) (map[string]constant, error) { + data, err := io.ReadAll(reader) + + if err != nil { + return nil, err + } + + scanner := bufio.NewScanner(bytes.NewReader(data)) + + var currentComment []string + + var comments []struct { + Text string + ForType string + } + + for scanner.Scan() { + line := scanner.Text() + + if commentText, found := cutPrefix(line, "// "); found { + currentComment = append(currentComment, commentText) + } else if len(currentComment) > 0 && strings.HasPrefix(line, "type ") { + comments = append(comments, struct { + Text string + ForType string + }{ + Text: strings.Join(currentComment, " "), + ForType: strings.Split(line, " ")[1], + }) + currentComment = nil + } + } + + consts := map[string]constant{} + // ex: 'StorageBlobCreatedEventData - Schema of the Data property of an Event for a Microsoft.Storage.BlobCreated event.' + // 'IotHubDeviceConnectedEventData - Event data for Microsoft.Devices.DeviceConnected event.' + typeRE := regexp.MustCompile(`([^ ]+) -.+?([A-Za-z0-9]+(?:\.[A-Za-z0-9]+){2,3})`) + + ignoredTypes := []string{ + "DeviceConnectionStateEventProperties", + "DeviceLifeCycleEventProperties", + "DeviceTelemetryEventProperties", + "EventGridMQTTClientEventData", + "MapsGeofenceEventProperties", + } + + for _, comment := range comments { + matches := typeRE.FindStringSubmatch(comment.Text) + + if strings.Contains(comment.Text, "Schema of the Data") && len(matches) == 0 { + ignorable := false + + // we have a few types that we can ignore - they're not top-level SystemEvents (they're + // embeded or used by other events). + for _, prefix := range ignoredTypes { + if strings.HasPrefix(comment.Text, prefix) { + ignorable = true + break + } + } + + if !ignorable { + log.Printf("===========> DIDN'T MATCH REGEX: %q ", comment) + } + } + + if len(matches) == 0 { + continue + } + + goTypeName, stringValue := matches[1], matches[2] + constantName := strings.Replace(goTypeName, "EventData", "", 1) + + consts[stringValue] = constant{ + ConstantName: "Type" + constantName, + GoType: goTypeName, + ConstantValue: stringValue, + } + } + + return consts, nil +} + +func writeConstantsFile(path string, constants map[string]constant) error { + writer, err := os.Create(path) + + if err != nil { + return err + } + + defer writer.Close() + + if _, err := writer.Write([]byte(header)); err != nil { + return err + } + + for _, key := range sortedKeys(constants) { + c := constants[key] + + // ex: + // TypeAPIManagementAPICreated Type = "Microsoft.ApiManagement.APICreated" // maps to APIManagementAPICreatedEventData + buff := fmt.Sprintf("%s Type = \"%s\" // maps to %s\n", c.ConstantName, c.ConstantValue, c.GoType) + _, err := writer.WriteString(buff) + + if err != nil { + return err + } + } + + if _, err := writer.Write([]byte(footer)); err != nil { + return err + } + + return nil +} + +func sortedKeys[T any](m map[string]T) []string { + var keys []string + for k := range m { + keys = append(keys, k) + } + + sort.Strings(keys) + return keys +} + +func readLines(path string) (map[string]bool, error) { + reader, err := os.Open(path) + + if err != nil { + return nil, err + } + + scanner := bufio.NewScanner(reader) + + m := map[string]bool{} + + for scanner.Scan() { + m[scanner.Text()] = true + } + + return m, nil +} + +/** +"ServiceBusDeadletterMessagesAvailableWithNoListenersEventData" => "ServiceBusDeadletterMessagesAvailableWithNoListener", +"SubscriptionDeletedEventData" => "EventGridSubscriptionDeleted", +"SubscriptionValidationEventData" => "EventGridSubscriptionValidation", +*/ + +// copy of strings.CutPrefix, which doesn't exist in our oldest support compiler (1.18) +func cutPrefix(s, prefix string) (after string, found bool) { + if !strings.HasPrefix(s, prefix) { + return s, false + } + return s[len(prefix):], true +} diff --git a/sdk/messaging/eventgrid/azsystemevents/internal/version.go b/sdk/messaging/eventgrid/azsystemevents/internal/version.go new file mode 100644 index 000000000000..2c9ad2b1a538 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/internal/version.go @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package internal + +// Constants to identify the module +const ( + // ModuleName is the module name that shows in telemetry. + ModuleName = "azsystemevents" + + // ModuleVersion is the semantic version (see http://semver.org) of this module. + ModuleVersion = "v0.1.0" +) diff --git a/sdk/messaging/eventgrid/azsystemevents/models.go b/sdk/messaging/eventgrid/azsystemevents/models.go new file mode 100644 index 000000000000..7fcbea4155d2 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/models.go @@ -0,0 +1,5156 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package azsystemevents + +import "time" + +// APIManagementAPICreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.APICreated +// event. +type APIManagementAPICreatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementAPIDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.APIDeleted +// event. +type APIManagementAPIDeletedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementAPIReleaseCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.APIReleaseCreated +// event. +type APIManagementAPIReleaseCreatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementAPIReleaseDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.APIReleaseDeleted +// event. +type APIManagementAPIReleaseDeletedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementAPIReleaseUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.APIReleaseUpdated +// event. +type APIManagementAPIReleaseUpdatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementAPIUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.APIUpdated +// event. +type APIManagementAPIUpdatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementGatewayAPIAddedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayAPIAdded +// event. +type APIManagementGatewayAPIAddedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways//apis/ + ResourceURI *string +} + +// APIManagementGatewayAPIRemovedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayAPIRemoved +// event. +type APIManagementGatewayAPIRemovedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways//apis/ + ResourceURI *string +} + +// APIManagementGatewayCertificateAuthorityCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayCertificateAuthorityCreated +// event. +type APIManagementGatewayCertificateAuthorityCreatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways//certificateAuthorities/ + ResourceURI *string +} + +// APIManagementGatewayCertificateAuthorityDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayCertificateAuthorityDeleted +// event. +type APIManagementGatewayCertificateAuthorityDeletedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways//certificateAuthorities/ + ResourceURI *string +} + +// APIManagementGatewayCertificateAuthorityUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayCertificateAuthorityUpdated +// event. +type APIManagementGatewayCertificateAuthorityUpdatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways//certificateAuthorities/ + ResourceURI *string +} + +// APIManagementGatewayCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayCreated +// event. +type APIManagementGatewayCreatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways/ + ResourceURI *string +} + +// APIManagementGatewayDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayDeleted +// event. +type APIManagementGatewayDeletedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways/ + ResourceURI *string +} + +// APIManagementGatewayHostnameConfigurationCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayHostnameConfigurationCreated +// event. +type APIManagementGatewayHostnameConfigurationCreatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways//hostnameConfigurations/ + ResourceURI *string +} + +// APIManagementGatewayHostnameConfigurationDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayHostnameConfigurationDeleted +// event. +type APIManagementGatewayHostnameConfigurationDeletedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways//hostnameConfigurations/ + ResourceURI *string +} + +// APIManagementGatewayHostnameConfigurationUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayHostnameConfigurationUpdated +// event. +type APIManagementGatewayHostnameConfigurationUpdatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways//hostnameConfigurations/ + ResourceURI *string +} + +// APIManagementGatewayUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.GatewayUpdated +// event. +type APIManagementGatewayUpdatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service//gateways/ + ResourceURI *string +} + +// APIManagementProductCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.ProductCreated +// event. +type APIManagementProductCreatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementProductDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.ProductDeleted +// event. +type APIManagementProductDeletedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementProductUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.ProductUpdated +// event. +type APIManagementProductUpdatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementSubscriptionCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.SubscriptionCreated +// event. +type APIManagementSubscriptionCreatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementSubscriptionDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.SubscriptionDeleted +// event. +type APIManagementSubscriptionDeletedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementSubscriptionUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.SubscriptionUpdated +// event. +type APIManagementSubscriptionUpdatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementUserCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.UserCreated +// event. +type APIManagementUserCreatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementUserDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.UserDeleted +// event. +type APIManagementUserDeletedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// APIManagementUserUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ApiManagement.UserUpdated +// event. +type APIManagementUserUpdatedEventData struct { + // The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource + // type. Uses the format, + // /subscriptions//resourceGroups//Microsoft.ApiManagement/service/// + ResourceURI *string +} + +// AcsChatEventBaseProperties - Schema of common properties of all chat events +type AcsChatEventBaseProperties struct { + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string +} + +// AcsChatEventInThreadBaseProperties - Schema of common properties of all thread-level chat events +type AcsChatEventInThreadBaseProperties struct { + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string +} + +// AcsChatMessageDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatMessageDeleted +// event. +type AcsChatMessageDeletedEventData struct { + // The original compose time of the message + ComposeTime *time.Time + + // The time at which the message was deleted + DeleteTime *time.Time + + // The chat message id + MessageID *string + + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The communication identifier of the sender + SenderCommunicationIdentifier *CommunicationIdentifierModel + + // The display name of the sender + SenderDisplayName *string + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The type of the message + Type *string + + // The version of the message + Version *int64 +} + +// AcsChatMessageDeletedInThreadEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatMessageDeletedInThread +// event. +type AcsChatMessageDeletedInThreadEventData struct { + // The original compose time of the message + ComposeTime *time.Time + + // The time at which the message was deleted + DeleteTime *time.Time + + // The chat message id + MessageID *string + + // The communication identifier of the sender + SenderCommunicationIdentifier *CommunicationIdentifierModel + + // The display name of the sender + SenderDisplayName *string + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The type of the message + Type *string + + // The version of the message + Version *int64 +} + +// AcsChatMessageEditedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatMessageEdited +// event. +type AcsChatMessageEditedEventData struct { + // The original compose time of the message + ComposeTime *time.Time + + // The time at which the message was edited + EditTime *time.Time + + // The body of the chat message + MessageBody *string + + // The chat message id + MessageID *string + + // The chat message metadata + Metadata map[string]*string + + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The communication identifier of the sender + SenderCommunicationIdentifier *CommunicationIdentifierModel + + // The display name of the sender + SenderDisplayName *string + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The type of the message + Type *string + + // The version of the message + Version *int64 +} + +// AcsChatMessageEditedInThreadEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatMessageEditedInThread +// event. +type AcsChatMessageEditedInThreadEventData struct { + // The original compose time of the message + ComposeTime *time.Time + + // The time at which the message was edited + EditTime *time.Time + + // The body of the chat message + MessageBody *string + + // The chat message id + MessageID *string + + // The chat message metadata + Metadata map[string]*string + + // The communication identifier of the sender + SenderCommunicationIdentifier *CommunicationIdentifierModel + + // The display name of the sender + SenderDisplayName *string + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The type of the message + Type *string + + // The version of the message + Version *int64 +} + +// AcsChatMessageEventBaseProperties - Schema of common properties of all chat message events +type AcsChatMessageEventBaseProperties struct { + // The original compose time of the message + ComposeTime *time.Time + + // The chat message id + MessageID *string + + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The communication identifier of the sender + SenderCommunicationIdentifier *CommunicationIdentifierModel + + // The display name of the sender + SenderDisplayName *string + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The type of the message + Type *string + + // The version of the message + Version *int64 +} + +// AcsChatMessageEventInThreadBaseProperties - Schema of common properties of all thread-level chat message events +type AcsChatMessageEventInThreadBaseProperties struct { + // The original compose time of the message + ComposeTime *time.Time + + // The chat message id + MessageID *string + + // The communication identifier of the sender + SenderCommunicationIdentifier *CommunicationIdentifierModel + + // The display name of the sender + SenderDisplayName *string + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The type of the message + Type *string + + // The version of the message + Version *int64 +} + +// AcsChatMessageReceivedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatMessageReceived +// event. +type AcsChatMessageReceivedEventData struct { + // The original compose time of the message + ComposeTime *time.Time + + // The body of the chat message + MessageBody *string + + // The chat message id + MessageID *string + + // The chat message metadata + Metadata map[string]*string + + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The communication identifier of the sender + SenderCommunicationIdentifier *CommunicationIdentifierModel + + // The display name of the sender + SenderDisplayName *string + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The type of the message + Type *string + + // The version of the message + Version *int64 +} + +// AcsChatMessageReceivedInThreadEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatMessageReceivedInThread +// event. +type AcsChatMessageReceivedInThreadEventData struct { + // The original compose time of the message + ComposeTime *time.Time + + // The body of the chat message + MessageBody *string + + // The chat message id + MessageID *string + + // The chat message metadata + Metadata map[string]*string + + // The communication identifier of the sender + SenderCommunicationIdentifier *CommunicationIdentifierModel + + // The display name of the sender + SenderDisplayName *string + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The type of the message + Type *string + + // The version of the message + Version *int64 +} + +// AcsChatParticipantAddedToThreadEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatThreadParticipantAdded +// event. +type AcsChatParticipantAddedToThreadEventData struct { + // The communication identifier of the user who added the user + AddedByCommunicationIdentifier *CommunicationIdentifierModel + + // The details of the user who was added + ParticipantAdded *AcsChatThreadParticipantProperties + + // The chat thread id + ThreadID *string + + // The time at which the user was added to the thread + Time *time.Time + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatParticipantAddedToThreadWithUserEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatParticipantAddedToThreadWithUser +// event. +type AcsChatParticipantAddedToThreadWithUserEventData struct { + // The communication identifier of the user who added the user + AddedByCommunicationIdentifier *CommunicationIdentifierModel + + // The original creation time of the thread + CreateTime *time.Time + + // The details of the user who was added + ParticipantAdded *AcsChatThreadParticipantProperties + + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The chat thread id + ThreadID *string + + // The time at which the user was added to the thread + Time *time.Time + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatParticipantRemovedFromThreadEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatThreadParticipantRemoved +// event. +type AcsChatParticipantRemovedFromThreadEventData struct { + // The details of the user who was removed + ParticipantRemoved *AcsChatThreadParticipantProperties + + // The communication identifier of the user who removed the user + RemovedByCommunicationIdentifier *CommunicationIdentifierModel + + // The chat thread id + ThreadID *string + + // The time at which the user was removed to the thread + Time *time.Time + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatParticipantRemovedFromThreadWithUserEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatParticipantRemovedFromThreadWithUser +// event. +type AcsChatParticipantRemovedFromThreadWithUserEventData struct { + // The original creation time of the thread + CreateTime *time.Time + + // The details of the user who was removed + ParticipantRemoved *AcsChatThreadParticipantProperties + + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The communication identifier of the user who removed the user + RemovedByCommunicationIdentifier *CommunicationIdentifierModel + + // The chat thread id + ThreadID *string + + // The time at which the user was removed to the thread + Time *time.Time + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatThreadCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatThreadCreated +// event. +type AcsChatThreadCreatedEventData struct { + // The original creation time of the thread + CreateTime *time.Time + + // The communication identifier of the user who created the thread + CreatedByCommunicationIdentifier *CommunicationIdentifierModel + + // The list of properties of participants who are part of the thread + Participants []AcsChatThreadParticipantProperties + + // The thread properties + Properties map[string]any + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatThreadCreatedWithUserEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatThreadCreatedWithUser +// event. +type AcsChatThreadCreatedWithUserEventData struct { + // The original creation time of the thread + CreateTime *time.Time + + // The communication identifier of the user who created the thread + CreatedByCommunicationIdentifier *CommunicationIdentifierModel + + // The thread metadata + Metadata map[string]*string + + // The list of properties of participants who are part of the thread + Participants []AcsChatThreadParticipantProperties + + // The thread properties + Properties map[string]any + + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatThreadDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatThreadDeleted +// event. +type AcsChatThreadDeletedEventData struct { + // The original creation time of the thread + CreateTime *time.Time + + // The deletion time of the thread + DeleteTime *time.Time + + // The communication identifier of the user who deleted the thread + DeletedByCommunicationIdentifier *CommunicationIdentifierModel + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatThreadEventBaseProperties - Schema of common properties of all chat thread events +type AcsChatThreadEventBaseProperties struct { + // The original creation time of the thread + CreateTime *time.Time + + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatThreadEventInThreadBaseProperties - Schema of common properties of all chat thread events +type AcsChatThreadEventInThreadBaseProperties struct { + // The original creation time of the thread + CreateTime *time.Time + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatThreadParticipantProperties - Schema of the chat thread participant +type AcsChatThreadParticipantProperties struct { + // The name of the user + DisplayName *string + + // The metadata of the user + Metadata map[string]*string + + // The communication identifier of the user + ParticipantCommunicationIdentifier *CommunicationIdentifierModel +} + +// AcsChatThreadPropertiesUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatThreadPropertiesUpdated +// event. +type AcsChatThreadPropertiesUpdatedEventData struct { + // The original creation time of the thread + CreateTime *time.Time + + // The time at which the properties of the thread were updated + EditTime *time.Time + + // The communication identifier of the user who updated the thread properties + EditedByCommunicationIdentifier *CommunicationIdentifierModel + + // The thread metadata + Metadata map[string]*string + + // The updated thread properties + Properties map[string]any + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatThreadPropertiesUpdatedPerUserEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser +// event. +type AcsChatThreadPropertiesUpdatedPerUserEventData struct { + // The original creation time of the thread + CreateTime *time.Time + + // The time at which the properties of the thread were updated + EditTime *time.Time + + // The communication identifier of the user who updated the thread properties + EditedByCommunicationIdentifier *CommunicationIdentifierModel + + // The thread metadata + Metadata map[string]*string + + // The updated thread properties + Properties map[string]any + + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsChatThreadWithUserDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.ChatThreadWithUserDeleted +// event. +type AcsChatThreadWithUserDeletedEventData struct { + // The original creation time of the thread + CreateTime *time.Time + + // The deletion time of the thread + DeleteTime *time.Time + + // The communication identifier of the user who deleted the thread + DeletedByCommunicationIdentifier *CommunicationIdentifierModel + + // The communication identifier of the target user + RecipientCommunicationIdentifier *CommunicationIdentifierModel + + // The chat thread id + ThreadID *string + + // The transaction id will be used as co-relation vector + TransactionID *string + + // The version of the thread + Version *int64 +} + +// AcsEmailDeliveryReportReceivedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.EmailDeliveryReportReceived +// event. +type AcsEmailDeliveryReportReceivedEventData struct { + // The time at which the email delivery report received timestamp + DeliveryAttemptTimestamp *time.Time + + // Detailed information about the status if any + DeliveryStatusDetails *AcsEmailDeliveryReportStatusDetails + + // The Id of the email been sent + MessageID *string + + // The recipient Email Address + Recipient *string + + // The Sender Email Address + Sender *string + + // The status of the email. Any value other than Delivered is considered failed. + Status *AcsEmailDeliveryReportStatus +} + +// AcsEmailDeliveryReportStatusDetails - Detailed information about the status if any +type AcsEmailDeliveryReportStatusDetails struct { + // Detailed status message + StatusMessage *string +} + +// AcsEmailEngagementTrackingReportReceivedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.EmailEngagementTrackingReportReceived +// event. +type AcsEmailEngagementTrackingReportReceivedEventData struct { + // The type of engagement user have with email + Engagement *AcsUserEngagement + + // The context of the type of engagement user had with email + EngagementContext *string + + // The Id of the email that has been sent + MessageID *string + + // The Recipient Email Address + Recipient *string + + // The Sender Email Address + Sender *string + + // The time at which the user interacted with the email + UserActionTimestamp *time.Time + + // The user agent interacting with the email + UserAgent *string +} + +// AcsIncomingCallCustomContext - Custom Context of Incoming Call +type AcsIncomingCallCustomContext struct { + // Sip Headers for incoming call + SipHeaders map[string]*string + + // Voip Headers for incoming call + VoipHeaders map[string]*string +} + +// AcsIncomingCallEventData - Schema of the Data property of an CloudEvent/EventGridEvent for an Microsoft.Communication.IncomingCall +// event +type AcsIncomingCallEventData struct { + // Display name of caller. + CallerDisplayName *string + + // CorrelationId (CallId). + CorrelationID *string + + // Custom Context of Incoming Call + CustomContext *AcsIncomingCallCustomContext + + // The communication identifier of the user who initiated the call. + FromCommunicationIdentifier *CommunicationIdentifierModel + + // Signed incoming call context. + IncomingCallContext *string + + // The Id of the server call + ServerCallID *string + + // The communication identifier of the target user. + ToCommunicationIdentifier *CommunicationIdentifierModel +} + +// AcsRecordingChunkInfoProperties - Schema for all properties of Recording Chunk Information. +type AcsRecordingChunkInfoProperties struct { + // The location of the content for this chunk + ContentLocation *string + + // The location to delete all chunk storage + DeleteLocation *string + + // The documentId of the recording chunk + DocumentID *string + + // The reason for ending the recording chunk + EndReason *string + + // The index of the recording chunk + Index *int64 + + // The location of the metadata for this chunk + MetadataLocation *string +} + +// AcsRecordingFileStatusUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RecordingFileStatusUpdated +// event. +type AcsRecordingFileStatusUpdatedEventData struct { + // The recording channel type - Mixed, Unmixed + RecordingChannelType *RecordingChannelType + + // The recording content type- AudioVideo, or Audio + RecordingContentType *RecordingContentType + + // The recording duration in milliseconds + RecordingDurationMs *int64 + + // The recording format type - Mp4, Mp3, Wav + RecordingFormatType *RecordingFormatType + + // The time at which the recording started + RecordingStartTime *time.Time + + // The details of recording storage information + RecordingStorageInfo *AcsRecordingStorageInfoProperties + + // The reason for ending recording session + SessionEndReason *string +} + +// AcsRecordingStorageInfoProperties - Schema for all properties of Recording Storage Information. +type AcsRecordingStorageInfoProperties struct { + // List of details of recording chunks information + RecordingChunks []AcsRecordingChunkInfoProperties +} + +// AcsRouterChannelConfiguration - Router Channel Configuration +type AcsRouterChannelConfiguration struct { + // Capacity Cost Per Job for Router Job + CapacityCostPerJob *int32 + + // Channel ID for Router Job + ChannelID *string + + // Max Number of Jobs for Router Job + MaxNumberOfJobs *int32 +} + +// AcsRouterCommunicationError - Router Communication Error +type AcsRouterCommunicationError struct { + // Router Communication Error Code + Code *string + + // List of Router Communication Errors + Details []AcsRouterCommunicationError + + // Router Communication Inner Error + Innererror *AcsRouterCommunicationError + + // Router Communication Error Message + Message *string + + // Router Communication Error Target + Target *string +} + +// AcsRouterEventData - Schema of common properties of all Router events +type AcsRouterEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string +} + +// AcsRouterJobCancelledEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobCancelled +// event +type AcsRouterJobCancelledEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Job Disposition Code + DispositionCode *string + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job Note + Note *string + + // Router Job events Queue Id + QueueID *string + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterJobClassificationFailedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobClassificationFailed +// event +type AcsRouterJobClassificationFailedEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Job Classification Policy Id + ClassificationPolicyID *string + + // Router Job Classification Failed Errors + Errors []AcsRouterCommunicationError + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job events Queue Id + QueueID *string + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterJobClassifiedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobClassified +// event +type AcsRouterJobClassifiedEventData struct { + // Router Job Attached Worker Selector + AttachedWorkerSelectors []AcsRouterWorkerSelector + + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Job Classification Policy Id + ClassificationPolicyID *string + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job Priority + Priority *int32 + + // Router Job Queue Info + QueueDetails *AcsRouterQueueDetails + + // Router Job events Queue Id + QueueID *string + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterJobClosedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobClosed +// event +type AcsRouterJobClosedEventData struct { + // Router Job Closed Assignment Id + AssignmentID *string + + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Job Closed Disposition Code + DispositionCode *string + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job events Queue Id + QueueID *string + + // Router Jobs events Tags + Tags map[string]*string + + // Router Job Closed Worker Id + WorkerID *string +} + +// AcsRouterJobCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobCompleted +// event +type AcsRouterJobCompletedEventData struct { + // Router Job Completed Assignment Id + AssignmentID *string + + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job events Queue Id + QueueID *string + + // Router Jobs events Tags + Tags map[string]*string + + // Router Job Completed Worker Id + WorkerID *string +} + +// AcsRouterJobDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobDeleted +// event +type AcsRouterJobDeletedEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job events Queue Id + QueueID *string + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterJobEventData - Schema of common properties of all Router Job events +type AcsRouterJobEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job events Queue Id + QueueID *string + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterJobExceptionTriggeredEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobExceptionTriggered +// event +type AcsRouterJobExceptionTriggeredEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Job Exception Triggered Rule Id + ExceptionRuleID *string + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job events Queue Id + QueueID *string + + // Router Job Exception Triggered Rule Key + RuleKey *string + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterJobQueuedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobQueued +// event +type AcsRouterJobQueuedEventData struct { + // Router Job Queued Attached Worker Selector + AttachedWorkerSelectors []AcsRouterWorkerSelector + + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job Priority + Priority *int32 + + // Router Job events Queue Id + QueueID *string + + // Router Job Queued Requested Worker Selector + RequestedWorkerSelectors []AcsRouterWorkerSelector + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterJobReceivedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobReceived +// event +type AcsRouterJobReceivedEventData struct { + // REQUIRED; Unavailable For Matching for Router Job Received + UnavailableForMatching *bool + + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Job Classification Policy Id + ClassificationPolicyID *string + + // Router Event Job ID + JobID *string + + // Router Job Received Job Status + JobStatus *AcsRouterJobStatus + + // Router Job events Labels + Labels map[string]*string + + // Router Job Priority + Priority *int32 + + // Router Job events Queue Id + QueueID *string + + // Router Job Received Requested Worker Selectors + RequestedWorkerSelectors []AcsRouterWorkerSelector + + // Router Job Received Scheduled Time in UTC + ScheduledOn *time.Time + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterJobSchedulingFailedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobSchedulingFailed +// event +type AcsRouterJobSchedulingFailedEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Job Scheduling Failed Attached Worker Selector Expired + ExpiredAttachedWorkerSelectors []AcsRouterWorkerSelector + + // Router Job Scheduling Failed Requested Worker Selector Expired + ExpiredRequestedWorkerSelectors []AcsRouterWorkerSelector + + // Router Job Scheduling Failed Reason + FailureReason *string + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job Priority + Priority *int32 + + // Router Job events Queue Id + QueueID *string + + // Router Job Scheduling Failed Scheduled Time in UTC + ScheduledOn *time.Time + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterJobUnassignedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobUnassigned +// event +type AcsRouterJobUnassignedEventData struct { + // Router Job Unassigned Assignment Id + AssignmentID *string + + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job events Queue Id + QueueID *string + + // Router Jobs events Tags + Tags map[string]*string + + // Router Job Unassigned Worker Id + WorkerID *string +} + +// AcsRouterJobWaitingForActivationEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobWaitingForActivation +// event +type AcsRouterJobWaitingForActivationEventData struct { + // REQUIRED; Router Job Waiting For Activation Unavailable For Matching + UnavailableForMatching *bool + + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Job Waiting For Activation Worker Selector Expired + ExpiredAttachedWorkerSelectors []AcsRouterWorkerSelector + + // Router Job Waiting For Activation Requested Worker Selector Expired + ExpiredRequestedWorkerSelectors []AcsRouterWorkerSelector + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job Waiting For Activation Priority + Priority *int32 + + // Router Job events Queue Id + QueueID *string + + // Router Job Waiting For Activation Scheduled Time in UTC + ScheduledOn *time.Time + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterJobWorkerSelectorsExpiredEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterJobWorkerSelectorsExpired +// event +type AcsRouterJobWorkerSelectorsExpiredEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Job Worker Selectors Expired Attached Worker Selectors + ExpiredAttachedWorkerSelectors []AcsRouterWorkerSelector + + // Router Job Worker Selectors Expired Requested Worker Selectors + ExpiredRequestedWorkerSelectors []AcsRouterWorkerSelector + + // Router Event Job ID + JobID *string + + // Router Job events Labels + Labels map[string]*string + + // Router Job events Queue Id + QueueID *string + + // Router Jobs events Tags + Tags map[string]*string +} + +// AcsRouterQueueDetails - Router Queue Details +type AcsRouterQueueDetails struct { + // Router Queue Id + ID *string + + // Router Queue Labels + Labels map[string]*string + + // Router Queue Name + Name *string +} + +// AcsRouterWorkerDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterWorkerDeleted +// event +type AcsRouterWorkerDeletedEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Worker events Worker Id + WorkerID *string +} + +// AcsRouterWorkerDeregisteredEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterWorkerDeregistered +// event +type AcsRouterWorkerDeregisteredEventData struct { + // Router Worker Deregistered Worker Id + WorkerID *string +} + +// AcsRouterWorkerEventData - Schema of common properties of all Router Worker events +type AcsRouterWorkerEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Worker events Worker Id + WorkerID *string +} + +// AcsRouterWorkerOfferAcceptedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterWorkerOfferAccepted +// event +type AcsRouterWorkerOfferAcceptedEventData struct { + // Router Worker Offer Accepted Assignment Id + AssignmentID *string + + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Worker Offer Accepted Job Labels + JobLabels map[string]*string + + // Router Worker Offer Accepted Job Priority + JobPriority *int32 + + // Router Worker Offer Accepted Job Tags + JobTags map[string]*string + + // Router Worker Offer Accepted Offer Id + OfferID *string + + // Router Worker Offer Accepted Queue Id + QueueID *string + + // Router Worker events Worker Id + WorkerID *string + + // Router Worker Offer Accepted Worker Labels + WorkerLabels map[string]*string + + // Router Worker Offer Accepted Worker Tags + WorkerTags map[string]*string +} + +// AcsRouterWorkerOfferDeclinedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterWorkerOfferDeclined +// event +type AcsRouterWorkerOfferDeclinedEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Worker Offer Declined Offer Id + OfferID *string + + // Router Worker Offer Declined Queue Id + QueueID *string + + // Router Worker events Worker Id + WorkerID *string +} + +// AcsRouterWorkerOfferExpiredEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterWorkerOfferExpired +// event +type AcsRouterWorkerOfferExpiredEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Worker Offer Expired Offer Id + OfferID *string + + // Router Worker Offer Expired Queue Id + QueueID *string + + // Router Worker events Worker Id + WorkerID *string +} + +// AcsRouterWorkerOfferIssuedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterWorkerOfferIssued +// event +type AcsRouterWorkerOfferIssuedEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Worker Offer Issued Expiration Time in UTC + ExpiresOn *time.Time + + // Router Event Job ID + JobID *string + + // Router Worker Offer Issued Job Labels + JobLabels map[string]*string + + // Router Worker Offer Issued Job Priority + JobPriority *int32 + + // Router Worker Offer Issued Job Tags + JobTags map[string]*string + + // Router Worker Offer Issued Offer Id + OfferID *string + + // Router Worker Offer Issued Time in UTC + OfferedOn *time.Time + + // Router Worker Offer Issued Queue Id + QueueID *string + + // Router Worker events Worker Id + WorkerID *string + + // Router Worker Offer Issued Worker Labels + WorkerLabels map[string]*string + + // Router Worker Offer Issued Worker Tags + WorkerTags map[string]*string +} + +// AcsRouterWorkerOfferRevokedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterWorkerOfferRevoked +// event +type AcsRouterWorkerOfferRevokedEventData struct { + // Router Event Channel ID + ChannelID *string + + // Router Event Channel Reference + ChannelReference *string + + // Router Event Job ID + JobID *string + + // Router Worker Offer Revoked Offer Id + OfferID *string + + // Router Worker Offer Revoked Queue Id + QueueID *string + + // Router Worker events Worker Id + WorkerID *string +} + +// AcsRouterWorkerRegisteredEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.RouterWorkerRegistered +// event +type AcsRouterWorkerRegisteredEventData struct { + // Router Worker Registered Channel Configuration + ChannelConfigurations []AcsRouterChannelConfiguration + + // Router Worker Registered Labels + Labels map[string]*string + + // Router Worker Registered Queue Info + QueueAssignments []AcsRouterQueueDetails + + // Router Worker Registered Tags + Tags map[string]*string + + // Router Worker Register Total Capacity + TotalCapacity *int32 + + // Router Worker Registered Worker Id + WorkerID *string +} + +// AcsRouterWorkerSelector - Router Job Worker Selector +type AcsRouterWorkerSelector struct { + // Router Job Worker Selector Expiration Time + ExpirationTime *time.Time + + // Router Job Worker Selector Key + Key *string + + // Router Job Worker Selector Label Operator + LabelOperator *AcsRouterLabelOperator + + // Router Job Worker Selector Value + LabelValue any + + // Router Job Worker Selector State + State *AcsRouterWorkerSelectorState + + // Router Job Worker Selector Time to Live in Seconds + TimeToLive *float32 +} + +// AcsSmsDeliveryAttemptProperties - Schema for details of a delivery attempt +type AcsSmsDeliveryAttemptProperties struct { + // Number of segments whose delivery failed + SegmentsFailed *int32 + + // Number of segments that were successfully delivered + SegmentsSucceeded *int32 + + // TimeStamp when delivery was attempted + Timestamp *time.Time +} + +// AcsSmsDeliveryReportReceivedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.SMSDeliveryReportReceived +// event. +type AcsSmsDeliveryReportReceivedEventData struct { + // List of details of delivery attempts made + DeliveryAttempts []AcsSmsDeliveryAttemptProperties + + // Status of Delivery + DeliveryStatus *string + + // Details about Delivery Status + DeliveryStatusDetails *string + + // The identity of SMS message sender + From *string + + // The identity of the SMS message + MessageID *string + + // The time at which the SMS delivery report was received + ReceivedTimestamp *time.Time + + // Customer Content + Tag *string + + // The identity of SMS message receiver + To *string +} + +// AcsSmsEventBaseProperties - Schema of common properties of all SMS events +type AcsSmsEventBaseProperties struct { + // The identity of SMS message sender + From *string + + // The identity of the SMS message + MessageID *string + + // The identity of SMS message receiver + To *string +} + +// AcsSmsReceivedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Communication.SMSReceived event. +type AcsSmsReceivedEventData struct { + // The identity of SMS message sender + From *string + + // The SMS content + Message *string + + // The identity of the SMS message + MessageID *string + + // The time at which the SMS was received + ReceivedTimestamp *time.Time + + // The identity of SMS message receiver + To *string +} + +// AcsUserDisconnectedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for an Microsoft.Communication.UserDisconnected +// event. +type AcsUserDisconnectedEventData struct { + // The communication identifier of the user who was disconnected + UserCommunicationIdentifier *CommunicationIdentifierModel +} + +// AppConfigurationKeyValueDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.AppConfiguration.KeyValueDeleted +// event. +type AppConfigurationKeyValueDeletedEventData struct { + // The etag representing the key-value that was deleted. + Etag *string + + // 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 sync token representing the server state after the event. + SyncToken *string +} + +// AppConfigurationKeyValueModifiedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.AppConfiguration.KeyValueModified +// event. +type AppConfigurationKeyValueModifiedEventData struct { + // The etag representing the new state of the key-value. + Etag *string + + // 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 sync token representing the server state after the event. + SyncToken *string +} + +// AppConfigurationSnapshotCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.AppConfiguration.SnapshotCreated +// event. +type AppConfigurationSnapshotCreatedEventData struct { + // The etag representing the new state of the snapshot. + Etag *string + + // The name of the snapshot. + Name *string + + // The sync token representing the server state after the event. + SyncToken *string +} + +// AppConfigurationSnapshotEventData - Schema of common properties of snapshot events +type AppConfigurationSnapshotEventData struct { + // The etag representing the new state of the snapshot. + Etag *string + + // The name of the snapshot. + Name *string + + // The sync token representing the server state after the event. + SyncToken *string +} + +// AppConfigurationSnapshotModifiedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.AppConfiguration.SnapshotModified +// event. +type AppConfigurationSnapshotModifiedEventData struct { + // The etag representing the new state of the snapshot. + Etag *string + + // The name of the snapshot. + Name *string + + // The sync token representing the server state after the event. + SyncToken *string +} + +// AppEventTypeDetail - Detail of action on the app. +type AppEventTypeDetail struct { + // Type of action of the operation. + Action *AppAction +} + +// AppServicePlanEventTypeDetail - Detail of action on the app service plan. +type AppServicePlanEventTypeDetail struct { + // Type of action on the app service plan. + Action *AppServicePlanAction + + // Kind of environment where app service plan is. + StampKind *StampKind + + // Asynchronous operation status of the operation on the app service plan. + Status *AsyncStatus +} + +// CommunicationIdentifierModel - Identifies a participant in Azure Communication services. A participant is, for example, +// a phone number or an Azure communication user. This model must be interpreted as a union: Apart from rawId, at +// most one further property may be set. +type CommunicationIdentifierModel struct { + // The communication user. + CommunicationUser *CommunicationUserIdentifierModel + + // The Microsoft Teams user. + MicrosoftTeamsUser *MicrosoftTeamsUserIdentifierModel + + // The phone number. + PhoneNumber *PhoneNumberIdentifierModel + + // Raw Id of the identifier. Optional in requests, required in responses. + RawID *string +} + +// CommunicationUserIdentifierModel - A user that got created with an Azure Communication Services resource. +type CommunicationUserIdentifierModel struct { + // REQUIRED; The Id of the communication user. + ID *string +} + +// ContainerRegistryArtifactEventData - The content of the event request message. +type ContainerRegistryArtifactEventData struct { + // The action that encompasses the provided event. + Action *string + + // The connected registry information if the event is generated by a connected registry. + ConnectedRegistry *ContainerRegistryEventConnectedRegistry + + // The event ID. + ID *string + + // The location of the event. + Location *string + + // The target of the event. + Target *ContainerRegistryArtifactEventTarget + + // The time at which the event occurred. + Timestamp *time.Time +} + +// ContainerRegistryArtifactEventTarget - The target of the event. +type ContainerRegistryArtifactEventTarget struct { + // The digest of the artifact. + Digest *string + + // The MIME type of the artifact. + MediaType *string + + // The name of the artifact. + Name *string + + // The repository name of the artifact. + Repository *string + + // The size in bytes of the artifact. + Size *int64 + + // The tag of the artifact. + Tag *string + + // The version of the artifact. + Version *string +} + +// ContainerRegistryChartDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ContainerRegistry.ChartDeleted +// event. +type ContainerRegistryChartDeletedEventData struct { + // The action that encompasses the provided event. + Action *string + + // The connected registry information if the event is generated by a connected registry. + ConnectedRegistry *ContainerRegistryEventConnectedRegistry + + // The event ID. + ID *string + + // The location of the event. + Location *string + + // The target of the event. + Target *ContainerRegistryArtifactEventTarget + + // The time at which the event occurred. + Timestamp *time.Time +} + +// ContainerRegistryChartPushedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ContainerRegistry.ChartPushed +// event. +type ContainerRegistryChartPushedEventData struct { + // The action that encompasses the provided event. + Action *string + + // The connected registry information if the event is generated by a connected registry. + ConnectedRegistry *ContainerRegistryEventConnectedRegistry + + // The event ID. + ID *string + + // The location of the event. + Location *string + + // The target of the event. + Target *ContainerRegistryArtifactEventTarget + + // The time at which the event occurred. + Timestamp *time.Time +} + +// ContainerRegistryEventActor - The agent that initiated the event. For most situations, this could be from the authorization +// context of the request. +type ContainerRegistryEventActor struct { + // The subject or username associated with the request context that generated the event. + Name *string +} + +// ContainerRegistryEventConnectedRegistry - The connected registry information if the event is generated by a connected registry. +type ContainerRegistryEventConnectedRegistry struct { + // The name of the connected registry that generated this event. + Name *string +} + +// ContainerRegistryEventData - The content of the event request message. +type ContainerRegistryEventData struct { + // The action that encompasses the provided event. + Action *string + + // The agent that initiated the event. For most situations, this could be from the authorization context of the request. + Actor *ContainerRegistryEventActor + + // The connected registry information if the event is generated by a connected registry. + ConnectedRegistry *ContainerRegistryEventConnectedRegistry + + // The event ID. + ID *string + + // The location of the event. + Location *string + + // The request that generated the event. + Request *ContainerRegistryEventRequest + + // 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. + Target *ContainerRegistryEventTarget + + // The time at which the event occurred. + Timestamp *time.Time +} + +// ContainerRegistryEventRequest - The request that generated the event. +type ContainerRegistryEventRequest struct { + // 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 ID of the request that initiated the event. + ID *string + + // The request method that generated the event. + Method *string + + // The user agent header of the request. + Useragent *string +} + +// ContainerRegistryEventSource - The registry node that generated the event. Put differently, while the actor initiates the +// event, the source generates it. +type ContainerRegistryEventSource struct { + // 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 +} + +// ContainerRegistryEventTarget - The target of the event. +type ContainerRegistryEventTarget struct { + // 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 *int64 + + // The MIME type of the referenced object. + MediaType *string + + // The repository name. + Repository *string + + // The number of bytes of the content. Same as Length field. + Size *int64 + + // The tag name. + Tag *string + + // The direct URL to the content. + URL *string +} + +// ContainerRegistryImageDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ContainerRegistry.ImageDeleted +// event. +type ContainerRegistryImageDeletedEventData struct { + // The action that encompasses the provided event. + Action *string + + // The agent that initiated the event. For most situations, this could be from the authorization context of the request. + Actor *ContainerRegistryEventActor + + // The connected registry information if the event is generated by a connected registry. + ConnectedRegistry *ContainerRegistryEventConnectedRegistry + + // The event ID. + ID *string + + // The location of the event. + Location *string + + // The request that generated the event. + Request *ContainerRegistryEventRequest + + // 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. + Target *ContainerRegistryEventTarget + + // The time at which the event occurred. + Timestamp *time.Time +} + +// ContainerRegistryImagePushedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ContainerRegistry.ImagePushed +// event. +type ContainerRegistryImagePushedEventData struct { + // The action that encompasses the provided event. + Action *string + + // The agent that initiated the event. For most situations, this could be from the authorization context of the request. + Actor *ContainerRegistryEventActor + + // The connected registry information if the event is generated by a connected registry. + ConnectedRegistry *ContainerRegistryEventConnectedRegistry + + // The event ID. + ID *string + + // The location of the event. + Location *string + + // The request that generated the event. + Request *ContainerRegistryEventRequest + + // 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. + Target *ContainerRegistryEventTarget + + // The time at which the event occurred. + Timestamp *time.Time +} + +// ContainerServiceClusterSupportEndedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ContainerService.ClusterSupportEnded +// event +type ContainerServiceClusterSupportEndedEventData struct { + // The Kubernetes version of the ManagedCluster resource + KubernetesVersion *string +} + +// ContainerServiceClusterSupportEndingEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ContainerService.ClusterSupportEnding +// event +type ContainerServiceClusterSupportEndingEventData struct { + // The Kubernetes version of the ManagedCluster resource + KubernetesVersion *string +} + +// ContainerServiceClusterSupportEventData - Schema of common properties of cluster support events +type ContainerServiceClusterSupportEventData struct { + // The Kubernetes version of the ManagedCluster resource + KubernetesVersion *string +} + +// ContainerServiceNewKubernetesVersionAvailableEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ContainerService.NewKubernetesVersionAvailable +// event +type ContainerServiceNewKubernetesVersionAvailableEventData struct { + // The highest PATCH Kubernetes version considered preview for the ManagedCluster resource. There might not be any version + // in preview at the time of publishing the event + LatestPreviewKubernetesVersion *string + + // The highest PATCH Kubernetes version for the MINOR version considered stable for the ManagedCluster resource + LatestStableKubernetesVersion *string + + // The highest PATCH Kubernetes version for the highest MINOR version supported by ManagedCluster resource + LatestSupportedKubernetesVersion *string + + // The highest PATCH Kubernetes version for the lowest applicable MINOR version available for the ManagedCluster resource + LowestMinorKubernetesVersion *string +} + +// ContainerServiceNodePoolRollingEventData - Schema of common properties of node pool rolling events +type ContainerServiceNodePoolRollingEventData struct { + // The name of the node pool in the ManagedCluster resource + NodePoolName *string +} + +// ContainerServiceNodePoolRollingFailedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ContainerService.NodePoolRollingFailed +// event +type ContainerServiceNodePoolRollingFailedEventData struct { + // The name of the node pool in the ManagedCluster resource + NodePoolName *string +} + +// ContainerServiceNodePoolRollingStartedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ContainerService.NodePoolRollingStarted +// event +type ContainerServiceNodePoolRollingStartedEventData struct { + // The name of the node pool in the ManagedCluster resource + NodePoolName *string +} + +// ContainerServiceNodePoolRollingSucceededEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ContainerService.NodePoolRollingSucceeded +// event +type ContainerServiceNodePoolRollingSucceededEventData struct { + // The name of the node pool in the ManagedCluster resource + NodePoolName *string +} + +// DataBoxCopyCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.DataBox.CopyCompleted +// event. +type DataBoxCopyCompletedEventData struct { + // Serial Number of the device associated with the event. The list is comma separated if more than one serial number is associated. + SerialNumber *string + + // Name of the current Stage + StageName *DataBoxStageName + + // The time at which the stage happened. + StageTime *time.Time +} + +// DataBoxCopyStartedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.DataBox.CopyStarted event. +type DataBoxCopyStartedEventData struct { + // Serial Number of the device associated with the event. The list is comma separated if more than one serial number is associated. + SerialNumber *string + + // Name of the current Stage + StageName *DataBoxStageName + + // The time at which the stage happened. + StageTime *time.Time +} + +// DataBoxOrderCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.DataBox.OrderCompleted +// event. +type DataBoxOrderCompletedEventData struct { + // Serial Number of the device associated with the event. The list is comma separated if more than one serial number is associated. + SerialNumber *string + + // Name of the current Stage + StageName *DataBoxStageName + + // The time at which the stage happened. + StageTime *time.Time +} + +// DeviceConnectionStateEventInfo - Information about the device connection state event. +type DeviceConnectionStateEventInfo struct { + // 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 +} + +// DeviceConnectionStateEventProperties - Schema of the Data property of an CloudEvent/EventGridEvent for a device connection state event +// (DeviceConnected, DeviceDisconnected). +type DeviceConnectionStateEventProperties struct { + // Information about the device connection state event. + DeviceConnectionStateEventInfo *DeviceConnectionStateEventInfo + + // 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 + + // 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 +} + +// DeviceLifeCycleEventProperties - Schema of the Data property of an CloudEvent/EventGridEvent for a device life cycle event (DeviceCreated, +// DeviceDeleted). +type DeviceLifeCycleEventProperties struct { + // 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 +} + +// DeviceTelemetryEventProperties - Schema of the Data property of an CloudEvent/EventGridEvent for a device telemetry event (DeviceTelemetry). +type DeviceTelemetryEventProperties struct { + // 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 map[string]*string + + // System properties help identify contents and source of the messages. + SystemProperties map[string]*string +} + +// DeviceTwinInfo - Information about the device twin, which is the cloud representation of application device metadata. +type DeviceTwinInfo struct { + // Authentication type used for this device: either SAS, SelfSigned, or CertificateAuthority. + AuthenticationType *string + + // Count of cloud to device messages sent to this device. + CloudToDeviceMessageCount *float32 + + // 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 *float32 + + // 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 +} + +// DeviceTwinInfoProperties - Properties JSON element. +type DeviceTwinInfoProperties struct { + // 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 +} + +// DeviceTwinInfoX509Thumbprint - 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. +type DeviceTwinInfoX509Thumbprint struct { + // Primary thumbprint for the x509 certificate. + PrimaryThumbprint *string + + // Secondary thumbprint for the x509 certificate. + SecondaryThumbprint *string +} + +// DeviceTwinMetadata - Metadata information for the properties JSON document. +type DeviceTwinMetadata struct { + // The ISO8601 timestamp of the last time the properties were updated. + LastUpdated *string +} + +// DeviceTwinProperties - A portion of the properties that can be written only by the application back-end, and read by the +// device. +type DeviceTwinProperties struct { + // Metadata information for the properties JSON document. + Metadata *DeviceTwinMetadata + + // Version of device twin properties. + Version *float32 +} + +// EventGridEvent - Properties of an event published to an Event Grid topic using the EventGrid Schema. +type EventGridEvent struct { + // REQUIRED; Event data specific to the event type. + Data any + + // REQUIRED; The schema version of the data object. + DataVersion *string + + // REQUIRED; The time (in UTC) the event was generated. + EventTime *time.Time + + // REQUIRED; The type of the event that occurred. + EventType *string + + // REQUIRED; An unique identifier for the event. + ID *string + + // REQUIRED; A resource path relative to the topic path. + Subject *string + + // The resource path of the event source. + Topic *string + + // READ-ONLY; The schema version of the event metadata. + MetadataVersion *string +} + +// EventGridMQTTClientCreatedOrUpdatedEventData - Event data for Microsoft.EventGrid.MQTTClientCreatedOrUpdated event. +type EventGridMQTTClientCreatedOrUpdatedEventData struct { + // The key-value attributes that are assigned to the client resource. + Attributes map[string]*string + + // Unique identifier for the MQTT client that the client presents to the service for authentication. This case-sensitive string + // can be up to 128 characters long, and supports UTF-8 characters. + ClientAuthenticationName *string + + // Name of the client resource in the Event Grid namespace. + ClientName *string + + // Time the client resource is created based on the provider's UTC time. + CreatedOn *time.Time + + // Name of the Event Grid namespace where the MQTT client was created or updated. + NamespaceName *string + + // Configured state of the client. The value could be Enabled or Disabled + State *EventGridMqttClientState + + // Time the client resource is last updated based on the provider's UTC time. If the client resource was never updated, this + // value is identical to the value of the 'createdOn' property. + UpdatedOn *time.Time +} + +// EventGridMQTTClientDeletedEventData - Event data for Microsoft.EventGrid.MQTTClientDeleted event. +type EventGridMQTTClientDeletedEventData struct { + // Unique identifier for the MQTT client that the client presents to the service for authentication. This case-sensitive string + // can be up to 128 characters long, and supports UTF-8 characters. + ClientAuthenticationName *string + + // Name of the client resource in the Event Grid namespace. + ClientName *string + + // Name of the Event Grid namespace where the MQTT client was created or updated. + NamespaceName *string +} + +// EventGridMQTTClientEventData - Schema of the Data property of an CloudEvent/EventGridEvent for MQTT Client state changes. +type EventGridMQTTClientEventData struct { + // Unique identifier for the MQTT client that the client presents to the service for authentication. This case-sensitive string + // can be up to 128 characters long, and supports UTF-8 characters. + ClientAuthenticationName *string + + // Name of the client resource in the Event Grid namespace. + ClientName *string + + // Name of the Event Grid namespace where the MQTT client was created or updated. + NamespaceName *string +} + +// EventGridMQTTClientSessionConnectedEventData - Event data for Microsoft.EventGrid.MQTTClientSessionConnected event. +type EventGridMQTTClientSessionConnectedEventData struct { + // Unique identifier for the MQTT client that the client presents to the service for authentication. This case-sensitive string + // can be up to 128 characters long, and supports UTF-8 characters. + ClientAuthenticationName *string + + // Name of the client resource in the Event Grid namespace. + ClientName *string + + // Unique identifier for the MQTT client's session. This case-sensitive string can be up to 128 characters long, and supports + // UTF-8 characters. + ClientSessionName *string + + // Name of the Event Grid namespace where the MQTT client was created or updated. + NamespaceName *string + + // A number that helps indicate order of MQTT client session connected or disconnected events. Latest event will have a sequence + // number that is higher than the previous event. + SequenceNumber *int64 +} + +// EventGridMQTTClientSessionDisconnectedEventData - Event data for Microsoft.EventGrid.MQTTClientSessionDisconnected event. +type EventGridMQTTClientSessionDisconnectedEventData struct { + // Unique identifier for the MQTT client that the client presents to the service for authentication. This case-sensitive string + // can be up to 128 characters long, and supports UTF-8 characters. + ClientAuthenticationName *string + + // Name of the client resource in the Event Grid namespace. + ClientName *string + + // Unique identifier for the MQTT client's session. This case-sensitive string can be up to 128 characters long, and supports + // UTF-8 characters. + ClientSessionName *string + + // Reason for the disconnection of the MQTT client's session. The value could be one of the values in the disconnection reasons + // table. + DisconnectionReason *EventGridMQTTClientDisconnectionReason + + // Name of the Event Grid namespace where the MQTT client was created or updated. + NamespaceName *string + + // A number that helps indicate order of MQTT client session connected or disconnected events. Latest event will have a sequence + // number that is higher than the previous event. + SequenceNumber *int64 +} + +// EventHubCaptureFileCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.EventHub.CaptureFileCreated +// event. +type EventHubCaptureFileCreatedEventData struct { + // The number of events in the file. + EventCount *int32 + + // The file type of the capture file. + FileType *string + + // The path to the capture file. + Fileurl *string + + // The first time from the queue. + FirstEnqueueTime *time.Time + + // The smallest sequence number from the queue. + FirstSequenceNumber *int32 + + // The last time from the queue. + LastEnqueueTime *time.Time + + // The last sequence number from the queue. + LastSequenceNumber *int32 + + // The shard ID. + PartitionID *string + + // The file size. + SizeInBytes *int32 +} + +// HealthcareDicomImageCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.HealthcareApis.DicomImageCreated +// event. +type HealthcareDicomImageCreatedEventData struct { + // Unique identifier for the Series + ImageSeriesInstanceUID *string + + // Unique identifier for the DICOM Image + ImageSopInstanceUID *string + + // Unique identifier for the Study + ImageStudyInstanceUID *string + + // Data partition name + PartitionName *string + + // Sequence number of the DICOM Service within Azure Health Data Services. It is unique for every image creation and deletion + // within the service. + SequenceNumber *int64 + + // Domain name of the DICOM account for this image. + ServiceHostName *string +} + +// HealthcareDicomImageDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.HealthcareApis.DicomImageDeleted +// event. +type HealthcareDicomImageDeletedEventData struct { + // Unique identifier for the Series + ImageSeriesInstanceUID *string + + // Unique identifier for the DICOM Image + ImageSopInstanceUID *string + + // Unique identifier for the Study + ImageStudyInstanceUID *string + + // Data partition name + PartitionName *string + + // Sequence number of the DICOM Service within Azure Health Data Services. It is unique for every image creation and deletion + // within the service. + SequenceNumber *int64 + + // Host name of the DICOM account for this image. + ServiceHostName *string +} + +// HealthcareDicomImageUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.HealthcareApis.DicomImageUpdated +// event. +type HealthcareDicomImageUpdatedEventData struct { + // Unique identifier for the Series + ImageSeriesInstanceUID *string + + // Unique identifier for the DICOM Image + ImageSopInstanceUID *string + + // Unique identifier for the Study + ImageStudyInstanceUID *string + + // Data partition name + PartitionName *string + + // Sequence number of the DICOM Service within Azure Health Data Services. It is unique for every image creation, updation + // and deletion within the service. + SequenceNumber *int64 + + // Domain name of the DICOM account for this image. + ServiceHostName *string +} + +// HealthcareFhirResourceCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.HealthcareApis.FhirResourceCreated +// event. +type HealthcareFhirResourceCreatedEventData struct { + // Id of HL7 FHIR resource. + FhirResourceID *string + + // Type of HL7 FHIR resource. + FhirResourceType *HealthcareFhirResourceType + + // VersionId of HL7 FHIR resource. It changes when the resource is created, updated, or deleted(soft-deletion). + FhirResourceVersionID *int64 + + // Domain name of FHIR account for this resource. + FhirServiceHostName *string +} + +// HealthcareFhirResourceDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.HealthcareApis.FhirResourceDeleted +// event. +type HealthcareFhirResourceDeletedEventData struct { + // Id of HL7 FHIR resource. + FhirResourceID *string + + // Type of HL7 FHIR resource. + FhirResourceType *HealthcareFhirResourceType + + // VersionId of HL7 FHIR resource. It changes when the resource is created, updated, or deleted(soft-deletion). + FhirResourceVersionID *int64 + + // Domain name of FHIR account for this resource. + FhirServiceHostName *string +} + +// HealthcareFhirResourceUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.HealthcareApis.FhirResourceUpdated +// event. +type HealthcareFhirResourceUpdatedEventData struct { + // Id of HL7 FHIR resource. + FhirResourceID *string + + // Type of HL7 FHIR resource. + FhirResourceType *HealthcareFhirResourceType + + // VersionId of HL7 FHIR resource. It changes when the resource is created, updated, or deleted(soft-deletion). + FhirResourceVersionID *int64 + + // Domain name of FHIR account for this resource. + FhirServiceHostName *string +} + +// IotHubDeviceConnectedEventData - Event data for Microsoft.Devices.DeviceConnected event. +type IotHubDeviceConnectedEventData struct { + // Information about the device connection state event. + DeviceConnectionStateEventInfo *DeviceConnectionStateEventInfo + + // 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 + + // 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 +} + +// IotHubDeviceCreatedEventData - Event data for Microsoft.Devices.DeviceCreated event. +type IotHubDeviceCreatedEventData struct { + // 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 +} + +// IotHubDeviceDeletedEventData - Event data for Microsoft.Devices.DeviceDeleted event. +type IotHubDeviceDeletedEventData struct { + // 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 +} + +// IotHubDeviceDisconnectedEventData - Event data for Microsoft.Devices.DeviceDisconnected event. +type IotHubDeviceDisconnectedEventData struct { + // Information about the device connection state event. + DeviceConnectionStateEventInfo *DeviceConnectionStateEventInfo + + // 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 + + // 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 +} + +// IotHubDeviceTelemetryEventData - Event data for Microsoft.Devices.DeviceTelemetry event. +type IotHubDeviceTelemetryEventData struct { + // 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 map[string]*string + + // System properties help identify contents and source of the messages. + SystemProperties map[string]*string +} + +// KeyVaultAccessPolicyChangedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.KeyVault.VaultAccessPolicyChanged +// event. +type KeyVaultAccessPolicyChangedEventData struct { + // The expiration date of the object that triggered this event + EXP *float32 + + // The id of the object that triggered this event. + ID *string + + // Not before date of the object that triggered this event + NBF *float32 + + // The name of the object that triggered this event + ObjectName *string + + // The type of the object that triggered this event + ObjectType *string + + // Key vault name of the object that triggered this event. + VaultName *string + + // The version of the object that triggered this event + Version *string +} + +// KeyVaultCertificateExpiredEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.KeyVault.CertificateExpired +// event. +type KeyVaultCertificateExpiredEventData struct { + // The expiration date of the object that triggered this event + EXP *float32 + + // The id of the object that triggered this event. + ID *string + + // Not before date of the object that triggered this event + NBF *float32 + + // The name of the object that triggered this event + ObjectName *string + + // The type of the object that triggered this event + ObjectType *string + + // Key vault name of the object that triggered this event. + VaultName *string + + // The version of the object that triggered this event + Version *string +} + +// KeyVaultCertificateNearExpiryEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.KeyVault.CertificateNearExpiry +// event. +type KeyVaultCertificateNearExpiryEventData struct { + // The expiration date of the object that triggered this event + EXP *float32 + + // The id of the object that triggered this event. + ID *string + + // Not before date of the object that triggered this event + NBF *float32 + + // The name of the object that triggered this event + ObjectName *string + + // The type of the object that triggered this event + ObjectType *string + + // Key vault name of the object that triggered this event. + VaultName *string + + // The version of the object that triggered this event + Version *string +} + +// KeyVaultCertificateNewVersionCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.KeyVault.CertificateNewVersionCreated +// event. +type KeyVaultCertificateNewVersionCreatedEventData struct { + // The expiration date of the object that triggered this event + EXP *float32 + + // The id of the object that triggered this event. + ID *string + + // Not before date of the object that triggered this event + NBF *float32 + + // The name of the object that triggered this event + ObjectName *string + + // The type of the object that triggered this event + ObjectType *string + + // Key vault name of the object that triggered this event. + VaultName *string + + // The version of the object that triggered this event + Version *string +} + +// KeyVaultKeyExpiredEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.KeyVault.KeyExpired event. +type KeyVaultKeyExpiredEventData struct { + // The expiration date of the object that triggered this event + EXP *float32 + + // The id of the object that triggered this event. + ID *string + + // Not before date of the object that triggered this event + NBF *float32 + + // The name of the object that triggered this event + ObjectName *string + + // The type of the object that triggered this event + ObjectType *string + + // Key vault name of the object that triggered this event. + VaultName *string + + // The version of the object that triggered this event + Version *string +} + +// KeyVaultKeyNearExpiryEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.KeyVault.KeyNearExpiry +// event. +type KeyVaultKeyNearExpiryEventData struct { + // The expiration date of the object that triggered this event + EXP *float32 + + // The id of the object that triggered this event. + ID *string + + // Not before date of the object that triggered this event + NBF *float32 + + // The name of the object that triggered this event + ObjectName *string + + // The type of the object that triggered this event + ObjectType *string + + // Key vault name of the object that triggered this event. + VaultName *string + + // The version of the object that triggered this event + Version *string +} + +// KeyVaultKeyNewVersionCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.KeyVault.KeyNewVersionCreated +// event. +type KeyVaultKeyNewVersionCreatedEventData struct { + // The expiration date of the object that triggered this event + EXP *float32 + + // The id of the object that triggered this event. + ID *string + + // Not before date of the object that triggered this event + NBF *float32 + + // The name of the object that triggered this event + ObjectName *string + + // The type of the object that triggered this event + ObjectType *string + + // Key vault name of the object that triggered this event. + VaultName *string + + // The version of the object that triggered this event + Version *string +} + +// KeyVaultSecretExpiredEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.KeyVault.SecretExpired +// event. +type KeyVaultSecretExpiredEventData struct { + // The expiration date of the object that triggered this event + EXP *float32 + + // The id of the object that triggered this event. + ID *string + + // Not before date of the object that triggered this event + NBF *float32 + + // The name of the object that triggered this event + ObjectName *string + + // The type of the object that triggered this event + ObjectType *string + + // Key vault name of the object that triggered this event. + VaultName *string + + // The version of the object that triggered this event + Version *string +} + +// KeyVaultSecretNearExpiryEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.KeyVault.SecretNearExpiry +// event. +type KeyVaultSecretNearExpiryEventData struct { + // The expiration date of the object that triggered this event + EXP *float32 + + // The id of the object that triggered this event. + ID *string + + // Not before date of the object that triggered this event + NBF *float32 + + // The name of the object that triggered this event + ObjectName *string + + // The type of the object that triggered this event + ObjectType *string + + // Key vault name of the object that triggered this event. + VaultName *string + + // The version of the object that triggered this event + Version *string +} + +// KeyVaultSecretNewVersionCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.KeyVault.SecretNewVersionCreated +// event. +type KeyVaultSecretNewVersionCreatedEventData struct { + // The expiration date of the object that triggered this event + EXP *float32 + + // The id of the object that triggered this event. + ID *string + + // Not before date of the object that triggered this event + NBF *float32 + + // The name of the object that triggered this event + ObjectName *string + + // The type of the object that triggered this event + ObjectType *string + + // Key vault name of the object that triggered this event. + VaultName *string + + // The version of the object that triggered this event + Version *string +} + +// MachineLearningServicesDatasetDriftDetectedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.MachineLearningServices.DatasetDriftDetected +// event. +type MachineLearningServicesDatasetDriftDetectedEventData struct { + // The ID of the base Dataset used to detect drift. + BaseDatasetID *string + + // 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 coefficient result that triggered the event. + DriftCoefficient *float64 + + // The end time of the target dataset time series that resulted in drift detection. + EndTime *time.Time + + // The ID of the Run that detected data drift. + RunID *string + + // The start time of the target dataset time series that resulted in drift detection. + StartTime *time.Time + + // The ID of the target Dataset used to detect drift. + TargetDatasetID *string +} + +// MachineLearningServicesModelDeployedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.MachineLearningServices.ModelDeployed +// event. +type MachineLearningServicesModelDeployedEventData struct { + // A common separated list of model IDs. The IDs of the models deployed in the service. + ModelIDs *string + + // The compute type (e.g. ACI, AKS) of the deployed service. + ServiceComputeType *string + + // The name of the deployed service. + ServiceName *string + + // The properties of the deployed service. + ServiceProperties any + + // The tags of the deployed service. + ServiceTags any +} + +// MachineLearningServicesModelRegisteredEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.MachineLearningServices.ModelRegistered +// event. +type MachineLearningServicesModelRegisteredEventData struct { + // The name of the model that was registered. + ModelName *string + + // The properties of the model that was registered. + ModelProperties any + + // The tags of the model that was registered. + ModelTags any + + // The version of the model that was registered. + ModelVersion *string +} + +// MachineLearningServicesRunCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.MachineLearningServices.RunCompleted +// event. +type MachineLearningServicesRunCompletedEventData struct { + // 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 properties of the completed Run. + RunProperties any + + // The tags of the completed Run. + RunTags any + + // The Run Type of the completed Run. + RunType *string +} + +// MachineLearningServicesRunStatusChangedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.MachineLearningServices.RunStatusChanged +// event. +type MachineLearningServicesRunStatusChangedEventData struct { + // 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 properties of the Machine Learning Run. + RunProperties any + + // The status of the Machine Learning Run. + RunStatus *string + + // The tags of the Machine Learning Run. + RunTags any + + // The Run Type of the Machine Learning Run. + RunType *string +} + +// MapsGeofenceEnteredEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Maps.GeofenceEntered event. +type MapsGeofenceEnteredEventData struct { + // 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 *bool +} + +// MapsGeofenceEventProperties - Schema of the Data property of an CloudEvent/EventGridEvent for a Geofence event (GeofenceEntered, GeofenceExited, +// GeofenceResult). +type MapsGeofenceEventProperties struct { + // 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 *bool +} + +// MapsGeofenceExitedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Maps.GeofenceExited event. +type MapsGeofenceExitedEventData struct { + // 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 *bool +} + +// MapsGeofenceGeometry - The geofence geometry. +type MapsGeofenceGeometry struct { + // 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 *float32 + + // The unique ID for the geofence geometry. + GeometryID *string + + // Latitude of the nearest point of the geometry. + NearestLat *float32 + + // Longitude of the nearest point of the geometry. + NearestLon *float32 + + // The unique id returned from user upload service when uploading a geofence. Will not be included in geofencing post API. + UdID *string +} + +// MapsGeofenceResultEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Maps.GeofenceResult event. +type MapsGeofenceResultEventData struct { + // 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 *bool +} + +// MediaJobCanceledEventData - Job canceled event data. Schema of the data property of an EventGridEvent for a Microsoft.Media.JobCanceled +// event. +type MediaJobCanceledEventData struct { + // Gets the Job correlation data. + CorrelationData map[string]*string + + // Gets the Job outputs. + Outputs []MediaJobOutputClassification + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState + + // READ-ONLY; The new state of the Job. + State *MediaJobState +} + +// MediaJobCancelingEventData - Job canceling event data. Schema of the data property of an EventGridEvent for a Microsoft.Media.JobCanceling +// event. +type MediaJobCancelingEventData struct { + // Gets the Job correlation data. + CorrelationData map[string]*string + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState + + // READ-ONLY; The new state of the Job. + State *MediaJobState +} + +// MediaJobError - Details of JobOutput errors. +type MediaJobError struct { + // READ-ONLY; Helps with categorization of errors. + Category *MediaJobErrorCategory + + // READ-ONLY; Error code describing the error. + Code *MediaJobErrorCode + + // READ-ONLY; An array of details about specific errors that led to this reported error. + Details []MediaJobErrorDetail + + // READ-ONLY; A human-readable language-dependent representation of the error. + Message *string + + // READ-ONLY; Indicates that it may be possible to retry the Job. If retry is unsuccessful, please contact Azure support via + // Azure Portal. + Retry *MediaJobRetry +} + +// MediaJobErrorDetail - Details of JobOutput errors. +type MediaJobErrorDetail struct { + // READ-ONLY; Code describing the error detail. + Code *string + + // READ-ONLY; A human-readable representation of the error. + Message *string +} + +// MediaJobErroredEventData - Job error state event data. Schema of the data property of an EventGridEvent for a Microsoft.Media.JobErrored +// event. +type MediaJobErroredEventData struct { + // Gets the Job correlation data. + CorrelationData map[string]*string + + // Gets the Job outputs. + Outputs []MediaJobOutputClassification + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState + + // READ-ONLY; The new state of the Job. + State *MediaJobState +} + +// MediaJobFinishedEventData - Job finished event data. Schema of the data property of an EventGridEvent for a Microsoft.Media.JobFinished +// event. +type MediaJobFinishedEventData struct { + // Gets the Job correlation data. + CorrelationData map[string]*string + + // Gets the Job outputs. + Outputs []MediaJobOutputClassification + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState + + // READ-ONLY; The new state of the Job. + State *MediaJobState +} + +// MediaJobOutput - The event data for a Job output. +type MediaJobOutput struct { + // REQUIRED; The discriminator for derived types. + ODataType *string + + // REQUIRED; Gets the Job output progress. + Progress *int64 + + // REQUIRED; Gets the Job output state. + State *MediaJobState + + // Gets the Job output error. + Error *MediaJobError + + // Gets the Job output label. + Label *string +} + +// GetMediaJobOutput implements the MediaJobOutputClassification interface for type MediaJobOutput. +func (m *MediaJobOutput) GetMediaJobOutput() *MediaJobOutput { return m } + +// MediaJobOutputAsset - The event data for a Job output asset. +type MediaJobOutputAsset struct { + // REQUIRED; The discriminator for derived types. + ODataType *string + + // REQUIRED; Gets the Job output progress. + Progress *int64 + + // REQUIRED; Gets the Job output state. + State *MediaJobState + + // Gets the Job output asset name. + AssetName *string + + // Gets the Job output error. + Error *MediaJobError + + // Gets the Job output label. + Label *string +} + +// GetMediaJobOutput implements the MediaJobOutputClassification interface for type MediaJobOutputAsset. +func (m *MediaJobOutputAsset) GetMediaJobOutput() *MediaJobOutput { + return &MediaJobOutput{ + Error: m.Error, + Label: m.Label, + ODataType: m.ODataType, + Progress: m.Progress, + State: m.State, + } +} + +// MediaJobOutputCanceledEventData - Job output canceled event data. Schema of the data property of an EventGridEvent for +// a Microsoft.Media.JobOutputCanceled event. +type MediaJobOutputCanceledEventData struct { + // Gets the Job correlation data. + JobCorrelationData map[string]*string + + // Gets the output. + Output MediaJobOutputClassification + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState +} + +// MediaJobOutputCancelingEventData - Job output canceling event data. Schema of the data property of an EventGridEvent for +// a Microsoft.Media.JobOutputCanceling event. +type MediaJobOutputCancelingEventData struct { + // Gets the Job correlation data. + JobCorrelationData map[string]*string + + // Gets the output. + Output MediaJobOutputClassification + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState +} + +// MediaJobOutputErroredEventData - Job output error event data. Schema of the data property of an EventGridEvent for a Microsoft.Media.JobOutputErrored +// event. +type MediaJobOutputErroredEventData struct { + // Gets the Job correlation data. + JobCorrelationData map[string]*string + + // Gets the output. + Output MediaJobOutputClassification + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState +} + +// MediaJobOutputFinishedEventData - Job output finished event data. Schema of the data property of an EventGridEvent for +// a Microsoft.Media.JobOutputFinished event. +type MediaJobOutputFinishedEventData struct { + // Gets the Job correlation data. + JobCorrelationData map[string]*string + + // Gets the output. + Output MediaJobOutputClassification + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState +} + +// MediaJobOutputProcessingEventData - Job output processing event data. Schema of the data property of an EventGridEvent +// for a Microsoft.Media.JobOutputProcessing event. +type MediaJobOutputProcessingEventData struct { + // Gets the Job correlation data. + JobCorrelationData map[string]*string + + // Gets the output. + Output MediaJobOutputClassification + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState +} + +// MediaJobOutputProgressEventData - Job Output Progress Event Data. Schema of the Data property of an CloudEvent/EventGridEvent for +// a Microsoft.Media.JobOutputProgress event. +type MediaJobOutputProgressEventData struct { + // Gets the Job correlation data. + JobCorrelationData map[string]*string + + // Gets the Job output label. + Label *string + + // Gets the Job output progress. + Progress *int64 +} + +// MediaJobOutputScheduledEventData - Job output scheduled event data. Schema of the data property of an EventGridEvent for +// a Microsoft.Media.JobOutputScheduled event. +type MediaJobOutputScheduledEventData struct { + // Gets the Job correlation data. + JobCorrelationData map[string]*string + + // Gets the output. + Output MediaJobOutputClassification + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState +} + +// MediaJobOutputStateChangeEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Media.JobOutputStateChange +// event. +type MediaJobOutputStateChangeEventData struct { + // Gets the Job correlation data. + JobCorrelationData map[string]*string + + // Gets the output. + Output MediaJobOutputClassification + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState +} + +// MediaJobProcessingEventData - Job processing event data. Schema of the data property of an EventGridEvent for a Microsoft.Media.JobProcessing +// event. +type MediaJobProcessingEventData struct { + // Gets the Job correlation data. + CorrelationData map[string]*string + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState + + // READ-ONLY; The new state of the Job. + State *MediaJobState +} + +// MediaJobScheduledEventData - Job scheduled event data. Schema of the data property of an EventGridEvent for a Microsoft.Media.JobScheduled +// event. +type MediaJobScheduledEventData struct { + // Gets the Job correlation data. + CorrelationData map[string]*string + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState + + // READ-ONLY; The new state of the Job. + State *MediaJobState +} + +// MediaJobStateChangeEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Media.JobStateChange event. +type MediaJobStateChangeEventData struct { + // Gets the Job correlation data. + CorrelationData map[string]*string + + // READ-ONLY; The previous state of the Job. + PreviousState *MediaJobState + + // READ-ONLY; The new state of the Job. + State *MediaJobState +} + +// MediaLiveEventChannelArchiveHeartbeatEventData - Channel Archive heartbeat event data. Schema of the data property of an +// EventGridEvent for a Microsoft.Media.LiveEventChannelArchiveHeartbeat event. +type MediaLiveEventChannelArchiveHeartbeatEventData struct { + // READ-ONLY; Gets the channel latency in ms. + ChannelLatencyMS *string + + // READ-ONLY; Gets the latency result code. + LatencyResultCode *string +} + +// MediaLiveEventConnectionRejectedEventData - Encoder connection rejected event data. Schema of the data property of an EventGridEvent +// for a Microsoft.Media.LiveEventConnectionRejected event. +type MediaLiveEventConnectionRejectedEventData struct { + // READ-ONLY; Gets the remote IP. + EncoderIP *string + + // READ-ONLY; Gets the remote port. + EncoderPort *string + + // READ-ONLY; Gets the ingest URL provided by the live event. + IngestURL *string + + // READ-ONLY; Gets the result code. + ResultCode *string + + // READ-ONLY; Gets the stream Id. + StreamID *string +} + +// MediaLiveEventEncoderConnectedEventData - Encoder connect event data. Schema of the data property of an EventGridEvent +// for a Microsoft.Media.LiveEventEncoderConnected event. +type MediaLiveEventEncoderConnectedEventData struct { + // READ-ONLY; Gets the remote IP. + EncoderIP *string + + // READ-ONLY; Gets the remote port. + EncoderPort *string + + // READ-ONLY; Gets the ingest URL provided by the live event. + IngestURL *string + + // READ-ONLY; Gets the stream Id. + StreamID *string +} + +// MediaLiveEventEncoderDisconnectedEventData - Encoder disconnected event data. Schema of the Data property of an CloudEvent/EventGridEvent +// for a Microsoft.Media.LiveEventEncoderDisconnected event. +type MediaLiveEventEncoderDisconnectedEventData struct { + // READ-ONLY; Gets the remote IP. + EncoderIP *string + + // READ-ONLY; Gets the remote port. + EncoderPort *string + + // READ-ONLY; Gets the ingest URL provided by the live event. + IngestURL *string + + // READ-ONLY; Gets the result code. + ResultCode *string + + // READ-ONLY; Gets the stream Id. + StreamID *string +} + +// MediaLiveEventIncomingDataChunkDroppedEventData - Ingest fragment dropped event data. Schema of the data property of an +// EventGridEvent for a Microsoft.Media.LiveEventIncomingDataChunkDropped event. +type MediaLiveEventIncomingDataChunkDroppedEventData struct { + // READ-ONLY; Gets the bitrate of the track. + Bitrate *int64 + + // READ-ONLY; Gets the result code for fragment drop operation. + ResultCode *string + + // READ-ONLY; Gets the timescale of the Timestamp. + Timescale *string + + // READ-ONLY; Gets the timestamp of the data chunk dropped. + Timestamp *string + + // READ-ONLY; Gets the name of the track for which fragment is dropped. + TrackName *string + + // READ-ONLY; Gets the type of the track (Audio / Video). + TrackType *string +} + +// MediaLiveEventIncomingStreamReceivedEventData - Encoder connect event data. Schema of the data property of an EventGridEvent +// for a Microsoft.Media.LiveEventIncomingStreamReceived event. +type MediaLiveEventIncomingStreamReceivedEventData struct { + // READ-ONLY; Gets the bitrate of the track. + Bitrate *int64 + + // READ-ONLY; Gets the duration of the first data chunk. + Duration *string + + // READ-ONLY; Gets the remote IP. + EncoderIP *string + + // READ-ONLY; Gets the remote port. + EncoderPort *string + + // READ-ONLY; Gets the ingest URL provided by the live event. + IngestURL *string + + // READ-ONLY; Gets the timescale in which timestamp is represented. + Timescale *string + + // READ-ONLY; Gets the first timestamp of the data chunk received. + Timestamp *string + + // READ-ONLY; Gets the track name. + TrackName *string + + // READ-ONLY; Gets the type of the track (Audio / Video). + TrackType *string +} + +// MediaLiveEventIncomingStreamsOutOfSyncEventData - Incoming streams out of sync event data. Schema of the data property +// of an EventGridEvent for a Microsoft.Media.LiveEventIncomingStreamsOutOfSync event. +type MediaLiveEventIncomingStreamsOutOfSyncEventData struct { + // READ-ONLY; Gets the maximum timestamp among all the tracks (audio or video). + MaxLastTimestamp *string + + // READ-ONLY; Gets the minimum last timestamp received. + MinLastTimestamp *string + + // READ-ONLY; Gets the timescale in which "MaxLastTimestamp" is represented. + TimescaleOfMaxLastTimestamp *string + + // READ-ONLY; Gets the timescale in which "MinLastTimestamp" is represented. + TimescaleOfMinLastTimestamp *string + + // READ-ONLY; Gets the type of stream with maximum last timestamp. + TypeOfStreamWithMaxLastTimestamp *string + + // READ-ONLY; Gets the type of stream with minimum last timestamp. + TypeOfStreamWithMinLastTimestamp *string +} + +// MediaLiveEventIncomingVideoStreamsOutOfSyncEventData - Incoming video stream out of sync event data. Schema of the data +// property of an EventGridEvent for a Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync event. +type MediaLiveEventIncomingVideoStreamsOutOfSyncEventData struct { + // READ-ONLY; Gets the duration of the data chunk with first timestamp. + FirstDuration *string + + // READ-ONLY; Gets the first timestamp received for one of the quality levels. + FirstTimestamp *string + + // READ-ONLY; Gets the duration of the data chunk with second timestamp. + SecondDuration *string + + // READ-ONLY; Gets the timestamp received for some other quality levels. + SecondTimestamp *string + + // READ-ONLY; Gets the timescale in which both the timestamps and durations are represented. + Timescale *string +} + +// MediaLiveEventIngestHeartbeatEventData - Ingest heartbeat event data. Schema of the data property of an EventGridEvent +// for a Microsoft.Media.LiveEventIngestHeartbeat event. +type MediaLiveEventIngestHeartbeatEventData struct { + // READ-ONLY; Gets the bitrate of the track. + Bitrate *int64 + + // READ-ONLY; Gets the fragment Discontinuity count. + DiscontinuityCount *int64 + + // READ-ONLY; Gets a value indicating whether preview is healthy or not. + Healthy *bool + + // READ-ONLY; Gets the incoming bitrate. + IncomingBitrate *int64 + + // READ-ONLY; Gets the track ingest drift value. + IngestDriftValue *string + + // READ-ONLY; Gets the arrival UTC time of the last fragment. + LastFragmentArrivalTime *string + + // READ-ONLY; Gets the last timestamp. + LastTimestamp *string + + // READ-ONLY; Gets Non increasing count. + NonincreasingCount *int64 + + // READ-ONLY; Gets the fragment Overlap count. + OverlapCount *int64 + + // READ-ONLY; Gets the state of the live event. + State *string + + // READ-ONLY; Gets the timescale of the last timestamp. + Timescale *string + + // READ-ONLY; Gets the track name. + TrackName *string + + // READ-ONLY; Gets the type of the track (Audio / Video). + TrackType *string + + // READ-ONLY; Gets the Live Transcription language. + TranscriptionLanguage *string + + // READ-ONLY; Gets the Live Transcription state. + TranscriptionState *string + + // READ-ONLY; Gets a value indicating whether unexpected bitrate is present or not. + UnexpectedBitrate *bool +} + +// MediaLiveEventTrackDiscontinuityDetectedEventData - Ingest track discontinuity detected event data. Schema of the data +// property of an EventGridEvent for a Microsoft.Media.LiveEventTrackDiscontinuityDetected event. +type MediaLiveEventTrackDiscontinuityDetectedEventData struct { + // READ-ONLY; Gets the bitrate. + Bitrate *int64 + + // READ-ONLY; Gets the discontinuity gap between PreviousTimestamp and NewTimestamp. + DiscontinuityGap *string + + // READ-ONLY; Gets the timestamp of the current fragment. + NewTimestamp *string + + // READ-ONLY; Gets the timestamp of the previous fragment. + PreviousTimestamp *string + + // READ-ONLY; Gets the timescale in which both timestamps and discontinuity gap are represented. + Timescale *string + + // READ-ONLY; Gets the track name. + TrackName *string + + // READ-ONLY; Gets the type of the track (Audio / Video). + TrackType *string +} + +// MicrosoftTeamsUserIdentifierModel - A Microsoft Teams user. +type MicrosoftTeamsUserIdentifierModel struct { + // REQUIRED; The Id of the Microsoft Teams user. If not anonymous, this is the AAD object Id of the user. + UserID *string + + // The cloud that the Microsoft Teams user belongs to. By default 'public' if missing. + Cloud *CommunicationCloudEnvironmentModel + + // True if the Microsoft Teams user is anonymous. By default false if missing. + IsAnonymous *bool +} + +// PhoneNumberIdentifierModel - A phone number. +type PhoneNumberIdentifierModel struct { + // REQUIRED; The phone number in E.164 format. + Value *string +} + +// PolicyInsightsPolicyStateChangedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.PolicyInsights.PolicyStateChanged +// event. +type PolicyInsightsPolicyStateChangedEventData struct { + // The compliance reason code. May be empty. + ComplianceReasonCode *string + + // The compliance state of the resource with respect to the policy assignment. + ComplianceState *string + + // The resource ID of the policy assignment. + PolicyAssignmentID *string + + // The resource ID of the policy definition. + PolicyDefinitionID *string + + // The reference ID for the policy definition inside the initiative definition, if the policy assignment is for an initiative. + // May be empty. + PolicyDefinitionReferenceID *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The time that the resource was scanned by Azure Policy in the Universal ISO 8601 DateTime format yyyy-MM-ddTHH:mm:ss.fffffffZ. + Timestamp *time.Time +} + +// PolicyInsightsPolicyStateCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.PolicyInsights.PolicyStateCreated +// event. +type PolicyInsightsPolicyStateCreatedEventData struct { + // The compliance reason code. May be empty. + ComplianceReasonCode *string + + // The compliance state of the resource with respect to the policy assignment. + ComplianceState *string + + // The resource ID of the policy assignment. + PolicyAssignmentID *string + + // The resource ID of the policy definition. + PolicyDefinitionID *string + + // The reference ID for the policy definition inside the initiative definition, if the policy assignment is for an initiative. + // May be empty. + PolicyDefinitionReferenceID *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The time that the resource was scanned by Azure Policy in the Universal ISO 8601 DateTime format yyyy-MM-ddTHH:mm:ss.fffffffZ. + Timestamp *time.Time +} + +// PolicyInsightsPolicyStateDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.PolicyInsights.PolicyStateDeleted +// event. +type PolicyInsightsPolicyStateDeletedEventData struct { + // The compliance reason code. May be empty. + ComplianceReasonCode *string + + // The compliance state of the resource with respect to the policy assignment. + ComplianceState *string + + // The resource ID of the policy assignment. + PolicyAssignmentID *string + + // The resource ID of the policy definition. + PolicyDefinitionID *string + + // The reference ID for the policy definition inside the initiative definition, if the policy assignment is for an initiative. + // May be empty. + PolicyDefinitionReferenceID *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The time that the resource was scanned by Azure Policy in the Universal ISO 8601 DateTime format yyyy-MM-ddTHH:mm:ss.fffffffZ. + Timestamp *time.Time +} + +// RedisExportRDBCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Cache.ExportRDBCompleted +// event. +type RedisExportRDBCompletedEventData struct { + // The name of this event. + Name *string + + // The status of this event. Failed or succeeded + Status *string + + // The time at which the event occurred. + Timestamp *time.Time +} + +// RedisImportRDBCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Cache.ImportRDBCompleted +// event. +type RedisImportRDBCompletedEventData struct { + // The name of this event. + Name *string + + // The status of this event. Failed or succeeded + Status *string + + // The time at which the event occurred. + Timestamp *time.Time +} + +// RedisPatchingCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Cache.PatchingCompleted +// event. +type RedisPatchingCompletedEventData struct { + // The name of this event. + Name *string + + // The status of this event. Failed or succeeded + Status *string + + // The time at which the event occurred. + Timestamp *time.Time +} + +// RedisScalingCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Cache.ScalingCompleted +// event. +type RedisScalingCompletedEventData struct { + // The name of this event. + Name *string + + // The status of this event. Failed or succeeded + Status *string + + // The time at which the event occurred. + Timestamp *time.Time +} + +// ResourceActionCancelEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Resources.ResourceActionCancel +// event. This is raised when a resource action operation is canceled. +type ResourceActionCancelEventData struct { + // The requested authorization for the operation. + Authorization *ResourceAuthorization + + // The properties of the claims. + Claims map[string]*string + + // An operation ID used for troubleshooting. + CorrelationID *string + + // The details of the operation. + HTTPRequest *ResourceHTTPRequest + + // The operation that was performed. + OperationName *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 status of the operation. + Status *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The tenant ID of the resource. + TenantID *string +} + +// ResourceActionFailureEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Resources.ResourceActionFailure +// event. This is raised when a resource action operation fails. +type ResourceActionFailureEventData struct { + // The requested authorization for the operation. + Authorization *ResourceAuthorization + + // The properties of the claims. + Claims map[string]*string + + // An operation ID used for troubleshooting. + CorrelationID *string + + // The details of the operation. + HTTPRequest *ResourceHTTPRequest + + // The operation that was performed. + OperationName *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 status of the operation. + Status *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The tenant ID of the resource. + TenantID *string +} + +// ResourceActionSuccessEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Resources.ResourceActionSuccess +// event. This is raised when a resource action operation succeeds. +type ResourceActionSuccessEventData struct { + // The requested authorization for the operation. + Authorization *ResourceAuthorization + + // The properties of the claims. + Claims map[string]*string + + // An operation ID used for troubleshooting. + CorrelationID *string + + // The details of the operation. + HTTPRequest *ResourceHTTPRequest + + // The operation that was performed. + OperationName *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 status of the operation. + Status *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The tenant ID of the resource. + TenantID *string +} + +// ResourceAuthorization - The details of the authorization for the resource. +type ResourceAuthorization struct { + // The action being requested. + Action *string + + // The evidence for the authorization. + Evidence map[string]*string + + // The scope of the authorization. + Scope *string +} + +// ResourceDeleteCancelEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Resources.ResourceDeleteCancel +// event. This is raised when a resource delete operation is canceled. +type ResourceDeleteCancelEventData struct { + // The requested authorization for the operation. + Authorization *ResourceAuthorization + + // The properties of the claims. + Claims map[string]*string + + // An operation ID used for troubleshooting. + CorrelationID *string + + // The details of the operation. + HTTPRequest *ResourceHTTPRequest + + // The operation that was performed. + OperationName *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 status of the operation. + Status *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The tenant ID of the resource. + TenantID *string +} + +// ResourceDeleteFailureEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Resources.ResourceDeleteFailure +// event. This is raised when a resource delete operation fails. +type ResourceDeleteFailureEventData struct { + // The requested authorization for the operation. + Authorization *ResourceAuthorization + + // The properties of the claims. + Claims map[string]*string + + // An operation ID used for troubleshooting. + CorrelationID *string + + // The details of the operation. + HTTPRequest *ResourceHTTPRequest + + // The operation that was performed. + OperationName *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 status of the operation. + Status *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The tenant ID of the resource. + TenantID *string +} + +// ResourceDeleteSuccessEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Resources.ResourceDeleteSuccess +// event. This is raised when a resource delete operation succeeds. +type ResourceDeleteSuccessEventData struct { + // The requested authorization for the operation. + Authorization *ResourceAuthorization + + // The properties of the claims. + Claims map[string]*string + + // An operation ID used for troubleshooting. + CorrelationID *string + + // The details of the operation. + HTTPRequest *ResourceHTTPRequest + + // The operation that was performed. + OperationName *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 status of the operation. + Status *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The tenant ID of the resource. + TenantID *string +} + +// ResourceHTTPRequest - The details of the HTTP request. +type ResourceHTTPRequest struct { + // The client IP address. + ClientIPAddress *string + + // The client request ID. + ClientRequestID *string + + // The request method. + Method *string + + // The url used in the request. + URL *string +} + +// ResourceNotificationsHealthResourcesAnnotatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ResourceNotifications.HealthResources.ResourceAnnotated +// event. +type ResourceNotificationsHealthResourcesAnnotatedEventData struct { + // api version of the resource properties bag + APIVersion *string + + // details about operational info + OperationalDetails *ResourceNotificationsOperationalDetails + + // resourceInfo details for update event + ResourceDetails *ResourceNotificationsResourceUpdatedDetails +} + +// ResourceNotificationsHealthResourcesAvailabilityStatusChangedEventData - Schema of the Data property of an CloudEvent/EventGridEvent +// for a Microsoft.ResourceNotifications.HealthResources.AvailabilityStatusChanged event. +type ResourceNotificationsHealthResourcesAvailabilityStatusChangedEventData struct { + // api version of the resource properties bag + APIVersion *string + + // details about operational info + OperationalDetails *ResourceNotificationsOperationalDetails + + // resourceInfo details for update event + ResourceDetails *ResourceNotificationsResourceUpdatedDetails +} + +// ResourceNotificationsOperationalDetails - details of operational info +type ResourceNotificationsOperationalDetails struct { + // Date and Time when resource was updated + ResourceEventTime *time.Time +} + +// ResourceNotificationsResourceDeletedDetails - Describes the schema of the properties under resource info which are common +// across all ARN system topic delete events +type ResourceNotificationsResourceDeletedDetails struct { + // id of the resource for which the event is being emitted + ID *string + + // name of the resource for which the event is being emitted + Name *string + + // the type of the resource for which the event is being emitted + Type *string +} + +// ResourceNotificationsResourceDeletedEventData - Describes the schema of the common properties across all ARN system topic +// delete events +type ResourceNotificationsResourceDeletedEventData struct { + // details about operational info + OperationalDetails *ResourceNotificationsOperationalDetails + + // resourceInfo details for delete event + ResourceDetails *ResourceNotificationsResourceDeletedDetails +} + +// ResourceNotificationsResourceManagementCreatedOrUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for +// a Microsoft.ResourceNotifications.Resources.CreatedOrUpdated event. +type ResourceNotificationsResourceManagementCreatedOrUpdatedEventData struct { + // api version of the resource properties bag + APIVersion *string + + // details about operational info + OperationalDetails *ResourceNotificationsOperationalDetails + + // resourceInfo details for update event + ResourceDetails *ResourceNotificationsResourceUpdatedDetails +} + +// ResourceNotificationsResourceManagementDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ResourceNotifications.Resources.Deleted +// event. +type ResourceNotificationsResourceManagementDeletedEventData struct { + // details about operational info + OperationalDetails *ResourceNotificationsOperationalDetails + + // resourceInfo details for delete event + ResourceDetails *ResourceNotificationsResourceDeletedDetails +} + +// ResourceNotificationsResourceUpdatedDetails - Describes the schema of the properties under resource info which are common +// across all ARN system topic events +type ResourceNotificationsResourceUpdatedDetails struct { + // id of the resource for which the event is being emitted + ID *string + + // the location of the resource for which the event is being emitted + Location *string + + // name of the resource for which the event is being emitted + Name *string + + // properties in the payload of the resource for which the event is being emitted + Properties map[string]any + + // the tags on the resource for which the event is being emitted + Tags map[string]*string + + // the type of the resource for which the event is being emitted + Type *string +} + +// ResourceNotificationsResourceUpdatedEventData - Describes the schema of the common properties across all ARN system topic +// events +type ResourceNotificationsResourceUpdatedEventData struct { + // api version of the resource properties bag + APIVersion *string + + // details about operational info + OperationalDetails *ResourceNotificationsOperationalDetails + + // resourceInfo details for update event + ResourceDetails *ResourceNotificationsResourceUpdatedDetails +} + +// ResourceWriteCancelEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Resources.ResourceWriteCancel +// event. This is raised when a resource create or update operation is canceled. +type ResourceWriteCancelEventData struct { + // The requested authorization for the operation. + Authorization *ResourceAuthorization + + // The properties of the claims. + Claims map[string]*string + + // An operation ID used for troubleshooting. + CorrelationID *string + + // The details of the operation. + HTTPRequest *ResourceHTTPRequest + + // The operation that was performed. + OperationName *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 status of the operation. + Status *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The tenant ID of the resource. + TenantID *string +} + +// ResourceWriteFailureEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Resources.ResourceWriteFailure +// event. This is raised when a resource create or update operation fails. +type ResourceWriteFailureEventData struct { + // The requested authorization for the operation. + Authorization *ResourceAuthorization + + // The properties of the claims. + Claims map[string]*string + + // An operation ID used for troubleshooting. + CorrelationID *string + + // The details of the operation. + HTTPRequest *ResourceHTTPRequest + + // The operation that was performed. + OperationName *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 status of the operation. + Status *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The tenant ID of the resource. + TenantID *string +} + +// ResourceWriteSuccessEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Resources.ResourceWriteSuccess +// event. This is raised when a resource create or update operation succeeds. +type ResourceWriteSuccessEventData struct { + // The requested authorization for the operation. + Authorization *ResourceAuthorization + + // The properties of the claims. + Claims map[string]*string + + // An operation ID used for troubleshooting. + CorrelationID *string + + // The details of the operation. + HTTPRequest *ResourceHTTPRequest + + // The operation that was performed. + OperationName *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 status of the operation. + Status *string + + // The subscription ID of the resource. + SubscriptionID *string + + // The tenant ID of the resource. + TenantID *string +} + +// ServiceBusActiveMessagesAvailablePeriodicNotificationsEventData - Schema of the Data property of an CloudEvent/EventGridEvent for +// a Microsoft.ServiceBus.ActiveMessagesAvailablePeriodicNotifications event. +type ServiceBusActiveMessagesAvailablePeriodicNotificationsEventData struct { + // The entity type of the Microsoft.ServiceBus resource. Could be one of 'queue' or 'subscriber'. + EntityType *string + + // The namespace name of the Microsoft.ServiceBus resource. + NamespaceName *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 endpoint of the Microsoft.ServiceBus resource. + RequestURI *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 + + // The name of the Microsoft.ServiceBus topic. If the entity type is of type 'queue', then this value will be null. + TopicName *string +} + +// ServiceBusActiveMessagesAvailableWithNoListenersEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners +// event. +type ServiceBusActiveMessagesAvailableWithNoListenersEventData struct { + // The entity type of the Microsoft.ServiceBus resource. Could be one of 'queue' or 'subscriber'. + EntityType *string + + // The namespace name of the Microsoft.ServiceBus resource. + NamespaceName *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 endpoint of the Microsoft.ServiceBus resource. + RequestURI *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 + + // The name of the Microsoft.ServiceBus topic. If the entity type is of type 'queue', then this value will be null. + TopicName *string +} + +// ServiceBusDeadletterMessagesAvailablePeriodicNotificationsEventData - Schema of the Data property of an CloudEvent/EventGridEvent +// for a Microsoft.ServiceBus.DeadletterMessagesAvailablePeriodicNotifications event. +type ServiceBusDeadletterMessagesAvailablePeriodicNotificationsEventData struct { + // The entity type of the Microsoft.ServiceBus resource. Could be one of 'queue' or 'subscriber'. + EntityType *string + + // The namespace name of the Microsoft.ServiceBus resource. + NamespaceName *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 endpoint of the Microsoft.ServiceBus resource. + RequestURI *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 + + // The name of the Microsoft.ServiceBus topic. If the entity type is of type 'queue', then this value will be null. + TopicName *string +} + +// ServiceBusDeadletterMessagesAvailableWithNoListenersEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a +// Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListeners event. +type ServiceBusDeadletterMessagesAvailableWithNoListenersEventData struct { + // The entity type of the Microsoft.ServiceBus resource. Could be one of 'queue' or 'subscriber'. + EntityType *string + + // The namespace name of the Microsoft.ServiceBus resource. + NamespaceName *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 endpoint of the Microsoft.ServiceBus resource. + RequestURI *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 + + // The name of the Microsoft.ServiceBus topic. If the entity type is of type 'queue', then this value will be null. + TopicName *string +} + +// SignalRServiceClientConnectionConnectedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.SignalRService.ClientConnectionConnected +// event. +type SignalRServiceClientConnectionConnectedEventData struct { + // The connection Id of connected client connection. + ConnectionID *string + + // The hub of connected client connection. + HubName *string + + // The time at which the event occurred. + Timestamp *time.Time + + // The user Id of connected client connection. + UserID *string +} + +// SignalRServiceClientConnectionDisconnectedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.SignalRService.ClientConnectionDisconnected +// event. +type SignalRServiceClientConnectionDisconnectedEventData struct { + // The connection Id of connected client connection. + ConnectionID *string + + // The message of error that cause the client connection disconnected. + ErrorMessage *string + + // The hub of connected client connection. + HubName *string + + // The time at which the event occurred. + Timestamp *time.Time + + // The user Id of connected client connection. + UserID *string +} + +// StorageAsyncOperationInitiatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Storage.AsyncOperationInitiated +// event. +type StorageAsyncOperationInitiatedEventData struct { + // The name of the API/operation that triggered this event. + API *string + + // The type of blob. + BlobType *string + + // A request id provided by the client of the storage API operation that triggered this event. + ClientRequestID *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 *int64 + + // 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 identity of the requester that triggered this event. + Identity *string + + // The request id generated by the Storage service for the storage API operation that triggered this event. + RequestID *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 + + // For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored + // by event consumers. + StorageDiagnostics any + + // The path to the blob. + URL *string +} + +// StorageBlobCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Storage.BlobCreated event. +type StorageBlobCreatedEventData struct { + // The name of the API/operation that triggered this event. + API *string + + // The type of blob. + BlobType *string + + // A request id provided by the client of the storage API operation that triggered this event. + ClientRequestID *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 *int64 + + // The offset of the blob in bytes. + ContentOffset *int64 + + // 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 etag of the blob at the time this event was triggered. + ETag *string + + // The identity of the requester that triggered this event. + Identity *string + + // The request id generated by the Storage service for the storage API operation that triggered this event. + RequestID *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 + + // For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored + // by event consumers. + StorageDiagnostics any + + // The path to the blob. + URL *string +} + +// StorageBlobDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Storage.BlobDeleted event. +type StorageBlobDeletedEventData struct { + // The name of the API/operation that triggered this event. + API *string + + // The type of blob. + BlobType *string + + // A request id provided by the client of the storage API operation that triggered this event. + ClientRequestID *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 identity of the requester that triggered this event. + Identity *string + + // The request id generated by the Storage service for the storage API operation that triggered this event. + RequestID *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 + + // For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored + // by event consumers. + StorageDiagnostics any + + // The path to the blob. + URL *string +} + +// StorageBlobInventoryPolicyCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for an Microsoft.Storage.BlobInventoryPolicyCompleted +// event. +type StorageBlobInventoryPolicyCompletedEventData struct { + // The account name for which inventory policy is registered. + AccountName *string + + // The blob URL for manifest file for inventory run. + ManifestBlobURL *string + + // The policy run id for inventory run. + PolicyRunID *string + + // The status of inventory run, it can be Succeeded/PartiallySucceeded/Failed. + PolicyRunStatus *string + + // The status message for inventory run. + PolicyRunStatusMessage *string + + // The rule name for inventory policy. + RuleName *string + + // The time at which inventory policy was scheduled. + ScheduleDateTime *time.Time +} + +// StorageBlobRenamedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Storage.BlobRenamed event. +type StorageBlobRenamedEventData struct { + // 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 new path to the blob after the rename operation. + DestinationURL *string + + // The identity of the requester that triggered this event. + Identity *string + + // The request id generated by the storage service for the storage API operation that triggered this event. + RequestID *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 path to the blob that was renamed. + SourceURL *string + + // For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored + // by event consumers. + StorageDiagnostics any +} + +// StorageBlobTierChangedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Storage.BlobTierChanged +// event. +type StorageBlobTierChangedEventData struct { + // The name of the API/operation that triggered this event. + API *string + + // The type of blob. + BlobType *string + + // A request id provided by the client of the storage API operation that triggered this event. + ClientRequestID *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 *int64 + + // 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 identity of the requester that triggered this event. + Identity *string + + // The request id generated by the Storage service for the storage API operation that triggered this event. + RequestID *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 + + // For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored + // by event consumers. + StorageDiagnostics any + + // The path to the blob. + URL *string +} + +// StorageDirectoryCreatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Storage.DirectoryCreated +// event. +type StorageDirectoryCreatedEventData struct { + // 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 etag of the directory at the time this event was triggered. + ETag *string + + // The identity of the requester that triggered this event. + Identity *string + + // The request id generated by the storage service for the storage API operation that triggered this event. + RequestID *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 + + // For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored + // by event consumers. + StorageDiagnostics any + + // The path to the directory. + URL *string +} + +// StorageDirectoryDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Storage.DirectoryDeleted +// event. +type StorageDirectoryDeletedEventData struct { + // 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 identity of the requester that triggered this event. + Identity *string + + // Is this event for a recursive delete operation. + Recursive *string + + // The request id generated by the storage service for the storage API operation that triggered this event. + RequestID *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 + + // For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored + // by event consumers. + StorageDiagnostics any + + // The path to the deleted directory. + URL *string +} + +// StorageDirectoryRenamedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Storage.DirectoryRenamed +// event. +type StorageDirectoryRenamedEventData struct { + // 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 new path to the directory after the rename operation. + DestinationURL *string + + // The identity of the requester that triggered this event. + Identity *string + + // The request id generated by the storage service for the storage API operation that triggered this event. + RequestID *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 path to the directory that was renamed. + SourceURL *string + + // For service use only. Diagnostic data occasionally included by the Azure Storage service. This property should be ignored + // by event consumers. + StorageDiagnostics any +} + +// StorageLifecyclePolicyActionSummaryDetail - Execution statistics of a specific policy action in a Blob Management cycle. +type StorageLifecyclePolicyActionSummaryDetail struct { + // Error messages of this action if any. + ErrorList *string + + // Number of success operations of this action. + SuccessCount *int64 + + // Total number of objects to be acted on by this action. + TotalObjectsCount *int64 +} + +// StorageLifecyclePolicyCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Storage.LifecyclePolicyCompleted +// event. +type StorageLifecyclePolicyCompletedEventData struct { + // Execution statistics of a specific policy action in a Blob Management cycle. + DeleteSummary *StorageLifecyclePolicyActionSummaryDetail + + // The time the policy task was scheduled. + ScheduleTime *string + + // 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. + TierToCoolSummary *StorageLifecyclePolicyActionSummaryDetail +} + +// StorageTaskCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for an Microsoft.Storage.StorageTaskCompleted +// event. +type StorageTaskCompletedEventData struct { + // The time at which a storage task was completed. + CompletedDateTime *time.Time + + // The status for a storage task. + Status *StorageTaskCompletedStatus + + // The summary report blob url for a storage task + SummaryReportBlobURL *string + + // The execution id for a storage task. + TaskExecutionID *string + + // The task name for a storage task. + TaskName *string +} + +// StorageTaskQueuedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for an Microsoft.Storage.StorageTaskQueued +// event. +type StorageTaskQueuedEventData struct { + // The time at which a storage task was queued. + QueuedDateTime *time.Time + + // The execution id for a storage task. + TaskExecutionID *string +} + +// SubscriptionDeletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.EventGrid.SubscriptionDeletedEvent +// event. +type SubscriptionDeletedEventData struct { + // READ-ONLY; The Azure resource ID of the deleted event subscription. + EventSubscriptionID *string +} + +// SubscriptionValidationEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.EventGrid.SubscriptionValidationEvent +// event. +type SubscriptionValidationEventData struct { + // READ-ONLY; 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). + ValidationCode *string + + // READ-ONLY; 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). + ValidationURL *string +} + +// SubscriptionValidationResponse - 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. +type SubscriptionValidationResponse struct { + // The validation response sent by the subscriber to Azure Event Grid to complete the validation of an event subscription. + ValidationResponse *string +} + +// WebAppServicePlanUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.AppServicePlanUpdated +// event. +type WebAppServicePlanUpdatedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app service plan. + AppServicePlanEventTypeDetail *AppServicePlanEventTypeDetail + + // 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 + + // name of the app service plan that had this event. + Name *string + + // The request id generated by the app service for the app service plan API operation that triggered this event. + RequestID *string + + // sku of app service plan. + SKU *WebAppServicePlanUpdatedEventDataSKU + + // HTTP verb of this operation. + Verb *string +} + +// WebAppServicePlanUpdatedEventDataSKU - sku of app service plan. +type WebAppServicePlanUpdatedEventDataSKU struct { + // capacity of app service plan sku. + Capacity *string + + // family of app service plan sku. + Family *string + + // name of app service plan sku. + Name *string + + // size of app service plan sku. + Size *string + + // tier of app service plan sku. + Tier *string +} + +// WebAppUpdatedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.AppUpdated event. +type WebAppUpdatedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebBackupOperationCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.BackupOperationCompleted +// event. +type WebBackupOperationCompletedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebBackupOperationFailedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.BackupOperationFailed +// event. +type WebBackupOperationFailedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebBackupOperationStartedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.BackupOperationStarted +// event. +type WebBackupOperationStartedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebRestoreOperationCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.RestoreOperationCompleted +// event. +type WebRestoreOperationCompletedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebRestoreOperationFailedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.RestoreOperationFailed +// event. +type WebRestoreOperationFailedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebRestoreOperationStartedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.RestoreOperationStarted +// event. +type WebRestoreOperationStartedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebSlotSwapCompletedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.SlotSwapCompleted +// event. +type WebSlotSwapCompletedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebSlotSwapFailedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.SlotSwapFailed event. +type WebSlotSwapFailedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebSlotSwapStartedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.SlotSwapStarted event. +type WebSlotSwapStartedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebSlotSwapWithPreviewCancelledEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.SlotSwapWithPreviewCancelled +// event. +type WebSlotSwapWithPreviewCancelledEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} + +// WebSlotSwapWithPreviewStartedEventData - Schema of the Data property of an CloudEvent/EventGridEvent for a Microsoft.Web.SlotSwapWithPreviewStarted +// event. +type WebSlotSwapWithPreviewStartedEventData struct { + // HTTP request URL of this operation. + Address *string + + // Detail of action on the app. + AppEventTypeDetail *AppEventTypeDetail + + // 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 + + // name of the web site that had this event. + Name *string + + // The request id generated by the app service for the site API operation that triggered this event. + RequestID *string + + // HTTP verb of this operation. + Verb *string +} diff --git a/sdk/messaging/eventgrid/azsystemevents/models_serde.go b/sdk/messaging/eventgrid/azsystemevents/models_serde.go new file mode 100644 index 000000000000..936e725fb550 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/models_serde.go @@ -0,0 +1,11438 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package azsystemevents + +import ( + "encoding/json" + "fmt" + "reflect" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +// MarshalJSON implements the json.Marshaller interface for type APIManagementAPICreatedEventData. +func (a APIManagementAPICreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementAPICreatedEventData. +func (a *APIManagementAPICreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementAPIDeletedEventData. +func (a APIManagementAPIDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementAPIDeletedEventData. +func (a *APIManagementAPIDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementAPIReleaseCreatedEventData. +func (a APIManagementAPIReleaseCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementAPIReleaseCreatedEventData. +func (a *APIManagementAPIReleaseCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementAPIReleaseDeletedEventData. +func (a APIManagementAPIReleaseDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementAPIReleaseDeletedEventData. +func (a *APIManagementAPIReleaseDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementAPIReleaseUpdatedEventData. +func (a APIManagementAPIReleaseUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementAPIReleaseUpdatedEventData. +func (a *APIManagementAPIReleaseUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementAPIUpdatedEventData. +func (a APIManagementAPIUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementAPIUpdatedEventData. +func (a *APIManagementAPIUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayAPIAddedEventData. +func (a APIManagementGatewayAPIAddedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayAPIAddedEventData. +func (a *APIManagementGatewayAPIAddedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayAPIRemovedEventData. +func (a APIManagementGatewayAPIRemovedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayAPIRemovedEventData. +func (a *APIManagementGatewayAPIRemovedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayCertificateAuthorityCreatedEventData. +func (a APIManagementGatewayCertificateAuthorityCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayCertificateAuthorityCreatedEventData. +func (a *APIManagementGatewayCertificateAuthorityCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayCertificateAuthorityDeletedEventData. +func (a APIManagementGatewayCertificateAuthorityDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayCertificateAuthorityDeletedEventData. +func (a *APIManagementGatewayCertificateAuthorityDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayCertificateAuthorityUpdatedEventData. +func (a APIManagementGatewayCertificateAuthorityUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayCertificateAuthorityUpdatedEventData. +func (a *APIManagementGatewayCertificateAuthorityUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayCreatedEventData. +func (a APIManagementGatewayCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayCreatedEventData. +func (a *APIManagementGatewayCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayDeletedEventData. +func (a APIManagementGatewayDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayDeletedEventData. +func (a *APIManagementGatewayDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayHostnameConfigurationCreatedEventData. +func (a APIManagementGatewayHostnameConfigurationCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayHostnameConfigurationCreatedEventData. +func (a *APIManagementGatewayHostnameConfigurationCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayHostnameConfigurationDeletedEventData. +func (a APIManagementGatewayHostnameConfigurationDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayHostnameConfigurationDeletedEventData. +func (a *APIManagementGatewayHostnameConfigurationDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayHostnameConfigurationUpdatedEventData. +func (a APIManagementGatewayHostnameConfigurationUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayHostnameConfigurationUpdatedEventData. +func (a *APIManagementGatewayHostnameConfigurationUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementGatewayUpdatedEventData. +func (a APIManagementGatewayUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementGatewayUpdatedEventData. +func (a *APIManagementGatewayUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementProductCreatedEventData. +func (a APIManagementProductCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementProductCreatedEventData. +func (a *APIManagementProductCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementProductDeletedEventData. +func (a APIManagementProductDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementProductDeletedEventData. +func (a *APIManagementProductDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementProductUpdatedEventData. +func (a APIManagementProductUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementProductUpdatedEventData. +func (a *APIManagementProductUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementSubscriptionCreatedEventData. +func (a APIManagementSubscriptionCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementSubscriptionCreatedEventData. +func (a *APIManagementSubscriptionCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementSubscriptionDeletedEventData. +func (a APIManagementSubscriptionDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementSubscriptionDeletedEventData. +func (a *APIManagementSubscriptionDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementSubscriptionUpdatedEventData. +func (a APIManagementSubscriptionUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementSubscriptionUpdatedEventData. +func (a *APIManagementSubscriptionUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementUserCreatedEventData. +func (a APIManagementUserCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementUserCreatedEventData. +func (a *APIManagementUserCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementUserDeletedEventData. +func (a APIManagementUserDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementUserDeletedEventData. +func (a *APIManagementUserDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementUserUpdatedEventData. +func (a APIManagementUserUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceUri", a.ResourceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementUserUpdatedEventData. +func (a *APIManagementUserUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceUri": + err = unpopulate(val, "ResourceURI", &a.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatEventBaseProperties. +func (a AcsChatEventBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatEventBaseProperties. +func (a *AcsChatEventBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatEventInThreadBaseProperties. +func (a AcsChatEventInThreadBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatEventInThreadBaseProperties. +func (a *AcsChatEventInThreadBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatMessageDeletedEventData. +func (a AcsChatMessageDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "composeTime", a.ComposeTime) + populateDateTimeRFC3339(objectMap, "deleteTime", a.DeleteTime) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "senderCommunicationIdentifier", a.SenderCommunicationIdentifier) + populate(objectMap, "senderDisplayName", a.SenderDisplayName) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "type", a.Type) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatMessageDeletedEventData. +func (a *AcsChatMessageDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "composeTime": + err = unpopulateDateTimeRFC3339(val, "ComposeTime", &a.ComposeTime) + delete(rawMsg, key) + case "deleteTime": + err = unpopulateDateTimeRFC3339(val, "DeleteTime", &a.DeleteTime) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "senderCommunicationIdentifier": + err = unpopulate(val, "SenderCommunicationIdentifier", &a.SenderCommunicationIdentifier) + delete(rawMsg, key) + case "senderDisplayName": + err = unpopulate(val, "SenderDisplayName", &a.SenderDisplayName) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatMessageDeletedInThreadEventData. +func (a AcsChatMessageDeletedInThreadEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "composeTime", a.ComposeTime) + populateDateTimeRFC3339(objectMap, "deleteTime", a.DeleteTime) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "senderCommunicationIdentifier", a.SenderCommunicationIdentifier) + populate(objectMap, "senderDisplayName", a.SenderDisplayName) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "type", a.Type) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatMessageDeletedInThreadEventData. +func (a *AcsChatMessageDeletedInThreadEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "composeTime": + err = unpopulateDateTimeRFC3339(val, "ComposeTime", &a.ComposeTime) + delete(rawMsg, key) + case "deleteTime": + err = unpopulateDateTimeRFC3339(val, "DeleteTime", &a.DeleteTime) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "senderCommunicationIdentifier": + err = unpopulate(val, "SenderCommunicationIdentifier", &a.SenderCommunicationIdentifier) + delete(rawMsg, key) + case "senderDisplayName": + err = unpopulate(val, "SenderDisplayName", &a.SenderDisplayName) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatMessageEditedEventData. +func (a AcsChatMessageEditedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "composeTime", a.ComposeTime) + populateDateTimeRFC3339(objectMap, "editTime", a.EditTime) + populate(objectMap, "messageBody", a.MessageBody) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "metadata", a.Metadata) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "senderCommunicationIdentifier", a.SenderCommunicationIdentifier) + populate(objectMap, "senderDisplayName", a.SenderDisplayName) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "type", a.Type) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatMessageEditedEventData. +func (a *AcsChatMessageEditedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "composeTime": + err = unpopulateDateTimeRFC3339(val, "ComposeTime", &a.ComposeTime) + delete(rawMsg, key) + case "editTime": + err = unpopulateDateTimeRFC3339(val, "EditTime", &a.EditTime) + delete(rawMsg, key) + case "messageBody": + err = unpopulate(val, "MessageBody", &a.MessageBody) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "senderCommunicationIdentifier": + err = unpopulate(val, "SenderCommunicationIdentifier", &a.SenderCommunicationIdentifier) + delete(rawMsg, key) + case "senderDisplayName": + err = unpopulate(val, "SenderDisplayName", &a.SenderDisplayName) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatMessageEditedInThreadEventData. +func (a AcsChatMessageEditedInThreadEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "composeTime", a.ComposeTime) + populateDateTimeRFC3339(objectMap, "editTime", a.EditTime) + populate(objectMap, "messageBody", a.MessageBody) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "metadata", a.Metadata) + populate(objectMap, "senderCommunicationIdentifier", a.SenderCommunicationIdentifier) + populate(objectMap, "senderDisplayName", a.SenderDisplayName) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "type", a.Type) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatMessageEditedInThreadEventData. +func (a *AcsChatMessageEditedInThreadEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "composeTime": + err = unpopulateDateTimeRFC3339(val, "ComposeTime", &a.ComposeTime) + delete(rawMsg, key) + case "editTime": + err = unpopulateDateTimeRFC3339(val, "EditTime", &a.EditTime) + delete(rawMsg, key) + case "messageBody": + err = unpopulate(val, "MessageBody", &a.MessageBody) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "senderCommunicationIdentifier": + err = unpopulate(val, "SenderCommunicationIdentifier", &a.SenderCommunicationIdentifier) + delete(rawMsg, key) + case "senderDisplayName": + err = unpopulate(val, "SenderDisplayName", &a.SenderDisplayName) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatMessageEventBaseProperties. +func (a AcsChatMessageEventBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "composeTime", a.ComposeTime) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "senderCommunicationIdentifier", a.SenderCommunicationIdentifier) + populate(objectMap, "senderDisplayName", a.SenderDisplayName) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "type", a.Type) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatMessageEventBaseProperties. +func (a *AcsChatMessageEventBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "composeTime": + err = unpopulateDateTimeRFC3339(val, "ComposeTime", &a.ComposeTime) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "senderCommunicationIdentifier": + err = unpopulate(val, "SenderCommunicationIdentifier", &a.SenderCommunicationIdentifier) + delete(rawMsg, key) + case "senderDisplayName": + err = unpopulate(val, "SenderDisplayName", &a.SenderDisplayName) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatMessageEventInThreadBaseProperties. +func (a AcsChatMessageEventInThreadBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "composeTime", a.ComposeTime) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "senderCommunicationIdentifier", a.SenderCommunicationIdentifier) + populate(objectMap, "senderDisplayName", a.SenderDisplayName) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "type", a.Type) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatMessageEventInThreadBaseProperties. +func (a *AcsChatMessageEventInThreadBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "composeTime": + err = unpopulateDateTimeRFC3339(val, "ComposeTime", &a.ComposeTime) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "senderCommunicationIdentifier": + err = unpopulate(val, "SenderCommunicationIdentifier", &a.SenderCommunicationIdentifier) + delete(rawMsg, key) + case "senderDisplayName": + err = unpopulate(val, "SenderDisplayName", &a.SenderDisplayName) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatMessageReceivedEventData. +func (a AcsChatMessageReceivedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "composeTime", a.ComposeTime) + populate(objectMap, "messageBody", a.MessageBody) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "metadata", a.Metadata) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "senderCommunicationIdentifier", a.SenderCommunicationIdentifier) + populate(objectMap, "senderDisplayName", a.SenderDisplayName) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "type", a.Type) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatMessageReceivedEventData. +func (a *AcsChatMessageReceivedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "composeTime": + err = unpopulateDateTimeRFC3339(val, "ComposeTime", &a.ComposeTime) + delete(rawMsg, key) + case "messageBody": + err = unpopulate(val, "MessageBody", &a.MessageBody) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "senderCommunicationIdentifier": + err = unpopulate(val, "SenderCommunicationIdentifier", &a.SenderCommunicationIdentifier) + delete(rawMsg, key) + case "senderDisplayName": + err = unpopulate(val, "SenderDisplayName", &a.SenderDisplayName) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatMessageReceivedInThreadEventData. +func (a AcsChatMessageReceivedInThreadEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "composeTime", a.ComposeTime) + populate(objectMap, "messageBody", a.MessageBody) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "metadata", a.Metadata) + populate(objectMap, "senderCommunicationIdentifier", a.SenderCommunicationIdentifier) + populate(objectMap, "senderDisplayName", a.SenderDisplayName) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "type", a.Type) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatMessageReceivedInThreadEventData. +func (a *AcsChatMessageReceivedInThreadEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "composeTime": + err = unpopulateDateTimeRFC3339(val, "ComposeTime", &a.ComposeTime) + delete(rawMsg, key) + case "messageBody": + err = unpopulate(val, "MessageBody", &a.MessageBody) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "senderCommunicationIdentifier": + err = unpopulate(val, "SenderCommunicationIdentifier", &a.SenderCommunicationIdentifier) + delete(rawMsg, key) + case "senderDisplayName": + err = unpopulate(val, "SenderDisplayName", &a.SenderDisplayName) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatParticipantAddedToThreadEventData. +func (a AcsChatParticipantAddedToThreadEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addedByCommunicationIdentifier", a.AddedByCommunicationIdentifier) + populate(objectMap, "participantAdded", a.ParticipantAdded) + populate(objectMap, "threadId", a.ThreadID) + populateDateTimeRFC3339(objectMap, "time", a.Time) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatParticipantAddedToThreadEventData. +func (a *AcsChatParticipantAddedToThreadEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addedByCommunicationIdentifier": + err = unpopulate(val, "AddedByCommunicationIdentifier", &a.AddedByCommunicationIdentifier) + delete(rawMsg, key) + case "participantAdded": + err = unpopulate(val, "ParticipantAdded", &a.ParticipantAdded) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "time": + err = unpopulateDateTimeRFC3339(val, "Time", &a.Time) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatParticipantAddedToThreadWithUserEventData. +func (a AcsChatParticipantAddedToThreadWithUserEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addedByCommunicationIdentifier", a.AddedByCommunicationIdentifier) + populateDateTimeRFC3339(objectMap, "createTime", a.CreateTime) + populate(objectMap, "participantAdded", a.ParticipantAdded) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "threadId", a.ThreadID) + populateDateTimeRFC3339(objectMap, "time", a.Time) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatParticipantAddedToThreadWithUserEventData. +func (a *AcsChatParticipantAddedToThreadWithUserEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addedByCommunicationIdentifier": + err = unpopulate(val, "AddedByCommunicationIdentifier", &a.AddedByCommunicationIdentifier) + delete(rawMsg, key) + case "createTime": + err = unpopulateDateTimeRFC3339(val, "CreateTime", &a.CreateTime) + delete(rawMsg, key) + case "participantAdded": + err = unpopulate(val, "ParticipantAdded", &a.ParticipantAdded) + delete(rawMsg, key) + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "time": + err = unpopulateDateTimeRFC3339(val, "Time", &a.Time) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatParticipantRemovedFromThreadEventData. +func (a AcsChatParticipantRemovedFromThreadEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "participantRemoved", a.ParticipantRemoved) + populate(objectMap, "removedByCommunicationIdentifier", a.RemovedByCommunicationIdentifier) + populate(objectMap, "threadId", a.ThreadID) + populateDateTimeRFC3339(objectMap, "time", a.Time) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatParticipantRemovedFromThreadEventData. +func (a *AcsChatParticipantRemovedFromThreadEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "participantRemoved": + err = unpopulate(val, "ParticipantRemoved", &a.ParticipantRemoved) + delete(rawMsg, key) + case "removedByCommunicationIdentifier": + err = unpopulate(val, "RemovedByCommunicationIdentifier", &a.RemovedByCommunicationIdentifier) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "time": + err = unpopulateDateTimeRFC3339(val, "Time", &a.Time) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatParticipantRemovedFromThreadWithUserEventData. +func (a AcsChatParticipantRemovedFromThreadWithUserEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createTime", a.CreateTime) + populate(objectMap, "participantRemoved", a.ParticipantRemoved) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "removedByCommunicationIdentifier", a.RemovedByCommunicationIdentifier) + populate(objectMap, "threadId", a.ThreadID) + populateDateTimeRFC3339(objectMap, "time", a.Time) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatParticipantRemovedFromThreadWithUserEventData. +func (a *AcsChatParticipantRemovedFromThreadWithUserEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createTime": + err = unpopulateDateTimeRFC3339(val, "CreateTime", &a.CreateTime) + delete(rawMsg, key) + case "participantRemoved": + err = unpopulate(val, "ParticipantRemoved", &a.ParticipantRemoved) + delete(rawMsg, key) + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "removedByCommunicationIdentifier": + err = unpopulate(val, "RemovedByCommunicationIdentifier", &a.RemovedByCommunicationIdentifier) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "time": + err = unpopulateDateTimeRFC3339(val, "Time", &a.Time) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatThreadCreatedEventData. +func (a AcsChatThreadCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createTime", a.CreateTime) + populate(objectMap, "createdByCommunicationIdentifier", a.CreatedByCommunicationIdentifier) + populate(objectMap, "participants", a.Participants) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatThreadCreatedEventData. +func (a *AcsChatThreadCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createTime": + err = unpopulateDateTimeRFC3339(val, "CreateTime", &a.CreateTime) + delete(rawMsg, key) + case "createdByCommunicationIdentifier": + err = unpopulate(val, "CreatedByCommunicationIdentifier", &a.CreatedByCommunicationIdentifier) + delete(rawMsg, key) + case "participants": + err = unpopulate(val, "Participants", &a.Participants) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatThreadCreatedWithUserEventData. +func (a AcsChatThreadCreatedWithUserEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createTime", a.CreateTime) + populate(objectMap, "createdByCommunicationIdentifier", a.CreatedByCommunicationIdentifier) + populate(objectMap, "metadata", a.Metadata) + populate(objectMap, "participants", a.Participants) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatThreadCreatedWithUserEventData. +func (a *AcsChatThreadCreatedWithUserEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createTime": + err = unpopulateDateTimeRFC3339(val, "CreateTime", &a.CreateTime) + delete(rawMsg, key) + case "createdByCommunicationIdentifier": + err = unpopulate(val, "CreatedByCommunicationIdentifier", &a.CreatedByCommunicationIdentifier) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "participants": + err = unpopulate(val, "Participants", &a.Participants) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatThreadDeletedEventData. +func (a AcsChatThreadDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createTime", a.CreateTime) + populateDateTimeRFC3339(objectMap, "deleteTime", a.DeleteTime) + populate(objectMap, "deletedByCommunicationIdentifier", a.DeletedByCommunicationIdentifier) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatThreadDeletedEventData. +func (a *AcsChatThreadDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createTime": + err = unpopulateDateTimeRFC3339(val, "CreateTime", &a.CreateTime) + delete(rawMsg, key) + case "deleteTime": + err = unpopulateDateTimeRFC3339(val, "DeleteTime", &a.DeleteTime) + delete(rawMsg, key) + case "deletedByCommunicationIdentifier": + err = unpopulate(val, "DeletedByCommunicationIdentifier", &a.DeletedByCommunicationIdentifier) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatThreadEventBaseProperties. +func (a AcsChatThreadEventBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createTime", a.CreateTime) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatThreadEventBaseProperties. +func (a *AcsChatThreadEventBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createTime": + err = unpopulateDateTimeRFC3339(val, "CreateTime", &a.CreateTime) + delete(rawMsg, key) + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatThreadEventInThreadBaseProperties. +func (a AcsChatThreadEventInThreadBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createTime", a.CreateTime) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatThreadEventInThreadBaseProperties. +func (a *AcsChatThreadEventInThreadBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createTime": + err = unpopulateDateTimeRFC3339(val, "CreateTime", &a.CreateTime) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatThreadParticipantProperties. +func (a AcsChatThreadParticipantProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "metadata", a.Metadata) + populate(objectMap, "participantCommunicationIdentifier", a.ParticipantCommunicationIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatThreadParticipantProperties. +func (a *AcsChatThreadParticipantProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "participantCommunicationIdentifier": + err = unpopulate(val, "ParticipantCommunicationIdentifier", &a.ParticipantCommunicationIdentifier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatThreadPropertiesUpdatedEventData. +func (a AcsChatThreadPropertiesUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createTime", a.CreateTime) + populateDateTimeRFC3339(objectMap, "editTime", a.EditTime) + populate(objectMap, "editedByCommunicationIdentifier", a.EditedByCommunicationIdentifier) + populate(objectMap, "metadata", a.Metadata) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatThreadPropertiesUpdatedEventData. +func (a *AcsChatThreadPropertiesUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createTime": + err = unpopulateDateTimeRFC3339(val, "CreateTime", &a.CreateTime) + delete(rawMsg, key) + case "editTime": + err = unpopulateDateTimeRFC3339(val, "EditTime", &a.EditTime) + delete(rawMsg, key) + case "editedByCommunicationIdentifier": + err = unpopulate(val, "EditedByCommunicationIdentifier", &a.EditedByCommunicationIdentifier) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatThreadPropertiesUpdatedPerUserEventData. +func (a AcsChatThreadPropertiesUpdatedPerUserEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createTime", a.CreateTime) + populateDateTimeRFC3339(objectMap, "editTime", a.EditTime) + populate(objectMap, "editedByCommunicationIdentifier", a.EditedByCommunicationIdentifier) + populate(objectMap, "metadata", a.Metadata) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatThreadPropertiesUpdatedPerUserEventData. +func (a *AcsChatThreadPropertiesUpdatedPerUserEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createTime": + err = unpopulateDateTimeRFC3339(val, "CreateTime", &a.CreateTime) + delete(rawMsg, key) + case "editTime": + err = unpopulateDateTimeRFC3339(val, "EditTime", &a.EditTime) + delete(rawMsg, key) + case "editedByCommunicationIdentifier": + err = unpopulate(val, "EditedByCommunicationIdentifier", &a.EditedByCommunicationIdentifier) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsChatThreadWithUserDeletedEventData. +func (a AcsChatThreadWithUserDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createTime", a.CreateTime) + populateDateTimeRFC3339(objectMap, "deleteTime", a.DeleteTime) + populate(objectMap, "deletedByCommunicationIdentifier", a.DeletedByCommunicationIdentifier) + populate(objectMap, "recipientCommunicationIdentifier", a.RecipientCommunicationIdentifier) + populate(objectMap, "threadId", a.ThreadID) + populate(objectMap, "transactionId", a.TransactionID) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsChatThreadWithUserDeletedEventData. +func (a *AcsChatThreadWithUserDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createTime": + err = unpopulateDateTimeRFC3339(val, "CreateTime", &a.CreateTime) + delete(rawMsg, key) + case "deleteTime": + err = unpopulateDateTimeRFC3339(val, "DeleteTime", &a.DeleteTime) + delete(rawMsg, key) + case "deletedByCommunicationIdentifier": + err = unpopulate(val, "DeletedByCommunicationIdentifier", &a.DeletedByCommunicationIdentifier) + delete(rawMsg, key) + case "recipientCommunicationIdentifier": + err = unpopulate(val, "RecipientCommunicationIdentifier", &a.RecipientCommunicationIdentifier) + delete(rawMsg, key) + case "threadId": + err = unpopulate(val, "ThreadID", &a.ThreadID) + delete(rawMsg, key) + case "transactionId": + err = unpopulate(val, "TransactionID", &a.TransactionID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &a.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsEmailDeliveryReportReceivedEventData. +func (a AcsEmailDeliveryReportReceivedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "deliveryAttemptTimeStamp", a.DeliveryAttemptTimestamp) + populate(objectMap, "deliveryStatusDetails", a.DeliveryStatusDetails) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "recipient", a.Recipient) + populate(objectMap, "sender", a.Sender) + populate(objectMap, "status", a.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsEmailDeliveryReportReceivedEventData. +func (a *AcsEmailDeliveryReportReceivedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deliveryAttemptTimeStamp": + err = unpopulateDateTimeRFC3339(val, "DeliveryAttemptTimestamp", &a.DeliveryAttemptTimestamp) + delete(rawMsg, key) + case "deliveryStatusDetails": + err = unpopulate(val, "DeliveryStatusDetails", &a.DeliveryStatusDetails) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "recipient": + err = unpopulate(val, "Recipient", &a.Recipient) + delete(rawMsg, key) + case "sender": + err = unpopulate(val, "Sender", &a.Sender) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsEmailDeliveryReportStatusDetails. +func (a AcsEmailDeliveryReportStatusDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "statusMessage", a.StatusMessage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsEmailDeliveryReportStatusDetails. +func (a *AcsEmailDeliveryReportStatusDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "statusMessage": + err = unpopulate(val, "StatusMessage", &a.StatusMessage) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsEmailEngagementTrackingReportReceivedEventData. +func (a AcsEmailEngagementTrackingReportReceivedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "engagementType", a.Engagement) + populate(objectMap, "engagementContext", a.EngagementContext) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "recipient", a.Recipient) + populate(objectMap, "sender", a.Sender) + populateDateTimeRFC3339(objectMap, "userActionTimeStamp", a.UserActionTimestamp) + populate(objectMap, "userAgent", a.UserAgent) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsEmailEngagementTrackingReportReceivedEventData. +func (a *AcsEmailEngagementTrackingReportReceivedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "engagementType": + err = unpopulate(val, "Engagement", &a.Engagement) + delete(rawMsg, key) + case "engagementContext": + err = unpopulate(val, "EngagementContext", &a.EngagementContext) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "recipient": + err = unpopulate(val, "Recipient", &a.Recipient) + delete(rawMsg, key) + case "sender": + err = unpopulate(val, "Sender", &a.Sender) + delete(rawMsg, key) + case "userActionTimeStamp": + err = unpopulateDateTimeRFC3339(val, "UserActionTimestamp", &a.UserActionTimestamp) + delete(rawMsg, key) + case "userAgent": + err = unpopulate(val, "UserAgent", &a.UserAgent) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsIncomingCallCustomContext. +func (a AcsIncomingCallCustomContext) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sipHeaders", a.SipHeaders) + populate(objectMap, "voipHeaders", a.VoipHeaders) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsIncomingCallCustomContext. +func (a *AcsIncomingCallCustomContext) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "sipHeaders": + err = unpopulate(val, "SipHeaders", &a.SipHeaders) + delete(rawMsg, key) + case "voipHeaders": + err = unpopulate(val, "VoipHeaders", &a.VoipHeaders) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsIncomingCallEventData. +func (a AcsIncomingCallEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "callerDisplayName", a.CallerDisplayName) + populate(objectMap, "correlationId", a.CorrelationID) + populate(objectMap, "customContext", a.CustomContext) + populate(objectMap, "from", a.FromCommunicationIdentifier) + populate(objectMap, "incomingCallContext", a.IncomingCallContext) + populate(objectMap, "serverCallId", a.ServerCallID) + populate(objectMap, "to", a.ToCommunicationIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsIncomingCallEventData. +func (a *AcsIncomingCallEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "callerDisplayName": + err = unpopulate(val, "CallerDisplayName", &a.CallerDisplayName) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &a.CorrelationID) + delete(rawMsg, key) + case "customContext": + err = unpopulate(val, "CustomContext", &a.CustomContext) + delete(rawMsg, key) + case "from": + err = unpopulate(val, "FromCommunicationIdentifier", &a.FromCommunicationIdentifier) + delete(rawMsg, key) + case "incomingCallContext": + err = unpopulate(val, "IncomingCallContext", &a.IncomingCallContext) + delete(rawMsg, key) + case "serverCallId": + err = unpopulate(val, "ServerCallID", &a.ServerCallID) + delete(rawMsg, key) + case "to": + err = unpopulate(val, "ToCommunicationIdentifier", &a.ToCommunicationIdentifier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRecordingChunkInfoProperties. +func (a AcsRecordingChunkInfoProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contentLocation", a.ContentLocation) + populate(objectMap, "deleteLocation", a.DeleteLocation) + populate(objectMap, "documentId", a.DocumentID) + populate(objectMap, "endReason", a.EndReason) + populate(objectMap, "index", a.Index) + populate(objectMap, "metadataLocation", a.MetadataLocation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRecordingChunkInfoProperties. +func (a *AcsRecordingChunkInfoProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contentLocation": + err = unpopulate(val, "ContentLocation", &a.ContentLocation) + delete(rawMsg, key) + case "deleteLocation": + err = unpopulate(val, "DeleteLocation", &a.DeleteLocation) + delete(rawMsg, key) + case "documentId": + err = unpopulate(val, "DocumentID", &a.DocumentID) + delete(rawMsg, key) + case "endReason": + err = unpopulate(val, "EndReason", &a.EndReason) + delete(rawMsg, key) + case "index": + err = unpopulate(val, "Index", &a.Index) + delete(rawMsg, key) + case "metadataLocation": + err = unpopulate(val, "MetadataLocation", &a.MetadataLocation) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRecordingFileStatusUpdatedEventData. +func (a AcsRecordingFileStatusUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "recordingChannelType", a.RecordingChannelType) + populate(objectMap, "recordingContentType", a.RecordingContentType) + populate(objectMap, "recordingDurationMs", a.RecordingDurationMs) + populate(objectMap, "recordingFormatType", a.RecordingFormatType) + populateDateTimeRFC3339(objectMap, "recordingStartTime", a.RecordingStartTime) + populate(objectMap, "recordingStorageInfo", a.RecordingStorageInfo) + populate(objectMap, "sessionEndReason", a.SessionEndReason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRecordingFileStatusUpdatedEventData. +func (a *AcsRecordingFileStatusUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "recordingChannelType": + err = unpopulate(val, "RecordingChannelType", &a.RecordingChannelType) + delete(rawMsg, key) + case "recordingContentType": + err = unpopulate(val, "RecordingContentType", &a.RecordingContentType) + delete(rawMsg, key) + case "recordingDurationMs": + err = unpopulate(val, "RecordingDurationMs", &a.RecordingDurationMs) + delete(rawMsg, key) + case "recordingFormatType": + err = unpopulate(val, "RecordingFormatType", &a.RecordingFormatType) + delete(rawMsg, key) + case "recordingStartTime": + err = unpopulateDateTimeRFC3339(val, "RecordingStartTime", &a.RecordingStartTime) + delete(rawMsg, key) + case "recordingStorageInfo": + err = unpopulate(val, "RecordingStorageInfo", &a.RecordingStorageInfo) + delete(rawMsg, key) + case "sessionEndReason": + err = unpopulate(val, "SessionEndReason", &a.SessionEndReason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRecordingStorageInfoProperties. +func (a AcsRecordingStorageInfoProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "recordingChunks", a.RecordingChunks) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRecordingStorageInfoProperties. +func (a *AcsRecordingStorageInfoProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "recordingChunks": + err = unpopulate(val, "RecordingChunks", &a.RecordingChunks) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterChannelConfiguration. +func (a AcsRouterChannelConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacityCostPerJob", a.CapacityCostPerJob) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "maxNumberOfJobs", a.MaxNumberOfJobs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterChannelConfiguration. +func (a *AcsRouterChannelConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "capacityCostPerJob": + err = unpopulate(val, "CapacityCostPerJob", &a.CapacityCostPerJob) + delete(rawMsg, key) + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "maxNumberOfJobs": + err = unpopulate(val, "MaxNumberOfJobs", &a.MaxNumberOfJobs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterCommunicationError. +func (a AcsRouterCommunicationError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", a.Code) + populate(objectMap, "details", a.Details) + populate(objectMap, "innererror", a.Innererror) + populate(objectMap, "message", a.Message) + populate(objectMap, "target", a.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterCommunicationError. +func (a *AcsRouterCommunicationError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &a.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &a.Details) + delete(rawMsg, key) + case "innererror": + err = unpopulate(val, "Innererror", &a.Innererror) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &a.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &a.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterEventData. +func (a AcsRouterEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterEventData. +func (a *AcsRouterEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobCancelledEventData. +func (a AcsRouterJobCancelledEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "dispositionCode", a.DispositionCode) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "note", a.Note) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobCancelledEventData. +func (a *AcsRouterJobCancelledEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "dispositionCode": + err = unpopulate(val, "DispositionCode", &a.DispositionCode) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "note": + err = unpopulate(val, "Note", &a.Note) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobClassificationFailedEventData. +func (a AcsRouterJobClassificationFailedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "classificationPolicyId", a.ClassificationPolicyID) + populate(objectMap, "errors", a.Errors) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobClassificationFailedEventData. +func (a *AcsRouterJobClassificationFailedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "classificationPolicyId": + err = unpopulate(val, "ClassificationPolicyID", &a.ClassificationPolicyID) + delete(rawMsg, key) + case "errors": + err = unpopulate(val, "Errors", &a.Errors) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobClassifiedEventData. +func (a AcsRouterJobClassifiedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "attachedWorkerSelectors", a.AttachedWorkerSelectors) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "classificationPolicyId", a.ClassificationPolicyID) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "priority", a.Priority) + populate(objectMap, "queueDetails", a.QueueDetails) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobClassifiedEventData. +func (a *AcsRouterJobClassifiedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "attachedWorkerSelectors": + err = unpopulate(val, "AttachedWorkerSelectors", &a.AttachedWorkerSelectors) + delete(rawMsg, key) + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "classificationPolicyId": + err = unpopulate(val, "ClassificationPolicyID", &a.ClassificationPolicyID) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &a.Priority) + delete(rawMsg, key) + case "queueDetails": + err = unpopulate(val, "QueueDetails", &a.QueueDetails) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobClosedEventData. +func (a AcsRouterJobClosedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignmentId", a.AssignmentID) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "dispositionCode", a.DispositionCode) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "workerId", a.WorkerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobClosedEventData. +func (a *AcsRouterJobClosedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignmentId": + err = unpopulate(val, "AssignmentID", &a.AssignmentID) + delete(rawMsg, key) + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "dispositionCode": + err = unpopulate(val, "DispositionCode", &a.DispositionCode) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobCompletedEventData. +func (a AcsRouterJobCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignmentId", a.AssignmentID) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "workerId", a.WorkerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobCompletedEventData. +func (a *AcsRouterJobCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignmentId": + err = unpopulate(val, "AssignmentID", &a.AssignmentID) + delete(rawMsg, key) + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobDeletedEventData. +func (a AcsRouterJobDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobDeletedEventData. +func (a *AcsRouterJobDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobEventData. +func (a AcsRouterJobEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobEventData. +func (a *AcsRouterJobEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobExceptionTriggeredEventData. +func (a AcsRouterJobExceptionTriggeredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "exceptionRuleId", a.ExceptionRuleID) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "ruleKey", a.RuleKey) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobExceptionTriggeredEventData. +func (a *AcsRouterJobExceptionTriggeredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "exceptionRuleId": + err = unpopulate(val, "ExceptionRuleID", &a.ExceptionRuleID) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "ruleKey": + err = unpopulate(val, "RuleKey", &a.RuleKey) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobQueuedEventData. +func (a AcsRouterJobQueuedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "attachedWorkerSelectors", a.AttachedWorkerSelectors) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "priority", a.Priority) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "requestedWorkerSelectors", a.RequestedWorkerSelectors) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobQueuedEventData. +func (a *AcsRouterJobQueuedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "attachedWorkerSelectors": + err = unpopulate(val, "AttachedWorkerSelectors", &a.AttachedWorkerSelectors) + delete(rawMsg, key) + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &a.Priority) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "requestedWorkerSelectors": + err = unpopulate(val, "RequestedWorkerSelectors", &a.RequestedWorkerSelectors) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobReceivedEventData. +func (a AcsRouterJobReceivedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "classificationPolicyId", a.ClassificationPolicyID) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "jobStatus", a.JobStatus) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "priority", a.Priority) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "requestedWorkerSelectors", a.RequestedWorkerSelectors) + populateDateTimeRFC3339(objectMap, "scheduledOn", a.ScheduledOn) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "unavailableForMatching", a.UnavailableForMatching) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobReceivedEventData. +func (a *AcsRouterJobReceivedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "classificationPolicyId": + err = unpopulate(val, "ClassificationPolicyID", &a.ClassificationPolicyID) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "jobStatus": + err = unpopulate(val, "JobStatus", &a.JobStatus) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &a.Priority) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "requestedWorkerSelectors": + err = unpopulate(val, "RequestedWorkerSelectors", &a.RequestedWorkerSelectors) + delete(rawMsg, key) + case "scheduledOn": + err = unpopulateDateTimeRFC3339(val, "ScheduledOn", &a.ScheduledOn) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "unavailableForMatching": + err = unpopulate(val, "UnavailableForMatching", &a.UnavailableForMatching) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobSchedulingFailedEventData. +func (a AcsRouterJobSchedulingFailedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "expiredAttachedWorkerSelectors", a.ExpiredAttachedWorkerSelectors) + populate(objectMap, "expiredRequestedWorkerSelectors", a.ExpiredRequestedWorkerSelectors) + populate(objectMap, "failureReason", a.FailureReason) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "priority", a.Priority) + populate(objectMap, "queueId", a.QueueID) + populateDateTimeRFC3339(objectMap, "scheduledOn", a.ScheduledOn) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobSchedulingFailedEventData. +func (a *AcsRouterJobSchedulingFailedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "expiredAttachedWorkerSelectors": + err = unpopulate(val, "ExpiredAttachedWorkerSelectors", &a.ExpiredAttachedWorkerSelectors) + delete(rawMsg, key) + case "expiredRequestedWorkerSelectors": + err = unpopulate(val, "ExpiredRequestedWorkerSelectors", &a.ExpiredRequestedWorkerSelectors) + delete(rawMsg, key) + case "failureReason": + err = unpopulate(val, "FailureReason", &a.FailureReason) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &a.Priority) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "scheduledOn": + err = unpopulateDateTimeRFC3339(val, "ScheduledOn", &a.ScheduledOn) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobUnassignedEventData. +func (a AcsRouterJobUnassignedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignmentId", a.AssignmentID) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "workerId", a.WorkerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobUnassignedEventData. +func (a *AcsRouterJobUnassignedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignmentId": + err = unpopulate(val, "AssignmentID", &a.AssignmentID) + delete(rawMsg, key) + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobWaitingForActivationEventData. +func (a AcsRouterJobWaitingForActivationEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "expiredAttachedWorkerSelectors", a.ExpiredAttachedWorkerSelectors) + populate(objectMap, "expiredRequestedWorkerSelectors", a.ExpiredRequestedWorkerSelectors) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "priority", a.Priority) + populate(objectMap, "queueId", a.QueueID) + populateDateTimeRFC3339(objectMap, "scheduledOn", a.ScheduledOn) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "unavailableForMatching", a.UnavailableForMatching) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobWaitingForActivationEventData. +func (a *AcsRouterJobWaitingForActivationEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "expiredAttachedWorkerSelectors": + err = unpopulate(val, "ExpiredAttachedWorkerSelectors", &a.ExpiredAttachedWorkerSelectors) + delete(rawMsg, key) + case "expiredRequestedWorkerSelectors": + err = unpopulate(val, "ExpiredRequestedWorkerSelectors", &a.ExpiredRequestedWorkerSelectors) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &a.Priority) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "scheduledOn": + err = unpopulateDateTimeRFC3339(val, "ScheduledOn", &a.ScheduledOn) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "unavailableForMatching": + err = unpopulate(val, "UnavailableForMatching", &a.UnavailableForMatching) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterJobWorkerSelectorsExpiredEventData. +func (a AcsRouterJobWorkerSelectorsExpiredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "expiredAttachedWorkerSelectors", a.ExpiredAttachedWorkerSelectors) + populate(objectMap, "expiredRequestedWorkerSelectors", a.ExpiredRequestedWorkerSelectors) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterJobWorkerSelectorsExpiredEventData. +func (a *AcsRouterJobWorkerSelectorsExpiredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "expiredAttachedWorkerSelectors": + err = unpopulate(val, "ExpiredAttachedWorkerSelectors", &a.ExpiredAttachedWorkerSelectors) + delete(rawMsg, key) + case "expiredRequestedWorkerSelectors": + err = unpopulate(val, "ExpiredRequestedWorkerSelectors", &a.ExpiredRequestedWorkerSelectors) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterQueueDetails. +func (a AcsRouterQueueDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "name", a.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterQueueDetails. +func (a *AcsRouterQueueDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterWorkerDeletedEventData. +func (a AcsRouterWorkerDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "workerId", a.WorkerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterWorkerDeletedEventData. +func (a *AcsRouterWorkerDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterWorkerDeregisteredEventData. +func (a AcsRouterWorkerDeregisteredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "workerId", a.WorkerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterWorkerDeregisteredEventData. +func (a *AcsRouterWorkerDeregisteredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterWorkerEventData. +func (a AcsRouterWorkerEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "workerId", a.WorkerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterWorkerEventData. +func (a *AcsRouterWorkerEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterWorkerOfferAcceptedEventData. +func (a AcsRouterWorkerOfferAcceptedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignmentId", a.AssignmentID) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "jobLabels", a.JobLabels) + populate(objectMap, "jobPriority", a.JobPriority) + populate(objectMap, "jobTags", a.JobTags) + populate(objectMap, "offerId", a.OfferID) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "workerId", a.WorkerID) + populate(objectMap, "workerLabels", a.WorkerLabels) + populate(objectMap, "workerTags", a.WorkerTags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterWorkerOfferAcceptedEventData. +func (a *AcsRouterWorkerOfferAcceptedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignmentId": + err = unpopulate(val, "AssignmentID", &a.AssignmentID) + delete(rawMsg, key) + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "jobLabels": + err = unpopulate(val, "JobLabels", &a.JobLabels) + delete(rawMsg, key) + case "jobPriority": + err = unpopulate(val, "JobPriority", &a.JobPriority) + delete(rawMsg, key) + case "jobTags": + err = unpopulate(val, "JobTags", &a.JobTags) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &a.OfferID) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + case "workerLabels": + err = unpopulate(val, "WorkerLabels", &a.WorkerLabels) + delete(rawMsg, key) + case "workerTags": + err = unpopulate(val, "WorkerTags", &a.WorkerTags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterWorkerOfferDeclinedEventData. +func (a AcsRouterWorkerOfferDeclinedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "offerId", a.OfferID) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "workerId", a.WorkerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterWorkerOfferDeclinedEventData. +func (a *AcsRouterWorkerOfferDeclinedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &a.OfferID) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterWorkerOfferExpiredEventData. +func (a AcsRouterWorkerOfferExpiredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "offerId", a.OfferID) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "workerId", a.WorkerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterWorkerOfferExpiredEventData. +func (a *AcsRouterWorkerOfferExpiredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &a.OfferID) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterWorkerOfferIssuedEventData. +func (a AcsRouterWorkerOfferIssuedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populateDateTimeRFC3339(objectMap, "expiresOn", a.ExpiresOn) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "jobLabels", a.JobLabels) + populate(objectMap, "jobPriority", a.JobPriority) + populate(objectMap, "jobTags", a.JobTags) + populate(objectMap, "offerId", a.OfferID) + populateDateTimeRFC3339(objectMap, "offeredOn", a.OfferedOn) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "workerId", a.WorkerID) + populate(objectMap, "workerLabels", a.WorkerLabels) + populate(objectMap, "workerTags", a.WorkerTags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterWorkerOfferIssuedEventData. +func (a *AcsRouterWorkerOfferIssuedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "expiresOn": + err = unpopulateDateTimeRFC3339(val, "ExpiresOn", &a.ExpiresOn) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "jobLabels": + err = unpopulate(val, "JobLabels", &a.JobLabels) + delete(rawMsg, key) + case "jobPriority": + err = unpopulate(val, "JobPriority", &a.JobPriority) + delete(rawMsg, key) + case "jobTags": + err = unpopulate(val, "JobTags", &a.JobTags) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &a.OfferID) + delete(rawMsg, key) + case "offeredOn": + err = unpopulateDateTimeRFC3339(val, "OfferedOn", &a.OfferedOn) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + case "workerLabels": + err = unpopulate(val, "WorkerLabels", &a.WorkerLabels) + delete(rawMsg, key) + case "workerTags": + err = unpopulate(val, "WorkerTags", &a.WorkerTags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterWorkerOfferRevokedEventData. +func (a AcsRouterWorkerOfferRevokedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelId", a.ChannelID) + populate(objectMap, "channelReference", a.ChannelReference) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "offerId", a.OfferID) + populate(objectMap, "queueId", a.QueueID) + populate(objectMap, "workerId", a.WorkerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterWorkerOfferRevokedEventData. +func (a *AcsRouterWorkerOfferRevokedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelId": + err = unpopulate(val, "ChannelID", &a.ChannelID) + delete(rawMsg, key) + case "channelReference": + err = unpopulate(val, "ChannelReference", &a.ChannelReference) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &a.OfferID) + delete(rawMsg, key) + case "queueId": + err = unpopulate(val, "QueueID", &a.QueueID) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterWorkerRegisteredEventData. +func (a AcsRouterWorkerRegisteredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelConfigurations", a.ChannelConfigurations) + populate(objectMap, "labels", a.Labels) + populate(objectMap, "queueAssignments", a.QueueAssignments) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "totalCapacity", a.TotalCapacity) + populate(objectMap, "workerId", a.WorkerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterWorkerRegisteredEventData. +func (a *AcsRouterWorkerRegisteredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelConfigurations": + err = unpopulate(val, "ChannelConfigurations", &a.ChannelConfigurations) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &a.Labels) + delete(rawMsg, key) + case "queueAssignments": + err = unpopulate(val, "QueueAssignments", &a.QueueAssignments) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "totalCapacity": + err = unpopulate(val, "TotalCapacity", &a.TotalCapacity) + delete(rawMsg, key) + case "workerId": + err = unpopulate(val, "WorkerID", &a.WorkerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsRouterWorkerSelector. +func (a AcsRouterWorkerSelector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "expirationTime", a.ExpirationTime) + populate(objectMap, "key", a.Key) + populate(objectMap, "labelOperator", a.LabelOperator) + populateAny(objectMap, "labelValue", a.LabelValue) + populate(objectMap, "state", a.State) + populate(objectMap, "ttlSeconds", a.TimeToLive) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsRouterWorkerSelector. +func (a *AcsRouterWorkerSelector) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expirationTime": + err = unpopulateDateTimeRFC3339(val, "ExpirationTime", &a.ExpirationTime) + delete(rawMsg, key) + case "key": + err = unpopulate(val, "Key", &a.Key) + delete(rawMsg, key) + case "labelOperator": + err = unpopulate(val, "LabelOperator", &a.LabelOperator) + delete(rawMsg, key) + case "labelValue": + err = unpopulate(val, "LabelValue", &a.LabelValue) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &a.State) + delete(rawMsg, key) + case "ttlSeconds": + err = unpopulate(val, "TTLSeconds", &a.TimeToLive) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsSmsDeliveryAttemptProperties. +func (a AcsSmsDeliveryAttemptProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "segmentsFailed", a.SegmentsFailed) + populate(objectMap, "segmentsSucceeded", a.SegmentsSucceeded) + populateDateTimeRFC3339(objectMap, "timestamp", a.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsSmsDeliveryAttemptProperties. +func (a *AcsSmsDeliveryAttemptProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "segmentsFailed": + err = unpopulate(val, "SegmentsFailed", &a.SegmentsFailed) + delete(rawMsg, key) + case "segmentsSucceeded": + err = unpopulate(val, "SegmentsSucceeded", &a.SegmentsSucceeded) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &a.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsSmsDeliveryReportReceivedEventData. +func (a AcsSmsDeliveryReportReceivedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deliveryAttempts", a.DeliveryAttempts) + populate(objectMap, "deliveryStatus", a.DeliveryStatus) + populate(objectMap, "deliveryStatusDetails", a.DeliveryStatusDetails) + populate(objectMap, "from", a.From) + populate(objectMap, "messageId", a.MessageID) + populateDateTimeRFC3339(objectMap, "receivedTimestamp", a.ReceivedTimestamp) + populate(objectMap, "tag", a.Tag) + populate(objectMap, "to", a.To) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsSmsDeliveryReportReceivedEventData. +func (a *AcsSmsDeliveryReportReceivedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deliveryAttempts": + err = unpopulate(val, "DeliveryAttempts", &a.DeliveryAttempts) + delete(rawMsg, key) + case "deliveryStatus": + err = unpopulate(val, "DeliveryStatus", &a.DeliveryStatus) + delete(rawMsg, key) + case "deliveryStatusDetails": + err = unpopulate(val, "DeliveryStatusDetails", &a.DeliveryStatusDetails) + delete(rawMsg, key) + case "from": + err = unpopulate(val, "From", &a.From) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "receivedTimestamp": + err = unpopulateDateTimeRFC3339(val, "ReceivedTimestamp", &a.ReceivedTimestamp) + delete(rawMsg, key) + case "tag": + err = unpopulate(val, "Tag", &a.Tag) + delete(rawMsg, key) + case "to": + err = unpopulate(val, "To", &a.To) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsSmsEventBaseProperties. +func (a AcsSmsEventBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "from", a.From) + populate(objectMap, "messageId", a.MessageID) + populate(objectMap, "to", a.To) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsSmsEventBaseProperties. +func (a *AcsSmsEventBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "from": + err = unpopulate(val, "From", &a.From) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "to": + err = unpopulate(val, "To", &a.To) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsSmsReceivedEventData. +func (a AcsSmsReceivedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "from", a.From) + populate(objectMap, "message", a.Message) + populate(objectMap, "messageId", a.MessageID) + populateDateTimeRFC3339(objectMap, "receivedTimestamp", a.ReceivedTimestamp) + populate(objectMap, "to", a.To) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsSmsReceivedEventData. +func (a *AcsSmsReceivedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "from": + err = unpopulate(val, "From", &a.From) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &a.Message) + delete(rawMsg, key) + case "messageId": + err = unpopulate(val, "MessageID", &a.MessageID) + delete(rawMsg, key) + case "receivedTimestamp": + err = unpopulateDateTimeRFC3339(val, "ReceivedTimestamp", &a.ReceivedTimestamp) + delete(rawMsg, key) + case "to": + err = unpopulate(val, "To", &a.To) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AcsUserDisconnectedEventData. +func (a AcsUserDisconnectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "userCommunicationIdentifier", a.UserCommunicationIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AcsUserDisconnectedEventData. +func (a *AcsUserDisconnectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "userCommunicationIdentifier": + err = unpopulate(val, "UserCommunicationIdentifier", &a.UserCommunicationIdentifier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppConfigurationKeyValueDeletedEventData. +func (a AppConfigurationKeyValueDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", a.Etag) + populate(objectMap, "key", a.Key) + populate(objectMap, "label", a.Label) + populate(objectMap, "syncToken", a.SyncToken) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppConfigurationKeyValueDeletedEventData. +func (a *AppConfigurationKeyValueDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &a.Etag) + delete(rawMsg, key) + case "key": + err = unpopulate(val, "Key", &a.Key) + delete(rawMsg, key) + case "label": + err = unpopulate(val, "Label", &a.Label) + delete(rawMsg, key) + case "syncToken": + err = unpopulate(val, "SyncToken", &a.SyncToken) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppConfigurationKeyValueModifiedEventData. +func (a AppConfigurationKeyValueModifiedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", a.Etag) + populate(objectMap, "key", a.Key) + populate(objectMap, "label", a.Label) + populate(objectMap, "syncToken", a.SyncToken) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppConfigurationKeyValueModifiedEventData. +func (a *AppConfigurationKeyValueModifiedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &a.Etag) + delete(rawMsg, key) + case "key": + err = unpopulate(val, "Key", &a.Key) + delete(rawMsg, key) + case "label": + err = unpopulate(val, "Label", &a.Label) + delete(rawMsg, key) + case "syncToken": + err = unpopulate(val, "SyncToken", &a.SyncToken) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppConfigurationSnapshotCreatedEventData. +func (a AppConfigurationSnapshotCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", a.Etag) + populate(objectMap, "name", a.Name) + populate(objectMap, "syncToken", a.SyncToken) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppConfigurationSnapshotCreatedEventData. +func (a *AppConfigurationSnapshotCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &a.Etag) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "syncToken": + err = unpopulate(val, "SyncToken", &a.SyncToken) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppConfigurationSnapshotEventData. +func (a AppConfigurationSnapshotEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", a.Etag) + populate(objectMap, "name", a.Name) + populate(objectMap, "syncToken", a.SyncToken) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppConfigurationSnapshotEventData. +func (a *AppConfigurationSnapshotEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &a.Etag) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "syncToken": + err = unpopulate(val, "SyncToken", &a.SyncToken) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppConfigurationSnapshotModifiedEventData. +func (a AppConfigurationSnapshotModifiedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", a.Etag) + populate(objectMap, "name", a.Name) + populate(objectMap, "syncToken", a.SyncToken) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppConfigurationSnapshotModifiedEventData. +func (a *AppConfigurationSnapshotModifiedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &a.Etag) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "syncToken": + err = unpopulate(val, "SyncToken", &a.SyncToken) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppEventTypeDetail. +func (a AppEventTypeDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", a.Action) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppEventTypeDetail. +func (a *AppEventTypeDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &a.Action) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppServicePlanEventTypeDetail. +func (a AppServicePlanEventTypeDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", a.Action) + populate(objectMap, "stampKind", a.StampKind) + populate(objectMap, "status", a.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppServicePlanEventTypeDetail. +func (a *AppServicePlanEventTypeDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &a.Action) + delete(rawMsg, key) + case "stampKind": + err = unpopulate(val, "StampKind", &a.StampKind) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunicationIdentifierModel. +func (c CommunicationIdentifierModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "communicationUser", c.CommunicationUser) + populate(objectMap, "microsoftTeamsUser", c.MicrosoftTeamsUser) + populate(objectMap, "phoneNumber", c.PhoneNumber) + populate(objectMap, "rawId", c.RawID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunicationIdentifierModel. +func (c *CommunicationIdentifierModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "communicationUser": + err = unpopulate(val, "CommunicationUser", &c.CommunicationUser) + delete(rawMsg, key) + case "microsoftTeamsUser": + err = unpopulate(val, "MicrosoftTeamsUser", &c.MicrosoftTeamsUser) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &c.PhoneNumber) + delete(rawMsg, key) + case "rawId": + err = unpopulate(val, "RawID", &c.RawID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunicationUserIdentifierModel. +func (c CommunicationUserIdentifierModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunicationUserIdentifierModel. +func (c *CommunicationUserIdentifierModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryArtifactEventData. +func (c ContainerRegistryArtifactEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", c.Action) + populate(objectMap, "connectedRegistry", c.ConnectedRegistry) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "target", c.Target) + populateDateTimeRFC3339(objectMap, "timestamp", c.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryArtifactEventData. +func (c *ContainerRegistryArtifactEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &c.Action) + delete(rawMsg, key) + case "connectedRegistry": + err = unpopulate(val, "ConnectedRegistry", &c.ConnectedRegistry) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &c.Target) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &c.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryArtifactEventTarget. +func (c ContainerRegistryArtifactEventTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "digest", c.Digest) + populate(objectMap, "mediaType", c.MediaType) + populate(objectMap, "name", c.Name) + populate(objectMap, "repository", c.Repository) + populate(objectMap, "size", c.Size) + populate(objectMap, "tag", c.Tag) + populate(objectMap, "version", c.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryArtifactEventTarget. +func (c *ContainerRegistryArtifactEventTarget) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "digest": + err = unpopulate(val, "Digest", &c.Digest) + delete(rawMsg, key) + case "mediaType": + err = unpopulate(val, "MediaType", &c.MediaType) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "repository": + err = unpopulate(val, "Repository", &c.Repository) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &c.Size) + delete(rawMsg, key) + case "tag": + err = unpopulate(val, "Tag", &c.Tag) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &c.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryChartDeletedEventData. +func (c ContainerRegistryChartDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", c.Action) + populate(objectMap, "connectedRegistry", c.ConnectedRegistry) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "target", c.Target) + populateDateTimeRFC3339(objectMap, "timestamp", c.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryChartDeletedEventData. +func (c *ContainerRegistryChartDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &c.Action) + delete(rawMsg, key) + case "connectedRegistry": + err = unpopulate(val, "ConnectedRegistry", &c.ConnectedRegistry) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &c.Target) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &c.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryChartPushedEventData. +func (c ContainerRegistryChartPushedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", c.Action) + populate(objectMap, "connectedRegistry", c.ConnectedRegistry) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "target", c.Target) + populateDateTimeRFC3339(objectMap, "timestamp", c.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryChartPushedEventData. +func (c *ContainerRegistryChartPushedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &c.Action) + delete(rawMsg, key) + case "connectedRegistry": + err = unpopulate(val, "ConnectedRegistry", &c.ConnectedRegistry) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &c.Target) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &c.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryEventActor. +func (c ContainerRegistryEventActor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryEventActor. +func (c *ContainerRegistryEventActor) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryEventConnectedRegistry. +func (c ContainerRegistryEventConnectedRegistry) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryEventConnectedRegistry. +func (c *ContainerRegistryEventConnectedRegistry) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryEventData. +func (c ContainerRegistryEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", c.Action) + populate(objectMap, "actor", c.Actor) + populate(objectMap, "connectedRegistry", c.ConnectedRegistry) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "request", c.Request) + populate(objectMap, "source", c.Source) + populate(objectMap, "target", c.Target) + populateDateTimeRFC3339(objectMap, "timestamp", c.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryEventData. +func (c *ContainerRegistryEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &c.Action) + delete(rawMsg, key) + case "actor": + err = unpopulate(val, "Actor", &c.Actor) + delete(rawMsg, key) + case "connectedRegistry": + err = unpopulate(val, "ConnectedRegistry", &c.ConnectedRegistry) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "request": + err = unpopulate(val, "Request", &c.Request) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &c.Source) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &c.Target) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &c.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryEventRequest. +func (c ContainerRegistryEventRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addr", c.Addr) + populate(objectMap, "host", c.Host) + populate(objectMap, "id", c.ID) + populate(objectMap, "method", c.Method) + populate(objectMap, "useragent", c.Useragent) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryEventRequest. +func (c *ContainerRegistryEventRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addr": + err = unpopulate(val, "Addr", &c.Addr) + delete(rawMsg, key) + case "host": + err = unpopulate(val, "Host", &c.Host) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "method": + err = unpopulate(val, "Method", &c.Method) + delete(rawMsg, key) + case "useragent": + err = unpopulate(val, "Useragent", &c.Useragent) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryEventSource. +func (c ContainerRegistryEventSource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addr", c.Addr) + populate(objectMap, "instanceID", c.InstanceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryEventSource. +func (c *ContainerRegistryEventSource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addr": + err = unpopulate(val, "Addr", &c.Addr) + delete(rawMsg, key) + case "instanceID": + err = unpopulate(val, "InstanceID", &c.InstanceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryEventTarget. +func (c ContainerRegistryEventTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "digest", c.Digest) + populate(objectMap, "length", c.Length) + populate(objectMap, "mediaType", c.MediaType) + populate(objectMap, "repository", c.Repository) + populate(objectMap, "size", c.Size) + populate(objectMap, "tag", c.Tag) + populate(objectMap, "url", c.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryEventTarget. +func (c *ContainerRegistryEventTarget) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "digest": + err = unpopulate(val, "Digest", &c.Digest) + delete(rawMsg, key) + case "length": + err = unpopulate(val, "Length", &c.Length) + delete(rawMsg, key) + case "mediaType": + err = unpopulate(val, "MediaType", &c.MediaType) + delete(rawMsg, key) + case "repository": + err = unpopulate(val, "Repository", &c.Repository) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &c.Size) + delete(rawMsg, key) + case "tag": + err = unpopulate(val, "Tag", &c.Tag) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &c.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryImageDeletedEventData. +func (c ContainerRegistryImageDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", c.Action) + populate(objectMap, "actor", c.Actor) + populate(objectMap, "connectedRegistry", c.ConnectedRegistry) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "request", c.Request) + populate(objectMap, "source", c.Source) + populate(objectMap, "target", c.Target) + populateDateTimeRFC3339(objectMap, "timestamp", c.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryImageDeletedEventData. +func (c *ContainerRegistryImageDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &c.Action) + delete(rawMsg, key) + case "actor": + err = unpopulate(val, "Actor", &c.Actor) + delete(rawMsg, key) + case "connectedRegistry": + err = unpopulate(val, "ConnectedRegistry", &c.ConnectedRegistry) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "request": + err = unpopulate(val, "Request", &c.Request) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &c.Source) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &c.Target) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &c.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerRegistryImagePushedEventData. +func (c ContainerRegistryImagePushedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", c.Action) + populate(objectMap, "actor", c.Actor) + populate(objectMap, "connectedRegistry", c.ConnectedRegistry) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "request", c.Request) + populate(objectMap, "source", c.Source) + populate(objectMap, "target", c.Target) + populateDateTimeRFC3339(objectMap, "timestamp", c.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRegistryImagePushedEventData. +func (c *ContainerRegistryImagePushedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &c.Action) + delete(rawMsg, key) + case "actor": + err = unpopulate(val, "Actor", &c.Actor) + delete(rawMsg, key) + case "connectedRegistry": + err = unpopulate(val, "ConnectedRegistry", &c.ConnectedRegistry) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "request": + err = unpopulate(val, "Request", &c.Request) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &c.Source) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &c.Target) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &c.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerServiceClusterSupportEndedEventData. +func (c ContainerServiceClusterSupportEndedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kubernetesVersion", c.KubernetesVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerServiceClusterSupportEndedEventData. +func (c *ContainerServiceClusterSupportEndedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kubernetesVersion": + err = unpopulate(val, "KubernetesVersion", &c.KubernetesVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerServiceClusterSupportEndingEventData. +func (c ContainerServiceClusterSupportEndingEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kubernetesVersion", c.KubernetesVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerServiceClusterSupportEndingEventData. +func (c *ContainerServiceClusterSupportEndingEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kubernetesVersion": + err = unpopulate(val, "KubernetesVersion", &c.KubernetesVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerServiceClusterSupportEventData. +func (c ContainerServiceClusterSupportEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kubernetesVersion", c.KubernetesVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerServiceClusterSupportEventData. +func (c *ContainerServiceClusterSupportEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kubernetesVersion": + err = unpopulate(val, "KubernetesVersion", &c.KubernetesVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerServiceNewKubernetesVersionAvailableEventData. +func (c ContainerServiceNewKubernetesVersionAvailableEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "latestPreviewKubernetesVersion", c.LatestPreviewKubernetesVersion) + populate(objectMap, "latestStableKubernetesVersion", c.LatestStableKubernetesVersion) + populate(objectMap, "latestSupportedKubernetesVersion", c.LatestSupportedKubernetesVersion) + populate(objectMap, "lowestMinorKubernetesVersion", c.LowestMinorKubernetesVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerServiceNewKubernetesVersionAvailableEventData. +func (c *ContainerServiceNewKubernetesVersionAvailableEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "latestPreviewKubernetesVersion": + err = unpopulate(val, "LatestPreviewKubernetesVersion", &c.LatestPreviewKubernetesVersion) + delete(rawMsg, key) + case "latestStableKubernetesVersion": + err = unpopulate(val, "LatestStableKubernetesVersion", &c.LatestStableKubernetesVersion) + delete(rawMsg, key) + case "latestSupportedKubernetesVersion": + err = unpopulate(val, "LatestSupportedKubernetesVersion", &c.LatestSupportedKubernetesVersion) + delete(rawMsg, key) + case "lowestMinorKubernetesVersion": + err = unpopulate(val, "LowestMinorKubernetesVersion", &c.LowestMinorKubernetesVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerServiceNodePoolRollingEventData. +func (c ContainerServiceNodePoolRollingEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nodePoolName", c.NodePoolName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerServiceNodePoolRollingEventData. +func (c *ContainerServiceNodePoolRollingEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nodePoolName": + err = unpopulate(val, "NodePoolName", &c.NodePoolName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerServiceNodePoolRollingFailedEventData. +func (c ContainerServiceNodePoolRollingFailedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nodePoolName", c.NodePoolName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerServiceNodePoolRollingFailedEventData. +func (c *ContainerServiceNodePoolRollingFailedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nodePoolName": + err = unpopulate(val, "NodePoolName", &c.NodePoolName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerServiceNodePoolRollingStartedEventData. +func (c ContainerServiceNodePoolRollingStartedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nodePoolName", c.NodePoolName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerServiceNodePoolRollingStartedEventData. +func (c *ContainerServiceNodePoolRollingStartedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nodePoolName": + err = unpopulate(val, "NodePoolName", &c.NodePoolName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerServiceNodePoolRollingSucceededEventData. +func (c ContainerServiceNodePoolRollingSucceededEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nodePoolName", c.NodePoolName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerServiceNodePoolRollingSucceededEventData. +func (c *ContainerServiceNodePoolRollingSucceededEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nodePoolName": + err = unpopulate(val, "NodePoolName", &c.NodePoolName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataBoxCopyCompletedEventData. +func (d DataBoxCopyCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serialNumber", d.SerialNumber) + populate(objectMap, "stageName", d.StageName) + populateDateTimeRFC3339(objectMap, "stageTime", d.StageTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataBoxCopyCompletedEventData. +func (d *DataBoxCopyCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "serialNumber": + err = unpopulate(val, "SerialNumber", &d.SerialNumber) + delete(rawMsg, key) + case "stageName": + err = unpopulate(val, "StageName", &d.StageName) + delete(rawMsg, key) + case "stageTime": + err = unpopulateDateTimeRFC3339(val, "StageTime", &d.StageTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataBoxCopyStartedEventData. +func (d DataBoxCopyStartedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serialNumber", d.SerialNumber) + populate(objectMap, "stageName", d.StageName) + populateDateTimeRFC3339(objectMap, "stageTime", d.StageTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataBoxCopyStartedEventData. +func (d *DataBoxCopyStartedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "serialNumber": + err = unpopulate(val, "SerialNumber", &d.SerialNumber) + delete(rawMsg, key) + case "stageName": + err = unpopulate(val, "StageName", &d.StageName) + delete(rawMsg, key) + case "stageTime": + err = unpopulateDateTimeRFC3339(val, "StageTime", &d.StageTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataBoxOrderCompletedEventData. +func (d DataBoxOrderCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serialNumber", d.SerialNumber) + populate(objectMap, "stageName", d.StageName) + populateDateTimeRFC3339(objectMap, "stageTime", d.StageTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataBoxOrderCompletedEventData. +func (d *DataBoxOrderCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "serialNumber": + err = unpopulate(val, "SerialNumber", &d.SerialNumber) + delete(rawMsg, key) + case "stageName": + err = unpopulate(val, "StageName", &d.StageName) + delete(rawMsg, key) + case "stageTime": + err = unpopulateDateTimeRFC3339(val, "StageTime", &d.StageTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceConnectionStateEventInfo. +func (d DeviceConnectionStateEventInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sequenceNumber", d.SequenceNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceConnectionStateEventInfo. +func (d *DeviceConnectionStateEventInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "sequenceNumber": + err = unpopulate(val, "SequenceNumber", &d.SequenceNumber) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceConnectionStateEventProperties. +func (d DeviceConnectionStateEventProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceConnectionStateEventInfo", d.DeviceConnectionStateEventInfo) + populate(objectMap, "deviceId", d.DeviceID) + populate(objectMap, "hubName", d.HubName) + populate(objectMap, "moduleId", d.ModuleID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceConnectionStateEventProperties. +func (d *DeviceConnectionStateEventProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deviceConnectionStateEventInfo": + err = unpopulate(val, "DeviceConnectionStateEventInfo", &d.DeviceConnectionStateEventInfo) + delete(rawMsg, key) + case "deviceId": + err = unpopulate(val, "DeviceID", &d.DeviceID) + delete(rawMsg, key) + case "hubName": + err = unpopulate(val, "HubName", &d.HubName) + delete(rawMsg, key) + case "moduleId": + err = unpopulate(val, "ModuleID", &d.ModuleID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceLifeCycleEventProperties. +func (d DeviceLifeCycleEventProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceId", d.DeviceID) + populate(objectMap, "hubName", d.HubName) + populate(objectMap, "twin", d.Twin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceLifeCycleEventProperties. +func (d *DeviceLifeCycleEventProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deviceId": + err = unpopulate(val, "DeviceID", &d.DeviceID) + delete(rawMsg, key) + case "hubName": + err = unpopulate(val, "HubName", &d.HubName) + delete(rawMsg, key) + case "twin": + err = unpopulate(val, "Twin", &d.Twin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceTelemetryEventProperties. +func (d DeviceTelemetryEventProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "body", d.Body) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemProperties", d.SystemProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceTelemetryEventProperties. +func (d *DeviceTelemetryEventProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "body": + err = unpopulate(val, "Body", &d.Body) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemProperties": + err = unpopulate(val, "SystemProperties", &d.SystemProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceTwinInfo. +func (d DeviceTwinInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authenticationType", d.AuthenticationType) + populate(objectMap, "cloudToDeviceMessageCount", d.CloudToDeviceMessageCount) + populate(objectMap, "connectionState", d.ConnectionState) + populate(objectMap, "deviceId", d.DeviceID) + populate(objectMap, "etag", d.Etag) + populate(objectMap, "lastActivityTime", d.LastActivityTime) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "status", d.Status) + populate(objectMap, "statusUpdateTime", d.StatusUpdateTime) + populate(objectMap, "version", d.Version) + populate(objectMap, "x509Thumbprint", d.X509Thumbprint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceTwinInfo. +func (d *DeviceTwinInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authenticationType": + err = unpopulate(val, "AuthenticationType", &d.AuthenticationType) + delete(rawMsg, key) + case "cloudToDeviceMessageCount": + err = unpopulate(val, "CloudToDeviceMessageCount", &d.CloudToDeviceMessageCount) + delete(rawMsg, key) + case "connectionState": + err = unpopulate(val, "ConnectionState", &d.ConnectionState) + delete(rawMsg, key) + case "deviceId": + err = unpopulate(val, "DeviceID", &d.DeviceID) + delete(rawMsg, key) + case "etag": + err = unpopulate(val, "Etag", &d.Etag) + delete(rawMsg, key) + case "lastActivityTime": + err = unpopulate(val, "LastActivityTime", &d.LastActivityTime) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &d.Status) + delete(rawMsg, key) + case "statusUpdateTime": + err = unpopulate(val, "StatusUpdateTime", &d.StatusUpdateTime) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) + delete(rawMsg, key) + case "x509Thumbprint": + err = unpopulate(val, "X509Thumbprint", &d.X509Thumbprint) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceTwinInfoProperties. +func (d DeviceTwinInfoProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "desired", d.Desired) + populate(objectMap, "reported", d.Reported) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceTwinInfoProperties. +func (d *DeviceTwinInfoProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "desired": + err = unpopulate(val, "Desired", &d.Desired) + delete(rawMsg, key) + case "reported": + err = unpopulate(val, "Reported", &d.Reported) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceTwinInfoX509Thumbprint. +func (d DeviceTwinInfoX509Thumbprint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "primaryThumbprint", d.PrimaryThumbprint) + populate(objectMap, "secondaryThumbprint", d.SecondaryThumbprint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceTwinInfoX509Thumbprint. +func (d *DeviceTwinInfoX509Thumbprint) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "primaryThumbprint": + err = unpopulate(val, "PrimaryThumbprint", &d.PrimaryThumbprint) + delete(rawMsg, key) + case "secondaryThumbprint": + err = unpopulate(val, "SecondaryThumbprint", &d.SecondaryThumbprint) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceTwinMetadata. +func (d DeviceTwinMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "lastUpdated", d.LastUpdated) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceTwinMetadata. +func (d *DeviceTwinMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "lastUpdated": + err = unpopulate(val, "LastUpdated", &d.LastUpdated) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceTwinProperties. +func (d DeviceTwinProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "metadata", d.Metadata) + populate(objectMap, "version", d.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceTwinProperties. +func (d *DeviceTwinProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "metadata": + err = unpopulate(val, "Metadata", &d.Metadata) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventGridEvent. +func (e EventGridEvent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "data", e.Data) + populate(objectMap, "dataVersion", e.DataVersion) + populateDateTimeRFC3339(objectMap, "eventTime", e.EventTime) + populate(objectMap, "eventType", e.EventType) + populate(objectMap, "id", e.ID) + populate(objectMap, "metadataVersion", e.MetadataVersion) + populate(objectMap, "subject", e.Subject) + populate(objectMap, "topic", e.Topic) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventGridEvent. +func (e *EventGridEvent) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "data": + e.Data = []byte(val) + delete(rawMsg, key) + case "dataVersion": + err = unpopulate(val, "DataVersion", &e.DataVersion) + delete(rawMsg, key) + case "eventTime": + err = unpopulateDateTimeRFC3339(val, "EventTime", &e.EventTime) + delete(rawMsg, key) + case "eventType": + err = unpopulate(val, "EventType", &e.EventType) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "metadataVersion": + err = unpopulate(val, "MetadataVersion", &e.MetadataVersion) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, "Subject", &e.Subject) + delete(rawMsg, key) + case "topic": + err = unpopulate(val, "Topic", &e.Topic) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventGridMQTTClientCreatedOrUpdatedEventData. +func (e EventGridMQTTClientCreatedOrUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "attributes", e.Attributes) + populate(objectMap, "clientAuthenticationName", e.ClientAuthenticationName) + populate(objectMap, "clientName", e.ClientName) + populateDateTimeRFC3339(objectMap, "createdOn", e.CreatedOn) + populate(objectMap, "namespaceName", e.NamespaceName) + populate(objectMap, "state", e.State) + populateDateTimeRFC3339(objectMap, "updatedOn", e.UpdatedOn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventGridMQTTClientCreatedOrUpdatedEventData. +func (e *EventGridMQTTClientCreatedOrUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "attributes": + err = unpopulate(val, "Attributes", &e.Attributes) + delete(rawMsg, key) + case "clientAuthenticationName": + err = unpopulate(val, "ClientAuthenticationName", &e.ClientAuthenticationName) + delete(rawMsg, key) + case "clientName": + err = unpopulate(val, "ClientName", &e.ClientName) + delete(rawMsg, key) + case "createdOn": + err = unpopulateDateTimeRFC3339(val, "CreatedOn", &e.CreatedOn) + delete(rawMsg, key) + case "namespaceName": + err = unpopulate(val, "NamespaceName", &e.NamespaceName) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &e.State) + delete(rawMsg, key) + case "updatedOn": + err = unpopulateDateTimeRFC3339(val, "UpdatedOn", &e.UpdatedOn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventGridMQTTClientDeletedEventData. +func (e EventGridMQTTClientDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientAuthenticationName", e.ClientAuthenticationName) + populate(objectMap, "clientName", e.ClientName) + populate(objectMap, "namespaceName", e.NamespaceName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventGridMQTTClientDeletedEventData. +func (e *EventGridMQTTClientDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientAuthenticationName": + err = unpopulate(val, "ClientAuthenticationName", &e.ClientAuthenticationName) + delete(rawMsg, key) + case "clientName": + err = unpopulate(val, "ClientName", &e.ClientName) + delete(rawMsg, key) + case "namespaceName": + err = unpopulate(val, "NamespaceName", &e.NamespaceName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventGridMQTTClientEventData. +func (e EventGridMQTTClientEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientAuthenticationName", e.ClientAuthenticationName) + populate(objectMap, "clientName", e.ClientName) + populate(objectMap, "namespaceName", e.NamespaceName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventGridMQTTClientEventData. +func (e *EventGridMQTTClientEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientAuthenticationName": + err = unpopulate(val, "ClientAuthenticationName", &e.ClientAuthenticationName) + delete(rawMsg, key) + case "clientName": + err = unpopulate(val, "ClientName", &e.ClientName) + delete(rawMsg, key) + case "namespaceName": + err = unpopulate(val, "NamespaceName", &e.NamespaceName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventGridMQTTClientSessionConnectedEventData. +func (e EventGridMQTTClientSessionConnectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientAuthenticationName", e.ClientAuthenticationName) + populate(objectMap, "clientName", e.ClientName) + populate(objectMap, "clientSessionName", e.ClientSessionName) + populate(objectMap, "namespaceName", e.NamespaceName) + populate(objectMap, "sequenceNumber", e.SequenceNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventGridMQTTClientSessionConnectedEventData. +func (e *EventGridMQTTClientSessionConnectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientAuthenticationName": + err = unpopulate(val, "ClientAuthenticationName", &e.ClientAuthenticationName) + delete(rawMsg, key) + case "clientName": + err = unpopulate(val, "ClientName", &e.ClientName) + delete(rawMsg, key) + case "clientSessionName": + err = unpopulate(val, "ClientSessionName", &e.ClientSessionName) + delete(rawMsg, key) + case "namespaceName": + err = unpopulate(val, "NamespaceName", &e.NamespaceName) + delete(rawMsg, key) + case "sequenceNumber": + err = unpopulate(val, "SequenceNumber", &e.SequenceNumber) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventGridMQTTClientSessionDisconnectedEventData. +func (e EventGridMQTTClientSessionDisconnectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientAuthenticationName", e.ClientAuthenticationName) + populate(objectMap, "clientName", e.ClientName) + populate(objectMap, "clientSessionName", e.ClientSessionName) + populate(objectMap, "disconnectionReason", e.DisconnectionReason) + populate(objectMap, "namespaceName", e.NamespaceName) + populate(objectMap, "sequenceNumber", e.SequenceNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventGridMQTTClientSessionDisconnectedEventData. +func (e *EventGridMQTTClientSessionDisconnectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientAuthenticationName": + err = unpopulate(val, "ClientAuthenticationName", &e.ClientAuthenticationName) + delete(rawMsg, key) + case "clientName": + err = unpopulate(val, "ClientName", &e.ClientName) + delete(rawMsg, key) + case "clientSessionName": + err = unpopulate(val, "ClientSessionName", &e.ClientSessionName) + delete(rawMsg, key) + case "disconnectionReason": + err = unpopulate(val, "DisconnectionReason", &e.DisconnectionReason) + delete(rawMsg, key) + case "namespaceName": + err = unpopulate(val, "NamespaceName", &e.NamespaceName) + delete(rawMsg, key) + case "sequenceNumber": + err = unpopulate(val, "SequenceNumber", &e.SequenceNumber) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventHubCaptureFileCreatedEventData. +func (e EventHubCaptureFileCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eventCount", e.EventCount) + populate(objectMap, "fileType", e.FileType) + populate(objectMap, "fileUrl", e.Fileurl) + populateDateTimeRFC3339(objectMap, "firstEnqueueTime", e.FirstEnqueueTime) + populate(objectMap, "firstSequenceNumber", e.FirstSequenceNumber) + populateDateTimeRFC3339(objectMap, "lastEnqueueTime", e.LastEnqueueTime) + populate(objectMap, "lastSequenceNumber", e.LastSequenceNumber) + populate(objectMap, "partitionId", e.PartitionID) + populate(objectMap, "sizeInBytes", e.SizeInBytes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubCaptureFileCreatedEventData. +func (e *EventHubCaptureFileCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eventCount": + err = unpopulate(val, "EventCount", &e.EventCount) + delete(rawMsg, key) + case "fileType": + err = unpopulate(val, "FileType", &e.FileType) + delete(rawMsg, key) + case "fileUrl": + err = unpopulate(val, "Fileurl", &e.Fileurl) + delete(rawMsg, key) + case "firstEnqueueTime": + err = unpopulateDateTimeRFC3339(val, "FirstEnqueueTime", &e.FirstEnqueueTime) + delete(rawMsg, key) + case "firstSequenceNumber": + err = unpopulate(val, "FirstSequenceNumber", &e.FirstSequenceNumber) + delete(rawMsg, key) + case "lastEnqueueTime": + err = unpopulateDateTimeRFC3339(val, "LastEnqueueTime", &e.LastEnqueueTime) + delete(rawMsg, key) + case "lastSequenceNumber": + err = unpopulate(val, "LastSequenceNumber", &e.LastSequenceNumber) + delete(rawMsg, key) + case "partitionId": + err = unpopulate(val, "PartitionID", &e.PartitionID) + delete(rawMsg, key) + case "sizeInBytes": + err = unpopulate(val, "SizeInBytes", &e.SizeInBytes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthcareDicomImageCreatedEventData. +func (h HealthcareDicomImageCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "imageSeriesInstanceUid", h.ImageSeriesInstanceUID) + populate(objectMap, "imageSopInstanceUid", h.ImageSopInstanceUID) + populate(objectMap, "imageStudyInstanceUid", h.ImageStudyInstanceUID) + populate(objectMap, "partitionName", h.PartitionName) + populate(objectMap, "sequenceNumber", h.SequenceNumber) + populate(objectMap, "serviceHostName", h.ServiceHostName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthcareDicomImageCreatedEventData. +func (h *HealthcareDicomImageCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "imageSeriesInstanceUid": + err = unpopulate(val, "ImageSeriesInstanceUID", &h.ImageSeriesInstanceUID) + delete(rawMsg, key) + case "imageSopInstanceUid": + err = unpopulate(val, "ImageSopInstanceUID", &h.ImageSopInstanceUID) + delete(rawMsg, key) + case "imageStudyInstanceUid": + err = unpopulate(val, "ImageStudyInstanceUID", &h.ImageStudyInstanceUID) + delete(rawMsg, key) + case "partitionName": + err = unpopulate(val, "PartitionName", &h.PartitionName) + delete(rawMsg, key) + case "sequenceNumber": + err = unpopulate(val, "SequenceNumber", &h.SequenceNumber) + delete(rawMsg, key) + case "serviceHostName": + err = unpopulate(val, "ServiceHostName", &h.ServiceHostName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthcareDicomImageDeletedEventData. +func (h HealthcareDicomImageDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "imageSeriesInstanceUid", h.ImageSeriesInstanceUID) + populate(objectMap, "imageSopInstanceUid", h.ImageSopInstanceUID) + populate(objectMap, "imageStudyInstanceUid", h.ImageStudyInstanceUID) + populate(objectMap, "partitionName", h.PartitionName) + populate(objectMap, "sequenceNumber", h.SequenceNumber) + populate(objectMap, "serviceHostName", h.ServiceHostName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthcareDicomImageDeletedEventData. +func (h *HealthcareDicomImageDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "imageSeriesInstanceUid": + err = unpopulate(val, "ImageSeriesInstanceUID", &h.ImageSeriesInstanceUID) + delete(rawMsg, key) + case "imageSopInstanceUid": + err = unpopulate(val, "ImageSopInstanceUID", &h.ImageSopInstanceUID) + delete(rawMsg, key) + case "imageStudyInstanceUid": + err = unpopulate(val, "ImageStudyInstanceUID", &h.ImageStudyInstanceUID) + delete(rawMsg, key) + case "partitionName": + err = unpopulate(val, "PartitionName", &h.PartitionName) + delete(rawMsg, key) + case "sequenceNumber": + err = unpopulate(val, "SequenceNumber", &h.SequenceNumber) + delete(rawMsg, key) + case "serviceHostName": + err = unpopulate(val, "ServiceHostName", &h.ServiceHostName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthcareDicomImageUpdatedEventData. +func (h HealthcareDicomImageUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "imageSeriesInstanceUid", h.ImageSeriesInstanceUID) + populate(objectMap, "imageSopInstanceUid", h.ImageSopInstanceUID) + populate(objectMap, "imageStudyInstanceUid", h.ImageStudyInstanceUID) + populate(objectMap, "partitionName", h.PartitionName) + populate(objectMap, "sequenceNumber", h.SequenceNumber) + populate(objectMap, "serviceHostName", h.ServiceHostName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthcareDicomImageUpdatedEventData. +func (h *HealthcareDicomImageUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "imageSeriesInstanceUid": + err = unpopulate(val, "ImageSeriesInstanceUID", &h.ImageSeriesInstanceUID) + delete(rawMsg, key) + case "imageSopInstanceUid": + err = unpopulate(val, "ImageSopInstanceUID", &h.ImageSopInstanceUID) + delete(rawMsg, key) + case "imageStudyInstanceUid": + err = unpopulate(val, "ImageStudyInstanceUID", &h.ImageStudyInstanceUID) + delete(rawMsg, key) + case "partitionName": + err = unpopulate(val, "PartitionName", &h.PartitionName) + delete(rawMsg, key) + case "sequenceNumber": + err = unpopulate(val, "SequenceNumber", &h.SequenceNumber) + delete(rawMsg, key) + case "serviceHostName": + err = unpopulate(val, "ServiceHostName", &h.ServiceHostName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthcareFhirResourceCreatedEventData. +func (h HealthcareFhirResourceCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceFhirId", h.FhirResourceID) + populate(objectMap, "resourceType", h.FhirResourceType) + populate(objectMap, "resourceVersionId", h.FhirResourceVersionID) + populate(objectMap, "resourceFhirAccount", h.FhirServiceHostName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthcareFhirResourceCreatedEventData. +func (h *HealthcareFhirResourceCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceFhirId": + err = unpopulate(val, "FhirResourceID", &h.FhirResourceID) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "FhirResourceType", &h.FhirResourceType) + delete(rawMsg, key) + case "resourceVersionId": + err = unpopulate(val, "FhirResourceVersionID", &h.FhirResourceVersionID) + delete(rawMsg, key) + case "resourceFhirAccount": + err = unpopulate(val, "FhirServiceHostName", &h.FhirServiceHostName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthcareFhirResourceDeletedEventData. +func (h HealthcareFhirResourceDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceFhirId", h.FhirResourceID) + populate(objectMap, "resourceType", h.FhirResourceType) + populate(objectMap, "resourceVersionId", h.FhirResourceVersionID) + populate(objectMap, "resourceFhirAccount", h.FhirServiceHostName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthcareFhirResourceDeletedEventData. +func (h *HealthcareFhirResourceDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceFhirId": + err = unpopulate(val, "FhirResourceID", &h.FhirResourceID) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "FhirResourceType", &h.FhirResourceType) + delete(rawMsg, key) + case "resourceVersionId": + err = unpopulate(val, "FhirResourceVersionID", &h.FhirResourceVersionID) + delete(rawMsg, key) + case "resourceFhirAccount": + err = unpopulate(val, "FhirServiceHostName", &h.FhirServiceHostName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthcareFhirResourceUpdatedEventData. +func (h HealthcareFhirResourceUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceFhirId", h.FhirResourceID) + populate(objectMap, "resourceType", h.FhirResourceType) + populate(objectMap, "resourceVersionId", h.FhirResourceVersionID) + populate(objectMap, "resourceFhirAccount", h.FhirServiceHostName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthcareFhirResourceUpdatedEventData. +func (h *HealthcareFhirResourceUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceFhirId": + err = unpopulate(val, "FhirResourceID", &h.FhirResourceID) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "FhirResourceType", &h.FhirResourceType) + delete(rawMsg, key) + case "resourceVersionId": + err = unpopulate(val, "FhirResourceVersionID", &h.FhirResourceVersionID) + delete(rawMsg, key) + case "resourceFhirAccount": + err = unpopulate(val, "FhirServiceHostName", &h.FhirServiceHostName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IotHubDeviceConnectedEventData. +func (i IotHubDeviceConnectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceConnectionStateEventInfo", i.DeviceConnectionStateEventInfo) + populate(objectMap, "deviceId", i.DeviceID) + populate(objectMap, "hubName", i.HubName) + populate(objectMap, "moduleId", i.ModuleID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotHubDeviceConnectedEventData. +func (i *IotHubDeviceConnectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deviceConnectionStateEventInfo": + err = unpopulate(val, "DeviceConnectionStateEventInfo", &i.DeviceConnectionStateEventInfo) + delete(rawMsg, key) + case "deviceId": + err = unpopulate(val, "DeviceID", &i.DeviceID) + delete(rawMsg, key) + case "hubName": + err = unpopulate(val, "HubName", &i.HubName) + delete(rawMsg, key) + case "moduleId": + err = unpopulate(val, "ModuleID", &i.ModuleID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IotHubDeviceCreatedEventData. +func (i IotHubDeviceCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceId", i.DeviceID) + populate(objectMap, "hubName", i.HubName) + populate(objectMap, "twin", i.Twin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotHubDeviceCreatedEventData. +func (i *IotHubDeviceCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deviceId": + err = unpopulate(val, "DeviceID", &i.DeviceID) + delete(rawMsg, key) + case "hubName": + err = unpopulate(val, "HubName", &i.HubName) + delete(rawMsg, key) + case "twin": + err = unpopulate(val, "Twin", &i.Twin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IotHubDeviceDeletedEventData. +func (i IotHubDeviceDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceId", i.DeviceID) + populate(objectMap, "hubName", i.HubName) + populate(objectMap, "twin", i.Twin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotHubDeviceDeletedEventData. +func (i *IotHubDeviceDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deviceId": + err = unpopulate(val, "DeviceID", &i.DeviceID) + delete(rawMsg, key) + case "hubName": + err = unpopulate(val, "HubName", &i.HubName) + delete(rawMsg, key) + case "twin": + err = unpopulate(val, "Twin", &i.Twin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IotHubDeviceDisconnectedEventData. +func (i IotHubDeviceDisconnectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceConnectionStateEventInfo", i.DeviceConnectionStateEventInfo) + populate(objectMap, "deviceId", i.DeviceID) + populate(objectMap, "hubName", i.HubName) + populate(objectMap, "moduleId", i.ModuleID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotHubDeviceDisconnectedEventData. +func (i *IotHubDeviceDisconnectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deviceConnectionStateEventInfo": + err = unpopulate(val, "DeviceConnectionStateEventInfo", &i.DeviceConnectionStateEventInfo) + delete(rawMsg, key) + case "deviceId": + err = unpopulate(val, "DeviceID", &i.DeviceID) + delete(rawMsg, key) + case "hubName": + err = unpopulate(val, "HubName", &i.HubName) + delete(rawMsg, key) + case "moduleId": + err = unpopulate(val, "ModuleID", &i.ModuleID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IotHubDeviceTelemetryEventData. +func (i IotHubDeviceTelemetryEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "body", i.Body) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemProperties", i.SystemProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotHubDeviceTelemetryEventData. +func (i *IotHubDeviceTelemetryEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "body": + err = unpopulate(val, "Body", &i.Body) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemProperties": + err = unpopulate(val, "SystemProperties", &i.SystemProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultAccessPolicyChangedEventData. +func (k KeyVaultAccessPolicyChangedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "EXP", k.EXP) + populate(objectMap, "Id", k.ID) + populate(objectMap, "NBF", k.NBF) + populate(objectMap, "ObjectName", k.ObjectName) + populate(objectMap, "ObjectType", k.ObjectType) + populate(objectMap, "VaultName", k.VaultName) + populate(objectMap, "Version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultAccessPolicyChangedEventData. +func (k *KeyVaultAccessPolicyChangedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EXP": + err = unpopulate(val, "EXP", &k.EXP) + delete(rawMsg, key) + case "Id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "NBF": + err = unpopulate(val, "NBF", &k.NBF) + delete(rawMsg, key) + case "ObjectName": + err = unpopulate(val, "ObjectName", &k.ObjectName) + delete(rawMsg, key) + case "ObjectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "VaultName": + err = unpopulate(val, "VaultName", &k.VaultName) + delete(rawMsg, key) + case "Version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultCertificateExpiredEventData. +func (k KeyVaultCertificateExpiredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "EXP", k.EXP) + populate(objectMap, "Id", k.ID) + populate(objectMap, "NBF", k.NBF) + populate(objectMap, "ObjectName", k.ObjectName) + populate(objectMap, "ObjectType", k.ObjectType) + populate(objectMap, "VaultName", k.VaultName) + populate(objectMap, "Version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultCertificateExpiredEventData. +func (k *KeyVaultCertificateExpiredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EXP": + err = unpopulate(val, "EXP", &k.EXP) + delete(rawMsg, key) + case "Id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "NBF": + err = unpopulate(val, "NBF", &k.NBF) + delete(rawMsg, key) + case "ObjectName": + err = unpopulate(val, "ObjectName", &k.ObjectName) + delete(rawMsg, key) + case "ObjectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "VaultName": + err = unpopulate(val, "VaultName", &k.VaultName) + delete(rawMsg, key) + case "Version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultCertificateNearExpiryEventData. +func (k KeyVaultCertificateNearExpiryEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "EXP", k.EXP) + populate(objectMap, "Id", k.ID) + populate(objectMap, "NBF", k.NBF) + populate(objectMap, "ObjectName", k.ObjectName) + populate(objectMap, "ObjectType", k.ObjectType) + populate(objectMap, "VaultName", k.VaultName) + populate(objectMap, "Version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultCertificateNearExpiryEventData. +func (k *KeyVaultCertificateNearExpiryEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EXP": + err = unpopulate(val, "EXP", &k.EXP) + delete(rawMsg, key) + case "Id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "NBF": + err = unpopulate(val, "NBF", &k.NBF) + delete(rawMsg, key) + case "ObjectName": + err = unpopulate(val, "ObjectName", &k.ObjectName) + delete(rawMsg, key) + case "ObjectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "VaultName": + err = unpopulate(val, "VaultName", &k.VaultName) + delete(rawMsg, key) + case "Version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultCertificateNewVersionCreatedEventData. +func (k KeyVaultCertificateNewVersionCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "EXP", k.EXP) + populate(objectMap, "Id", k.ID) + populate(objectMap, "NBF", k.NBF) + populate(objectMap, "ObjectName", k.ObjectName) + populate(objectMap, "ObjectType", k.ObjectType) + populate(objectMap, "VaultName", k.VaultName) + populate(objectMap, "Version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultCertificateNewVersionCreatedEventData. +func (k *KeyVaultCertificateNewVersionCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EXP": + err = unpopulate(val, "EXP", &k.EXP) + delete(rawMsg, key) + case "Id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "NBF": + err = unpopulate(val, "NBF", &k.NBF) + delete(rawMsg, key) + case "ObjectName": + err = unpopulate(val, "ObjectName", &k.ObjectName) + delete(rawMsg, key) + case "ObjectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "VaultName": + err = unpopulate(val, "VaultName", &k.VaultName) + delete(rawMsg, key) + case "Version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultKeyExpiredEventData. +func (k KeyVaultKeyExpiredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "EXP", k.EXP) + populate(objectMap, "Id", k.ID) + populate(objectMap, "NBF", k.NBF) + populate(objectMap, "ObjectName", k.ObjectName) + populate(objectMap, "ObjectType", k.ObjectType) + populate(objectMap, "VaultName", k.VaultName) + populate(objectMap, "Version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultKeyExpiredEventData. +func (k *KeyVaultKeyExpiredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EXP": + err = unpopulate(val, "EXP", &k.EXP) + delete(rawMsg, key) + case "Id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "NBF": + err = unpopulate(val, "NBF", &k.NBF) + delete(rawMsg, key) + case "ObjectName": + err = unpopulate(val, "ObjectName", &k.ObjectName) + delete(rawMsg, key) + case "ObjectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "VaultName": + err = unpopulate(val, "VaultName", &k.VaultName) + delete(rawMsg, key) + case "Version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultKeyNearExpiryEventData. +func (k KeyVaultKeyNearExpiryEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "EXP", k.EXP) + populate(objectMap, "Id", k.ID) + populate(objectMap, "NBF", k.NBF) + populate(objectMap, "ObjectName", k.ObjectName) + populate(objectMap, "ObjectType", k.ObjectType) + populate(objectMap, "VaultName", k.VaultName) + populate(objectMap, "Version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultKeyNearExpiryEventData. +func (k *KeyVaultKeyNearExpiryEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EXP": + err = unpopulate(val, "EXP", &k.EXP) + delete(rawMsg, key) + case "Id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "NBF": + err = unpopulate(val, "NBF", &k.NBF) + delete(rawMsg, key) + case "ObjectName": + err = unpopulate(val, "ObjectName", &k.ObjectName) + delete(rawMsg, key) + case "ObjectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "VaultName": + err = unpopulate(val, "VaultName", &k.VaultName) + delete(rawMsg, key) + case "Version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultKeyNewVersionCreatedEventData. +func (k KeyVaultKeyNewVersionCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "EXP", k.EXP) + populate(objectMap, "Id", k.ID) + populate(objectMap, "NBF", k.NBF) + populate(objectMap, "ObjectName", k.ObjectName) + populate(objectMap, "ObjectType", k.ObjectType) + populate(objectMap, "VaultName", k.VaultName) + populate(objectMap, "Version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultKeyNewVersionCreatedEventData. +func (k *KeyVaultKeyNewVersionCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EXP": + err = unpopulate(val, "EXP", &k.EXP) + delete(rawMsg, key) + case "Id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "NBF": + err = unpopulate(val, "NBF", &k.NBF) + delete(rawMsg, key) + case "ObjectName": + err = unpopulate(val, "ObjectName", &k.ObjectName) + delete(rawMsg, key) + case "ObjectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "VaultName": + err = unpopulate(val, "VaultName", &k.VaultName) + delete(rawMsg, key) + case "Version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultSecretExpiredEventData. +func (k KeyVaultSecretExpiredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "EXP", k.EXP) + populate(objectMap, "Id", k.ID) + populate(objectMap, "NBF", k.NBF) + populate(objectMap, "ObjectName", k.ObjectName) + populate(objectMap, "ObjectType", k.ObjectType) + populate(objectMap, "VaultName", k.VaultName) + populate(objectMap, "Version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultSecretExpiredEventData. +func (k *KeyVaultSecretExpiredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EXP": + err = unpopulate(val, "EXP", &k.EXP) + delete(rawMsg, key) + case "Id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "NBF": + err = unpopulate(val, "NBF", &k.NBF) + delete(rawMsg, key) + case "ObjectName": + err = unpopulate(val, "ObjectName", &k.ObjectName) + delete(rawMsg, key) + case "ObjectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "VaultName": + err = unpopulate(val, "VaultName", &k.VaultName) + delete(rawMsg, key) + case "Version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultSecretNearExpiryEventData. +func (k KeyVaultSecretNearExpiryEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "EXP", k.EXP) + populate(objectMap, "Id", k.ID) + populate(objectMap, "NBF", k.NBF) + populate(objectMap, "ObjectName", k.ObjectName) + populate(objectMap, "ObjectType", k.ObjectType) + populate(objectMap, "VaultName", k.VaultName) + populate(objectMap, "Version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultSecretNearExpiryEventData. +func (k *KeyVaultSecretNearExpiryEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EXP": + err = unpopulate(val, "EXP", &k.EXP) + delete(rawMsg, key) + case "Id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "NBF": + err = unpopulate(val, "NBF", &k.NBF) + delete(rawMsg, key) + case "ObjectName": + err = unpopulate(val, "ObjectName", &k.ObjectName) + delete(rawMsg, key) + case "ObjectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "VaultName": + err = unpopulate(val, "VaultName", &k.VaultName) + delete(rawMsg, key) + case "Version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultSecretNewVersionCreatedEventData. +func (k KeyVaultSecretNewVersionCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "EXP", k.EXP) + populate(objectMap, "Id", k.ID) + populate(objectMap, "NBF", k.NBF) + populate(objectMap, "ObjectName", k.ObjectName) + populate(objectMap, "ObjectType", k.ObjectType) + populate(objectMap, "VaultName", k.VaultName) + populate(objectMap, "Version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultSecretNewVersionCreatedEventData. +func (k *KeyVaultSecretNewVersionCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EXP": + err = unpopulate(val, "EXP", &k.EXP) + delete(rawMsg, key) + case "Id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "NBF": + err = unpopulate(val, "NBF", &k.NBF) + delete(rawMsg, key) + case "ObjectName": + err = unpopulate(val, "ObjectName", &k.ObjectName) + delete(rawMsg, key) + case "ObjectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "VaultName": + err = unpopulate(val, "VaultName", &k.VaultName) + delete(rawMsg, key) + case "Version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MachineLearningServicesDatasetDriftDetectedEventData. +func (m MachineLearningServicesDatasetDriftDetectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "baseDatasetId", m.BaseDatasetID) + populate(objectMap, "dataDriftId", m.DataDriftID) + populate(objectMap, "dataDriftName", m.DataDriftName) + populate(objectMap, "driftCoefficient", m.DriftCoefficient) + populateDateTimeRFC3339(objectMap, "endTime", m.EndTime) + populate(objectMap, "runId", m.RunID) + populateDateTimeRFC3339(objectMap, "startTime", m.StartTime) + populate(objectMap, "targetDatasetId", m.TargetDatasetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MachineLearningServicesDatasetDriftDetectedEventData. +func (m *MachineLearningServicesDatasetDriftDetectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "baseDatasetId": + err = unpopulate(val, "BaseDatasetID", &m.BaseDatasetID) + delete(rawMsg, key) + case "dataDriftId": + err = unpopulate(val, "DataDriftID", &m.DataDriftID) + delete(rawMsg, key) + case "dataDriftName": + err = unpopulate(val, "DataDriftName", &m.DataDriftName) + delete(rawMsg, key) + case "driftCoefficient": + err = unpopulate(val, "DriftCoefficient", &m.DriftCoefficient) + delete(rawMsg, key) + case "endTime": + err = unpopulateDateTimeRFC3339(val, "EndTime", &m.EndTime) + delete(rawMsg, key) + case "runId": + err = unpopulate(val, "RunID", &m.RunID) + delete(rawMsg, key) + case "startTime": + err = unpopulateDateTimeRFC3339(val, "StartTime", &m.StartTime) + delete(rawMsg, key) + case "targetDatasetId": + err = unpopulate(val, "TargetDatasetID", &m.TargetDatasetID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MachineLearningServicesModelDeployedEventData. +func (m MachineLearningServicesModelDeployedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "modelIds", m.ModelIDs) + populate(objectMap, "serviceComputeType", m.ServiceComputeType) + populate(objectMap, "serviceName", m.ServiceName) + populateAny(objectMap, "serviceProperties", m.ServiceProperties) + populateAny(objectMap, "serviceTags", m.ServiceTags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MachineLearningServicesModelDeployedEventData. +func (m *MachineLearningServicesModelDeployedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "modelIds": + err = unpopulate(val, "ModelIDs", &m.ModelIDs) + delete(rawMsg, key) + case "serviceComputeType": + err = unpopulate(val, "ServiceComputeType", &m.ServiceComputeType) + delete(rawMsg, key) + case "serviceName": + err = unpopulate(val, "ServiceName", &m.ServiceName) + delete(rawMsg, key) + case "serviceProperties": + err = unpopulate(val, "ServiceProperties", &m.ServiceProperties) + delete(rawMsg, key) + case "serviceTags": + err = unpopulate(val, "ServiceTags", &m.ServiceTags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MachineLearningServicesModelRegisteredEventData. +func (m MachineLearningServicesModelRegisteredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "modelName", m.ModelName) + populateAny(objectMap, "modelProperties", m.ModelProperties) + populateAny(objectMap, "modelTags", m.ModelTags) + populate(objectMap, "modelVersion", m.ModelVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MachineLearningServicesModelRegisteredEventData. +func (m *MachineLearningServicesModelRegisteredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "modelName": + err = unpopulate(val, "ModelName", &m.ModelName) + delete(rawMsg, key) + case "modelProperties": + err = unpopulate(val, "ModelProperties", &m.ModelProperties) + delete(rawMsg, key) + case "modelTags": + err = unpopulate(val, "ModelTags", &m.ModelTags) + delete(rawMsg, key) + case "modelVersion": + err = unpopulate(val, "ModelVersion", &m.ModelVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MachineLearningServicesRunCompletedEventData. +func (m MachineLearningServicesRunCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "experimentId", m.ExperimentID) + populate(objectMap, "experimentName", m.ExperimentName) + populate(objectMap, "runId", m.RunID) + populateAny(objectMap, "runProperties", m.RunProperties) + populateAny(objectMap, "runTags", m.RunTags) + populate(objectMap, "runType", m.RunType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MachineLearningServicesRunCompletedEventData. +func (m *MachineLearningServicesRunCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "experimentId": + err = unpopulate(val, "ExperimentID", &m.ExperimentID) + delete(rawMsg, key) + case "experimentName": + err = unpopulate(val, "ExperimentName", &m.ExperimentName) + delete(rawMsg, key) + case "runId": + err = unpopulate(val, "RunID", &m.RunID) + delete(rawMsg, key) + case "runProperties": + err = unpopulate(val, "RunProperties", &m.RunProperties) + delete(rawMsg, key) + case "runTags": + err = unpopulate(val, "RunTags", &m.RunTags) + delete(rawMsg, key) + case "runType": + err = unpopulate(val, "RunType", &m.RunType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MachineLearningServicesRunStatusChangedEventData. +func (m MachineLearningServicesRunStatusChangedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "experimentId", m.ExperimentID) + populate(objectMap, "experimentName", m.ExperimentName) + populate(objectMap, "runId", m.RunID) + populateAny(objectMap, "runProperties", m.RunProperties) + populate(objectMap, "runStatus", m.RunStatus) + populateAny(objectMap, "runTags", m.RunTags) + populate(objectMap, "runType", m.RunType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MachineLearningServicesRunStatusChangedEventData. +func (m *MachineLearningServicesRunStatusChangedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "experimentId": + err = unpopulate(val, "ExperimentID", &m.ExperimentID) + delete(rawMsg, key) + case "experimentName": + err = unpopulate(val, "ExperimentName", &m.ExperimentName) + delete(rawMsg, key) + case "runId": + err = unpopulate(val, "RunID", &m.RunID) + delete(rawMsg, key) + case "runProperties": + err = unpopulate(val, "RunProperties", &m.RunProperties) + delete(rawMsg, key) + case "runStatus": + err = unpopulate(val, "RunStatus", &m.RunStatus) + delete(rawMsg, key) + case "runTags": + err = unpopulate(val, "RunTags", &m.RunTags) + delete(rawMsg, key) + case "runType": + err = unpopulate(val, "RunType", &m.RunType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MapsGeofenceEnteredEventData. +func (m MapsGeofenceEnteredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "expiredGeofenceGeometryId", m.ExpiredGeofenceGeometryID) + populate(objectMap, "geometries", m.Geometries) + populate(objectMap, "invalidPeriodGeofenceGeometryId", m.InvalidPeriodGeofenceGeometryID) + populate(objectMap, "isEventPublished", m.IsEventPublished) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MapsGeofenceEnteredEventData. +func (m *MapsGeofenceEnteredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expiredGeofenceGeometryId": + err = unpopulate(val, "ExpiredGeofenceGeometryID", &m.ExpiredGeofenceGeometryID) + delete(rawMsg, key) + case "geometries": + err = unpopulate(val, "Geometries", &m.Geometries) + delete(rawMsg, key) + case "invalidPeriodGeofenceGeometryId": + err = unpopulate(val, "InvalidPeriodGeofenceGeometryID", &m.InvalidPeriodGeofenceGeometryID) + delete(rawMsg, key) + case "isEventPublished": + err = unpopulate(val, "IsEventPublished", &m.IsEventPublished) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MapsGeofenceEventProperties. +func (m MapsGeofenceEventProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "expiredGeofenceGeometryId", m.ExpiredGeofenceGeometryID) + populate(objectMap, "geometries", m.Geometries) + populate(objectMap, "invalidPeriodGeofenceGeometryId", m.InvalidPeriodGeofenceGeometryID) + populate(objectMap, "isEventPublished", m.IsEventPublished) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MapsGeofenceEventProperties. +func (m *MapsGeofenceEventProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expiredGeofenceGeometryId": + err = unpopulate(val, "ExpiredGeofenceGeometryID", &m.ExpiredGeofenceGeometryID) + delete(rawMsg, key) + case "geometries": + err = unpopulate(val, "Geometries", &m.Geometries) + delete(rawMsg, key) + case "invalidPeriodGeofenceGeometryId": + err = unpopulate(val, "InvalidPeriodGeofenceGeometryID", &m.InvalidPeriodGeofenceGeometryID) + delete(rawMsg, key) + case "isEventPublished": + err = unpopulate(val, "IsEventPublished", &m.IsEventPublished) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MapsGeofenceExitedEventData. +func (m MapsGeofenceExitedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "expiredGeofenceGeometryId", m.ExpiredGeofenceGeometryID) + populate(objectMap, "geometries", m.Geometries) + populate(objectMap, "invalidPeriodGeofenceGeometryId", m.InvalidPeriodGeofenceGeometryID) + populate(objectMap, "isEventPublished", m.IsEventPublished) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MapsGeofenceExitedEventData. +func (m *MapsGeofenceExitedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expiredGeofenceGeometryId": + err = unpopulate(val, "ExpiredGeofenceGeometryID", &m.ExpiredGeofenceGeometryID) + delete(rawMsg, key) + case "geometries": + err = unpopulate(val, "Geometries", &m.Geometries) + delete(rawMsg, key) + case "invalidPeriodGeofenceGeometryId": + err = unpopulate(val, "InvalidPeriodGeofenceGeometryID", &m.InvalidPeriodGeofenceGeometryID) + delete(rawMsg, key) + case "isEventPublished": + err = unpopulate(val, "IsEventPublished", &m.IsEventPublished) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MapsGeofenceGeometry. +func (m MapsGeofenceGeometry) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceId", m.DeviceID) + populate(objectMap, "distance", m.Distance) + populate(objectMap, "geometryId", m.GeometryID) + populate(objectMap, "nearestLat", m.NearestLat) + populate(objectMap, "nearestLon", m.NearestLon) + populate(objectMap, "udId", m.UdID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MapsGeofenceGeometry. +func (m *MapsGeofenceGeometry) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deviceId": + err = unpopulate(val, "DeviceID", &m.DeviceID) + delete(rawMsg, key) + case "distance": + err = unpopulate(val, "Distance", &m.Distance) + delete(rawMsg, key) + case "geometryId": + err = unpopulate(val, "GeometryID", &m.GeometryID) + delete(rawMsg, key) + case "nearestLat": + err = unpopulate(val, "NearestLat", &m.NearestLat) + delete(rawMsg, key) + case "nearestLon": + err = unpopulate(val, "NearestLon", &m.NearestLon) + delete(rawMsg, key) + case "udId": + err = unpopulate(val, "UdID", &m.UdID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MapsGeofenceResultEventData. +func (m MapsGeofenceResultEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "expiredGeofenceGeometryId", m.ExpiredGeofenceGeometryID) + populate(objectMap, "geometries", m.Geometries) + populate(objectMap, "invalidPeriodGeofenceGeometryId", m.InvalidPeriodGeofenceGeometryID) + populate(objectMap, "isEventPublished", m.IsEventPublished) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MapsGeofenceResultEventData. +func (m *MapsGeofenceResultEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expiredGeofenceGeometryId": + err = unpopulate(val, "ExpiredGeofenceGeometryID", &m.ExpiredGeofenceGeometryID) + delete(rawMsg, key) + case "geometries": + err = unpopulate(val, "Geometries", &m.Geometries) + delete(rawMsg, key) + case "invalidPeriodGeofenceGeometryId": + err = unpopulate(val, "InvalidPeriodGeofenceGeometryID", &m.InvalidPeriodGeofenceGeometryID) + delete(rawMsg, key) + case "isEventPublished": + err = unpopulate(val, "IsEventPublished", &m.IsEventPublished) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobCanceledEventData. +func (m MediaJobCanceledEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationData", m.CorrelationData) + populate(objectMap, "outputs", m.Outputs) + populate(objectMap, "previousState", m.PreviousState) + populate(objectMap, "state", m.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobCanceledEventData. +func (m *MediaJobCanceledEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "correlationData": + err = unpopulate(val, "CorrelationData", &m.CorrelationData) + delete(rawMsg, key) + case "outputs": + m.Outputs, err = unmarshalMediaJobOutputClassificationArray(val) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &m.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobCancelingEventData. +func (m MediaJobCancelingEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationData", m.CorrelationData) + populate(objectMap, "previousState", m.PreviousState) + populate(objectMap, "state", m.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobCancelingEventData. +func (m *MediaJobCancelingEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "correlationData": + err = unpopulate(val, "CorrelationData", &m.CorrelationData) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &m.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobError. +func (m MediaJobError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "category", m.Category) + populate(objectMap, "code", m.Code) + populate(objectMap, "details", m.Details) + populate(objectMap, "message", m.Message) + populate(objectMap, "retry", m.Retry) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobError. +func (m *MediaJobError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "category": + err = unpopulate(val, "Category", &m.Category) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &m.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &m.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &m.Message) + delete(rawMsg, key) + case "retry": + err = unpopulate(val, "Retry", &m.Retry) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobErrorDetail. +func (m MediaJobErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", m.Code) + populate(objectMap, "message", m.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobErrorDetail. +func (m *MediaJobErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &m.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &m.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobErroredEventData. +func (m MediaJobErroredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationData", m.CorrelationData) + populate(objectMap, "outputs", m.Outputs) + populate(objectMap, "previousState", m.PreviousState) + populate(objectMap, "state", m.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobErroredEventData. +func (m *MediaJobErroredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "correlationData": + err = unpopulate(val, "CorrelationData", &m.CorrelationData) + delete(rawMsg, key) + case "outputs": + m.Outputs, err = unmarshalMediaJobOutputClassificationArray(val) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &m.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobFinishedEventData. +func (m MediaJobFinishedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationData", m.CorrelationData) + populate(objectMap, "outputs", m.Outputs) + populate(objectMap, "previousState", m.PreviousState) + populate(objectMap, "state", m.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobFinishedEventData. +func (m *MediaJobFinishedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "correlationData": + err = unpopulate(val, "CorrelationData", &m.CorrelationData) + delete(rawMsg, key) + case "outputs": + m.Outputs, err = unmarshalMediaJobOutputClassificationArray(val) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &m.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobOutput. +func (m MediaJobOutput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", m.Error) + populate(objectMap, "label", m.Label) + objectMap["@odata.type"] = m.ODataType + populate(objectMap, "progress", m.Progress) + populate(objectMap, "state", m.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobOutput. +func (m *MediaJobOutput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &m.Error) + delete(rawMsg, key) + case "label": + err = unpopulate(val, "Label", &m.Label) + delete(rawMsg, key) + case "@odata.type": + err = unpopulate(val, "ODataType", &m.ODataType) + delete(rawMsg, key) + case "progress": + err = unpopulate(val, "Progress", &m.Progress) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &m.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobOutputAsset. +func (m MediaJobOutputAsset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assetName", m.AssetName) + populate(objectMap, "error", m.Error) + populate(objectMap, "label", m.Label) + objectMap["@odata.type"] = "#Microsoft.Media.JobOutputAsset" + populate(objectMap, "progress", m.Progress) + populate(objectMap, "state", m.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobOutputAsset. +func (m *MediaJobOutputAsset) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assetName": + err = unpopulate(val, "AssetName", &m.AssetName) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &m.Error) + delete(rawMsg, key) + case "label": + err = unpopulate(val, "Label", &m.Label) + delete(rawMsg, key) + case "@odata.type": + err = unpopulate(val, "ODataType", &m.ODataType) + delete(rawMsg, key) + case "progress": + err = unpopulate(val, "Progress", &m.Progress) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &m.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobOutputCanceledEventData. +func (m MediaJobOutputCanceledEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "jobCorrelationData", m.JobCorrelationData) + populate(objectMap, "output", m.Output) + populate(objectMap, "previousState", m.PreviousState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobOutputCanceledEventData. +func (m *MediaJobOutputCanceledEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "jobCorrelationData": + err = unpopulate(val, "JobCorrelationData", &m.JobCorrelationData) + delete(rawMsg, key) + case "output": + m.Output, err = unmarshalMediaJobOutputClassification(val) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobOutputCancelingEventData. +func (m MediaJobOutputCancelingEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "jobCorrelationData", m.JobCorrelationData) + populate(objectMap, "output", m.Output) + populate(objectMap, "previousState", m.PreviousState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobOutputCancelingEventData. +func (m *MediaJobOutputCancelingEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "jobCorrelationData": + err = unpopulate(val, "JobCorrelationData", &m.JobCorrelationData) + delete(rawMsg, key) + case "output": + m.Output, err = unmarshalMediaJobOutputClassification(val) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobOutputErroredEventData. +func (m MediaJobOutputErroredEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "jobCorrelationData", m.JobCorrelationData) + populate(objectMap, "output", m.Output) + populate(objectMap, "previousState", m.PreviousState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobOutputErroredEventData. +func (m *MediaJobOutputErroredEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "jobCorrelationData": + err = unpopulate(val, "JobCorrelationData", &m.JobCorrelationData) + delete(rawMsg, key) + case "output": + m.Output, err = unmarshalMediaJobOutputClassification(val) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobOutputFinishedEventData. +func (m MediaJobOutputFinishedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "jobCorrelationData", m.JobCorrelationData) + populate(objectMap, "output", m.Output) + populate(objectMap, "previousState", m.PreviousState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobOutputFinishedEventData. +func (m *MediaJobOutputFinishedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "jobCorrelationData": + err = unpopulate(val, "JobCorrelationData", &m.JobCorrelationData) + delete(rawMsg, key) + case "output": + m.Output, err = unmarshalMediaJobOutputClassification(val) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobOutputProcessingEventData. +func (m MediaJobOutputProcessingEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "jobCorrelationData", m.JobCorrelationData) + populate(objectMap, "output", m.Output) + populate(objectMap, "previousState", m.PreviousState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobOutputProcessingEventData. +func (m *MediaJobOutputProcessingEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "jobCorrelationData": + err = unpopulate(val, "JobCorrelationData", &m.JobCorrelationData) + delete(rawMsg, key) + case "output": + m.Output, err = unmarshalMediaJobOutputClassification(val) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobOutputProgressEventData. +func (m MediaJobOutputProgressEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "jobCorrelationData", m.JobCorrelationData) + populate(objectMap, "label", m.Label) + populate(objectMap, "progress", m.Progress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobOutputProgressEventData. +func (m *MediaJobOutputProgressEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "jobCorrelationData": + err = unpopulate(val, "JobCorrelationData", &m.JobCorrelationData) + delete(rawMsg, key) + case "label": + err = unpopulate(val, "Label", &m.Label) + delete(rawMsg, key) + case "progress": + err = unpopulate(val, "Progress", &m.Progress) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobOutputScheduledEventData. +func (m MediaJobOutputScheduledEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "jobCorrelationData", m.JobCorrelationData) + populate(objectMap, "output", m.Output) + populate(objectMap, "previousState", m.PreviousState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobOutputScheduledEventData. +func (m *MediaJobOutputScheduledEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "jobCorrelationData": + err = unpopulate(val, "JobCorrelationData", &m.JobCorrelationData) + delete(rawMsg, key) + case "output": + m.Output, err = unmarshalMediaJobOutputClassification(val) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobOutputStateChangeEventData. +func (m MediaJobOutputStateChangeEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "jobCorrelationData", m.JobCorrelationData) + populate(objectMap, "output", m.Output) + populate(objectMap, "previousState", m.PreviousState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobOutputStateChangeEventData. +func (m *MediaJobOutputStateChangeEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "jobCorrelationData": + err = unpopulate(val, "JobCorrelationData", &m.JobCorrelationData) + delete(rawMsg, key) + case "output": + m.Output, err = unmarshalMediaJobOutputClassification(val) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobProcessingEventData. +func (m MediaJobProcessingEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationData", m.CorrelationData) + populate(objectMap, "previousState", m.PreviousState) + populate(objectMap, "state", m.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobProcessingEventData. +func (m *MediaJobProcessingEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "correlationData": + err = unpopulate(val, "CorrelationData", &m.CorrelationData) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &m.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobScheduledEventData. +func (m MediaJobScheduledEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationData", m.CorrelationData) + populate(objectMap, "previousState", m.PreviousState) + populate(objectMap, "state", m.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobScheduledEventData. +func (m *MediaJobScheduledEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "correlationData": + err = unpopulate(val, "CorrelationData", &m.CorrelationData) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &m.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaJobStateChangeEventData. +func (m MediaJobStateChangeEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationData", m.CorrelationData) + populate(objectMap, "previousState", m.PreviousState) + populate(objectMap, "state", m.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaJobStateChangeEventData. +func (m *MediaJobStateChangeEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "correlationData": + err = unpopulate(val, "CorrelationData", &m.CorrelationData) + delete(rawMsg, key) + case "previousState": + err = unpopulate(val, "PreviousState", &m.PreviousState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &m.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaLiveEventChannelArchiveHeartbeatEventData. +func (m MediaLiveEventChannelArchiveHeartbeatEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelLatencyMs", m.ChannelLatencyMS) + populate(objectMap, "latencyResultCode", m.LatencyResultCode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaLiveEventChannelArchiveHeartbeatEventData. +func (m *MediaLiveEventChannelArchiveHeartbeatEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelLatencyMs": + err = unpopulate(val, "ChannelLatencyMs", &m.ChannelLatencyMS) + fixNAValue(&m.ChannelLatencyMS) + delete(rawMsg, key) + case "latencyResultCode": + err = unpopulate(val, "LatencyResultCode", &m.LatencyResultCode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaLiveEventConnectionRejectedEventData. +func (m MediaLiveEventConnectionRejectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "encoderIp", m.EncoderIP) + populate(objectMap, "encoderPort", m.EncoderPort) + populate(objectMap, "ingestUrl", m.IngestURL) + populate(objectMap, "resultCode", m.ResultCode) + populate(objectMap, "streamId", m.StreamID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaLiveEventConnectionRejectedEventData. +func (m *MediaLiveEventConnectionRejectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "encoderIp": + err = unpopulate(val, "EncoderIP", &m.EncoderIP) + delete(rawMsg, key) + case "encoderPort": + err = unpopulate(val, "EncoderPort", &m.EncoderPort) + delete(rawMsg, key) + case "ingestUrl": + err = unpopulate(val, "IngestURL", &m.IngestURL) + delete(rawMsg, key) + case "resultCode": + err = unpopulate(val, "ResultCode", &m.ResultCode) + delete(rawMsg, key) + case "streamId": + err = unpopulate(val, "StreamID", &m.StreamID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaLiveEventEncoderConnectedEventData. +func (m MediaLiveEventEncoderConnectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "encoderIp", m.EncoderIP) + populate(objectMap, "encoderPort", m.EncoderPort) + populate(objectMap, "ingestUrl", m.IngestURL) + populate(objectMap, "streamId", m.StreamID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaLiveEventEncoderConnectedEventData. +func (m *MediaLiveEventEncoderConnectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "encoderIp": + err = unpopulate(val, "EncoderIP", &m.EncoderIP) + delete(rawMsg, key) + case "encoderPort": + err = unpopulate(val, "EncoderPort", &m.EncoderPort) + delete(rawMsg, key) + case "ingestUrl": + err = unpopulate(val, "IngestURL", &m.IngestURL) + delete(rawMsg, key) + case "streamId": + err = unpopulate(val, "StreamID", &m.StreamID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaLiveEventEncoderDisconnectedEventData. +func (m MediaLiveEventEncoderDisconnectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "encoderIp", m.EncoderIP) + populate(objectMap, "encoderPort", m.EncoderPort) + populate(objectMap, "ingestUrl", m.IngestURL) + populate(objectMap, "resultCode", m.ResultCode) + populate(objectMap, "streamId", m.StreamID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaLiveEventEncoderDisconnectedEventData. +func (m *MediaLiveEventEncoderDisconnectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "encoderIp": + err = unpopulate(val, "EncoderIP", &m.EncoderIP) + delete(rawMsg, key) + case "encoderPort": + err = unpopulate(val, "EncoderPort", &m.EncoderPort) + delete(rawMsg, key) + case "ingestUrl": + err = unpopulate(val, "IngestURL", &m.IngestURL) + delete(rawMsg, key) + case "resultCode": + err = unpopulate(val, "ResultCode", &m.ResultCode) + delete(rawMsg, key) + case "streamId": + err = unpopulate(val, "StreamID", &m.StreamID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaLiveEventIncomingDataChunkDroppedEventData. +func (m MediaLiveEventIncomingDataChunkDroppedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bitrate", m.Bitrate) + populate(objectMap, "resultCode", m.ResultCode) + populate(objectMap, "timescale", m.Timescale) + populate(objectMap, "timestamp", m.Timestamp) + populate(objectMap, "trackName", m.TrackName) + populate(objectMap, "trackType", m.TrackType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaLiveEventIncomingDataChunkDroppedEventData. +func (m *MediaLiveEventIncomingDataChunkDroppedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "bitrate": + err = unpopulate(val, "Bitrate", &m.Bitrate) + delete(rawMsg, key) + case "resultCode": + err = unpopulate(val, "ResultCode", &m.ResultCode) + delete(rawMsg, key) + case "timescale": + err = unpopulate(val, "Timescale", &m.Timescale) + delete(rawMsg, key) + case "timestamp": + err = unpopulate(val, "Timestamp", &m.Timestamp) + delete(rawMsg, key) + case "trackName": + err = unpopulate(val, "TrackName", &m.TrackName) + delete(rawMsg, key) + case "trackType": + err = unpopulate(val, "TrackType", &m.TrackType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaLiveEventIncomingStreamReceivedEventData. +func (m MediaLiveEventIncomingStreamReceivedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bitrate", m.Bitrate) + populate(objectMap, "duration", m.Duration) + populate(objectMap, "encoderIp", m.EncoderIP) + populate(objectMap, "encoderPort", m.EncoderPort) + populate(objectMap, "ingestUrl", m.IngestURL) + populate(objectMap, "timescale", m.Timescale) + populate(objectMap, "timestamp", m.Timestamp) + populate(objectMap, "trackName", m.TrackName) + populate(objectMap, "trackType", m.TrackType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaLiveEventIncomingStreamReceivedEventData. +func (m *MediaLiveEventIncomingStreamReceivedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "bitrate": + err = unpopulate(val, "Bitrate", &m.Bitrate) + delete(rawMsg, key) + case "duration": + err = unpopulate(val, "Duration", &m.Duration) + delete(rawMsg, key) + case "encoderIp": + err = unpopulate(val, "EncoderIP", &m.EncoderIP) + delete(rawMsg, key) + case "encoderPort": + err = unpopulate(val, "EncoderPort", &m.EncoderPort) + delete(rawMsg, key) + case "ingestUrl": + err = unpopulate(val, "IngestURL", &m.IngestURL) + delete(rawMsg, key) + case "timescale": + err = unpopulate(val, "Timescale", &m.Timescale) + delete(rawMsg, key) + case "timestamp": + err = unpopulate(val, "Timestamp", &m.Timestamp) + delete(rawMsg, key) + case "trackName": + err = unpopulate(val, "TrackName", &m.TrackName) + delete(rawMsg, key) + case "trackType": + err = unpopulate(val, "TrackType", &m.TrackType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaLiveEventIncomingStreamsOutOfSyncEventData. +func (m MediaLiveEventIncomingStreamsOutOfSyncEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "maxLastTimestamp", m.MaxLastTimestamp) + populate(objectMap, "minLastTimestamp", m.MinLastTimestamp) + populate(objectMap, "timescaleOfMaxLastTimestamp", m.TimescaleOfMaxLastTimestamp) + populate(objectMap, "timescaleOfMinLastTimestamp", m.TimescaleOfMinLastTimestamp) + populate(objectMap, "typeOfStreamWithMaxLastTimestamp", m.TypeOfStreamWithMaxLastTimestamp) + populate(objectMap, "typeOfStreamWithMinLastTimestamp", m.TypeOfStreamWithMinLastTimestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaLiveEventIncomingStreamsOutOfSyncEventData. +func (m *MediaLiveEventIncomingStreamsOutOfSyncEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "maxLastTimestamp": + err = unpopulate(val, "MaxLastTimestamp", &m.MaxLastTimestamp) + delete(rawMsg, key) + case "minLastTimestamp": + err = unpopulate(val, "MinLastTimestamp", &m.MinLastTimestamp) + delete(rawMsg, key) + case "timescaleOfMaxLastTimestamp": + err = unpopulate(val, "TimescaleOfMaxLastTimestamp", &m.TimescaleOfMaxLastTimestamp) + delete(rawMsg, key) + case "timescaleOfMinLastTimestamp": + err = unpopulate(val, "TimescaleOfMinLastTimestamp", &m.TimescaleOfMinLastTimestamp) + delete(rawMsg, key) + case "typeOfStreamWithMaxLastTimestamp": + err = unpopulate(val, "TypeOfStreamWithMaxLastTimestamp", &m.TypeOfStreamWithMaxLastTimestamp) + delete(rawMsg, key) + case "typeOfStreamWithMinLastTimestamp": + err = unpopulate(val, "TypeOfStreamWithMinLastTimestamp", &m.TypeOfStreamWithMinLastTimestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaLiveEventIncomingVideoStreamsOutOfSyncEventData. +func (m MediaLiveEventIncomingVideoStreamsOutOfSyncEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "firstDuration", m.FirstDuration) + populate(objectMap, "firstTimestamp", m.FirstTimestamp) + populate(objectMap, "secondDuration", m.SecondDuration) + populate(objectMap, "secondTimestamp", m.SecondTimestamp) + populate(objectMap, "timescale", m.Timescale) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaLiveEventIncomingVideoStreamsOutOfSyncEventData. +func (m *MediaLiveEventIncomingVideoStreamsOutOfSyncEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "firstDuration": + err = unpopulate(val, "FirstDuration", &m.FirstDuration) + delete(rawMsg, key) + case "firstTimestamp": + err = unpopulate(val, "FirstTimestamp", &m.FirstTimestamp) + delete(rawMsg, key) + case "secondDuration": + err = unpopulate(val, "SecondDuration", &m.SecondDuration) + delete(rawMsg, key) + case "secondTimestamp": + err = unpopulate(val, "SecondTimestamp", &m.SecondTimestamp) + delete(rawMsg, key) + case "timescale": + err = unpopulate(val, "Timescale", &m.Timescale) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaLiveEventIngestHeartbeatEventData. +func (m MediaLiveEventIngestHeartbeatEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bitrate", m.Bitrate) + populate(objectMap, "discontinuityCount", m.DiscontinuityCount) + populate(objectMap, "healthy", m.Healthy) + populate(objectMap, "incomingBitrate", m.IncomingBitrate) + populate(objectMap, "ingestDriftValue", m.IngestDriftValue) + populate(objectMap, "lastFragmentArrivalTime", m.LastFragmentArrivalTime) + populate(objectMap, "lastTimestamp", m.LastTimestamp) + populate(objectMap, "nonincreasingCount", m.NonincreasingCount) + populate(objectMap, "overlapCount", m.OverlapCount) + populate(objectMap, "state", m.State) + populate(objectMap, "timescale", m.Timescale) + populate(objectMap, "trackName", m.TrackName) + populate(objectMap, "trackType", m.TrackType) + populate(objectMap, "transcriptionLanguage", m.TranscriptionLanguage) + populate(objectMap, "transcriptionState", m.TranscriptionState) + populate(objectMap, "unexpectedBitrate", m.UnexpectedBitrate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaLiveEventIngestHeartbeatEventData. +func (m *MediaLiveEventIngestHeartbeatEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "bitrate": + err = unpopulate(val, "Bitrate", &m.Bitrate) + delete(rawMsg, key) + case "discontinuityCount": + err = unpopulate(val, "DiscontinuityCount", &m.DiscontinuityCount) + delete(rawMsg, key) + case "healthy": + err = unpopulate(val, "Healthy", &m.Healthy) + delete(rawMsg, key) + case "incomingBitrate": + err = unpopulate(val, "IncomingBitrate", &m.IncomingBitrate) + delete(rawMsg, key) + case "ingestDriftValue": + err = unpopulate(val, "IngestDriftValue", &m.IngestDriftValue) + fixNAValue(&m.IngestDriftValue) + delete(rawMsg, key) + case "lastFragmentArrivalTime": + err = unpopulate(val, "LastFragmentArrivalTime", &m.LastFragmentArrivalTime) + delete(rawMsg, key) + case "lastTimestamp": + err = unpopulate(val, "LastTimestamp", &m.LastTimestamp) + delete(rawMsg, key) + case "nonincreasingCount": + err = unpopulate(val, "NonincreasingCount", &m.NonincreasingCount) + delete(rawMsg, key) + case "overlapCount": + err = unpopulate(val, "OverlapCount", &m.OverlapCount) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &m.State) + delete(rawMsg, key) + case "timescale": + err = unpopulate(val, "Timescale", &m.Timescale) + delete(rawMsg, key) + case "trackName": + err = unpopulate(val, "TrackName", &m.TrackName) + delete(rawMsg, key) + case "trackType": + err = unpopulate(val, "TrackType", &m.TrackType) + delete(rawMsg, key) + case "transcriptionLanguage": + err = unpopulate(val, "TranscriptionLanguage", &m.TranscriptionLanguage) + delete(rawMsg, key) + case "transcriptionState": + err = unpopulate(val, "TranscriptionState", &m.TranscriptionState) + delete(rawMsg, key) + case "unexpectedBitrate": + err = unpopulate(val, "UnexpectedBitrate", &m.UnexpectedBitrate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MediaLiveEventTrackDiscontinuityDetectedEventData. +func (m MediaLiveEventTrackDiscontinuityDetectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bitrate", m.Bitrate) + populate(objectMap, "discontinuityGap", m.DiscontinuityGap) + populate(objectMap, "newTimestamp", m.NewTimestamp) + populate(objectMap, "previousTimestamp", m.PreviousTimestamp) + populate(objectMap, "timescale", m.Timescale) + populate(objectMap, "trackName", m.TrackName) + populate(objectMap, "trackType", m.TrackType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MediaLiveEventTrackDiscontinuityDetectedEventData. +func (m *MediaLiveEventTrackDiscontinuityDetectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "bitrate": + err = unpopulate(val, "Bitrate", &m.Bitrate) + delete(rawMsg, key) + case "discontinuityGap": + err = unpopulate(val, "DiscontinuityGap", &m.DiscontinuityGap) + delete(rawMsg, key) + case "newTimestamp": + err = unpopulate(val, "NewTimestamp", &m.NewTimestamp) + delete(rawMsg, key) + case "previousTimestamp": + err = unpopulate(val, "PreviousTimestamp", &m.PreviousTimestamp) + delete(rawMsg, key) + case "timescale": + err = unpopulate(val, "Timescale", &m.Timescale) + delete(rawMsg, key) + case "trackName": + err = unpopulate(val, "TrackName", &m.TrackName) + delete(rawMsg, key) + case "trackType": + err = unpopulate(val, "TrackType", &m.TrackType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MicrosoftTeamsUserIdentifierModel. +func (m MicrosoftTeamsUserIdentifierModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cloud", m.Cloud) + populate(objectMap, "isAnonymous", m.IsAnonymous) + populate(objectMap, "userId", m.UserID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MicrosoftTeamsUserIdentifierModel. +func (m *MicrosoftTeamsUserIdentifierModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cloud": + err = unpopulate(val, "Cloud", &m.Cloud) + delete(rawMsg, key) + case "isAnonymous": + err = unpopulate(val, "IsAnonymous", &m.IsAnonymous) + delete(rawMsg, key) + case "userId": + err = unpopulate(val, "UserID", &m.UserID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PhoneNumberIdentifierModel. +func (p PhoneNumberIdentifierModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PhoneNumberIdentifierModel. +func (p *PhoneNumberIdentifierModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyInsightsPolicyStateChangedEventData. +func (p PolicyInsightsPolicyStateChangedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "complianceReasonCode", p.ComplianceReasonCode) + populate(objectMap, "complianceState", p.ComplianceState) + populate(objectMap, "policyAssignmentId", p.PolicyAssignmentID) + populate(objectMap, "policyDefinitionId", p.PolicyDefinitionID) + populate(objectMap, "policyDefinitionReferenceId", p.PolicyDefinitionReferenceID) + populate(objectMap, "subscriptionId", p.SubscriptionID) + populateDateTimeRFC3339(objectMap, "timestamp", p.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyInsightsPolicyStateChangedEventData. +func (p *PolicyInsightsPolicyStateChangedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "complianceReasonCode": + err = unpopulate(val, "ComplianceReasonCode", &p.ComplianceReasonCode) + delete(rawMsg, key) + case "complianceState": + err = unpopulate(val, "ComplianceState", &p.ComplianceState) + delete(rawMsg, key) + case "policyAssignmentId": + err = unpopulate(val, "PolicyAssignmentID", &p.PolicyAssignmentID) + delete(rawMsg, key) + case "policyDefinitionId": + err = unpopulate(val, "PolicyDefinitionID", &p.PolicyDefinitionID) + delete(rawMsg, key) + case "policyDefinitionReferenceId": + err = unpopulate(val, "PolicyDefinitionReferenceID", &p.PolicyDefinitionReferenceID) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &p.SubscriptionID) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &p.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyInsightsPolicyStateCreatedEventData. +func (p PolicyInsightsPolicyStateCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "complianceReasonCode", p.ComplianceReasonCode) + populate(objectMap, "complianceState", p.ComplianceState) + populate(objectMap, "policyAssignmentId", p.PolicyAssignmentID) + populate(objectMap, "policyDefinitionId", p.PolicyDefinitionID) + populate(objectMap, "policyDefinitionReferenceId", p.PolicyDefinitionReferenceID) + populate(objectMap, "subscriptionId", p.SubscriptionID) + populateDateTimeRFC3339(objectMap, "timestamp", p.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyInsightsPolicyStateCreatedEventData. +func (p *PolicyInsightsPolicyStateCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "complianceReasonCode": + err = unpopulate(val, "ComplianceReasonCode", &p.ComplianceReasonCode) + delete(rawMsg, key) + case "complianceState": + err = unpopulate(val, "ComplianceState", &p.ComplianceState) + delete(rawMsg, key) + case "policyAssignmentId": + err = unpopulate(val, "PolicyAssignmentID", &p.PolicyAssignmentID) + delete(rawMsg, key) + case "policyDefinitionId": + err = unpopulate(val, "PolicyDefinitionID", &p.PolicyDefinitionID) + delete(rawMsg, key) + case "policyDefinitionReferenceId": + err = unpopulate(val, "PolicyDefinitionReferenceID", &p.PolicyDefinitionReferenceID) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &p.SubscriptionID) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &p.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyInsightsPolicyStateDeletedEventData. +func (p PolicyInsightsPolicyStateDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "complianceReasonCode", p.ComplianceReasonCode) + populate(objectMap, "complianceState", p.ComplianceState) + populate(objectMap, "policyAssignmentId", p.PolicyAssignmentID) + populate(objectMap, "policyDefinitionId", p.PolicyDefinitionID) + populate(objectMap, "policyDefinitionReferenceId", p.PolicyDefinitionReferenceID) + populate(objectMap, "subscriptionId", p.SubscriptionID) + populateDateTimeRFC3339(objectMap, "timestamp", p.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyInsightsPolicyStateDeletedEventData. +func (p *PolicyInsightsPolicyStateDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "complianceReasonCode": + err = unpopulate(val, "ComplianceReasonCode", &p.ComplianceReasonCode) + delete(rawMsg, key) + case "complianceState": + err = unpopulate(val, "ComplianceState", &p.ComplianceState) + delete(rawMsg, key) + case "policyAssignmentId": + err = unpopulate(val, "PolicyAssignmentID", &p.PolicyAssignmentID) + delete(rawMsg, key) + case "policyDefinitionId": + err = unpopulate(val, "PolicyDefinitionID", &p.PolicyDefinitionID) + delete(rawMsg, key) + case "policyDefinitionReferenceId": + err = unpopulate(val, "PolicyDefinitionReferenceID", &p.PolicyDefinitionReferenceID) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &p.SubscriptionID) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &p.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RedisExportRDBCompletedEventData. +func (r RedisExportRDBCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "status", r.Status) + populateDateTimeRFC3339(objectMap, "timestamp", r.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RedisExportRDBCompletedEventData. +func (r *RedisExportRDBCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &r.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RedisImportRDBCompletedEventData. +func (r RedisImportRDBCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "status", r.Status) + populateDateTimeRFC3339(objectMap, "timestamp", r.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RedisImportRDBCompletedEventData. +func (r *RedisImportRDBCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &r.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RedisPatchingCompletedEventData. +func (r RedisPatchingCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "status", r.Status) + populateDateTimeRFC3339(objectMap, "timestamp", r.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RedisPatchingCompletedEventData. +func (r *RedisPatchingCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &r.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RedisScalingCompletedEventData. +func (r RedisScalingCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "status", r.Status) + populateDateTimeRFC3339(objectMap, "timestamp", r.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RedisScalingCompletedEventData. +func (r *RedisScalingCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &r.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceActionCancelEventData. +func (r ResourceActionCancelEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorization", r.Authorization) + populate(objectMap, "claims", r.Claims) + populate(objectMap, "correlationId", r.CorrelationID) + populate(objectMap, "httpRequest", r.HTTPRequest) + populate(objectMap, "operationName", r.OperationName) + populate(objectMap, "resourceGroup", r.ResourceGroup) + populate(objectMap, "resourceProvider", r.ResourceProvider) + populate(objectMap, "resourceUri", r.ResourceURI) + populate(objectMap, "status", r.Status) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "tenantId", r.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceActionCancelEventData. +func (r *ResourceActionCancelEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authorization": + err = unpopulate(val, "Authorization", &r.Authorization) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, "Claims", &r.Claims) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &r.CorrelationID) + delete(rawMsg, key) + case "httpRequest": + err = unpopulate(val, "HTTPRequest", &r.HTTPRequest) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, "OperationName", &r.OperationName) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + delete(rawMsg, key) + case "resourceProvider": + err = unpopulate(val, "ResourceProvider", &r.ResourceProvider) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &r.ResourceURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceActionFailureEventData. +func (r ResourceActionFailureEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorization", r.Authorization) + populate(objectMap, "claims", r.Claims) + populate(objectMap, "correlationId", r.CorrelationID) + populate(objectMap, "httpRequest", r.HTTPRequest) + populate(objectMap, "operationName", r.OperationName) + populate(objectMap, "resourceGroup", r.ResourceGroup) + populate(objectMap, "resourceProvider", r.ResourceProvider) + populate(objectMap, "resourceUri", r.ResourceURI) + populate(objectMap, "status", r.Status) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "tenantId", r.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceActionFailureEventData. +func (r *ResourceActionFailureEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authorization": + err = unpopulate(val, "Authorization", &r.Authorization) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, "Claims", &r.Claims) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &r.CorrelationID) + delete(rawMsg, key) + case "httpRequest": + err = unpopulate(val, "HTTPRequest", &r.HTTPRequest) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, "OperationName", &r.OperationName) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + delete(rawMsg, key) + case "resourceProvider": + err = unpopulate(val, "ResourceProvider", &r.ResourceProvider) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &r.ResourceURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceActionSuccessEventData. +func (r ResourceActionSuccessEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorization", r.Authorization) + populate(objectMap, "claims", r.Claims) + populate(objectMap, "correlationId", r.CorrelationID) + populate(objectMap, "httpRequest", r.HTTPRequest) + populate(objectMap, "operationName", r.OperationName) + populate(objectMap, "resourceGroup", r.ResourceGroup) + populate(objectMap, "resourceProvider", r.ResourceProvider) + populate(objectMap, "resourceUri", r.ResourceURI) + populate(objectMap, "status", r.Status) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "tenantId", r.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceActionSuccessEventData. +func (r *ResourceActionSuccessEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authorization": + err = unpopulate(val, "Authorization", &r.Authorization) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, "Claims", &r.Claims) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &r.CorrelationID) + delete(rawMsg, key) + case "httpRequest": + err = unpopulate(val, "HTTPRequest", &r.HTTPRequest) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, "OperationName", &r.OperationName) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + delete(rawMsg, key) + case "resourceProvider": + err = unpopulate(val, "ResourceProvider", &r.ResourceProvider) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &r.ResourceURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceAuthorization. +func (r ResourceAuthorization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", r.Action) + populate(objectMap, "evidence", r.Evidence) + populate(objectMap, "scope", r.Scope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceAuthorization. +func (r *ResourceAuthorization) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &r.Action) + delete(rawMsg, key) + case "evidence": + err = unpopulate(val, "Evidence", &r.Evidence) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &r.Scope) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceDeleteCancelEventData. +func (r ResourceDeleteCancelEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorization", r.Authorization) + populate(objectMap, "claims", r.Claims) + populate(objectMap, "correlationId", r.CorrelationID) + populate(objectMap, "httpRequest", r.HTTPRequest) + populate(objectMap, "operationName", r.OperationName) + populate(objectMap, "resourceGroup", r.ResourceGroup) + populate(objectMap, "resourceProvider", r.ResourceProvider) + populate(objectMap, "resourceUri", r.ResourceURI) + populate(objectMap, "status", r.Status) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "tenantId", r.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceDeleteCancelEventData. +func (r *ResourceDeleteCancelEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authorization": + err = unpopulate(val, "Authorization", &r.Authorization) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, "Claims", &r.Claims) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &r.CorrelationID) + delete(rawMsg, key) + case "httpRequest": + err = unpopulate(val, "HTTPRequest", &r.HTTPRequest) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, "OperationName", &r.OperationName) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + delete(rawMsg, key) + case "resourceProvider": + err = unpopulate(val, "ResourceProvider", &r.ResourceProvider) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &r.ResourceURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceDeleteFailureEventData. +func (r ResourceDeleteFailureEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorization", r.Authorization) + populate(objectMap, "claims", r.Claims) + populate(objectMap, "correlationId", r.CorrelationID) + populate(objectMap, "httpRequest", r.HTTPRequest) + populate(objectMap, "operationName", r.OperationName) + populate(objectMap, "resourceGroup", r.ResourceGroup) + populate(objectMap, "resourceProvider", r.ResourceProvider) + populate(objectMap, "resourceUri", r.ResourceURI) + populate(objectMap, "status", r.Status) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "tenantId", r.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceDeleteFailureEventData. +func (r *ResourceDeleteFailureEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authorization": + err = unpopulate(val, "Authorization", &r.Authorization) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, "Claims", &r.Claims) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &r.CorrelationID) + delete(rawMsg, key) + case "httpRequest": + err = unpopulate(val, "HTTPRequest", &r.HTTPRequest) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, "OperationName", &r.OperationName) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + delete(rawMsg, key) + case "resourceProvider": + err = unpopulate(val, "ResourceProvider", &r.ResourceProvider) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &r.ResourceURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceDeleteSuccessEventData. +func (r ResourceDeleteSuccessEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorization", r.Authorization) + populate(objectMap, "claims", r.Claims) + populate(objectMap, "correlationId", r.CorrelationID) + populate(objectMap, "httpRequest", r.HTTPRequest) + populate(objectMap, "operationName", r.OperationName) + populate(objectMap, "resourceGroup", r.ResourceGroup) + populate(objectMap, "resourceProvider", r.ResourceProvider) + populate(objectMap, "resourceUri", r.ResourceURI) + populate(objectMap, "status", r.Status) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "tenantId", r.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceDeleteSuccessEventData. +func (r *ResourceDeleteSuccessEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authorization": + err = unpopulate(val, "Authorization", &r.Authorization) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, "Claims", &r.Claims) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &r.CorrelationID) + delete(rawMsg, key) + case "httpRequest": + err = unpopulate(val, "HTTPRequest", &r.HTTPRequest) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, "OperationName", &r.OperationName) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + delete(rawMsg, key) + case "resourceProvider": + err = unpopulate(val, "ResourceProvider", &r.ResourceProvider) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &r.ResourceURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceHTTPRequest. +func (r ResourceHTTPRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientIpAddress", r.ClientIPAddress) + populate(objectMap, "clientRequestId", r.ClientRequestID) + populate(objectMap, "method", r.Method) + populate(objectMap, "url", r.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceHTTPRequest. +func (r *ResourceHTTPRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientIpAddress": + err = unpopulate(val, "ClientIPAddress", &r.ClientIPAddress) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &r.ClientRequestID) + delete(rawMsg, key) + case "method": + err = unpopulate(val, "Method", &r.Method) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &r.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceNotificationsHealthResourcesAnnotatedEventData. +func (r ResourceNotificationsHealthResourcesAnnotatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiVersion", r.APIVersion) + populate(objectMap, "operationalInfo", r.OperationalDetails) + populate(objectMap, "resourceInfo", r.ResourceDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceNotificationsHealthResourcesAnnotatedEventData. +func (r *ResourceNotificationsHealthResourcesAnnotatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "apiVersion": + err = unpopulate(val, "APIVersion", &r.APIVersion) + delete(rawMsg, key) + case "operationalInfo": + err = unpopulate(val, "OperationalDetails", &r.OperationalDetails) + delete(rawMsg, key) + case "resourceInfo": + err = unpopulate(val, "ResourceDetails", &r.ResourceDetails) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceNotificationsHealthResourcesAvailabilityStatusChangedEventData. +func (r ResourceNotificationsHealthResourcesAvailabilityStatusChangedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiVersion", r.APIVersion) + populate(objectMap, "operationalInfo", r.OperationalDetails) + populate(objectMap, "resourceInfo", r.ResourceDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceNotificationsHealthResourcesAvailabilityStatusChangedEventData. +func (r *ResourceNotificationsHealthResourcesAvailabilityStatusChangedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "apiVersion": + err = unpopulate(val, "APIVersion", &r.APIVersion) + delete(rawMsg, key) + case "operationalInfo": + err = unpopulate(val, "OperationalDetails", &r.OperationalDetails) + delete(rawMsg, key) + case "resourceInfo": + err = unpopulate(val, "ResourceDetails", &r.ResourceDetails) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceNotificationsOperationalDetails. +func (r ResourceNotificationsOperationalDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "resourceEventTime", r.ResourceEventTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceNotificationsOperationalDetails. +func (r *ResourceNotificationsOperationalDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceEventTime": + err = unpopulateDateTimeRFC3339(val, "ResourceEventTime", &r.ResourceEventTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceNotificationsResourceDeletedDetails. +func (r ResourceNotificationsResourceDeletedDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceNotificationsResourceDeletedDetails. +func (r *ResourceNotificationsResourceDeletedDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceNotificationsResourceDeletedEventData. +func (r ResourceNotificationsResourceDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "operationalInfo", r.OperationalDetails) + populate(objectMap, "resourceInfo", r.ResourceDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceNotificationsResourceDeletedEventData. +func (r *ResourceNotificationsResourceDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "operationalInfo": + err = unpopulate(val, "OperationalDetails", &r.OperationalDetails) + delete(rawMsg, key) + case "resourceInfo": + err = unpopulate(val, "ResourceDetails", &r.ResourceDetails) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceNotificationsResourceManagementCreatedOrUpdatedEventData. +func (r ResourceNotificationsResourceManagementCreatedOrUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiVersion", r.APIVersion) + populate(objectMap, "operationalInfo", r.OperationalDetails) + populate(objectMap, "resourceInfo", r.ResourceDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceNotificationsResourceManagementCreatedOrUpdatedEventData. +func (r *ResourceNotificationsResourceManagementCreatedOrUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "apiVersion": + err = unpopulate(val, "APIVersion", &r.APIVersion) + delete(rawMsg, key) + case "operationalInfo": + err = unpopulate(val, "OperationalDetails", &r.OperationalDetails) + delete(rawMsg, key) + case "resourceInfo": + err = unpopulate(val, "ResourceDetails", &r.ResourceDetails) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceNotificationsResourceManagementDeletedEventData. +func (r ResourceNotificationsResourceManagementDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "operationalInfo", r.OperationalDetails) + populate(objectMap, "resourceInfo", r.ResourceDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceNotificationsResourceManagementDeletedEventData. +func (r *ResourceNotificationsResourceManagementDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "operationalInfo": + err = unpopulate(val, "OperationalDetails", &r.OperationalDetails) + delete(rawMsg, key) + case "resourceInfo": + err = unpopulate(val, "ResourceDetails", &r.ResourceDetails) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceNotificationsResourceUpdatedDetails. +func (r ResourceNotificationsResourceUpdatedDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceNotificationsResourceUpdatedDetails. +func (r *ResourceNotificationsResourceUpdatedDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceNotificationsResourceUpdatedEventData. +func (r ResourceNotificationsResourceUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiVersion", r.APIVersion) + populate(objectMap, "operationalInfo", r.OperationalDetails) + populate(objectMap, "resourceInfo", r.ResourceDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceNotificationsResourceUpdatedEventData. +func (r *ResourceNotificationsResourceUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "apiVersion": + err = unpopulate(val, "APIVersion", &r.APIVersion) + delete(rawMsg, key) + case "operationalInfo": + err = unpopulate(val, "OperationalDetails", &r.OperationalDetails) + delete(rawMsg, key) + case "resourceInfo": + err = unpopulate(val, "ResourceDetails", &r.ResourceDetails) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceWriteCancelEventData. +func (r ResourceWriteCancelEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorization", r.Authorization) + populate(objectMap, "claims", r.Claims) + populate(objectMap, "correlationId", r.CorrelationID) + populate(objectMap, "httpRequest", r.HTTPRequest) + populate(objectMap, "operationName", r.OperationName) + populate(objectMap, "resourceGroup", r.ResourceGroup) + populate(objectMap, "resourceProvider", r.ResourceProvider) + populate(objectMap, "resourceUri", r.ResourceURI) + populate(objectMap, "status", r.Status) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "tenantId", r.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceWriteCancelEventData. +func (r *ResourceWriteCancelEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authorization": + err = unpopulate(val, "Authorization", &r.Authorization) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, "Claims", &r.Claims) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &r.CorrelationID) + delete(rawMsg, key) + case "httpRequest": + err = unpopulate(val, "HTTPRequest", &r.HTTPRequest) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, "OperationName", &r.OperationName) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + delete(rawMsg, key) + case "resourceProvider": + err = unpopulate(val, "ResourceProvider", &r.ResourceProvider) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &r.ResourceURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceWriteFailureEventData. +func (r ResourceWriteFailureEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorization", r.Authorization) + populate(objectMap, "claims", r.Claims) + populate(objectMap, "correlationId", r.CorrelationID) + populate(objectMap, "httpRequest", r.HTTPRequest) + populate(objectMap, "operationName", r.OperationName) + populate(objectMap, "resourceGroup", r.ResourceGroup) + populate(objectMap, "resourceProvider", r.ResourceProvider) + populate(objectMap, "resourceUri", r.ResourceURI) + populate(objectMap, "status", r.Status) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "tenantId", r.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceWriteFailureEventData. +func (r *ResourceWriteFailureEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authorization": + err = unpopulate(val, "Authorization", &r.Authorization) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, "Claims", &r.Claims) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &r.CorrelationID) + delete(rawMsg, key) + case "httpRequest": + err = unpopulate(val, "HTTPRequest", &r.HTTPRequest) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, "OperationName", &r.OperationName) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + delete(rawMsg, key) + case "resourceProvider": + err = unpopulate(val, "ResourceProvider", &r.ResourceProvider) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &r.ResourceURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceWriteSuccessEventData. +func (r ResourceWriteSuccessEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authorization", r.Authorization) + populate(objectMap, "claims", r.Claims) + populate(objectMap, "correlationId", r.CorrelationID) + populate(objectMap, "httpRequest", r.HTTPRequest) + populate(objectMap, "operationName", r.OperationName) + populate(objectMap, "resourceGroup", r.ResourceGroup) + populate(objectMap, "resourceProvider", r.ResourceProvider) + populate(objectMap, "resourceUri", r.ResourceURI) + populate(objectMap, "status", r.Status) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "tenantId", r.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceWriteSuccessEventData. +func (r *ResourceWriteSuccessEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authorization": + err = unpopulate(val, "Authorization", &r.Authorization) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, "Claims", &r.Claims) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &r.CorrelationID) + delete(rawMsg, key) + case "httpRequest": + err = unpopulate(val, "HTTPRequest", &r.HTTPRequest) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, "OperationName", &r.OperationName) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &r.ResourceGroup) + delete(rawMsg, key) + case "resourceProvider": + err = unpopulate(val, "ResourceProvider", &r.ResourceProvider) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, "ResourceURI", &r.ResourceURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceBusActiveMessagesAvailablePeriodicNotificationsEventData. +func (s ServiceBusActiveMessagesAvailablePeriodicNotificationsEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "entityType", s.EntityType) + populate(objectMap, "namespaceName", s.NamespaceName) + populate(objectMap, "queueName", s.QueueName) + populate(objectMap, "requestUri", s.RequestURI) + populate(objectMap, "subscriptionName", s.SubscriptionName) + populate(objectMap, "topicName", s.TopicName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceBusActiveMessagesAvailablePeriodicNotificationsEventData. +func (s *ServiceBusActiveMessagesAvailablePeriodicNotificationsEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "entityType": + err = unpopulate(val, "EntityType", &s.EntityType) + delete(rawMsg, key) + case "namespaceName": + err = unpopulate(val, "NamespaceName", &s.NamespaceName) + delete(rawMsg, key) + case "queueName": + err = unpopulate(val, "QueueName", &s.QueueName) + delete(rawMsg, key) + case "requestUri": + err = unpopulate(val, "RequestURI", &s.RequestURI) + delete(rawMsg, key) + case "subscriptionName": + err = unpopulate(val, "SubscriptionName", &s.SubscriptionName) + delete(rawMsg, key) + case "topicName": + err = unpopulate(val, "TopicName", &s.TopicName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceBusActiveMessagesAvailableWithNoListenersEventData. +func (s ServiceBusActiveMessagesAvailableWithNoListenersEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "entityType", s.EntityType) + populate(objectMap, "namespaceName", s.NamespaceName) + populate(objectMap, "queueName", s.QueueName) + populate(objectMap, "requestUri", s.RequestURI) + populate(objectMap, "subscriptionName", s.SubscriptionName) + populate(objectMap, "topicName", s.TopicName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceBusActiveMessagesAvailableWithNoListenersEventData. +func (s *ServiceBusActiveMessagesAvailableWithNoListenersEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "entityType": + err = unpopulate(val, "EntityType", &s.EntityType) + delete(rawMsg, key) + case "namespaceName": + err = unpopulate(val, "NamespaceName", &s.NamespaceName) + delete(rawMsg, key) + case "queueName": + err = unpopulate(val, "QueueName", &s.QueueName) + delete(rawMsg, key) + case "requestUri": + err = unpopulate(val, "RequestURI", &s.RequestURI) + delete(rawMsg, key) + case "subscriptionName": + err = unpopulate(val, "SubscriptionName", &s.SubscriptionName) + delete(rawMsg, key) + case "topicName": + err = unpopulate(val, "TopicName", &s.TopicName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceBusDeadletterMessagesAvailablePeriodicNotificationsEventData. +func (s ServiceBusDeadletterMessagesAvailablePeriodicNotificationsEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "entityType", s.EntityType) + populate(objectMap, "namespaceName", s.NamespaceName) + populate(objectMap, "queueName", s.QueueName) + populate(objectMap, "requestUri", s.RequestURI) + populate(objectMap, "subscriptionName", s.SubscriptionName) + populate(objectMap, "topicName", s.TopicName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceBusDeadletterMessagesAvailablePeriodicNotificationsEventData. +func (s *ServiceBusDeadletterMessagesAvailablePeriodicNotificationsEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "entityType": + err = unpopulate(val, "EntityType", &s.EntityType) + delete(rawMsg, key) + case "namespaceName": + err = unpopulate(val, "NamespaceName", &s.NamespaceName) + delete(rawMsg, key) + case "queueName": + err = unpopulate(val, "QueueName", &s.QueueName) + delete(rawMsg, key) + case "requestUri": + err = unpopulate(val, "RequestURI", &s.RequestURI) + delete(rawMsg, key) + case "subscriptionName": + err = unpopulate(val, "SubscriptionName", &s.SubscriptionName) + delete(rawMsg, key) + case "topicName": + err = unpopulate(val, "TopicName", &s.TopicName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceBusDeadletterMessagesAvailableWithNoListenersEventData. +func (s ServiceBusDeadletterMessagesAvailableWithNoListenersEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "entityType", s.EntityType) + populate(objectMap, "namespaceName", s.NamespaceName) + populate(objectMap, "queueName", s.QueueName) + populate(objectMap, "requestUri", s.RequestURI) + populate(objectMap, "subscriptionName", s.SubscriptionName) + populate(objectMap, "topicName", s.TopicName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceBusDeadletterMessagesAvailableWithNoListenersEventData. +func (s *ServiceBusDeadletterMessagesAvailableWithNoListenersEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "entityType": + err = unpopulate(val, "EntityType", &s.EntityType) + delete(rawMsg, key) + case "namespaceName": + err = unpopulate(val, "NamespaceName", &s.NamespaceName) + delete(rawMsg, key) + case "queueName": + err = unpopulate(val, "QueueName", &s.QueueName) + delete(rawMsg, key) + case "requestUri": + err = unpopulate(val, "RequestURI", &s.RequestURI) + delete(rawMsg, key) + case "subscriptionName": + err = unpopulate(val, "SubscriptionName", &s.SubscriptionName) + delete(rawMsg, key) + case "topicName": + err = unpopulate(val, "TopicName", &s.TopicName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SignalRServiceClientConnectionConnectedEventData. +func (s SignalRServiceClientConnectionConnectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connectionId", s.ConnectionID) + populate(objectMap, "hubName", s.HubName) + populateDateTimeRFC3339(objectMap, "timestamp", s.Timestamp) + populate(objectMap, "userId", s.UserID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SignalRServiceClientConnectionConnectedEventData. +func (s *SignalRServiceClientConnectionConnectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "connectionId": + err = unpopulate(val, "ConnectionID", &s.ConnectionID) + delete(rawMsg, key) + case "hubName": + err = unpopulate(val, "HubName", &s.HubName) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &s.Timestamp) + delete(rawMsg, key) + case "userId": + err = unpopulate(val, "UserID", &s.UserID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SignalRServiceClientConnectionDisconnectedEventData. +func (s SignalRServiceClientConnectionDisconnectedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connectionId", s.ConnectionID) + populate(objectMap, "errorMessage", s.ErrorMessage) + populate(objectMap, "hubName", s.HubName) + populateDateTimeRFC3339(objectMap, "timestamp", s.Timestamp) + populate(objectMap, "userId", s.UserID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SignalRServiceClientConnectionDisconnectedEventData. +func (s *SignalRServiceClientConnectionDisconnectedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "connectionId": + err = unpopulate(val, "ConnectionID", &s.ConnectionID) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &s.ErrorMessage) + delete(rawMsg, key) + case "hubName": + err = unpopulate(val, "HubName", &s.HubName) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &s.Timestamp) + delete(rawMsg, key) + case "userId": + err = unpopulate(val, "UserID", &s.UserID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageAsyncOperationInitiatedEventData. +func (s StorageAsyncOperationInitiatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "api", s.API) + populate(objectMap, "blobType", s.BlobType) + populate(objectMap, "clientRequestId", s.ClientRequestID) + populate(objectMap, "contentLength", s.ContentLength) + populate(objectMap, "contentType", s.ContentType) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "requestId", s.RequestID) + populate(objectMap, "sequencer", s.Sequencer) + populateAny(objectMap, "storageDiagnostics", s.StorageDiagnostics) + populate(objectMap, "url", s.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageAsyncOperationInitiatedEventData. +func (s *StorageAsyncOperationInitiatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "api": + err = unpopulate(val, "API", &s.API) + delete(rawMsg, key) + case "blobType": + err = unpopulate(val, "BlobType", &s.BlobType) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &s.ClientRequestID) + delete(rawMsg, key) + case "contentLength": + err = unpopulate(val, "ContentLength", &s.ContentLength) + delete(rawMsg, key) + case "contentType": + err = unpopulate(val, "ContentType", &s.ContentType) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &s.RequestID) + delete(rawMsg, key) + case "sequencer": + err = unpopulate(val, "Sequencer", &s.Sequencer) + delete(rawMsg, key) + case "storageDiagnostics": + err = unpopulate(val, "StorageDiagnostics", &s.StorageDiagnostics) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &s.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageBlobCreatedEventData. +func (s StorageBlobCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "api", s.API) + populate(objectMap, "blobType", s.BlobType) + populate(objectMap, "clientRequestId", s.ClientRequestID) + populate(objectMap, "contentLength", s.ContentLength) + populate(objectMap, "contentOffset", s.ContentOffset) + populate(objectMap, "contentType", s.ContentType) + populate(objectMap, "eTag", s.ETag) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "requestId", s.RequestID) + populate(objectMap, "sequencer", s.Sequencer) + populateAny(objectMap, "storageDiagnostics", s.StorageDiagnostics) + populate(objectMap, "url", s.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageBlobCreatedEventData. +func (s *StorageBlobCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "api": + err = unpopulate(val, "API", &s.API) + delete(rawMsg, key) + case "blobType": + err = unpopulate(val, "BlobType", &s.BlobType) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &s.ClientRequestID) + delete(rawMsg, key) + case "contentLength": + err = unpopulate(val, "ContentLength", &s.ContentLength) + delete(rawMsg, key) + case "contentOffset": + err = unpopulate(val, "ContentOffset", &s.ContentOffset) + delete(rawMsg, key) + case "contentType": + err = unpopulate(val, "ContentType", &s.ContentType) + delete(rawMsg, key) + case "eTag": + err = unpopulate(val, "ETag", &s.ETag) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &s.RequestID) + delete(rawMsg, key) + case "sequencer": + err = unpopulate(val, "Sequencer", &s.Sequencer) + delete(rawMsg, key) + case "storageDiagnostics": + err = unpopulate(val, "StorageDiagnostics", &s.StorageDiagnostics) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &s.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageBlobDeletedEventData. +func (s StorageBlobDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "api", s.API) + populate(objectMap, "blobType", s.BlobType) + populate(objectMap, "clientRequestId", s.ClientRequestID) + populate(objectMap, "contentType", s.ContentType) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "requestId", s.RequestID) + populate(objectMap, "sequencer", s.Sequencer) + populateAny(objectMap, "storageDiagnostics", s.StorageDiagnostics) + populate(objectMap, "url", s.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageBlobDeletedEventData. +func (s *StorageBlobDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "api": + err = unpopulate(val, "API", &s.API) + delete(rawMsg, key) + case "blobType": + err = unpopulate(val, "BlobType", &s.BlobType) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &s.ClientRequestID) + delete(rawMsg, key) + case "contentType": + err = unpopulate(val, "ContentType", &s.ContentType) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &s.RequestID) + delete(rawMsg, key) + case "sequencer": + err = unpopulate(val, "Sequencer", &s.Sequencer) + delete(rawMsg, key) + case "storageDiagnostics": + err = unpopulate(val, "StorageDiagnostics", &s.StorageDiagnostics) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &s.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageBlobInventoryPolicyCompletedEventData. +func (s StorageBlobInventoryPolicyCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountName", s.AccountName) + populate(objectMap, "manifestBlobUrl", s.ManifestBlobURL) + populate(objectMap, "policyRunId", s.PolicyRunID) + populate(objectMap, "policyRunStatus", s.PolicyRunStatus) + populate(objectMap, "policyRunStatusMessage", s.PolicyRunStatusMessage) + populate(objectMap, "ruleName", s.RuleName) + populateDateTimeRFC3339(objectMap, "scheduleDateTime", s.ScheduleDateTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageBlobInventoryPolicyCompletedEventData. +func (s *StorageBlobInventoryPolicyCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountName": + err = unpopulate(val, "AccountName", &s.AccountName) + delete(rawMsg, key) + case "manifestBlobUrl": + err = unpopulate(val, "ManifestBlobURL", &s.ManifestBlobURL) + delete(rawMsg, key) + case "policyRunId": + err = unpopulate(val, "PolicyRunID", &s.PolicyRunID) + delete(rawMsg, key) + case "policyRunStatus": + err = unpopulate(val, "PolicyRunStatus", &s.PolicyRunStatus) + delete(rawMsg, key) + case "policyRunStatusMessage": + err = unpopulate(val, "PolicyRunStatusMessage", &s.PolicyRunStatusMessage) + delete(rawMsg, key) + case "ruleName": + err = unpopulate(val, "RuleName", &s.RuleName) + delete(rawMsg, key) + case "scheduleDateTime": + err = unpopulateDateTimeRFC3339(val, "ScheduleDateTime", &s.ScheduleDateTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageBlobRenamedEventData. +func (s StorageBlobRenamedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "api", s.API) + populate(objectMap, "clientRequestId", s.ClientRequestID) + populate(objectMap, "destinationUrl", s.DestinationURL) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "requestId", s.RequestID) + populate(objectMap, "sequencer", s.Sequencer) + populate(objectMap, "sourceUrl", s.SourceURL) + populateAny(objectMap, "storageDiagnostics", s.StorageDiagnostics) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageBlobRenamedEventData. +func (s *StorageBlobRenamedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "api": + err = unpopulate(val, "API", &s.API) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &s.ClientRequestID) + delete(rawMsg, key) + case "destinationUrl": + err = unpopulate(val, "DestinationURL", &s.DestinationURL) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &s.RequestID) + delete(rawMsg, key) + case "sequencer": + err = unpopulate(val, "Sequencer", &s.Sequencer) + delete(rawMsg, key) + case "sourceUrl": + err = unpopulate(val, "SourceURL", &s.SourceURL) + delete(rawMsg, key) + case "storageDiagnostics": + err = unpopulate(val, "StorageDiagnostics", &s.StorageDiagnostics) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageBlobTierChangedEventData. +func (s StorageBlobTierChangedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "api", s.API) + populate(objectMap, "blobType", s.BlobType) + populate(objectMap, "clientRequestId", s.ClientRequestID) + populate(objectMap, "contentLength", s.ContentLength) + populate(objectMap, "contentType", s.ContentType) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "requestId", s.RequestID) + populate(objectMap, "sequencer", s.Sequencer) + populateAny(objectMap, "storageDiagnostics", s.StorageDiagnostics) + populate(objectMap, "url", s.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageBlobTierChangedEventData. +func (s *StorageBlobTierChangedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "api": + err = unpopulate(val, "API", &s.API) + delete(rawMsg, key) + case "blobType": + err = unpopulate(val, "BlobType", &s.BlobType) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &s.ClientRequestID) + delete(rawMsg, key) + case "contentLength": + err = unpopulate(val, "ContentLength", &s.ContentLength) + delete(rawMsg, key) + case "contentType": + err = unpopulate(val, "ContentType", &s.ContentType) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &s.RequestID) + delete(rawMsg, key) + case "sequencer": + err = unpopulate(val, "Sequencer", &s.Sequencer) + delete(rawMsg, key) + case "storageDiagnostics": + err = unpopulate(val, "StorageDiagnostics", &s.StorageDiagnostics) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &s.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageDirectoryCreatedEventData. +func (s StorageDirectoryCreatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "api", s.API) + populate(objectMap, "clientRequestId", s.ClientRequestID) + populate(objectMap, "eTag", s.ETag) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "requestId", s.RequestID) + populate(objectMap, "sequencer", s.Sequencer) + populateAny(objectMap, "storageDiagnostics", s.StorageDiagnostics) + populate(objectMap, "url", s.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageDirectoryCreatedEventData. +func (s *StorageDirectoryCreatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "api": + err = unpopulate(val, "API", &s.API) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &s.ClientRequestID) + delete(rawMsg, key) + case "eTag": + err = unpopulate(val, "ETag", &s.ETag) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &s.RequestID) + delete(rawMsg, key) + case "sequencer": + err = unpopulate(val, "Sequencer", &s.Sequencer) + delete(rawMsg, key) + case "storageDiagnostics": + err = unpopulate(val, "StorageDiagnostics", &s.StorageDiagnostics) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &s.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageDirectoryDeletedEventData. +func (s StorageDirectoryDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "api", s.API) + populate(objectMap, "clientRequestId", s.ClientRequestID) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "recursive", s.Recursive) + populate(objectMap, "requestId", s.RequestID) + populate(objectMap, "sequencer", s.Sequencer) + populateAny(objectMap, "storageDiagnostics", s.StorageDiagnostics) + populate(objectMap, "url", s.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageDirectoryDeletedEventData. +func (s *StorageDirectoryDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "api": + err = unpopulate(val, "API", &s.API) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &s.ClientRequestID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "recursive": + err = unpopulate(val, "Recursive", &s.Recursive) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &s.RequestID) + delete(rawMsg, key) + case "sequencer": + err = unpopulate(val, "Sequencer", &s.Sequencer) + delete(rawMsg, key) + case "storageDiagnostics": + err = unpopulate(val, "StorageDiagnostics", &s.StorageDiagnostics) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &s.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageDirectoryRenamedEventData. +func (s StorageDirectoryRenamedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "api", s.API) + populate(objectMap, "clientRequestId", s.ClientRequestID) + populate(objectMap, "destinationUrl", s.DestinationURL) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "requestId", s.RequestID) + populate(objectMap, "sequencer", s.Sequencer) + populate(objectMap, "sourceUrl", s.SourceURL) + populateAny(objectMap, "storageDiagnostics", s.StorageDiagnostics) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageDirectoryRenamedEventData. +func (s *StorageDirectoryRenamedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "api": + err = unpopulate(val, "API", &s.API) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &s.ClientRequestID) + delete(rawMsg, key) + case "destinationUrl": + err = unpopulate(val, "DestinationURL", &s.DestinationURL) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &s.RequestID) + delete(rawMsg, key) + case "sequencer": + err = unpopulate(val, "Sequencer", &s.Sequencer) + delete(rawMsg, key) + case "sourceUrl": + err = unpopulate(val, "SourceURL", &s.SourceURL) + delete(rawMsg, key) + case "storageDiagnostics": + err = unpopulate(val, "StorageDiagnostics", &s.StorageDiagnostics) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageLifecyclePolicyActionSummaryDetail. +func (s StorageLifecyclePolicyActionSummaryDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "errorList", s.ErrorList) + populate(objectMap, "successCount", s.SuccessCount) + populate(objectMap, "totalObjectsCount", s.TotalObjectsCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageLifecyclePolicyActionSummaryDetail. +func (s *StorageLifecyclePolicyActionSummaryDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "errorList": + err = unpopulate(val, "ErrorList", &s.ErrorList) + delete(rawMsg, key) + case "successCount": + err = unpopulate(val, "SuccessCount", &s.SuccessCount) + delete(rawMsg, key) + case "totalObjectsCount": + err = unpopulate(val, "TotalObjectsCount", &s.TotalObjectsCount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageLifecyclePolicyCompletedEventData. +func (s StorageLifecyclePolicyCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deleteSummary", s.DeleteSummary) + populate(objectMap, "scheduleTime", s.ScheduleTime) + populate(objectMap, "tierToArchiveSummary", s.TierToArchiveSummary) + populate(objectMap, "tierToCoolSummary", s.TierToCoolSummary) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageLifecyclePolicyCompletedEventData. +func (s *StorageLifecyclePolicyCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deleteSummary": + err = unpopulate(val, "DeleteSummary", &s.DeleteSummary) + delete(rawMsg, key) + case "scheduleTime": + err = unpopulate(val, "ScheduleTime", &s.ScheduleTime) + delete(rawMsg, key) + case "tierToArchiveSummary": + err = unpopulate(val, "TierToArchiveSummary", &s.TierToArchiveSummary) + delete(rawMsg, key) + case "tierToCoolSummary": + err = unpopulate(val, "TierToCoolSummary", &s.TierToCoolSummary) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageTaskCompletedEventData. +func (s StorageTaskCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "completedDateTime", s.CompletedDateTime) + populate(objectMap, "status", s.Status) + populate(objectMap, "summaryReportBlobUrl", s.SummaryReportBlobURL) + populate(objectMap, "taskExecutionId", s.TaskExecutionID) + populate(objectMap, "taskName", s.TaskName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageTaskCompletedEventData. +func (s *StorageTaskCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "completedDateTime": + err = unpopulateDateTimeRFC3339(val, "CompletedDateTime", &s.CompletedDateTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + case "summaryReportBlobUrl": + err = unpopulate(val, "SummaryReportBlobURL", &s.SummaryReportBlobURL) + delete(rawMsg, key) + case "taskExecutionId": + err = unpopulate(val, "TaskExecutionID", &s.TaskExecutionID) + delete(rawMsg, key) + case "taskName": + err = unpopulate(val, "TaskName", &s.TaskName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageTaskQueuedEventData. +func (s StorageTaskQueuedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "queuedDateTime", s.QueuedDateTime) + populate(objectMap, "taskExecutionId", s.TaskExecutionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageTaskQueuedEventData. +func (s *StorageTaskQueuedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "queuedDateTime": + err = unpopulateDateTimeRFC3339(val, "QueuedDateTime", &s.QueuedDateTime) + delete(rawMsg, key) + case "taskExecutionId": + err = unpopulate(val, "TaskExecutionID", &s.TaskExecutionID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionDeletedEventData. +func (s SubscriptionDeletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eventSubscriptionId", s.EventSubscriptionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionDeletedEventData. +func (s *SubscriptionDeletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eventSubscriptionId": + err = unpopulate(val, "EventSubscriptionID", &s.EventSubscriptionID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionValidationEventData. +func (s SubscriptionValidationEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "validationCode", s.ValidationCode) + populate(objectMap, "validationUrl", s.ValidationURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionValidationEventData. +func (s *SubscriptionValidationEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "validationCode": + err = unpopulate(val, "ValidationCode", &s.ValidationCode) + delete(rawMsg, key) + case "validationUrl": + err = unpopulate(val, "ValidationURL", &s.ValidationURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionValidationResponse. +func (s SubscriptionValidationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "validationResponse", s.ValidationResponse) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionValidationResponse. +func (s *SubscriptionValidationResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "validationResponse": + err = unpopulate(val, "ValidationResponse", &s.ValidationResponse) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebAppServicePlanUpdatedEventData. +func (w WebAppServicePlanUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appServicePlanEventTypeDetail", w.AppServicePlanEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "sku", w.SKU) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebAppServicePlanUpdatedEventData. +func (w *WebAppServicePlanUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appServicePlanEventTypeDetail": + err = unpopulate(val, "AppServicePlanEventTypeDetail", &w.AppServicePlanEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &w.SKU) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebAppServicePlanUpdatedEventDataSKU. +func (w WebAppServicePlanUpdatedEventDataSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "Capacity", w.Capacity) + populate(objectMap, "Family", w.Family) + populate(objectMap, "name", w.Name) + populate(objectMap, "Size", w.Size) + populate(objectMap, "Tier", w.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebAppServicePlanUpdatedEventDataSKU. +func (w *WebAppServicePlanUpdatedEventDataSKU) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "Capacity": + err = unpopulate(val, "Capacity", &w.Capacity) + delete(rawMsg, key) + case "Family": + err = unpopulate(val, "Family", &w.Family) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "Size": + err = unpopulate(val, "Size", &w.Size) + delete(rawMsg, key) + case "Tier": + err = unpopulate(val, "Tier", &w.Tier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebAppUpdatedEventData. +func (w WebAppUpdatedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebAppUpdatedEventData. +func (w *WebAppUpdatedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebBackupOperationCompletedEventData. +func (w WebBackupOperationCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebBackupOperationCompletedEventData. +func (w *WebBackupOperationCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebBackupOperationFailedEventData. +func (w WebBackupOperationFailedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebBackupOperationFailedEventData. +func (w *WebBackupOperationFailedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebBackupOperationStartedEventData. +func (w WebBackupOperationStartedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebBackupOperationStartedEventData. +func (w *WebBackupOperationStartedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebRestoreOperationCompletedEventData. +func (w WebRestoreOperationCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebRestoreOperationCompletedEventData. +func (w *WebRestoreOperationCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebRestoreOperationFailedEventData. +func (w WebRestoreOperationFailedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebRestoreOperationFailedEventData. +func (w *WebRestoreOperationFailedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebRestoreOperationStartedEventData. +func (w WebRestoreOperationStartedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebRestoreOperationStartedEventData. +func (w *WebRestoreOperationStartedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebSlotSwapCompletedEventData. +func (w WebSlotSwapCompletedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebSlotSwapCompletedEventData. +func (w *WebSlotSwapCompletedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebSlotSwapFailedEventData. +func (w WebSlotSwapFailedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebSlotSwapFailedEventData. +func (w *WebSlotSwapFailedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebSlotSwapStartedEventData. +func (w WebSlotSwapStartedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebSlotSwapStartedEventData. +func (w *WebSlotSwapStartedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebSlotSwapWithPreviewCancelledEventData. +func (w WebSlotSwapWithPreviewCancelledEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebSlotSwapWithPreviewCancelledEventData. +func (w *WebSlotSwapWithPreviewCancelledEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebSlotSwapWithPreviewStartedEventData. +func (w WebSlotSwapWithPreviewStartedEventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", w.Address) + populate(objectMap, "appEventTypeDetail", w.AppEventTypeDetail) + populate(objectMap, "clientRequestId", w.ClientRequestID) + populate(objectMap, "correlationRequestId", w.CorrelationRequestID) + populate(objectMap, "name", w.Name) + populate(objectMap, "requestId", w.RequestID) + populate(objectMap, "verb", w.Verb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebSlotSwapWithPreviewStartedEventData. +func (w *WebSlotSwapWithPreviewStartedEventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &w.Address) + delete(rawMsg, key) + case "appEventTypeDetail": + err = unpopulate(val, "AppEventTypeDetail", &w.AppEventTypeDetail) + delete(rawMsg, key) + case "clientRequestId": + err = unpopulate(val, "ClientRequestID", &w.ClientRequestID) + delete(rawMsg, key) + case "correlationRequestId": + err = unpopulate(val, "CorrelationRequestID", &w.CorrelationRequestID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, "RequestID", &w.RequestID) + delete(rawMsg, key) + case "verb": + err = unpopulate(val, "Verb", &w.Verb) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/messaging/eventgrid/azsystemevents/polymorphic_helpers.go b/sdk/messaging/eventgrid/azsystemevents/polymorphic_helpers.go new file mode 100644 index 000000000000..6e20761b01fd --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/polymorphic_helpers.go @@ -0,0 +1,51 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package azsystemevents + +import "encoding/json" + +func unmarshalMediaJobOutputClassification(rawMsg json.RawMessage) (MediaJobOutputClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b MediaJobOutputClassification + switch m["@odata.type"] { + case "#Microsoft.Media.JobOutputAsset": + b = &MediaJobOutputAsset{} + default: + b = &MediaJobOutput{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalMediaJobOutputClassificationArray(rawMsg json.RawMessage) ([]MediaJobOutputClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]MediaJobOutputClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalMediaJobOutputClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} diff --git a/sdk/messaging/eventgrid/azsystemevents/system_events.go b/sdk/messaging/eventgrid/azsystemevents/system_events.go new file mode 100644 index 000000000000..d2046edc0ed0 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/system_events.go @@ -0,0 +1,213 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azsystemevents + +// Type represents the value set in EventData.EventType or messaging.CloudEvent.Type +// for system events. +type Type string + +const ( + TypeAPIManagementAPICreated Type = "Microsoft.ApiManagement.APICreated" // maps to APIManagementAPICreatedEventData + TypeAPIManagementAPIDeleted Type = "Microsoft.ApiManagement.APIDeleted" // maps to APIManagementAPIDeletedEventData + TypeAPIManagementAPIReleaseCreated Type = "Microsoft.ApiManagement.APIReleaseCreated" // maps to APIManagementAPIReleaseCreatedEventData + TypeAPIManagementAPIReleaseDeleted Type = "Microsoft.ApiManagement.APIReleaseDeleted" // maps to APIManagementAPIReleaseDeletedEventData + TypeAPIManagementAPIReleaseUpdated Type = "Microsoft.ApiManagement.APIReleaseUpdated" // maps to APIManagementAPIReleaseUpdatedEventData + TypeAPIManagementAPIUpdated Type = "Microsoft.ApiManagement.APIUpdated" // maps to APIManagementAPIUpdatedEventData + TypeAPIManagementGatewayAPIAdded Type = "Microsoft.ApiManagement.GatewayAPIAdded" // maps to APIManagementGatewayAPIAddedEventData + TypeAPIManagementGatewayAPIRemoved Type = "Microsoft.ApiManagement.GatewayAPIRemoved" // maps to APIManagementGatewayAPIRemovedEventData + TypeAPIManagementGatewayCertificateAuthorityCreated Type = "Microsoft.ApiManagement.GatewayCertificateAuthorityCreated" // maps to APIManagementGatewayCertificateAuthorityCreatedEventData + TypeAPIManagementGatewayCertificateAuthorityDeleted Type = "Microsoft.ApiManagement.GatewayCertificateAuthorityDeleted" // maps to APIManagementGatewayCertificateAuthorityDeletedEventData + TypeAPIManagementGatewayCertificateAuthorityUpdated Type = "Microsoft.ApiManagement.GatewayCertificateAuthorityUpdated" // maps to APIManagementGatewayCertificateAuthorityUpdatedEventData + TypeAPIManagementGatewayCreated Type = "Microsoft.ApiManagement.GatewayCreated" // maps to APIManagementGatewayCreatedEventData + TypeAPIManagementGatewayDeleted Type = "Microsoft.ApiManagement.GatewayDeleted" // maps to APIManagementGatewayDeletedEventData + TypeAPIManagementGatewayHostnameConfigurationCreated Type = "Microsoft.ApiManagement.GatewayHostnameConfigurationCreated" // maps to APIManagementGatewayHostnameConfigurationCreatedEventData + TypeAPIManagementGatewayHostnameConfigurationDeleted Type = "Microsoft.ApiManagement.GatewayHostnameConfigurationDeleted" // maps to APIManagementGatewayHostnameConfigurationDeletedEventData + TypeAPIManagementGatewayHostnameConfigurationUpdated Type = "Microsoft.ApiManagement.GatewayHostnameConfigurationUpdated" // maps to APIManagementGatewayHostnameConfigurationUpdatedEventData + TypeAPIManagementGatewayUpdated Type = "Microsoft.ApiManagement.GatewayUpdated" // maps to APIManagementGatewayUpdatedEventData + TypeAPIManagementProductCreated Type = "Microsoft.ApiManagement.ProductCreated" // maps to APIManagementProductCreatedEventData + TypeAPIManagementProductDeleted Type = "Microsoft.ApiManagement.ProductDeleted" // maps to APIManagementProductDeletedEventData + TypeAPIManagementProductUpdated Type = "Microsoft.ApiManagement.ProductUpdated" // maps to APIManagementProductUpdatedEventData + TypeAPIManagementSubscriptionCreated Type = "Microsoft.ApiManagement.SubscriptionCreated" // maps to APIManagementSubscriptionCreatedEventData + TypeAPIManagementSubscriptionDeleted Type = "Microsoft.ApiManagement.SubscriptionDeleted" // maps to APIManagementSubscriptionDeletedEventData + TypeAPIManagementSubscriptionUpdated Type = "Microsoft.ApiManagement.SubscriptionUpdated" // maps to APIManagementSubscriptionUpdatedEventData + TypeAPIManagementUserCreated Type = "Microsoft.ApiManagement.UserCreated" // maps to APIManagementUserCreatedEventData + TypeAPIManagementUserDeleted Type = "Microsoft.ApiManagement.UserDeleted" // maps to APIManagementUserDeletedEventData + TypeAPIManagementUserUpdated Type = "Microsoft.ApiManagement.UserUpdated" // maps to APIManagementUserUpdatedEventData + TypeAppConfigurationKeyValueDeleted Type = "Microsoft.AppConfiguration.KeyValueDeleted" // maps to AppConfigurationKeyValueDeletedEventData + TypeAppConfigurationKeyValueModified Type = "Microsoft.AppConfiguration.KeyValueModified" // maps to AppConfigurationKeyValueModifiedEventData + TypeAppConfigurationSnapshotCreated Type = "Microsoft.AppConfiguration.SnapshotCreated" // maps to AppConfigurationSnapshotCreatedEventData + TypeAppConfigurationSnapshotModified Type = "Microsoft.AppConfiguration.SnapshotModified" // maps to AppConfigurationSnapshotModifiedEventData + TypeRedisExportRDBCompleted Type = "Microsoft.Cache.ExportRDBCompleted" // maps to RedisExportRDBCompletedEventData + TypeRedisImportRDBCompleted Type = "Microsoft.Cache.ImportRDBCompleted" // maps to RedisImportRDBCompletedEventData + TypeRedisPatchingCompleted Type = "Microsoft.Cache.PatchingCompleted" // maps to RedisPatchingCompletedEventData + TypeRedisScalingCompleted Type = "Microsoft.Cache.ScalingCompleted" // maps to RedisScalingCompletedEventData + TypeAcsChatMessageDeleted Type = "Microsoft.Communication.ChatMessageDeleted" // maps to AcsChatMessageDeletedEventData + TypeAcsChatMessageDeletedInThread Type = "Microsoft.Communication.ChatMessageDeletedInThread" // maps to AcsChatMessageDeletedInThreadEventData + TypeAcsChatMessageEdited Type = "Microsoft.Communication.ChatMessageEdited" // maps to AcsChatMessageEditedEventData + TypeAcsChatMessageEditedInThread Type = "Microsoft.Communication.ChatMessageEditedInThread" // maps to AcsChatMessageEditedInThreadEventData + TypeAcsChatMessageReceived Type = "Microsoft.Communication.ChatMessageReceived" // maps to AcsChatMessageReceivedEventData + TypeAcsChatMessageReceivedInThread Type = "Microsoft.Communication.ChatMessageReceivedInThread" // maps to AcsChatMessageReceivedInThreadEventData + TypeAcsChatParticipantAddedToThreadWithUser Type = "Microsoft.Communication.ChatParticipantAddedToThreadWithUser" // maps to AcsChatParticipantAddedToThreadWithUserEventData + TypeAcsChatParticipantRemovedFromThreadWithUser Type = "Microsoft.Communication.ChatParticipantRemovedFromThreadWithUser" // maps to AcsChatParticipantRemovedFromThreadWithUserEventData + TypeAcsChatThreadCreated Type = "Microsoft.Communication.ChatThreadCreated" // maps to AcsChatThreadCreatedEventData + TypeAcsChatThreadCreatedWithUser Type = "Microsoft.Communication.ChatThreadCreatedWithUser" // maps to AcsChatThreadCreatedWithUserEventData + TypeAcsChatThreadDeleted Type = "Microsoft.Communication.ChatThreadDeleted" // maps to AcsChatThreadDeletedEventData + TypeAcsChatParticipantAddedToThread Type = "Microsoft.Communication.ChatThreadParticipantAdded" // maps to AcsChatParticipantAddedToThreadEventData + TypeAcsChatParticipantRemovedFromThread Type = "Microsoft.Communication.ChatThreadParticipantRemoved" // maps to AcsChatParticipantRemovedFromThreadEventData + TypeAcsChatThreadPropertiesUpdated Type = "Microsoft.Communication.ChatThreadPropertiesUpdated" // maps to AcsChatThreadPropertiesUpdatedEventData + TypeAcsChatThreadPropertiesUpdatedPerUser Type = "Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser" // maps to AcsChatThreadPropertiesUpdatedPerUserEventData + TypeAcsChatThreadWithUserDeleted Type = "Microsoft.Communication.ChatThreadWithUserDeleted" // maps to AcsChatThreadWithUserDeletedEventData + TypeAcsEmailDeliveryReportReceived Type = "Microsoft.Communication.EmailDeliveryReportReceived" // maps to AcsEmailDeliveryReportReceivedEventData + TypeAcsEmailEngagementTrackingReportReceived Type = "Microsoft.Communication.EmailEngagementTrackingReportReceived" // maps to AcsEmailEngagementTrackingReportReceivedEventData + TypeAcsIncomingCall Type = "Microsoft.Communication.IncomingCall" // maps to AcsIncomingCallEventData + TypeAcsRecordingFileStatusUpdated Type = "Microsoft.Communication.RecordingFileStatusUpdated" // maps to AcsRecordingFileStatusUpdatedEventData + TypeAcsRouterJobCancelled Type = "Microsoft.Communication.RouterJobCancelled" // maps to AcsRouterJobCancelledEventData + TypeAcsRouterJobClassificationFailed Type = "Microsoft.Communication.RouterJobClassificationFailed" // maps to AcsRouterJobClassificationFailedEventData + TypeAcsRouterJobClassified Type = "Microsoft.Communication.RouterJobClassified" // maps to AcsRouterJobClassifiedEventData + TypeAcsRouterJobClosed Type = "Microsoft.Communication.RouterJobClosed" // maps to AcsRouterJobClosedEventData + TypeAcsRouterJobCompleted Type = "Microsoft.Communication.RouterJobCompleted" // maps to AcsRouterJobCompletedEventData + TypeAcsRouterJobDeleted Type = "Microsoft.Communication.RouterJobDeleted" // maps to AcsRouterJobDeletedEventData + TypeAcsRouterJobExceptionTriggered Type = "Microsoft.Communication.RouterJobExceptionTriggered" // maps to AcsRouterJobExceptionTriggeredEventData + TypeAcsRouterJobQueued Type = "Microsoft.Communication.RouterJobQueued" // maps to AcsRouterJobQueuedEventData + TypeAcsRouterJobReceived Type = "Microsoft.Communication.RouterJobReceived" // maps to AcsRouterJobReceivedEventData + TypeAcsRouterJobSchedulingFailed Type = "Microsoft.Communication.RouterJobSchedulingFailed" // maps to AcsRouterJobSchedulingFailedEventData + TypeAcsRouterJobUnassigned Type = "Microsoft.Communication.RouterJobUnassigned" // maps to AcsRouterJobUnassignedEventData + TypeAcsRouterJobWaitingForActivation Type = "Microsoft.Communication.RouterJobWaitingForActivation" // maps to AcsRouterJobWaitingForActivationEventData + TypeAcsRouterJobWorkerSelectorsExpired Type = "Microsoft.Communication.RouterJobWorkerSelectorsExpired" // maps to AcsRouterJobWorkerSelectorsExpiredEventData + TypeAcsRouterWorkerDeleted Type = "Microsoft.Communication.RouterWorkerDeleted" // maps to AcsRouterWorkerDeletedEventData + TypeAcsRouterWorkerDeregistered Type = "Microsoft.Communication.RouterWorkerDeregistered" // maps to AcsRouterWorkerDeregisteredEventData + TypeAcsRouterWorkerOfferAccepted Type = "Microsoft.Communication.RouterWorkerOfferAccepted" // maps to AcsRouterWorkerOfferAcceptedEventData + TypeAcsRouterWorkerOfferDeclined Type = "Microsoft.Communication.RouterWorkerOfferDeclined" // maps to AcsRouterWorkerOfferDeclinedEventData + TypeAcsRouterWorkerOfferExpired Type = "Microsoft.Communication.RouterWorkerOfferExpired" // maps to AcsRouterWorkerOfferExpiredEventData + TypeAcsRouterWorkerOfferIssued Type = "Microsoft.Communication.RouterWorkerOfferIssued" // maps to AcsRouterWorkerOfferIssuedEventData + TypeAcsRouterWorkerOfferRevoked Type = "Microsoft.Communication.RouterWorkerOfferRevoked" // maps to AcsRouterWorkerOfferRevokedEventData + TypeAcsRouterWorkerRegistered Type = "Microsoft.Communication.RouterWorkerRegistered" // maps to AcsRouterWorkerRegisteredEventData + TypeAcsSmsDeliveryReportReceived Type = "Microsoft.Communication.SMSDeliveryReportReceived" // maps to AcsSmsDeliveryReportReceivedEventData + TypeAcsSmsReceived Type = "Microsoft.Communication.SMSReceived" // maps to AcsSmsReceivedEventData + TypeAcsUserDisconnected Type = "Microsoft.Communication.UserDisconnected" // maps to AcsUserDisconnectedEventData + TypeContainerRegistryChartDeleted Type = "Microsoft.ContainerRegistry.ChartDeleted" // maps to ContainerRegistryChartDeletedEventData + TypeContainerRegistryChartPushed Type = "Microsoft.ContainerRegistry.ChartPushed" // maps to ContainerRegistryChartPushedEventData + TypeContainerRegistryImageDeleted Type = "Microsoft.ContainerRegistry.ImageDeleted" // maps to ContainerRegistryImageDeletedEventData + TypeContainerRegistryImagePushed Type = "Microsoft.ContainerRegistry.ImagePushed" // maps to ContainerRegistryImagePushedEventData + TypeContainerServiceClusterSupportEnded Type = "Microsoft.ContainerService.ClusterSupportEnded" // maps to ContainerServiceClusterSupportEndedEventData + TypeContainerServiceClusterSupportEnding Type = "Microsoft.ContainerService.ClusterSupportEnding" // maps to ContainerServiceClusterSupportEndingEventData + TypeContainerServiceNewKubernetesVersionAvailable Type = "Microsoft.ContainerService.NewKubernetesVersionAvailable" // maps to ContainerServiceNewKubernetesVersionAvailableEventData + TypeContainerServiceNodePoolRollingFailed Type = "Microsoft.ContainerService.NodePoolRollingFailed" // maps to ContainerServiceNodePoolRollingFailedEventData + TypeContainerServiceNodePoolRollingStarted Type = "Microsoft.ContainerService.NodePoolRollingStarted" // maps to ContainerServiceNodePoolRollingStartedEventData + TypeContainerServiceNodePoolRollingSucceeded Type = "Microsoft.ContainerService.NodePoolRollingSucceeded" // maps to ContainerServiceNodePoolRollingSucceededEventData + TypeDataBoxCopyCompleted Type = "Microsoft.DataBox.CopyCompleted" // maps to DataBoxCopyCompletedEventData + TypeDataBoxCopyStarted Type = "Microsoft.DataBox.CopyStarted" // maps to DataBoxCopyStartedEventData + TypeDataBoxOrderCompleted Type = "Microsoft.DataBox.OrderCompleted" // maps to DataBoxOrderCompletedEventData + TypeIotHubDeviceConnected Type = "Microsoft.Devices.DeviceConnected" // maps to IotHubDeviceConnectedEventData + TypeIotHubDeviceCreated Type = "Microsoft.Devices.DeviceCreated" // maps to IotHubDeviceCreatedEventData + TypeIotHubDeviceDeleted Type = "Microsoft.Devices.DeviceDeleted" // maps to IotHubDeviceDeletedEventData + TypeIotHubDeviceDisconnected Type = "Microsoft.Devices.DeviceDisconnected" // maps to IotHubDeviceDisconnectedEventData + TypeIotHubDeviceTelemetry Type = "Microsoft.Devices.DeviceTelemetry" // maps to IotHubDeviceTelemetryEventData + TypeEventGridMQTTClientCreatedOrUpdated Type = "Microsoft.EventGrid.MQTTClientCreatedOrUpdated" // maps to EventGridMQTTClientCreatedOrUpdatedEventData + TypeEventGridMQTTClientDeleted Type = "Microsoft.EventGrid.MQTTClientDeleted" // maps to EventGridMQTTClientDeletedEventData + TypeEventGridMQTTClientSessionConnected Type = "Microsoft.EventGrid.MQTTClientSessionConnected" // maps to EventGridMQTTClientSessionConnectedEventData + TypeEventGridMQTTClientSessionDisconnected Type = "Microsoft.EventGrid.MQTTClientSessionDisconnected" // maps to EventGridMQTTClientSessionDisconnectedEventData + TypeSubscriptionDeleted Type = "Microsoft.EventGrid.SubscriptionDeletedEvent" // maps to SubscriptionDeletedEventData + TypeSubscriptionValidation Type = "Microsoft.EventGrid.SubscriptionValidationEvent" // maps to SubscriptionValidationEventData + TypeEventHubCaptureFileCreated Type = "Microsoft.EventHub.CaptureFileCreated" // maps to EventHubCaptureFileCreatedEventData + TypeHealthcareDicomImageCreated Type = "Microsoft.HealthcareApis.DicomImageCreated" // maps to HealthcareDicomImageCreatedEventData + TypeHealthcareDicomImageDeleted Type = "Microsoft.HealthcareApis.DicomImageDeleted" // maps to HealthcareDicomImageDeletedEventData + TypeHealthcareDicomImageUpdated Type = "Microsoft.HealthcareApis.DicomImageUpdated" // maps to HealthcareDicomImageUpdatedEventData + TypeHealthcareFhirResourceCreated Type = "Microsoft.HealthcareApis.FhirResourceCreated" // maps to HealthcareFhirResourceCreatedEventData + TypeHealthcareFhirResourceDeleted Type = "Microsoft.HealthcareApis.FhirResourceDeleted" // maps to HealthcareFhirResourceDeletedEventData + TypeHealthcareFhirResourceUpdated Type = "Microsoft.HealthcareApis.FhirResourceUpdated" // maps to HealthcareFhirResourceUpdatedEventData + TypeKeyVaultCertificateExpired Type = "Microsoft.KeyVault.CertificateExpired" // maps to KeyVaultCertificateExpiredEventData + TypeKeyVaultCertificateNearExpiry Type = "Microsoft.KeyVault.CertificateNearExpiry" // maps to KeyVaultCertificateNearExpiryEventData + TypeKeyVaultCertificateNewVersionCreated Type = "Microsoft.KeyVault.CertificateNewVersionCreated" // maps to KeyVaultCertificateNewVersionCreatedEventData + TypeKeyVaultKeyExpired Type = "Microsoft.KeyVault.KeyExpired" // maps to KeyVaultKeyExpiredEventData + TypeKeyVaultKeyNearExpiry Type = "Microsoft.KeyVault.KeyNearExpiry" // maps to KeyVaultKeyNearExpiryEventData + TypeKeyVaultKeyNewVersionCreated Type = "Microsoft.KeyVault.KeyNewVersionCreated" // maps to KeyVaultKeyNewVersionCreatedEventData + TypeKeyVaultSecretExpired Type = "Microsoft.KeyVault.SecretExpired" // maps to KeyVaultSecretExpiredEventData + TypeKeyVaultSecretNearExpiry Type = "Microsoft.KeyVault.SecretNearExpiry" // maps to KeyVaultSecretNearExpiryEventData + TypeKeyVaultSecretNewVersionCreated Type = "Microsoft.KeyVault.SecretNewVersionCreated" // maps to KeyVaultSecretNewVersionCreatedEventData + TypeKeyVaultAccessPolicyChanged Type = "Microsoft.KeyVault.VaultAccessPolicyChanged" // maps to KeyVaultAccessPolicyChangedEventData + TypeMachineLearningServicesDatasetDriftDetected Type = "Microsoft.MachineLearningServices.DatasetDriftDetected" // maps to MachineLearningServicesDatasetDriftDetectedEventData + TypeMachineLearningServicesModelDeployed Type = "Microsoft.MachineLearningServices.ModelDeployed" // maps to MachineLearningServicesModelDeployedEventData + TypeMachineLearningServicesModelRegistered Type = "Microsoft.MachineLearningServices.ModelRegistered" // maps to MachineLearningServicesModelRegisteredEventData + TypeMachineLearningServicesRunCompleted Type = "Microsoft.MachineLearningServices.RunCompleted" // maps to MachineLearningServicesRunCompletedEventData + TypeMachineLearningServicesRunStatusChanged Type = "Microsoft.MachineLearningServices.RunStatusChanged" // maps to MachineLearningServicesRunStatusChangedEventData + TypeMapsGeofenceEntered Type = "Microsoft.Maps.GeofenceEntered" // maps to MapsGeofenceEnteredEventData + TypeMapsGeofenceExited Type = "Microsoft.Maps.GeofenceExited" // maps to MapsGeofenceExitedEventData + TypeMapsGeofenceResult Type = "Microsoft.Maps.GeofenceResult" // maps to MapsGeofenceResultEventData + TypeMediaJobCanceled Type = "Microsoft.Media.JobCanceled" // maps to MediaJobCanceledEventData + TypeMediaJobCanceling Type = "Microsoft.Media.JobCanceling" // maps to MediaJobCancelingEventData + TypeMediaJobErrored Type = "Microsoft.Media.JobErrored" // maps to MediaJobErroredEventData + TypeMediaJobFinished Type = "Microsoft.Media.JobFinished" // maps to MediaJobFinishedEventData + TypeMediaJobOutputCanceled Type = "Microsoft.Media.JobOutputCanceled" // maps to MediaJobOutputCanceledEventData + TypeMediaJobOutputCanceling Type = "Microsoft.Media.JobOutputCanceling" // maps to MediaJobOutputCancelingEventData + TypeMediaJobOutputErrored Type = "Microsoft.Media.JobOutputErrored" // maps to MediaJobOutputErroredEventData + TypeMediaJobOutputFinished Type = "Microsoft.Media.JobOutputFinished" // maps to MediaJobOutputFinishedEventData + TypeMediaJobOutputProcessing Type = "Microsoft.Media.JobOutputProcessing" // maps to MediaJobOutputProcessingEventData + TypeMediaJobOutputProgress Type = "Microsoft.Media.JobOutputProgress" // maps to MediaJobOutputProgressEventData + TypeMediaJobOutputScheduled Type = "Microsoft.Media.JobOutputScheduled" // maps to MediaJobOutputScheduledEventData + TypeMediaJobOutputStateChange Type = "Microsoft.Media.JobOutputStateChange" // maps to MediaJobOutputStateChangeEventData + TypeMediaJobProcessing Type = "Microsoft.Media.JobProcessing" // maps to MediaJobProcessingEventData + TypeMediaJobScheduled Type = "Microsoft.Media.JobScheduled" // maps to MediaJobScheduledEventData + TypeMediaJobStateChange Type = "Microsoft.Media.JobStateChange" // maps to MediaJobStateChangeEventData + TypeMediaLiveEventChannelArchiveHeartbeat Type = "Microsoft.Media.LiveEventChannelArchiveHeartbeat" // maps to MediaLiveEventChannelArchiveHeartbeatEventData + TypeMediaLiveEventConnectionRejected Type = "Microsoft.Media.LiveEventConnectionRejected" // maps to MediaLiveEventConnectionRejectedEventData + TypeMediaLiveEventEncoderConnected Type = "Microsoft.Media.LiveEventEncoderConnected" // maps to MediaLiveEventEncoderConnectedEventData + TypeMediaLiveEventEncoderDisconnected Type = "Microsoft.Media.LiveEventEncoderDisconnected" // maps to MediaLiveEventEncoderDisconnectedEventData + TypeMediaLiveEventIncomingDataChunkDropped Type = "Microsoft.Media.LiveEventIncomingDataChunkDropped" // maps to MediaLiveEventIncomingDataChunkDroppedEventData + TypeMediaLiveEventIncomingStreamReceived Type = "Microsoft.Media.LiveEventIncomingStreamReceived" // maps to MediaLiveEventIncomingStreamReceivedEventData + TypeMediaLiveEventIncomingStreamsOutOfSync Type = "Microsoft.Media.LiveEventIncomingStreamsOutOfSync" // maps to MediaLiveEventIncomingStreamsOutOfSyncEventData + TypeMediaLiveEventIncomingVideoStreamsOutOfSync Type = "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync" // maps to MediaLiveEventIncomingVideoStreamsOutOfSyncEventData + TypeMediaLiveEventIngestHeartbeat Type = "Microsoft.Media.LiveEventIngestHeartbeat" // maps to MediaLiveEventIngestHeartbeatEventData + TypeMediaLiveEventTrackDiscontinuityDetected Type = "Microsoft.Media.LiveEventTrackDiscontinuityDetected" // maps to MediaLiveEventTrackDiscontinuityDetectedEventData + TypePolicyInsightsPolicyStateChanged Type = "Microsoft.PolicyInsights.PolicyStateChanged" // maps to PolicyInsightsPolicyStateChangedEventData + TypePolicyInsightsPolicyStateCreated Type = "Microsoft.PolicyInsights.PolicyStateCreated" // maps to PolicyInsightsPolicyStateCreatedEventData + TypePolicyInsightsPolicyStateDeleted Type = "Microsoft.PolicyInsights.PolicyStateDeleted" // maps to PolicyInsightsPolicyStateDeletedEventData + TypeResourceNotificationsHealthResourcesAvailabilityStatusChanged Type = "Microsoft.ResourceNotifications.HealthResources.AvailabilityStatusChanged" // maps to ResourceNotificationsHealthResourcesAvailabilityStatusChangedEventData + TypeResourceNotificationsHealthResourcesAnnotated Type = "Microsoft.ResourceNotifications.HealthResources.ResourceAnnotated" // maps to ResourceNotificationsHealthResourcesAnnotatedEventData + TypeResourceNotificationsResourceManagementCreatedOrUpdated Type = "Microsoft.ResourceNotifications.Resources.CreatedOrUpdated" // maps to ResourceNotificationsResourceManagementCreatedOrUpdatedEventData + TypeResourceNotificationsResourceManagementDeleted Type = "Microsoft.ResourceNotifications.Resources.Deleted" // maps to ResourceNotificationsResourceManagementDeletedEventData + TypeResourceActionCancel Type = "Microsoft.Resources.ResourceActionCancel" // maps to ResourceActionCancelEventData + TypeResourceActionFailure Type = "Microsoft.Resources.ResourceActionFailure" // maps to ResourceActionFailureEventData + TypeResourceActionSuccess Type = "Microsoft.Resources.ResourceActionSuccess" // maps to ResourceActionSuccessEventData + TypeResourceDeleteCancel Type = "Microsoft.Resources.ResourceDeleteCancel" // maps to ResourceDeleteCancelEventData + TypeResourceDeleteFailure Type = "Microsoft.Resources.ResourceDeleteFailure" // maps to ResourceDeleteFailureEventData + TypeResourceDeleteSuccess Type = "Microsoft.Resources.ResourceDeleteSuccess" // maps to ResourceDeleteSuccessEventData + TypeResourceWriteCancel Type = "Microsoft.Resources.ResourceWriteCancel" // maps to ResourceWriteCancelEventData + TypeResourceWriteFailure Type = "Microsoft.Resources.ResourceWriteFailure" // maps to ResourceWriteFailureEventData + TypeResourceWriteSuccess Type = "Microsoft.Resources.ResourceWriteSuccess" // maps to ResourceWriteSuccessEventData + TypeServiceBusActiveMessagesAvailablePeriodicNotifications Type = "Microsoft.ServiceBus.ActiveMessagesAvailablePeriodicNotifications" // maps to ServiceBusActiveMessagesAvailablePeriodicNotificationsEventData + TypeServiceBusActiveMessagesAvailableWithNoListeners Type = "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners" // maps to ServiceBusActiveMessagesAvailableWithNoListenersEventData + TypeServiceBusDeadletterMessagesAvailablePeriodicNotifications Type = "Microsoft.ServiceBus.DeadletterMessagesAvailablePeriodicNotifications" // maps to ServiceBusDeadletterMessagesAvailablePeriodicNotificationsEventData + TypeServiceBusDeadletterMessagesAvailableWithNoListeners Type = "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListeners" // maps to ServiceBusDeadletterMessagesAvailableWithNoListenersEventData + TypeSignalRServiceClientConnectionConnected Type = "Microsoft.SignalRService.ClientConnectionConnected" // maps to SignalRServiceClientConnectionConnectedEventData + TypeSignalRServiceClientConnectionDisconnected Type = "Microsoft.SignalRService.ClientConnectionDisconnected" // maps to SignalRServiceClientConnectionDisconnectedEventData + TypeStorageAsyncOperationInitiated Type = "Microsoft.Storage.AsyncOperationInitiated" // maps to StorageAsyncOperationInitiatedEventData + TypeStorageBlobCreated Type = "Microsoft.Storage.BlobCreated" // maps to StorageBlobCreatedEventData + TypeStorageBlobDeleted Type = "Microsoft.Storage.BlobDeleted" // maps to StorageBlobDeletedEventData + TypeStorageBlobInventoryPolicyCompleted Type = "Microsoft.Storage.BlobInventoryPolicyCompleted" // maps to StorageBlobInventoryPolicyCompletedEventData + TypeStorageBlobRenamed Type = "Microsoft.Storage.BlobRenamed" // maps to StorageBlobRenamedEventData + TypeStorageBlobTierChanged Type = "Microsoft.Storage.BlobTierChanged" // maps to StorageBlobTierChangedEventData + TypeStorageDirectoryCreated Type = "Microsoft.Storage.DirectoryCreated" // maps to StorageDirectoryCreatedEventData + TypeStorageDirectoryDeleted Type = "Microsoft.Storage.DirectoryDeleted" // maps to StorageDirectoryDeletedEventData + TypeStorageDirectoryRenamed Type = "Microsoft.Storage.DirectoryRenamed" // maps to StorageDirectoryRenamedEventData + TypeStorageLifecyclePolicyCompleted Type = "Microsoft.Storage.LifecyclePolicyCompleted" // maps to StorageLifecyclePolicyCompletedEventData + TypeStorageTaskCompleted Type = "Microsoft.Storage.StorageTaskCompleted" // maps to StorageTaskCompletedEventData + TypeStorageTaskQueued Type = "Microsoft.Storage.StorageTaskQueued" // maps to StorageTaskQueuedEventData + TypeWebAppServicePlanUpdated Type = "Microsoft.Web.AppServicePlanUpdated" // maps to WebAppServicePlanUpdatedEventData + TypeWebAppUpdated Type = "Microsoft.Web.AppUpdated" // maps to WebAppUpdatedEventData + TypeWebBackupOperationCompleted Type = "Microsoft.Web.BackupOperationCompleted" // maps to WebBackupOperationCompletedEventData + TypeWebBackupOperationFailed Type = "Microsoft.Web.BackupOperationFailed" // maps to WebBackupOperationFailedEventData + TypeWebBackupOperationStarted Type = "Microsoft.Web.BackupOperationStarted" // maps to WebBackupOperationStartedEventData + TypeWebRestoreOperationCompleted Type = "Microsoft.Web.RestoreOperationCompleted" // maps to WebRestoreOperationCompletedEventData + TypeWebRestoreOperationFailed Type = "Microsoft.Web.RestoreOperationFailed" // maps to WebRestoreOperationFailedEventData + TypeWebRestoreOperationStarted Type = "Microsoft.Web.RestoreOperationStarted" // maps to WebRestoreOperationStartedEventData + TypeWebSlotSwapCompleted Type = "Microsoft.Web.SlotSwapCompleted" // maps to WebSlotSwapCompletedEventData + TypeWebSlotSwapFailed Type = "Microsoft.Web.SlotSwapFailed" // maps to WebSlotSwapFailedEventData + TypeWebSlotSwapStarted Type = "Microsoft.Web.SlotSwapStarted" // maps to WebSlotSwapStartedEventData + TypeWebSlotSwapWithPreviewCancelled Type = "Microsoft.Web.SlotSwapWithPreviewCancelled" // maps to WebSlotSwapWithPreviewCancelledEventData + TypeWebSlotSwapWithPreviewStarted Type = "Microsoft.Web.SlotSwapWithPreviewStarted" // maps to WebSlotSwapWithPreviewStartedEventData +) diff --git a/sdk/messaging/eventgrid/azsystemevents/system_events2_test.go b/sdk/messaging/eventgrid/azsystemevents/system_events2_test.go new file mode 100644 index 000000000000..1e776debaea1 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/system_events2_test.go @@ -0,0 +1,1668 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azsystemevents_test + +import ( + "encoding/json" + "fmt" + "strings" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azsystemevents" + + "github.com/stretchr/testify/require" +) + +// As close a part as I could get to @JoshLove-msft's tests here: +// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs + +func TestParsesEventGridEnvelope(t *testing.T) { + requestContent := "[{ \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"topic\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"mySubject\", \"data\": { \"validationCode\": \"512d38b6-c7b8-40c8-89fe-f46f9e9622b6\", \"validationUrl\": \"https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=B2E34264-7D71-453A-B5FB-B62D0FDC85EE&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1BNqCxBBSSE9OnNSfZM4%2b5H9zDegKMY6uJ%2fO2DFRkwQ%3d\" }, \"eventType\": \"Microsoft.EventGrid.SubscriptionValidationEvent\", \"eventTime\": \"2018-01-25T22:12:19.4556811Z\", \"metadataVersion\": \"1\", \"dataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + var egEvent = events[0] + require.Equal(t, "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", *egEvent.Topic) + require.Equal(t, "2d1781af-3a4c-4d7c-bd0c-e34b19da4e66", *egEvent.ID) + require.Equal(t, "mySubject", *egEvent.Subject) + require.Equal(t, string(azsystemevents.TypeSubscriptionValidation), *egEvent.EventType) + require.Equal(t, mustParseTime(t, "2018-01-25T22:12:19.4556811Z"), *egEvent.EventTime) + require.Equal(t, "1", *egEvent.DataVersion) +} + +func TestParsesEventGridEnvelopeUsingConverter(t *testing.T) { + requestContent := "[{ \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"topic\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"mySubject\", \"data\": { \"validationCode\": \"512d38b6-c7b8-40c8-89fe-f46f9e9622b6\", \"validationUrl\": \"https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=B2E34264-7D71-453A-B5FB-B62D0FDC85EE&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1BNqCxBBSSE9OnNSfZM4%2b5H9zDegKMY6uJ%2fO2DFRkwQ%3d\" }, \"eventType\": \"Microsoft.EventGrid.SubscriptionValidationEvent\", \"eventTime\": \"2018-01-25T22:12:19.4556811Z\", \"metadataVersion\": \"1\", \"dataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + var egEvent = events[0] + require.Equal(t, "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", *egEvent.Topic) + require.Equal(t, "2d1781af-3a4c-4d7c-bd0c-e34b19da4e66", *egEvent.ID) + require.Equal(t, "mySubject", *egEvent.Subject) + require.Equal(t, string(azsystemevents.TypeSubscriptionValidation), *egEvent.EventType) + require.Equal(t, mustParseTime(t, "2018-01-25T22:12:19.4556811Z"), *egEvent.EventTime) + require.Equal(t, "1", *egEvent.DataVersion) +} + +func TestConsumeEventGridSubscriptionDeletedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"topic\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"\", \"data\": { \"eventSubscriptionId\": \"/subscriptions/id/resourceGroups/rg/providers/Microsoft.EventGrid/topics/topic1/providers/Microsoft.EventGrid/eventSubscriptions/eventsubscription1\" }, \"eventType\": \"Microsoft.EventGrid.SubscriptionDeletedEvent\", \"eventTime\": \"2018-01-25T22:12:19.4556811Z\", \"metadataVersion\": \"1\", \"dataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.SubscriptionDeletedEventData](t, events[0].Data) + require.Equal(t, + "/subscriptions/id/resourceGroups/rg/providers/Microsoft.EventGrid/topics/topic1/providers/Microsoft.EventGrid/eventSubscriptions/eventsubscription1", + *sysEvent.EventSubscriptionID) +} + +func TestConsumeStorageBlobDeletedEventWithExtraProperty(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"eventType\": \"Microsoft.Storage.BlobDeleted\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"brandNewProperty\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + require.NotEmpty(t, events) + + for _, egEvent := range events { + require.Equal(t, string(azsystemevents.TypeStorageBlobDeleted), *egEvent.EventType) + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobDeletedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testfile.txt", *sysEvent.URL) + require.Equal(t, "/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount", *egEvent.Topic) + } +} + +func TestConsumeEventNotWrappedInAnArray(t *testing.T) { + requestContent := "{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"eventType\": \"Microsoft.Storage.BlobDeleted\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"brandNewProperty\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}" + + egEvent := parseEvent(t, requestContent) + require.NotEmpty(t, egEvent) + + require.Equal(t, string(azsystemevents.TypeStorageBlobDeleted), *egEvent.EventType) + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobDeletedEventData](t, egEvent.Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testfile.txt", *sysEvent.URL) +} + +func TestConsumeEventNotWrappedInAnArrayWithConverter(t *testing.T) { + requestContent := "{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"eventType\": \"Microsoft.Storage.BlobDeleted\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"brandNewProperty\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}" + + egEvent := parseEvent(t, requestContent) + + require.Equal(t, string(azsystemevents.TypeStorageBlobDeleted), *egEvent.EventType) + + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobDeletedEventData](t, egEvent.Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testfile.txt", *sysEvent.URL) +} + +func TestConsumeMultipleEventsInSameBatch(t *testing.T) { + requestContent := "[ " + + "{ \"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Storage/storageAccounts/myaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/file1.txt\", \"eventType\": \"Microsoft.Storage.BlobCreated\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\", \"id\": \"602a88ef-0001-00e6-1233-1646070610ea\", \"data\": { \"api\": \"PutBlockList\", \"clientRequestId\": \"799304a4-bbc5-45b6-9849-ec2c66be800a\", \"requestId\": \"602a88ef-0001-00e6-1233-164607000000\", \"eTag\": \"0x8D4E44A24ABE7F1\", \"contentType\": \"text/plain\", \"contentLength\": 447, \"blobType\": \"BlockBlob\", \"url\": \"https://myaccount.blob.core.windows.net/testcontainer/file1.txt\", \"sequencer\": \"00000000000000EB000000000000C65A\" }, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}, " + + "{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"eventType\": \"Microsoft.Storage.BlobDeleted\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}, " + + "{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"eventType\": \"Microsoft.Storage.BlobDeleted\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + require.Equal(t, 3, len(events)) + + for _, egEvent := range events { + switch azsystemevents.Type(*egEvent.EventType) { + case azsystemevents.TypeStorageBlobCreated: + blobCreated := deserializeSystemEvent[azsystemevents.StorageBlobCreatedEventData](t, egEvent.Data) + require.Equal(t, "https://myaccount.blob.core.windows.net/testcontainer/file1.txt", *blobCreated.URL) + case azsystemevents.TypeStorageBlobDeleted: + blobDeleted := deserializeSystemEvent[azsystemevents.StorageBlobDeletedEventData](t, egEvent.Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testfile.txt", *blobDeleted.URL) + } + } +} + +func TestConsumeEventUsingBinaryDataExtensionMethod(t *testing.T) { + messageBody := "{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"eventType\": \"Microsoft.Storage.BlobDeleted\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"brandNewProperty\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}" + + egEvent := parseEvent(t, messageBody) + + require.NotEmpty(t, egEvent) + + switch azsystemevents.Type(*egEvent.EventType) { + case azsystemevents.TypeStorageBlobDeleted: + blobDeleted := deserializeSystemEvent[azsystemevents.StorageBlobDeletedEventData](t, egEvent.Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testfile.txt", *blobDeleted.URL) + } +} + +// func TestParseBinaryDataThrowsOnMultipleEgEvents(t *testing.T) { +// requestContent := "[{ \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"topic\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"mySubject\", \"data\": { \"validationCode\": \"512d38b6-c7b8-40c8-89fe-f46f9e9622b6\", \"validationUrl\": \"https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=B2E34264-7D71-453A-B5FB-B62D0FDC85EE&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1BNqCxBBSSE9OnNSfZM4%2b5H9zDegKMY6uJ%2fO2DFRkwQ%3d\" }, \"eventType\": \"Microsoft.EventGrid.SubscriptionValidationEvent\", \"eventTime\": \"2018-01-25T22:12:19.4556811Z\", \"metadataVersion\": \"1\", \"dataVersion\": \"1\"}, { \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"topic\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"mySubject\", \"data\": { \"validationCode\": \"512d38b6-c7b8-40c8-89fe-f46f9e9622b6\", \"validationUrl\": \"https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=B2E34264-7D71-453A-B5FB-B62D0FDC85EE&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1BNqCxBBSSE9OnNSfZM4%2b5H9zDegKMY6uJ%2fO2DFRkwQ%3d\" }, \"eventType\": \"Microsoft.EventGrid.SubscriptionValidationEvent\", \"eventTime\": \"2018-01-25T22:12:19.4556811Z\", \"metadataVersion\": \"1\", \"dataVersion\": \"1\"}]"; + +// Assert.That(() => EventGridEvent.Parse(new BinaryData(requestContent)), +// Throws.InstanceOf()); +// } + +func TestConsumeAppConfigurationKeyValueDeletedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"topic\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"eventType\": \"Microsoft.AppConfiguration.KeyValueDeleted\",\"eventTime\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"key\":\"key1\",\"label\":\"label1\",\"etag\":\"etag1\"}, \"dataVersion\": \"\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.AppConfigurationKeyValueDeletedEventData](t, events[0].Data) + require.Equal(t, "key1", *sysEvent.Key) +} + +func TestConsumeAppConfigurationKeyValueModifiedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"topic\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"eventType\": \"Microsoft.AppConfiguration.KeyValueModified\",\"eventTime\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"key\":\"key1\",\"label\":\"label1\",\"etag\":\"etag1\"}, \"dataVersion\": \"\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + + sysEvent := deserializeSystemEvent[azsystemevents.AppConfigurationKeyValueModifiedEventData](t, events[0].Data) + require.Equal(t, "key1", *sysEvent.Key) +} + +func TestConsumeContainerRegistryImagePushedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"topic\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.ContainerRegistry/test1\", \"subject\": \"test1\", \"eventType\": \"Microsoft.ContainerRegistry.ImagePushed\", \"eventTime\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"id\":\"eventID\",\"timestamp\":\"2018-06-20T12:00:33.6125843-07:00\",\"action\":\"testaction\",\"target\":{\"mediaType\":\"test\",\"size\":20,\"digest\":\"digest1\",\"length\":20,\"repository\":\"test\",\"url\":\"url1\",\"tag\":\"test\"},\"request\":{\"id\":\"id\",\"addr\":\"127.0.0.1\",\"host\":\"test\",\"method\":\"method1\",\"useragent\":\"useragent1\"},\"actor\":{\"name\":\"testactor\"},\"source\":{\"addr\":\"127.0.0.1\",\"instanceID\":\"id\"}}, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerRegistryImagePushedEventData](t, events[0].Data) + require.Equal(t, "127.0.0.1", *sysEvent.Request.Addr) +} + +func TestConsumeContainerRegistryImageDeletedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"topic\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.ContainerRegistry/test1\", \"subject\": \"test1\", \"eventType\": \"Microsoft.ContainerRegistry.ImageDeleted\", \"eventTime\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"id\":\"eventID\",\"timestamp\":\"2018-06-20T12:00:33.6125843-07:00\",\"action\":\"testaction\",\"target\":{\"mediaType\":\"test\",\"size\":20,\"digest\":\"digest1\",\"length\":20,\"repository\":\"test\",\"url\":\"url1\",\"tag\":\"test\"},\"request\":{\"id\":\"id\",\"addr\":\"127.0.0.1\",\"host\":\"test\",\"method\":\"method1\",\"useragent\":\"useragent1\"},\"actor\":{\"name\":\"testactor\"},\"source\":{\"addr\":\"127.0.0.1\",\"instanceID\":\"id\"}}, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerRegistryImageDeletedEventData](t, events[0].Data) + require.Equal(t, "testactor", *sysEvent.Actor.Name) +} + +func TestConsumeContainerRegistryChartDeletedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"topic\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.ContainerRegistry/test1\", \"subject\": \"test1\", \"eventType\": \"Microsoft.ContainerRegistry.ChartDeleted\", \"eventTime\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"id\":\"id\",\"timestamp\":\"2018-06-20T12:00:33.6125843-07:00\",\"action\":\"action1\",\"target\":{\"mediaType\":\"mediatype1\",\"size\":20,\"digest\":\"digest1\",\"repository\":null,\"tag\":null,\"name\":\"name1\",\"version\":null}}, \"dataVersion\":\"\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerRegistryChartDeletedEventData](t, events[0].Data) + require.Equal(t, "mediatype1", *sysEvent.Target.MediaType) +} + +func TestConsumeContainerRegistryChartPushedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"topic\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.ContainerRegistry/test1\", \"subject\": \"test1\", \"eventType\": \"Microsoft.ContainerRegistry.ChartPushed\", \"eventTime\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"id\":\"id\",\"timestamp\":\"2018-06-20T12:00:33.6125843-07:00\",\"action\":\"action1\",\"target\":{\"mediaType\":\"mediatype1\",\"size\":40,\"digest\":\"digest1\",\"repository\":null,\"tag\":null,\"name\":\"name1\",\"version\":null}}, \"dataVersion\":\"\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerRegistryChartPushedEventData](t, events[0].Data) + require.Equal(t, "mediatype1", *sysEvent.Target.MediaType) +} + +func TestConsumeContainerServiceSupportEndedEvent(t *testing.T) { + requestContent := ` + { + "topic": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster}", + "subject": "{cluster}", + "eventType": "Microsoft.ContainerService.ClusterSupportEnded", + "eventTime": "2023-03-29T18:00:00.0000000Z", + "id": "1234567890abcdef1234567890abcdef12345678", + "data": { + "kubernetesVersion": "1.23.15" + }, + "dataVersion": "1", + "metadataVersion": "1" + }` + + event := parseEvent(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.ContainerServiceClusterSupportEventData](t, event.Data) + require.Equal(t, "1.23.15", *sysEvent.KubernetesVersion) + + sysEvent2 := deserializeSystemEvent[azsystemevents.ContainerServiceClusterSupportEndedEventData](t, event.Data) + require.Equal(t, "1.23.15", *sysEvent2.KubernetesVersion) +} + +func TestConsumeContainerServiceSupportEndingEvent(t *testing.T) { + requestContent := ` + { + "topic": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster}", + "subject": "{cluster}", + "eventType": "Microsoft.ContainerService.ClusterSupportEnding", + "eventTime": "2023-03-29T18:00:00.0000000Z", + "id": "1234567890abcdef1234567890abcdef12345678", + "data": { + "kubernetesVersion": "1.23.15" + }, + "dataVersion": "1", + "metadataVersion": "1" + }` + + event := parseEvent(t, requestContent) + + require.NotEmpty(t, event) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerServiceClusterSupportEventData](t, event.Data) + require.Equal(t, "1.23.15", *sysEvent.KubernetesVersion) + + sysEvent2 := deserializeSystemEvent[azsystemevents.ContainerServiceClusterSupportEndingEventData](t, event.Data) + require.Equal(t, "1.23.15", *sysEvent2.KubernetesVersion) +} + +func TestConsumeContainerServiceNodePoolRollingFailed(t *testing.T) { + requestContent := ` + { + "topic": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster}", + "subject": "{cluster}", + "eventType": "Microsoft.ContainerService.NodePoolRollingFailed", + "eventTime": "2023-03-29T18:00:00.0000000Z", + "id": "1234567890abcdef1234567890abcdef12345678", + "data": { + "nodePoolName": "nodepool1" + }, + "dataVersion": "1", + "metadataVersion": "1" + }` + + event := parseEvent(t, requestContent) + + require.NotEmpty(t, event) + + sysEvent := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent.NodePoolName) + + sysEvent2 := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingFailedEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent2.NodePoolName) +} + +func TestConsumeContainerServiceNodePoolRollingStarted(t *testing.T) { + requestContent := ` + { + "topic": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster}", + "subject": "{cluster}", + "eventType": "Microsoft.ContainerService.NodePoolRollingStarted", + "eventTime": "2023-03-29T18:00:00.0000000Z", + "id": "1234567890abcdef1234567890abcdef12345678", + "data": { + "nodePoolName": "nodepool1" + }, + "dataVersion": "1", + "metadataVersion": "1" + }` + + event := parseEvent(t, requestContent) + + require.NotEmpty(t, event) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent.NodePoolName) + + sysEvent2 := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingStartedEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent2.NodePoolName) +} + +func TestConsumeContainerServiceNodePoolRollingSucceeded(t *testing.T) { + requestContent := ` + { + "topic": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster}", + "subject": "{cluster}", + "eventType": "Microsoft.ContainerService.NodePoolRollingSucceeded", + "eventTime": "2023-03-29T18:00:00.0000000Z", + "id": "1234567890abcdef1234567890abcdef12345678", + "data": { + "nodePoolName": "nodepool1" + }, + "dataVersion": "1", + "metadataVersion": "1" + }` + + event := parseEvent(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent.NodePoolName) + + sysEvent2 := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingSucceededEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent2.NodePoolName) +} + +func TestConsumeIoTHubDeviceCreatedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"2da5e9b4-4e38-04c1-cc58-9da0b37230c0\", \"topic\": \"/SUBSCRIPTIONS/BDF55CDD-8DAB-4CF4-9B2F-C21E8A780472/RESOURCEGROUPS/EGTESTRG/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/EGTESTHUB1\", \"subject\": \"devices/48e44e11-1437-4907-83b1-4a8d7e89859e\", \"eventType\": \"Microsoft.Devices.DeviceCreated\", \"eventTime\": \"2018-07-03T23:20:07.6532054Z\", \"data\": { \"twin\": { \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\", \"etag\": \"AAAAAAAAAAE=\", \"deviceEtag\": null, \"status\": \"enabled\", \"statusUpdateTime\": \"0001-01-01T00:00:00\", \"connectionState\": \"Disconnected\", \"lastActivityTime\": \"0001-01-01T00:00:00\", \"cloudToDeviceMessageCount\": 0, \"authenticationType\": \"sas\", \"x509Thumbprint\": { \"primaryThumbprint\": null, \"secondaryThumbprint\": null }, \"version\": 2, \"properties\": { \"desired\": { \"$metadata\": { \"$lastUpdated\": \"2018-07-03T23:20:07.6532054Z\" }, \"$version\": 1 }, \"reported\": { \"$metadata\": { \"$lastUpdated\": \"2018-07-03T23:20:07.6532054Z\" }, \"$version\": 1 } } }, \"hubName\": \"EGTESTHUB1\", \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\" }, \"dataVersion\": \"\", \"metadataVersion\": \"1\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.IotHubDeviceCreatedEventData](t, events[0].Data) + require.Equal(t, "enabled", *sysEvent.Twin.Status) +} + +func TestConsumeIoTHubDeviceDeletedEvent(t *testing.T) { + requestContent := "[ { \"id\": \"aaaf95c6-ed99-b307-e321-81d8e4f731a6\", \"topic\": \"/SUBSCRIPTIONS/BDF55CDD-8DAB-4CF4-9B2F-C21E8A780472/RESOURCEGROUPS/EGTESTRG/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/EGTESTHUB1\", \"subject\": \"devices/48e44e11-1437-4907-83b1-4a8d7e89859e\", \"eventType\": \"Microsoft.Devices.DeviceDeleted\", \"eventTime\": \"2018-07-03T23:21:33.2753956Z\", \"data\": { \"twin\": { \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\", \"etag\": \"AAAAAAAAAAI=\", \"deviceEtag\": null, \"status\": \"enabled\", \"statusUpdateTime\": \"0001-01-01T00:00:00\", \"connectionState\": \"Disconnected\", \"lastActivityTime\": \"0001-01-01T00:00:00\", \"cloudToDeviceMessageCount\": 0, \"authenticationType\": \"sas\", \"x509Thumbprint\": { \"primaryThumbprint\": null, \"secondaryThumbprint\": null }, \"version\": 3, \"tags\": { \"testKey\": \"testValue\" }, \"properties\": { \"desired\": { \"$metadata\": { \"$lastUpdated\": \"2018-07-03T23:20:07.6532054Z\" }, \"$version\": 1 }, \"reported\": { \"$metadata\": { \"$lastUpdated\": \"2018-07-03T23:20:07.6532054Z\" }, \"$version\": 1 } } }, \"hubName\": \"EGTESTHUB1\", \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\" }, \"dataVersion\": \"\", \"metadataVersion\": \"1\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.IotHubDeviceDeletedEventData](t, events[0].Data) + require.Equal(t, "AAAAAAAAAAI=", *sysEvent.Twin.Etag) +} + +func TestConsumeIoTHubDeviceConnectedEvent(t *testing.T) { + requestContent := "[ { \"id\": \"fbfd8ee1-cf78-74c6-dbcf-e1c58638ccbd\", \"topic\": \"/SUBSCRIPTIONS/BDF55CDD-8DAB-4CF4-9B2F-C21E8A780472/RESOURCEGROUPS/EGTESTRG/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/EGTESTHUB1\", \"subject\": \"devices/48e44e11-1437-4907-83b1-4a8d7e89859e\", \"eventType\": \"Microsoft.Devices.DeviceConnected\", \"eventTime\": \"2018-07-03T23:20:11.6921933+00:00\", \"data\": { \"deviceConnectionStateEventInfo\": { \"sequenceNumber\": \"000000000000000001D4132452F67CE200000002000000000000000000000001\" }, \"hubName\": \"EGTESTHUB1\", \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\", \"moduleId\": \"\" }, \"dataVersion\": \"\", \"metadataVersion\": \"1\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.IotHubDeviceConnectedEventData](t, events[0].Data) + require.Equal(t, "EGTESTHUB1", *sysEvent.HubName) +} + +func TestConsumeIoTHubDeviceDisconnectedEvent(t *testing.T) { + requestContent := "[ { \"id\": \"877f0b10-a086-98ec-27b8-6ae2dfbf5f67\", \"topic\": \"/SUBSCRIPTIONS/BDF55CDD-8DAB-4CF4-9B2F-C21E8A780472/RESOURCEGROUPS/EGTESTRG/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/EGTESTHUB1\", \"subject\": \"devices/48e44e11-1437-4907-83b1-4a8d7e89859e\", \"eventType\": \"Microsoft.Devices.DeviceDisconnected\", \"eventTime\": \"2018-07-03T23:20:52.646434+00:00\", \"data\": { \"deviceConnectionStateEventInfo\": { \"sequenceNumber\": \"000000000000000001D4132452F67CE200000002000000000000000000000002\" }, \"hubName\": \"EGTESTHUB1\", \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\", \"moduleId\": \"\" }, \"dataVersion\": \"\", \"metadataVersion\": \"1\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.IotHubDeviceDisconnectedEventData](t, events[0].Data) + require.Equal(t, "000000000000000001D4132452F67CE200000002000000000000000000000002", *sysEvent.DeviceConnectionStateEventInfo.SequenceNumber) +} + +func TestConsumeIoTHubDeviceTelemetryEvent(t *testing.T) { + requestContent := "[{ \"id\": \"877f0b10-a086-98ec-27b8-6ae2dfbf5f67\", \"topic\": \"/SUBSCRIPTIONS/BDF55CDD-8DAB-4CF4-9B2F-C21E8A780472/RESOURCEGROUPS/EGTESTRG/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/EGTESTHUB1\", \"subject\": \"devices/48e44e11-1437-4907-83b1-4a8d7e89859e\", \"eventType\": \"Microsoft.Devices.DeviceTelemetry\", \"eventTime\": \"2018-07-03T23:20:52.646434+00:00\", \"data\": { \"body\": { \"Weather\": { \"Temperature\": 900 }, \"Location\": \"USA\" }, \"properties\": { \"Status\": \"Active\" }, \"systemProperties\": { \"iothub-content-type\": \"application/json\", \"iothub-content-encoding\": \"utf-8\" } }, \"dataVersion\": \"\"} ]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.IotHubDeviceTelemetryEventData](t, events[0].Data) + require.Equal(t, "Active", *sysEvent.Properties["Status"]) +} + +// Event Hub Events +func TestConsumeEventHubCaptureFileCreatedEvent(t *testing.T) { + requestContent := "[ { \"topic\": \"/subscriptions/guid/resourcegroups/rgDataMigrationSample/providers/Microsoft.EventHub/namespaces/tfdatamigratens\", \"subject\": \"eventhubs/hubdatamigration\", \"eventType\": \"microsoft.EventHUB.CaptureFileCreated\", \"eventTime\": \"2017-08-31T19:12:46.0498024Z\", \"id\": \"14e87d03-6fbf-4bb2-9a21-92bd1281f247\", \"data\": { \"fileUrl\": \"https://tf0831datamigrate.blob.core.windows.net/windturbinecapture/tfdatamigratens/hubdatamigration/1/2017/08/31/19/11/45.avro\", \"fileType\": \"AzureBlockBlob\", \"partitionId\": \"1\", \"sizeInBytes\": 249168, \"eventCount\": 1500, \"firstSequenceNumber\": 2400, \"lastSequenceNumber\": 3899, \"firstEnqueueTime\": \"2017-08-31T19:12:14.674Z\", \"lastEnqueueTime\": \"2017-08-31T19:12:44.309Z\" }, \"dataVersion\": \"\", \"metadataVersion\": \"1\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.EventHubCaptureFileCreatedEventData](t, events[0].Data) + require.Equal(t, "AzureBlockBlob", *sysEvent.FileType) +} + +// MachineLearningServices events +func TestConsumeMachineLearningServicesModelRegisteredEvent(t *testing.T) { + requestContent := "[{\"topic\":\"/subscriptions/a5fe3bc5-98f0-4c84-affc-a589f54d9b23/resourceGroups/jenns/providers/Microsoft.MachineLearningServices/workspaces/jenns-canary\",\"eventType\":\"Microsoft.MachineLearningServices.ModelRegistered\",\"subject\":\"models/sklearn_regression_model:3\",\"eventTime\":\"2019-10-17T22:23:57.5350054+00:00\",\"id\":\"3b73ee51-bbf4-480d-9112-cfc23b41bfdb\",\"data\":{\"modelName\":\"sklearn_regression_model\",\"modelVersion\":\"3\",\"modelTags\":{\"area\":\"diabetes\",\"type\":\"regression\"},\"modelProperties\":{\"area\":\"test\"}},\"dataVersion\":\"2\",\"metadataVersion\":\"1\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MachineLearningServicesModelRegisteredEventData](t, events[0].Data) + require.Equal(t, "sklearn_regression_model", *sysEvent.ModelName) + require.Equal(t, "3", *sysEvent.ModelVersion) + + require.Equal(t, "regression", sysEvent.ModelTags.(map[string]any)["type"]) + require.Equal(t, "test", sysEvent.ModelProperties.(map[string]any)["area"]) +} + +func TestConsumeMachineLearningServicesModelDeployedEvent(t *testing.T) { + requestContent := "[{\"topic\":\"/subscriptions/a5fe3bc5-98f0-4c84-affc-a589f54d9b23/resourceGroups/jenns/providers/Microsoft.MachineLearningServices/workspaces/jenns-canary\",\"eventType\":\"Microsoft.MachineLearningServices.ModelDeployed\",\"subject\":\"endpoints/aciservice1\",\"eventTime\":\"2019-10-23T18:20:08.8824474+00:00\",\"id\":\"40d0b167-be44-477b-9d23-a2befba7cde0\",\"data\":{\"serviceName\":\"aciservice1\",\"serviceComputeType\":\"ACI\",\"serviceTags\":{\"mytag\":\"test tag\"},\"serviceProperties\":{\"myprop\":\"test property\"},\"modelIds\":\"my_first_model:1,my_second_model:1\"},\"dataVersion\":\"2\",\"metadataVersion\":\"1\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MachineLearningServicesModelDeployedEventData](t, events[0].Data) + require.Equal(t, "aciservice1", *sysEvent.ServiceName) + sysEvent2 := deserializeSystemEvent[azsystemevents.MachineLearningServicesModelDeployedEventData](t, events[0].Data) + require.Equal(t, 2, len(strings.Split(*sysEvent2.ModelIDs, ","))) +} + +func TestConsumeMachineLearningServicesRunCompletedEvent(t *testing.T) { + requestContent := "[{\"topic\":\"/subscriptions/a5fe3bc5-98f0-4c84-affc-a589f54d9b23/resourceGroups/jenns/providers/Microsoft.MachineLearningServices/workspaces/jenns-canary\",\"eventType\":\"Microsoft.MachineLearningServices.RunCompleted\",\"subject\":\"experiments/0fa9dfaa-cba3-4fa7-b590-23e48548f5c1/runs/AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc\",\"eventTime\":\"2019-10-18T19:29:55.8856038+00:00\",\"id\":\"044ac44d-462c-4043-99eb-d9e01dc760ab\",\"data\":{\"experimentId\":\"0fa9dfaa-cba3-4fa7-b590-23e48548f5c1\",\"experimentName\":\"automl-local-regression\",\"runId\":\"AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc\",\"runType\":\"automl\",\"RunTags\":{\"experiment_status\":\"ModelSelection\",\"experiment_status_descr\":\"Beginning model selection.\"},\"runProperties\":{\"num_iterations\":\"10\",\"target\":\"local\"}},\"dataVersion\":\"2\",\"metadataVersion\":\"1\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MachineLearningServicesRunCompletedEventData](t, events[0].Data) + require.Equal(t, "AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc", *sysEvent.RunID) + sysEvent2 := deserializeSystemEvent[azsystemevents.MachineLearningServicesRunCompletedEventData](t, events[0].Data) + require.Equal(t, "automl-local-regression", *sysEvent2.ExperimentName) +} + +func TestConsumeMachineLearningServicesRunStatusChangedEvent(t *testing.T) { + requestContent := "[{\"topic\":\"/subscriptions/a5fe3bc5-98f0-4c84-affc-a589f54d9b23/resourceGroups/jenns/providers/Microsoft.MachineLearningServices/workspaces/jenns-canary\",\"eventType\":\"Microsoft.MachineLearningServices.RunStatusChanged\",\"subject\":\"experiments/0fa9dfaa-cba3-4fa7-b590-23e48548f5c1/runs/AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc\",\"eventTime\":\"2020-03-09T23:53:04.4579724Z\",\"id\":\"aa8cd7df-fe28-5d5d-9b40-3342dbc2a887\",\"data\":{\"runStatus\": \"Running\",\"experimentId\":\"0fa9dfaa-cba3-4fa7-b590-23e48548f5c1\",\"experimentName\":\"automl-local-regression\",\"runId\":\"AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc\",\"runType\":\"automl\",\"runTags\":{\"experiment_status\":\"ModelSelection\",\"experiment_status_descr\":\"Beginning model selection.\"},\"runProperties\":{\"num_iterations\":\"10\",\"target\":\"local\"}},\"dataVersion\":\"2\",\"metadataVersion\":\"1\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MachineLearningServicesRunStatusChangedEventData](t, events[0].Data) + require.Equal(t, "AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc", *sysEvent.RunID) + require.Equal(t, "automl-local-regression", *sysEvent.ExperimentName) + require.Equal(t, "Running", *sysEvent.RunStatus) + require.Equal(t, "automl", *sysEvent.RunType) +} + +func TestConsumeMachineLearningServicesDatasetDriftDetectedEvent(t *testing.T) { + requestContent := "[{\"topic\":\"/subscriptions/60582a10-b9fd-49f1-a546-c4194134bba8/resourceGroups/copetersRG/providers/Microsoft.MachineLearningServices/workspaces/driftDemoWS\",\"eventType\":\"Microsoft.MachineLearningServices.DatasetDriftDetected\",\"subject\":\"datadrift/01d29aa4-e6a4-470a-9ef3-66660d21f8ef/run/01d29aa4-e6a4-470a-9ef3-66660d21f8ef_1571590300380\",\"eventTime\":\"2019-10-20T17:08:08.467191+00:00\",\"id\":\"2684de79-b145-4dcf-ad2e-6a1db798585f\",\"data\":{\"dataDriftId\":\"01d29aa4-e6a4-470a-9ef3-66660d21f8ef\",\"dataDriftName\":\"copetersDriftMonitor3\",\"runId\":\"01d29aa4-e6a4-470a-9ef3-66660d21f8ef_1571590300380\",\"baseDatasetId\":\"3c56d136-0f64-4657-a0e8-5162089a88a3\",\"tarAsSystemEventDatasetId\":\"d7e74d2e-c972-4266-b5fb-6c9c182d2a74\",\"driftCoefficient\":0.8350349068479208,\"startTime\":\"2019-07-04T00:00:00+00:00\",\"endTime\":\"2019-07-05T00:00:00+00:00\"},\"dataVersion\":\"2\",\"metadataVersion\":\"1\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MachineLearningServicesDatasetDriftDetectedEventData](t, events[0].Data) + require.Equal(t, "copetersDriftMonitor3", *sysEvent.DataDriftName) +} + +// Maps events +func TestConsumeMapsGeofenceEnteredEvent(t *testing.T) { + requestContent := "[{ \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"topic\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"eventType\": \"Microsoft.Maps.GeofenceEntered\",\"eventTime\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"expiredGeofenceGeometryId\":[\"id1\",\"id2\"],\"geometries\":[{\"deviceId\":\"id1\",\"distance\":1.0,\"geometryId\":\"gid1\",\"nearestLat\":72.4,\"nearestLon\":100.4,\"udId\":\"id22\"}],\"invalidPeriodGeofenceGeometryId\":[\"id1\",\"id2\"],\"isEventPublished\":true}, \"dataVersion\":\"\"}]" + events := parseManyEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MapsGeofenceEnteredEventData](t, events[0].Data) + require.Equal(t, float32(1.0), *sysEvent.Geometries[0].Distance) +} + +func TestConsumeMapsGeofenceExitedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"topic\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"eventType\": \"Microsoft.Maps.GeofenceExited\",\"eventTime\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"expiredGeofenceGeometryId\":[\"id1\",\"id2\"],\"geometries\":[{\"deviceId\":\"id1\",\"distance\":1.0,\"geometryId\":\"gid1\",\"nearestLat\":72.4,\"nearestLon\":100.4,\"udId\":\"id22\"}],\"invalidPeriodGeofenceGeometryId\":[\"id1\",\"id2\"],\"isEventPublished\":true}, \"dataVersion\":\"\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MapsGeofenceExitedEventData](t, events[0].Data) + require.Equal(t, float32(1.0), *sysEvent.Geometries[0].Distance) +} + +func TestConsumeMapsGeofenceResultEvent(t *testing.T) { + requestContent := "[{ \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"topic\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"eventType\": \"Microsoft.Maps.GeofenceResult\",\"eventTime\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"expiredGeofenceGeometryId\":[\"id1\",\"id2\"],\"geometries\":[{\"deviceId\":\"id1\",\"distance\":1.0,\"geometryId\":\"gid1\",\"nearestLat\":72.4,\"nearestLon\":100.4,\"udId\":\"id22\"}],\"invalidPeriodGeofenceGeometryId\":[\"id1\",\"id2\"],\"isEventPublished\":true}, \"dataVersion\":\"\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MapsGeofenceResultEventData](t, events[0].Data) + require.Equal(t, float32(1.0), *sysEvent.Geometries[0].Distance) +} + +// Media Services events +func TestConsumeMediaMediaJobStateChangeEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobStateChange\", \"eventTime\": \"2018-10-12T15:14:20.2412317\", \"id\": \"341520d0-dac0-4930-97dd-3085538c624f\", \"data\": { \"previousState\": \"Scheduled\", \"state\": \"Processing\", \"correlationData\": {} }, \"dataVersion\": \"2.0\", \"metadataVersion\": \"1\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobStateChangeEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.State) +} + +func TestConsumeMediaJobOutputStateChangeEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobOutputStateChange\", \"eventTime\": \"2018-10-12T15:14:17.8962704\", \"id\": \"8d0305c0-28c0-4cc9-b613-776e4dd31e9a\", \"data\": { \"previousState\": \"Scheduled\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": {\"code\":\"ServiceError\", \"message\":\"error message\", \"category\":\"Service\", \"retry\":\"DoNotRetry\", \"details\":[{\"code\":\"code\", \"message\":\"Service Error Message\"}]}, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 0, \"state\": \"Processing\" }, \"jobCorrelationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + require.NotEmpty(t, events) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputStateChangeEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.PreviousState) + mediaOutputAsset := sysEvent.Output.(*azsystemevents.MediaJobOutputAsset) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *mediaOutputAsset.State) + + require.Equal(t, "output-2ac2fe75-6557-4de5-ab25-5713b74a6901", *mediaOutputAsset.AssetName) + + require.Equal(t, azsystemevents.MediaJobErrorCategoryService, *mediaOutputAsset.Error.Category) + require.Equal(t, azsystemevents.MediaJobErrorCodeServiceError, *mediaOutputAsset.Error.Code) +} + +func TestConsumeMediaJobOutputStateChangeEvent_UnknownError(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobOutputStateChange\", \"eventTime\": \"2018-10-12T15:14:17.8962704\", \"id\": \"8d0305c0-28c0-4cc9-b613-776e4dd31e9a\", \"data\": { \"previousState\": \"Scheduled\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": {\"code\":\"SomeNewCode\", \"message\":\"error message\", \"category\":\"SomeNewCategory\", \"retry\":\"DoNotRetry\", \"details\":[{\"code\":\"code\", \"message\":\"Service Error Message\"}]}, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 0, \"state\": \"Processing\" }, \"jobCorrelationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputStateChangeEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.Output.(*azsystemevents.MediaJobOutputAsset).State) + + outputAsset := sysEvent.Output.(*azsystemevents.MediaJobOutputAsset) + require.Equal(t, "output-2ac2fe75-6557-4de5-ab25-5713b74a6901", *outputAsset.AssetName) + + require.Equal(t, azsystemevents.MediaJobErrorCategory("SomeNewCategory"), *outputAsset.Error.Category) + require.Equal(t, azsystemevents.MediaJobErrorCode("SomeNewCode"), *outputAsset.Error.Code) +} + +func TestConsumeMediaJobScheduledEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobScheduled\", \"eventTime\": \"2018-10-12T15:14:11.3028183\", \"id\": \"9b17dbf0-355d-4fb0-9a73-e76b150858c8\", \"data\": { \"previousState\": \"Queued\", \"state\": \"Scheduled\", \"correlationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobScheduledEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateQueued, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.State) +} + +func TestConsumeMediaJobProcessingEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobProcessing\", \"eventTime\": \"2018-10-12T15:14:20.2412317\", \"id\": \"72162c44-c7f4-437a-9592-48b83cec2d18\", \"data\": { \"previousState\": \"Scheduled\", \"state\": \"Processing\", \"correlationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobProcessingEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.State) +} + +func TestConsumeMediaJobCancelingEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"eventType\": \"Microsoft.Media.JobCanceling\", \"eventTime\": \"2018-10-12T15:41:50.5513295\", \"id\": \"1f9a488b-abe3-4fca-80b8-aae59bf7f123\", \"data\": { \"previousState\": \"Processing\", \"state\": \"Canceling\", \"correlationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobCancelingEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateCanceling, *sysEvent.State) +} + +func TestConsumeMediaJobFinishedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-298338bb-f8d1-4d0f-9fde-544e0ac4d983\", \"eventType\": \"Microsoft.Media.JobFinished\", \"eventTime\": \"2018-10-01T20:58:26.7886175\", \"id\": \"83f8464d-be94-48e5-b67b-46c6199fe28e\", \"data\": { \"outputs\": [ { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-298338bb-f8d1-4d0f-9fde-544e0ac4d983\", \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 100, \"state\": \"Finished\" } ], \"previousState\": \"Processing\", \"state\": \"Finished\", \"correlationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\" }]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobFinishedEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateFinished, *sysEvent.State) + require.Equal(t, 1, len(sysEvent.Outputs)) + + outputAsset := sysEvent.Outputs[0].(*azsystemevents.MediaJobOutputAsset) + + require.Equal(t, azsystemevents.MediaJobStateFinished, *outputAsset.State) + require.Nil(t, outputAsset.Error) + require.Equal(t, int64(100), *outputAsset.Progress) + require.Equal(t, "output-298338bb-f8d1-4d0f-9fde-544e0ac4d983", *outputAsset.AssetName) +} + +func TestConsumeMediaJobCanceledEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"eventType\": \"Microsoft.Media.JobCanceled\", \"eventTime\": \"2018-10-12T15:42:05.6519929\", \"id\": \"3fef7871-f916-4980-8a45-e79a2675808b\", \"data\": { \"outputs\": [ { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"error\": {\"code\":\"ServiceError\", \"message\":\"error message\", \"category\":\"Service\", \"retry\":\"DoNotRetry\", \"details\":[{\"code\":\"code\", \"message\":\"Service Error Message\"}]}, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 83, \"state\": \"Canceled\" } ], \"previousState\": \"Canceling\", \"state\": \"Canceled\", \"correlationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + require.NotEmpty(t, events) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobCanceledEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateCanceling, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateCanceled, *sysEvent.State) + require.Equal(t, 1, len(sysEvent.Outputs)) + + outputAsset := sysEvent.Outputs[0].(*azsystemevents.MediaJobOutputAsset) + + require.Equal(t, azsystemevents.MediaJobStateCanceled, *outputAsset.State) + require.NotEqual(t, int64(100), *outputAsset.Progress) + require.Equal(t, "output-7a8215f9-0f8d-48a6-82ed-1ead772bc221", *outputAsset.AssetName) +} + +func TestConsumeMediaJobErroredEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobErrored\", \"eventTime\": \"2018-10-12T15:29:20.9954767\", \"id\": \"2749e9cf-4095-4723-9bc5-df8e15289135\", \"data\": { \"outputs\": [ { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": { \"category\": \"Service\", \"code\": \"ServiceError\", \"details\": [ { \"code\": \"Internal\", \"message\": \"Internal error in initializing the task for processing\" } ], \"message\": \"Fatal service error, please contact support.\", \"retry\": \"DoNotRetry\" }, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 83, \"state\": \"Error\" } ], \"previousState\": \"Processing\", \"state\": \"Error\", \"correlationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobErroredEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateError, *sysEvent.State) + require.Equal(t, 1, len(sysEvent.Outputs)) + + outputAsset := sysEvent.Outputs[0].(*azsystemevents.MediaJobOutputAsset) + + require.Equal(t, azsystemevents.MediaJobStateError, *outputAsset.State) + require.NotEmpty(t, *outputAsset.Error) + require.Equal(t, azsystemevents.MediaJobErrorCategoryService, *outputAsset.Error.Category) + require.Equal(t, azsystemevents.MediaJobErrorCodeServiceError, *outputAsset.Error.Code) +} + +func TestConsumeMediaJobOutputCanceledEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"eventType\": \"Microsoft.Media.JobOutputCanceled\", \"eventTime\": \"2018-10-12T15:42:04.949555\", \"id\": \"9297cda2-4a50-4622-a679-c3785d27d512\", \"data\": { \"previousState\": \"Canceling\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"error\": {\"code\":\"ServiceError\", \"message\":\"error message\", \"category\":\"Service\", \"retry\":\"DoNotRetry\", \"details\":[{\"code\":\"code\", \"message\":\"Service Error Message\"}]}, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 83, \"state\": \"Canceled\" }, \"jobCorrelationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputCanceledEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateCanceling, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateCanceled, *sysEvent.Output.(*azsystemevents.MediaJobOutputAsset).State) +} + +func TestConsumeMediaJobOutputCancelingEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"eventType\": \"Microsoft.Media.JobOutputCanceling\", \"eventTime\": \"2018-10-12T15:42:04.949555\", \"id\": \"9297cda2-4a50-4622-a679-c3785d27d512\", \"data\": { \"previousState\": \"Processing\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"error\": { \"category\": \"Service\", \"code\": \"ServiceError\", \"details\": [ { \"code\": \"Internal\", \"message\": \"Internal error in initializing the task for processing\" } ], \"message\": \"Fatal service error, please contact support.\", \"retry\": \"DoNotRetry\" }, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 83, \"state\": \"Canceling\" }, \"jobCorrelationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputCancelingEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateCanceling, *sysEvent.Output.(*azsystemevents.MediaJobOutputAsset).State) +} + +func TestConsumeMediaJobOutputErroredEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobOutputErrored\", \"eventTime\": \"2018-10-12T15:29:20.2621252\", \"id\": \"bc9e6342-f081-49c2-a579-92f506a622c2\", \"data\": { \"previousState\": \"Processing\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": { \"category\": \"Service\", \"code\": \"ServiceError\", \"details\": [ { \"code\": \"Internal\", \"message\": \"Internal error in initializing the task for processing\" } ], \"message\": \"Fatal service error, please contact support.\", \"retry\": \"DoNotRetry\" }, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 83, \"state\": \"Error\" }, \"jobCorrelationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputErroredEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + + outputAsset := sysEvent.Output.(*azsystemevents.MediaJobOutputAsset) + require.Equal(t, azsystemevents.MediaJobStateError, *outputAsset.State) + require.NotEmpty(t, outputAsset.Error) + require.Equal(t, azsystemevents.MediaJobErrorCategoryService, *outputAsset.Error.Category) + require.Equal(t, azsystemevents.MediaJobErrorCodeServiceError, *outputAsset.Error.Code) +} + +func TestConsumeMediaJobOutputFinishedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobOutputFinished\", \"eventTime\": \"2018-10-12T15:29:20.2621252\", \"id\": \"bc9e6342-f081-49c2-a579-92f506a622c2\", \"data\": { \"previousState\": \"Processing\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 100, \"state\": \"Finished\" }, \"jobCorrelationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputFinishedEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + + outputAsset := sysEvent.Output.(*azsystemevents.MediaJobOutputAsset) + require.Equal(t, azsystemevents.MediaJobStateFinished, *outputAsset.State) + require.Equal(t, int64(100), *outputAsset.Progress) + require.Equal(t, "output-2ac2fe75-6557-4de5-ab25-5713b74a6901", *outputAsset.AssetName) +} + +func TestConsumeMediaJobOutputProcessingEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobOutputProcessing\", \"eventTime\": \"2018-10-12T15:14:17.8962704\", \"id\": \"d48eeb0b-2bfa-4265-a2f8-624654c3781c\", \"data\": { \"previousState\": \"Scheduled\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": { \"category\": \"Service\", \"code\": \"ServiceError\", \"details\": [ { \"code\": \"Internal\", \"message\": \"Internal error in initializing the task for processing\" } ], \"message\": \"Fatal service error, please contact support.\", \"retry\": \"DoNotRetry\" }, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 0, \"state\": \"Processing\" }, \"jobCorrelationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputProcessingEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.PreviousState) + + outputAsset := sysEvent.Output.(*azsystemevents.MediaJobOutputAsset) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *outputAsset.State) +} + +func TestConsumeMediaJobOutputScheduledEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"eventType\": \"Microsoft.Media.JobOutputScheduled\", \"eventTime\": \"2018-10-12T15:14:11.2244618\", \"id\": \"635ca6ea-5306-4590-b2e1-22f172759336\", \"data\": { \"previousState\": \"Queued\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": { \"category\": \"Service\", \"code\": \"ServiceError\", \"details\": [ { \"code\": \"Internal\", \"message\": \"Internal error in initializing the task for processing\" } ], \"message\": \"Fatal service error, please contact support.\", \"retry\": \"DoNotRetry\" }, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 0, \"state\": \"Scheduled\" }, \"jobCorrelationData\": {} }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputScheduledEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateQueued, *sysEvent.PreviousState) + + outputAsset := sysEvent.Output.(*azsystemevents.MediaJobOutputAsset) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *outputAsset.State) +} + +func TestConsumeMediaJobOutputProgressEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6981\", \"eventType\": \"Microsoft.Media.JobOutputProgress\", \"eventTime\": \"2018-10-12T15:14:11.2244618\", \"id\": \"635ca6ea-5306-4590-b2e1-22f172759336\", \"data\": { \"jobCorrelationData\": { \"Field1\": \"test1\", \"Field2\": \"test2\" }, \"label\": \"TestLabel\", \"progress\": 50 }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputProgressEventData](t, events[0].Data) + require.Equal(t, "TestLabel", *sysEvent.Label) + require.Equal(t, int64(50), *sysEvent.Progress) + + require.Equal(t, "test1", *sysEvent.JobCorrelationData["Field1"]) + require.Equal(t, "test2", *sysEvent.JobCorrelationData["Field2"]) +} + +func TestConsumeMediaLiveEventEncoderConnectedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"eventType\": \"Microsoft.Media.LiveEventEncoderConnected\", \"eventTime\": \"2018-10-12T15:52:04.2013501\", \"id\": \"3d1f5b26-c466-47e7-927b-900985e0c5d5\", \"data\": { \"ingestUrl\": \"rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59\", \"streamId\": \"Mystream1\", \"encoderIp\": \"\", \"encoderPort\": \"3557\" }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventEncoderConnectedEventData](t, events[0].Data) + + require.Equal(t, "rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59", *sysEvent.IngestURL) + require.Equal(t, "Mystream1", *sysEvent.StreamID) + require.Equal(t, "", *sysEvent.EncoderIP) + require.Equal(t, "3557", *sysEvent.EncoderPort) +} + +func TestConsumeMediaLiveEventConnectionRejectedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"eventType\": \"Microsoft.Media.LiveEventConnectionRejected\", \"eventTime\": \"2018-10-12T15:52:04.2013501\", \"id\": \"3d1f5b26-c466-47e7-927b-900985e0c5d5\", \"data\": { \"ingestUrl\": \"rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59\", \"streamId\": \"Mystream1\", \"encoderIp\": \"\", \"encoderPort\": \"3557\", \"resultCode\": \"MPE_INGEST_CODEC_NOT_SUPPORTED\" }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventConnectionRejectedEventData](t, events[0].Data) + require.Equal(t, "rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59", *sysEvent.IngestURL) + require.Equal(t, "Mystream1", *sysEvent.StreamID) + require.Equal(t, "", *sysEvent.EncoderIP) + require.Equal(t, "3557", *sysEvent.EncoderPort) +} + +func TestConsumeMediaLiveEventEncoderDisconnectedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"eventType\": \"Microsoft.Media.LiveEventEncoderDisconnected\", \"eventTime\": \"2018-10-12T15:52:19.8982128\", \"id\": \"e4b55140-42d2-4c24-b08e-9aa12f1587fc\", \"data\": { \"ingestUrl\": \"rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59\", \"streamId\": \"Mystream1\", \"encoderIp\": \"\", \"encoderPort\": \"3557\", \"resultCode\": \"MPE_CLIENT_TERMINATED_SESSION\" }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventEncoderDisconnectedEventData](t, events[0].Data) + + require.Equal(t, "MPE_CLIENT_TERMINATED_SESSION", *sysEvent.ResultCode) + require.Equal(t, "rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59", *sysEvent.IngestURL) + require.Equal(t, "Mystream1", *sysEvent.StreamID) + require.Equal(t, "", *sysEvent.EncoderIP) + require.Equal(t, "3557", *sysEvent.EncoderPort) +} + +func TestConsumeMediaLiveEventIncomingStreamReceivedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"eventType\": \"Microsoft.Media.LiveEventIncomingStreamReceived\", \"eventTime\": \"2018-10-12T15:52:16.5726463Z\", \"id\": \"eb688fa1-5a19-4703-8aeb-6a65a09790da\", \"data\": { \"ingestUrl\": \"rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59\", \"trackType\": \"audio\", \"trackName\": \"audio_160000\", \"bitrate\": 160000, \"encoderIp\": \"\", \"encoderPort\": \"3557\", \"timestamp\": \"66\", \"duration\": \"1950\", \"timescale\": \"1000\" }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventIncomingStreamReceivedEventData](t, events[0].Data) + + require.Equal(t, "rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59", *sysEvent.IngestURL) + require.Equal(t, "", *sysEvent.EncoderIP) + require.Equal(t, "3557", *sysEvent.EncoderPort) + require.Equal(t, "audio", *sysEvent.TrackType) + require.Equal(t, "audio_160000", *sysEvent.TrackName) + require.Equal(t, int64(160000), *sysEvent.Bitrate) + require.Equal(t, "66", *sysEvent.Timestamp) + require.Equal(t, "1950", *sysEvent.Duration) + require.Equal(t, "1000", *sysEvent.Timescale) +} + +func TestConsumeMediaLiveEventIncomingStreamsOutOfSyncEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"eventType\": \"Microsoft.Media.LiveEventIncomingStreamsOutOfSync\", \"eventTime\": \"2018-10-12T15:52:37.3710102\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"minLastTimestamp\": \"10999\", \"typeOfStreamWithMinLastTimestamp\": \"video\", \"maxLastTimestamp\": \"100999\", \"typeOfStreamWithMaxLastTimestamp\": \"audio\", \"timescaleOfMinLastTimestamp\": \"1000\", \"timescaleOfMaxLastTimestamp\": \"1000\" }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventIncomingStreamsOutOfSyncEventData](t, events[0].Data) + + require.Equal(t, "10999", *sysEvent.MinLastTimestamp) + require.Equal(t, "video", *sysEvent.TypeOfStreamWithMinLastTimestamp) + require.Equal(t, "100999", *sysEvent.MaxLastTimestamp) + require.Equal(t, "audio", *sysEvent.TypeOfStreamWithMaxLastTimestamp) + require.Equal(t, "1000", *sysEvent.TimescaleOfMinLastTimestamp) + require.Equal(t, "1000", *sysEvent.TimescaleOfMaxLastTimestamp) +} + +func TestConsumeMediaLiveEventIncomingVideoStreamsOutOfSyncEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"eventType\": \"Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync\", \"eventTime\": \"2018-10-12T15:52:37.3710102\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"firstTimestamp\": \"10999\", \"firstDuration\": \"2000\", \"secondTimestamp\": \"100999\", \"secondDuration\": \"2000\", \"timescale\": \"1000\" }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventIncomingVideoStreamsOutOfSyncEventData](t, events[0].Data) + + require.Equal(t, "10999", *sysEvent.FirstTimestamp) + require.Equal(t, "2000", *sysEvent.FirstDuration) + require.Equal(t, "100999", *sysEvent.SecondTimestamp) + require.Equal(t, "2000", *sysEvent.SecondDuration) + require.Equal(t, "1000", *sysEvent.Timescale) +} + +func TestConsumeMediaLiveEventIncomingDataChunkDroppedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"eventType\": \"Microsoft.Media.LiveEventIncomingDataChunkDropped\", \"eventTime\": \"2018-10-12T15:52:37.3710102\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"timestamp\": \"8999\", \"trackType\": \"video\", \"trackName\": \"video1\", \"bitrate\": 2500000, \"timescale\": \"1000\", \"resultCode\": \"FragmentDrop_OverlapTimestamp\" }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventIncomingDataChunkDroppedEventData](t, events[0].Data) + + require.Equal(t, "8999", *sysEvent.Timestamp) + require.Equal(t, "video", *sysEvent.TrackType) + require.Equal(t, "video1", *sysEvent.TrackName) + require.Equal(t, int64(2500000), *sysEvent.Bitrate) + require.Equal(t, "1000", *sysEvent.Timescale) + require.Equal(t, "FragmentDrop_OverlapTimestamp", *sysEvent.ResultCode) +} + +func TestConsumeMediaLiveEventIngestHeartbeatEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"eventType\": \"Microsoft.Media.LiveEventIngestHeartbeat\", \"eventTime\": \"2018-10-12T15:52:37.3710102\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"trackType\": \"video\", \"trackName\": \"video\", \"bitrate\": 2500000, \"incomingBitrate\": 500726, \"lastTimestamp\": \"11999\", \"timescale\": \"1000\", \"overlapCount\": 0, \"discontinuityCount\": 0, \"nonincreasingCount\": 0, \"unexpectedBitrate\": true, \"state\": \"Running\", \"healthy\": false, \"lastFragmentArrivalTime\": \"2021-05-14T23:50:00.00\", \"ingestDriftValue\": \"0\" }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventIngestHeartbeatEventData](t, events[0].Data) + require.Equal(t, "video", *sysEvent.TrackType) + require.Equal(t, "video", *sysEvent.TrackName) + require.Equal(t, int64(2500000), *sysEvent.Bitrate) + require.Equal(t, int64(500726), *sysEvent.IncomingBitrate) + require.Equal(t, "11999", *sysEvent.LastTimestamp) + require.Equal(t, "1000", *sysEvent.Timescale) + require.Equal(t, int64(0), *sysEvent.OverlapCount) + require.Equal(t, int64(0), *sysEvent.DiscontinuityCount) + require.Equal(t, int64(0), *sysEvent.NonincreasingCount) + require.True(t, *sysEvent.UnexpectedBitrate) + require.Equal(t, "Running", *sysEvent.State) + require.False(t, *sysEvent.Healthy) + require.Equal(t, "0", *sysEvent.IngestDriftValue) + require.Equal(t, "2021-05-14T23:50:00.00", *sysEvent.LastFragmentArrivalTime) + + requestContent = "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"eventType\": \"Microsoft.Media.LiveEventIngestHeartbeat\", \"eventTime\": \"2018-10-12T15:52:37.3710102\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"trackType\": \"video\", \"trackName\": \"video\", \"bitrate\": 2500000, \"incomingBitrate\": 500726, \"lastTimestamp\": \"11999\", \"timescale\": \"1000\", \"overlapCount\": 0, \"discontinuityCount\": 0, \"nonincreasingCount\": 0, \"unexpectedBitrate\": true, \"state\": \"Running\", \"healthy\": false, \"lastFragmentArrivalTime\": \"2021-05-14T23:50:00.00\", \"ingestDriftValue\": \"n/a\" }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events2 := parseManyEvents(t, requestContent) + sysEvent2 := deserializeSystemEvent[azsystemevents.MediaLiveEventIngestHeartbeatEventData](t, events2[0].Data) + require.Nil(t, sysEvent2.IngestDriftValue) +} + +func TestConsumeMediaLiveEventChannelArchiveHeartbeatEvent(t *testing.T) { + requestContent := `[ + { + "topic": "/subscriptions//resourceGroups//providers/Microsoft.Media/mediaservices/", + "subject": "liveEvent/mle1", + "eventType": "Microsoft.Media.LiveEventChannelArchiveHeartbeat", + "eventTime": "2021-05-14T23:50:00.324", + "id": "7f450938-491f-41e1-b06f-c6cd3965d786", + "data": { + "channelLatencyMs": "10", + "latencyResultCode": "S_OK" + }, + "dataVersion": "1.0", + "metadataVersion": "1" + }]` + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventChannelArchiveHeartbeatEventData](t, events[0].Data) + require.Equal(t, "10", *sysEvent.ChannelLatencyMS) + require.Equal(t, "S_OK", *sysEvent.LatencyResultCode) + + requestContent = `[ + { + "topic": "/subscriptions//resourceGroups//providers/Microsoft.Media/mediaservices/", + "subject": "liveEvent/mle1", + "eventType": "Microsoft.Media.LiveEventChannelArchiveHeartbeat", + "eventTime": "2021-05-14T23:50:00.324", + "id": "7f450938-491f-41e1-b06f-c6cd3965d786", + "data": { + "channelLatencyMs": "n/a", + "latencyResultCode": "S_OK" + }, + "dataVersion": "1.0", + "metadataVersion": "1" + }]` + + events2 := parseManyEvents(t, requestContent) + + sysEvent2 := deserializeSystemEvent[azsystemevents.MediaLiveEventChannelArchiveHeartbeatEventData](t, events2[0].Data) + + // n/a should be translated to null ChannelLatency + require.Nil(t, sysEvent2.ChannelLatencyMS) + require.Equal(t, "S_OK", *sysEvent2.LatencyResultCode) +} + +func TestConsumeMediaLiveEventTrackDiscontinuityDetectedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"eventType\": \"Microsoft.Media.LiveEventTrackDiscontinuityDetected\", \"eventTime\": \"2018-10-12T15:52:37.3710102\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"trackType\": \"video\", \"trackName\": \"video\", \"bitrate\": 2500000, \"previousTimestamp\": \"10999\", \"newTimestamp\": \"14999\", \"timescale\": \"1000\", \"discontinuityGap\": \"4000\" }, \"dataVersion\": \"1.0\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventTrackDiscontinuityDetectedEventData](t, events[0].Data) + require.Equal(t, "video", *sysEvent.TrackType) + require.Equal(t, "video", *sysEvent.TrackName) + require.Equal(t, int64(2500000), *sysEvent.Bitrate) + require.Equal(t, "10999", *sysEvent.PreviousTimestamp) + require.Equal(t, "14999", *sysEvent.NewTimestamp) + require.Equal(t, "1000", *sysEvent.Timescale) + require.Equal(t, "4000", *sysEvent.DiscontinuityGap) +} + +// Resource Manager (Azure Subscription/Resource Group) events + +const Authorization = `{"scope":"/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Web/sites/function/host/default","action":"Microsoft.Web/sites/host/listKeys/action","evidence":{"role":"Azure EventGrid Service BuiltIn Role","roleAssignmentScope":"/subscriptions/sub","roleAssignmentId":"rid","roleDefinitionId":"rd","principalId":"principal","principalType":"ServicePrincipal"}}` +const Claims = `{"aud":"https://management.core.windows.net","iat":"16303066","nbf":"16303066","exp":"16303066"}` +const HttpRequest = `{"clientRequestId":"","clientIpAddress":"ip","method":"POST","url":"https://management.azure.com/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Web/sites/function/host/default/listKeys?api-version=2018-11-01"}` + +func TestConsumeResourceWriteSuccessEvent(t *testing.T) { + requestContent := fmt.Sprintf(`[{"topic":"/subscriptions/subscription-id", "subject":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "eventType":"Microsoft.Resources.ResourceWriteSuccess", "eventTime":"2017-08-16T03:54:38.2696833Z", "id":"25b3b0d0-d79b-44d5-9963-440d4e6a9bba", "data": { "authorization":%s, "claims":%s, "correlationId":"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6", "httpRequest":%s, "resourceProvider":"Microsoft.EventGrid", "resourceUri":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "operationName":"Microsoft.EventGrid/eventSubscriptions/write", "status":"Succeeded", "subscriptionId":"subscription-id", "tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47" }, "dataVersion": "", "metadataVersion": "1" }]`, Authorization, Claims, HttpRequest) + + events := parseManyEvents(t, requestContent) + + eventData := deserializeSystemEvent[azsystemevents.ResourceWriteSuccessEventData](t, events[0].Data) + assertResourceEventData(t, eventData) +} + +func TestConsumeResourceWriteFailureEvent(t *testing.T) { + requestContent := fmt.Sprintf(`[{"topic":"/subscriptions/subscription-id", "subject":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "eventType":"Microsoft.Resources.ResourceWriteFailure", "eventTime":"2017-08-16T03:54:38.2696833Z", "id":"25b3b0d0-d79b-44d5-9963-440d4e6a9bba", "data": { "authorization":%s, "claims":%s, "correlationId":"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6", "httpRequest":%s, "resourceProvider":"Microsoft.EventGrid", "resourceUri":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "operationName":"Microsoft.EventGrid/eventSubscriptions/write", "status":"Succeeded", "subscriptionId":"subscription-id", "tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47" }, "dataVersion": "", "metadataVersion": "1" }]`, Authorization, Claims, HttpRequest) + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + eventData := deserializeSystemEvent[azsystemevents.ResourceWriteFailureEventData](t, events[0].Data) + + assertResourceEventData(t, eventData) +} + +func TestConsumeResourceWriteCancelEvent(t *testing.T) { + requestContent := fmt.Sprintf(`[{"topic":"/subscriptions/subscription-id", "subject":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "eventType":"Microsoft.Resources.ResourceWriteCancel", "eventTime":"2017-08-16T03:54:38.2696833Z", "id":"25b3b0d0-d79b-44d5-9963-440d4e6a9bba", "data": { "authorization":%s, "claims":%s, "correlationId":"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6", "httpRequest":%s, "resourceProvider":"Microsoft.EventGrid", "resourceUri":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "operationName":"Microsoft.EventGrid/eventSubscriptions/write", "status":"Succeeded", "subscriptionId":"subscription-id", "tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47" }, "dataVersion": "", "metadataVersion": "1" }]`, Authorization, Claims, HttpRequest) + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + eventData := deserializeSystemEvent[azsystemevents.ResourceWriteCancelEventData](t, events[0].Data) + + assertResourceEventData(t, eventData) +} + +func TestConsumeResourceDeleteSuccessEvent(t *testing.T) { + requestContent := fmt.Sprintf(`[{"topic":"/subscriptions/subscription-id", "subject":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "eventType":"Microsoft.Resources.ResourceDeleteSuccess", "eventTime":"2017-08-16T03:54:38.2696833Z", "id":"25b3b0d0-d79b-44d5-9963-440d4e6a9bba", "data": { "authorization":%s, "claims":%s, "correlationId":"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6", "httpRequest":%s, "resourceProvider":"Microsoft.EventGrid", "resourceUri":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "operationName":"Microsoft.EventGrid/eventSubscriptions/write", "status":"Succeeded", "subscriptionId":"subscription-id", "tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47" }, "dataVersion": "", "metadataVersion": "1" }]`, Authorization, Claims, HttpRequest) + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + eventData := deserializeSystemEvent[azsystemevents.ResourceDeleteSuccessEventData](t, events[0].Data) + + assertResourceEventData(t, eventData) +} + +func TestConsumeResourceDeleteFailureEvent(t *testing.T) { + requestContent := fmt.Sprintf(`[{"topic":"/subscriptions/subscription-id", "subject":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "eventType":"Microsoft.Resources.ResourceDeleteFailure", "eventTime":"2017-08-16T03:54:38.2696833Z", "id":"25b3b0d0-d79b-44d5-9963-440d4e6a9bba", "data": { "authorization":%s, "claims":%s, "correlationId":"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6", "httpRequest":%s, "resourceProvider":"Microsoft.EventGrid", "resourceUri":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "operationName":"Microsoft.EventGrid/eventSubscriptions/write", "status":"Succeeded", "subscriptionId":"subscription-id", "tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47" }, "dataVersion": "", "metadataVersion": "1" }]`, Authorization, Claims, HttpRequest) + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + eventData := deserializeSystemEvent[azsystemevents.ResourceDeleteFailureEventData](t, events[0].Data) + + assertResourceEventData(t, eventData) +} + +func TestConsumeResourceDeleteCancelEvent(t *testing.T) { + requestContent := fmt.Sprintf(`[{"topic":"/subscriptions/subscription-id", "subject":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "eventType":"Microsoft.Resources.ResourceDeleteCancel", "eventTime":"2017-08-16T03:54:38.2696833Z", "id":"25b3b0d0-d79b-44d5-9963-440d4e6a9bba", "data": { "authorization":%s, "claims":%s, "correlationId":"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6", "httpRequest":%s, "resourceProvider":"Microsoft.EventGrid", "resourceUri":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "operationName":"Microsoft.EventGrid/eventSubscriptions/write", "status":"Succeeded", "subscriptionId":"subscription-id", "tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47" }, "dataVersion": "", "metadataVersion": "1" }]`, Authorization, Claims, HttpRequest) + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + eventData := deserializeSystemEvent[azsystemevents.ResourceDeleteCancelEventData](t, events[0].Data) + + assertResourceEventData(t, eventData) +} + +func TestConsumeResourceActionSuccessEvent(t *testing.T) { + requestContent := fmt.Sprintf(`[{"topic":"/subscriptions/subscription-id", "subject":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "eventType":"Microsoft.Resources.ResourceActionSuccess", "eventTime":"2017-08-16T03:54:38.2696833Z", "id":"25b3b0d0-d79b-44d5-9963-440d4e6a9bba", "data": { "authorization":%s, "claims":%s, "correlationId":"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6", "httpRequest":%s, "resourceProvider":"Microsoft.EventGrid", "resourceUri":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "operationName":"Microsoft.EventGrid/eventSubscriptions/write", "status":"Succeeded", "subscriptionId":"subscription-id", "tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47" }, "dataVersion": "", "metadataVersion": "1" }]`, Authorization, Claims, HttpRequest) + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + eventData := deserializeSystemEvent[azsystemevents.ResourceActionSuccessEventData](t, events[0].Data) + + assertResourceEventData(t, eventData) +} + +func TestConsumeResourceActionFailureEvent(t *testing.T) { + requestContent := fmt.Sprintf(`[{"topic":"/subscriptions/subscription-id", "subject":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "eventType":"Microsoft.Resources.ResourceActionFailure", "eventTime":"2017-08-16T03:54:38.2696833Z", "id":"25b3b0d0-d79b-44d5-9963-440d4e6a9bba", "data": { "authorization":%s, "claims":%s, "correlationId":"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6", "httpRequest":%s, "resourceProvider":"Microsoft.EventGrid", "resourceUri":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "operationName":"Microsoft.EventGrid/eventSubscriptions/write", "status":"Succeeded", "subscriptionId":"subscription-id", "tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47" }, "dataVersion": "", "metadataVersion": "1" }]`, Authorization, Claims, HttpRequest) + + events := parseManyEvents(t, requestContent) + eventData := deserializeSystemEvent[azsystemevents.ResourceActionFailureEventData](t, events[0].Data) + assertResourceEventData(t, eventData) +} + +func TestConsumeResourceActionCancelEvent(t *testing.T) { + requestContent := fmt.Sprintf(`[{"topic":"/subscriptions/subscription-id", "subject":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "eventType":"Microsoft.Resources.ResourceActionCancel", "eventTime":"2017-08-16T03:54:38.2696833Z", "id":"25b3b0d0-d79b-44d5-9963-440d4e6a9bba", "data": { "authorization":%s, "claims":%s, "correlationId":"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6", "httpRequest":%s, "resourceProvider":"Microsoft.EventGrid", "resourceUri":"/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "operationName":"Microsoft.EventGrid/eventSubscriptions/write", "status":"Succeeded", "subscriptionId":"subscription-id", "tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47" }, "dataVersion": "", "metadataVersion": "1" }]`, Authorization, Claims, HttpRequest) + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + eventData := deserializeSystemEvent[azsystemevents.ResourceActionCancelEventData](t, events[0].Data) + + assertResourceEventData(t, eventData) +} + +// Using dynamic to avoid duplicating the test cases for each event. The events don't share a common base type but they all have the +// properties being tested below. +func assertResourceEventData(t *testing.T, rawEventData any) { + jsonBytes, err := json.Marshal(rawEventData) + require.NoError(t, err) + + var eventData *struct { + TenantID string + Authorization struct { + Scope string + Action string + Evidence struct { + Role string + RoleAssignmentScope string + PrincipalType string + } + } `json:"authorization"` + Claims struct { + Aud string + } + HttpRequest struct { + Method string + URL string + } + } = nil + + err = json.Unmarshal(jsonBytes, &eventData) + require.NoError(t, err) + + require.NotEmpty(t, eventData) + require.Equal(t, "72f988bf-86f1-41af-91ab-2d7cd011db47", eventData.TenantID) + + //var authorizationJson = JsonDocument.Parse(eventData.Authorization).RootElement + + require.Equal(t, "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Web/sites/function/host/default", + eventData.Authorization.Scope) + require.Equal(t, "Microsoft.Web/sites/host/listKeys/action", eventData.Authorization.Action) + require.Equal(t, "Azure EventGrid Service BuiltIn Role", eventData.Authorization.Evidence.Role) + require.Equal(t, "/subscriptions/sub", eventData.Authorization.Evidence.RoleAssignmentScope) + require.Equal(t, "ServicePrincipal", eventData.Authorization.Evidence.PrincipalType) + + require.Equal(t, "https://management.core.windows.net", eventData.Claims.Aud) + require.Equal(t, "POST", eventData.HttpRequest.Method) + require.Equal(t, "https://management.azure.com/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Web/sites/function/host/default/listKeys?api-version=2018-11-01", eventData.HttpRequest.URL) +} + +// ServiceBus events +func TestConsumeServiceBusActiveMessagesAvailableWithNoListenersEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/id/resourcegroups/rg/providers/Microsoft.ServiceBus/namespaces/testns1\", \"subject\": \"topics/topic1/subscriptions/sub1\", \"eventType\": \"Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners\", \"eventTime\": \"2018-02-14T05:12:53.4133526Z\", \"id\": \"dede87b0-3656-419c-acaf-70c95ddc60f5\", \"data\": { \"namespaceName\": \"testns1\", \"requestUri\": \"https://testns1.servicebus.windows.net/t1/subscriptions/sub1/messages/head\", \"entityType\": \"subscriber\", \"queueName\": \"queue1\", \"topicName\": \"topic1\", \"subscriptionName\": \"sub1\" }, \"dataVersion\": \"1\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ServiceBusActiveMessagesAvailableWithNoListenersEventData](t, events[0].Data) + require.Equal(t, "testns1", *sysEvent.NamespaceName) +} + +func TestConsumeServiceBusDeadletterMessagesAvailableWithNoListenersEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/id/resourcegroups/rg/providers/Microsoft.ServiceBus/namespaces/testns1\", \"subject\": \"topics/topic1/subscriptions/sub1\", \"eventType\": \"Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListeners\", \"eventTime\": \"2018-02-14T05:12:53.4133526Z\", \"id\": \"dede87b0-3656-419c-acaf-70c95ddc60f5\", \"data\": { \"namespaceName\": \"testns1\", \"requestUri\": \"https://testns1.servicebus.windows.net/t1/subscriptions/sub1/messages/head\", \"entityType\": \"subscriber\", \"queueName\": \"queue1\", \"topicName\": \"topic1\", \"subscriptionName\": \"sub1\" }, \"dataVersion\": \"1\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ServiceBusDeadletterMessagesAvailableWithNoListenersEventData](t, events[0].Data) + require.Equal(t, "testns1", *sysEvent.NamespaceName) +} + +// Storage events +func TestConsumeStorageBlobCreatedEvent(t *testing.T) { + requestContent := "[ { \"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Storage/storageAccounts/myaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/file1.txt\", \"eventType\": \"Microsoft.Storage.BlobCreated\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\", \"id\": \"602a88ef-0001-00e6-1233-1646070610ea\", \"data\": { \"api\": \"PutBlockList\", \"clientRequestId\": \"799304a4-bbc5-45b6-9849-ec2c66be800a\", \"requestId\": \"602a88ef-0001-00e6-1233-164607000000\", \"eTag\": \"0x8D4E44A24ABE7F1\", \"contentType\": \"text/plain\", \"contentLength\": 447, \"blobType\": \"BlockBlob\", \"url\": \"https://myaccount.blob.core.windows.net/testcontainer/file1.txt\", \"sequencer\": \"00000000000000EB000000000000C65A\" }, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobCreatedEventData](t, events[0].Data) + require.Equal(t, "https://myaccount.blob.core.windows.net/testcontainer/file1.txt", *sysEvent.URL) +} + +func TestConsumeStorageBlobDeletedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"eventType\": \"Microsoft.Storage.BlobDeleted\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobDeletedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testfile.txt", *sysEvent.URL) +} + +func TestConsumeStorageBlobRenamedEvent(t *testing.T) { + requestContent := "[ { \"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Storage/storageAccounts/myaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"eventType\": \"Microsoft.Storage.BlobRenamed\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\", \"id\": \"602a88ef-0001-00e6-1233-1646070610ea\", \"data\": { \"api\": \"RenameFile\", \"clientRequestId\": \"799304a4-bbc5-45b6-9849-ec2c66be800a\", \"requestId\": \"602a88ef-0001-00e6-1233-164607000000\", \"eTag\": \"0x8D4E44A24ABE7F1\", \"destinationUrl\": \"https://myaccount.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"00000000000000EB000000000000C65A\" }, \"dataVersion\": \"1\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobRenamedEventData](t, events[0].Data) + require.Equal(t, "https://myaccount.blob.core.windows.net/testcontainer/testfile.txt", *sysEvent.DestinationURL) +} + +func TestConsumeStorageDirectoryCreatedEvent(t *testing.T) { + requestContent := "[ { \"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Storage/storageAccounts/myaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"eventType\": \"Microsoft.Storage.DirectoryCreated\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\", \"id\": \"602a88ef-0001-00e6-1233-1646070610ea\", \"data\": { \"api\": \"CreateDirectory\", \"clientRequestId\": \"799304a4-bbc5-45b6-9849-ec2c66be800a\", \"requestId\": \"602a88ef-0001-00e6-1233-164607000000\", \"eTag\": \"0x8D4E44A24ABE7F1\", \"url\": \"https://myaccount.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"00000000000000EB000000000000C65A\" }, \"dataVersion\": \"2\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageDirectoryCreatedEventData](t, events[0].Data) + require.Equal(t, "https://myaccount.blob.core.windows.net/testcontainer/testDir", *sysEvent.URL) +} + +func TestConsumeStorageDirectoryDeletedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"eventType\": \"Microsoft.Storage.DirectoryDeleted\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"1\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageDirectoryDeletedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testDir", *sysEvent.URL) + require.Nil(t, sysEvent.Recursive) +} + +func TestConsumeStorageDirectoryDeletedEvent_Recursive(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"eventType\": \"Microsoft.Storage.DirectoryDeleted\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"recursive\":\"true\", \"api\": \"DeleteDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"1\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageDirectoryDeletedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testDir", *sysEvent.URL) + require.Equal(t, "true", *sysEvent.Recursive) +} + +func TestConsumeStorageDirectoryRenamedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"eventType\": \"Microsoft.Storage.DirectoryRenamed\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"RenameDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"destinationUrl\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"1\", \"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageDirectoryRenamedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testDir", *sysEvent.DestinationURL) +} + +func TestConsumeStorageAsyncOperationInitiatedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"eventType\": \"Microsoft.Storage.AsyncOperationInitiated\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"RenameDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"1.0\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageAsyncOperationInitiatedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testDir", *sysEvent.URL) +} + +func TestConsumeStorageBlobTierChangedEvent(t *testing.T) { + requestContent := "[{ \"topic\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"eventType\": \"Microsoft.Storage.BlobTierChanged\", \"eventTime\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"RenameDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"dataVersion\": \"1.0\"}]" + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobTierChangedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testDir", *sysEvent.URL) +} + +func TestConsumeStorageTaskQueuedEvent(t *testing.T) { + requestContent := `[{ + "topic": "/subscriptions/c86a9c18-8373-41fa-92d4-1d7bdc16977b/resourceGroups/shulin-rg/providers/Microsoft.Storage/storageAccounts/shulinstcanest2", + "subject": "DataManagement/StorageTasks", + "eventType": "Microsoft.Storage.StorageTaskQueued", + "id": "7fddaf06-24e8-4d57-9b66-5b7ab920a626", + "data": { + "queuedDateTime": "2023-03-23T16:43:50Z", + "taskExecutionId": "deletetest-2023-03-23T16:42:33.8658256Z_2023-03-23T16:42:58.8983000Z" + }, + "dataVersion": "1.0", + "metadataVersion": "1", + "eventTime": "2023-03-23T16:43:50Z" +}]` + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageTaskQueuedEventData](t, events[0].Data) + require.Equal(t, "deletetest-2023-03-23T16:42:33.8658256Z_2023-03-23T16:42:58.8983000Z", *sysEvent.TaskExecutionID) + require.Equal(t, mustParseTime(t, "2023-03-23T16:43:50Z"), *sysEvent.QueuedDateTime) +} + +func TestConsumeStorageTaskCompletedEvent(t *testing.T) { + requestContent := `[{ + "topic": "/subscriptions/c86a9c18-8373-41fa-92d4-1d7bdc16977b/resourceGroups/shulin-rg/providers/Microsoft.Storage/storageAccounts/shulinstcanest2", + "subject": "DataManagement/StorageTasks", + "eventType": "Microsoft.Storage.StorageTaskCompleted", + "id": "7fddaf06-24e8-4d57-9b66-5b7ab920a626", + "data": { + "status": "Succeeded", + "completedDateTime": "2023-03-23T16:52:58Z", + "taskExecutionId": "deletetest-2023-03-23T16:42:33.8658256Z_2023-03-23T16:42:58.8983000Z", + "taskName": "delete123", + "summaryReportBlobUrl": "https://shulinstcanest2.blob.core.windows.net/report/delete123_deletetest_2023-03-23T16:43:50/SummaryReport.json" + }, + "dataVersion": "1.0", + "metadataVersion": "1", + "eventTime": "2023-03-23T16:43:50Z" +}]` + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageTaskCompletedEventData](t, events[0].Data) + require.Equal(t, azsystemevents.StorageTaskCompletedStatusSucceeded, *sysEvent.Status) + require.Equal(t, mustParseTime(t, "2023-03-23T16:52:58Z"), *sysEvent.CompletedDateTime) + require.Equal(t, "deletetest-2023-03-23T16:42:33.8658256Z_2023-03-23T16:42:58.8983000Z", *sysEvent.TaskExecutionID) + require.Equal(t, "delete123", *sysEvent.TaskName) + require.Equal(t, "https://shulinstcanest2.blob.core.windows.net/report/delete123_deletetest_2023-03-23T16:43:50/SummaryReport.json", *sysEvent.SummaryReportBlobURL) +} + +// App Service events +func TestConsumeWebAppUpdatedEvent(t *testing.T) { + siteName := "testSite01" + + requestContent := `[{"topic": "/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01", "subject": "/Microsoft.Web/sites/testSite01","eventType": "Microsoft.Web.AppUpdated", "eventTime": "2017-08-16T01:57:26.005121Z","id": "602a88ef-0001-00e6-1233-1646070610ea","data": { "appEventTypeDetail": { "action": "Restarted"},"name": "testSite01","clientRequestId": "ce636635-2b81-4981-a9d4-cec28fb5b014","correlationRequestId": "61baa426-c91f-4e58-b9c6-d3852c4d88d","requestId": "0a4d5b5e-7147-482f-8e21-4219aaacf62a","address": "/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01","verb": "POST"},"dataVersion": "2","metadataVersion": "1"}]` + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebAppUpdatedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebBackupOperationStartedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.BackupOperationStarted\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebBackupOperationStartedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebBackupOperationCompletedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.BackupOperationCompleted\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebBackupOperationCompletedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebBackupOperationFailedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.BackupOperationFailed\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebBackupOperationFailedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebRestoreOperationStartedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.RestoreOperationStarted\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebRestoreOperationStartedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebRestoreOperationCompletedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.RestoreOperationCompleted\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebRestoreOperationCompletedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebRestoreOperationFailedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.RestoreOperationFailed\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebRestoreOperationFailedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebSlotSwapStartedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.SlotSwapStarted\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebSlotSwapStartedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebSlotSwapCompletedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.SlotSwapCompleted\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebSlotSwapCompletedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebSlotSwapFailedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.SlotSwapFailed\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebSlotSwapFailedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebSlotSwapWithPreviewStartedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.SlotSwapWithPreviewStarted\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebSlotSwapWithPreviewStartedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebSlotSwapWithPreviewCancelledEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"eventType\": \"Microsoft.Web.SlotSwapWithPreviewCancelled\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebSlotSwapWithPreviewCancelledEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeWebAppServicePlanUpdatedEvent(t *testing.T) { + planName := "testPlan01" + requestContent := "[{\"topic\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/serverfarms/testPlan01\", \"subject\": \"/Microsoft.Web/serverfarms/testPlan01\",\"eventType\": \"Microsoft.Web.AppServicePlanUpdated\", \"eventTime\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appServicePlanEventTypeDetail\": { \"stampKind\": \"Public\",\"action\": \"Updated\",\"status\": \"Started\" },\"name\": \"testPlan01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"dataVersion\": \"2\",\"metadataVersion\": \"1\"}]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebAppServicePlanUpdatedEventData](t, events[0].Data) + require.Equal(t, planName, *sysEvent.Name) +} + +// Policy Insights +func TestConsumePolicyInsightsPolicyStateChangedEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"eventType\":\"Microsoft.PolicyInsights.PolicyStateChanged\", \"eventTime\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":\"{request-operation}\", \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"dataVersion\": \"1.0\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.PolicyInsightsPolicyStateChangedEventData](t, events[0].Data) + require.Equal(t, "4c2359fe-001e-00ba-0e04-585868000000", *sysEvent.PolicyDefinitionID) +} + +func TestConsumePolicyInsightsPolicyStateCreatedEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"eventType\":\"Microsoft.PolicyInsights.PolicyStateCreated\", \"eventTime\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":\"{request-operation}\", \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"dataVersion\": \"1.0\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.PolicyInsightsPolicyStateCreatedEventData](t, events[0].Data) + require.Equal(t, "4c2359fe-001e-00ba-0e04-585868000000", *sysEvent.PolicyDefinitionID) +} + +func TestConsumePolicyInsightsPolicyStateDeletedEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"eventType\":\"Microsoft.PolicyInsights.PolicyStateDeleted\", \"eventTime\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":\"{request-operation}\", \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"dataVersion\": \"1.0\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.PolicyInsightsPolicyStateDeletedEventData](t, events[0].Data) + require.Equal(t, "4c2359fe-001e-00ba-0e04-585868000000", *sysEvent.PolicyDefinitionID) +} + +// Communication events +func TestConsumeAcsRecordingFileStatusUpdatedEventData(t *testing.T) { + requestContent := "[ { \"subject\":\"/recording/call/{call-id}/recordingId/{recording-id}\", \"eventType\":\"Microsoft.Communication.RecordingFileStatusUpdated\", \"eventTime\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"recordingStorageInfo\": { \"recordingChunks\": [ { \"documentId\": \"0-eus-d12-801b3f3fc462fe8a01e6810cbff729b8\", \"index\": 0, \"endReason\": \"SessionEnded\", \"contentLocation\": \"https://storage.asm.skype.com/v1/objects/0-eus-d12-801b3f3fc462fe8a01e6810cbff729b8/content/video\", \"metadataLocation\": \"https://storage.asm.skype.com/v1/objects/0-eus-d12-801b3f3fc462fe8a01e6810cbff729b8/content/acsmetadata\" }]}, \"recordingChannelType\": \"Mixed\", \"recordingContentType\": \"Audio\", \"recordingFormatType\": \"Mp3\"}, \"dataVersion\": \"1.0\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.AcsRecordingFileStatusUpdatedEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.RecordingChannelTypeMixed, *sysEvent.RecordingChannelType) + require.Equal(t, azsystemevents.RecordingContentTypeAudio, *sysEvent.RecordingContentType) + require.Equal(t, azsystemevents.RecordingFormatTypeMp3, *sysEvent.RecordingFormatType) +} + +func TestConsumeAcsEmailDeliveryReportReceivedEvent(t *testing.T) { + // TODO: the enum value here for 'status' used to be 'delivered'. I'm not sure if this is just + // a test artifact, or if the value really isn't cased like the enum value is ('Delivered'). + requestContent := `{ + "id": "5f04f77c-2a6a-43bd-9b74-576a64c01f9e", + "source": "source", + "specversion": "1.0", + "type": "type", + "topic": "/subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}", + "subject": "sender/test2@contoso.org/message/950850f5-bcdf-4315-b77a-6447cf56fac9", + "data": { + "sender": "test2@contoso.org", + "recipient": "test1@contoso.com", + "messageId": "950850f5-bcdf-4315-b77a-6447cf56fac9", + "status": "Delivered", + "deliveryAttemptTimeStamp": "2023-02-09T19:46:12.2480265+00:00", + "deliveryStatusDetails": { + "statusMessage": "DestinationMailboxFull" + } + }, + "eventType": "Microsoft.Communication.EmailDeliveryReportReceived", + "dataVersion": "1.0", + "metadataVersion": "1", + "eventTime": "2023-02-09T19:46:12.2478002Z" + }` + + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + emailEvent := deserializeSystemEvent[azsystemevents.AcsEmailDeliveryReportReceivedEventData](t, event.Data) + require.Equal(t, "test2@contoso.org", *emailEvent.Sender) + require.Equal(t, "test1@contoso.com", *emailEvent.Recipient) + require.Equal(t, azsystemevents.AcsEmailDeliveryReportStatusDelivered, *emailEvent.Status) + require.Equal(t, "DestinationMailboxFull", *emailEvent.DeliveryStatusDetails.StatusMessage) + require.Equal(t, mustParseTime(t, "2023-02-09T19:46:12.2480265+00:00"), *emailEvent.DeliveryAttemptTimestamp) +} + +func TestConsumeAcsIncomingCallEvent(t *testing.T) { + requestContent := `{ + "id": "e80026e7-e298-46ba-bc42-dab0eda92581", + "topic": "/subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}", + "subject": "/caller/{caller-id}/recipient/{recipient-id}", + "data": { + "to": { + "kind": "communicationUser", + "rawId": "{recipient-id}", + "communicationUser": { + "id": "{recipient-id}" + } + }, + "from": { + "kind": "communicationUser", + "rawId": "{caller-id}", + "communicationUser": { + "id": "{caller-id}" + } + }, + "serverCallId": "{server-call-id}", + "callerDisplayName": "VOIP Caller", + "customContext": { + "sipHeaders": { + "userToUser": "616d617a6f6e5f6368696;encoding=hex", + "X-MS-Custom-myheader1": "35567842", + "X-MS-Custom-myheader2": "customsipheadervalue" + }, + "voipHeaders": { + "customHeader": "customValue" + } + }, + "incomingCallContext": "{incoming-call-contextValue}", + "correlationId": "correlationId" + }, + "eventType": "Microsoft.Communication.IncomingCall", + "dataVersion": "1.0", + "metadataVersion": "1", + "eventTime": "2023-04-04T17:18:42.5542219Z" + }` + + event := parseEvent(t, requestContent) + + incomingCallEvent := deserializeSystemEvent[azsystemevents.AcsIncomingCallEventData](t, event.Data) + require.Equal(t, "{recipient-id}", *incomingCallEvent.ToCommunicationIdentifier.CommunicationUser.ID) + require.Equal(t, "{caller-id}", *incomingCallEvent.FromCommunicationIdentifier.CommunicationUser.ID) + require.Equal(t, "VOIP Caller", *incomingCallEvent.CallerDisplayName) + require.Equal(t, "616d617a6f6e5f6368696;encoding=hex", *incomingCallEvent.CustomContext.SipHeaders["userToUser"]) + require.Equal(t, "35567842", *incomingCallEvent.CustomContext.SipHeaders["X-MS-Custom-myheader1"]) + require.Equal(t, "customsipheadervalue", *incomingCallEvent.CustomContext.SipHeaders["X-MS-Custom-myheader2"]) + require.Equal(t, "customValue", *incomingCallEvent.CustomContext.VoipHeaders["customHeader"]) + require.Equal(t, "{incoming-call-contextValue}", *incomingCallEvent.IncomingCallContext) + require.Equal(t, "correlationId", *incomingCallEvent.CorrelationID) +} + +// Health Data Services events +func TestConsumeFhirResourceCreatedEvent(t *testing.T) { + requestContent := "[ { \"subject\":\"{fhir-account}.fhir.azurehealthcareapis.com/Patient/e0a1f743-1a70-451f-830e-e96477163902\", \"eventType\":\"Microsoft.HealthcareApis.FhirResourceCreated\", \"eventTime\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"resourceType\": \"Patient\", \"resourceFhirAccount\": \"{fhir-account}.fhir.azurehealthcareapis.com\", \"resourceFhirId\": \"e0a1f743-1a70-451f-830e-e96477163902\", \"resourceVersionId\": 1 }, \"dataVersion\": \"1.0\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareFhirResourceCreatedEventData](t, events[0].Data) + require.Equal(t, azsystemevents.HealthcareFhirResourceTypePatient, *healthEvent.FhirResourceType) + require.Equal(t, "{fhir-account}.fhir.azurehealthcareapis.com", *healthEvent.FhirServiceHostName) + require.Equal(t, "e0a1f743-1a70-451f-830e-e96477163902", *healthEvent.FhirResourceID) + require.Equal(t, int64(1), *healthEvent.FhirResourceVersionID) +} + +func TestConsumeFhirResourceUpdatedEvent(t *testing.T) { + requestContent := "[ { \"subject\":\"{fhir-account}.fhir.azurehealthcareapis.com/Patient/e0a1f743-1a70-451f-830e-e96477163902\", \"eventType\":\"Microsoft.HealthcareApis.FhirResourceUpdated\", \"eventTime\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"resourceType\": \"Patient\", \"resourceFhirAccount\": \"{fhir-account}.fhir.azurehealthcareapis.com\", \"resourceFhirId\": \"e0a1f743-1a70-451f-830e-e96477163902\", \"resourceVersionId\": 1 }, \"dataVersion\": \"1.0\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareFhirResourceUpdatedEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.HealthcareFhirResourceTypePatient, *healthEvent.FhirResourceType) + require.Equal(t, "{fhir-account}.fhir.azurehealthcareapis.com", *healthEvent.FhirServiceHostName) + require.Equal(t, "e0a1f743-1a70-451f-830e-e96477163902", *healthEvent.FhirResourceID) + require.Equal(t, int64(1), *healthEvent.FhirResourceVersionID) +} + +func TestConsumeFhirResourceDeletedEvent(t *testing.T) { + requestContent := "[ { \"subject\":\"{fhir-account}.fhir.azurehealthcareapis.com/Patient/e0a1f743-1a70-451f-830e-e96477163902\", \"eventType\":\"Microsoft.HealthcareApis.FhirResourceDeleted\", \"eventTime\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"resourceType\": \"Patient\", \"resourceFhirAccount\": \"{fhir-account}.fhir.azurehealthcareapis.com\", \"resourceFhirId\": \"e0a1f743-1a70-451f-830e-e96477163902\", \"resourceVersionId\": 1 }, \"dataVersion\": \"1.0\" }]" + + events := parseManyEvents(t, requestContent) + + require.NotEmpty(t, events) + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareFhirResourceDeletedEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.HealthcareFhirResourceTypePatient, *healthEvent.FhirResourceType) + require.Equal(t, "{fhir-account}.fhir.azurehealthcareapis.com", *healthEvent.FhirServiceHostName) + require.Equal(t, "e0a1f743-1a70-451f-830e-e96477163902", *healthEvent.FhirResourceID) + require.Equal(t, int64(1), *healthEvent.FhirResourceVersionID) +} + +func TestConsumeDicomImageCreatedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.HealthcareApis/workspaces/{workspace-name}", + "subject": "{dicom-account}.dicom.azurehealthcareapis.com/v1/studies/1.2.3.4.3/series/1.2.3.4.3.9423673/instances/1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "eventType": "Microsoft.HealthcareApis.DicomImageCreated", + "dataVersion": "1", + "metadataVersion": "1", + "eventTime": "2022-09-15T01:14:04.5613214Z", + "id": "d621839d-958b-4142-a638-bb966b4f7dfd", + "data": { + "partitionName": "Microsoft.Default", + "imageStudyInstanceUid": "1.2.3.4.3", + "imageSeriesInstanceUid": "1.2.3.4.3.9423673", + "imageSopInstanceUid": "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "serviceHostName": "{dicom-account}.dicom.azurehealthcareapis.com", + "sequenceNumber": 1 + }, + "specVersion": "1.0" +}` + event := parseEvent(t, requestContent) + + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareDicomImageCreatedEventData](t, event.Data) + + require.Equal(t, "1.2.3.4.3", *healthEvent.ImageStudyInstanceUID) + require.Equal(t, "1.2.3.4.3.9423673", *healthEvent.ImageSeriesInstanceUID) + require.Equal(t, "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", *healthEvent.ImageSopInstanceUID) + require.Equal(t, int64(1), *healthEvent.SequenceNumber) + require.Equal(t, "Microsoft.Default", *healthEvent.PartitionName) +} + +func TestConsumeDicomImageUpdatedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.HealthcareApis/workspaces/{workspace-name}", + "subject": "{dicom-account}.dicom.azurehealthcareapis.com/v1/studies/1.2.3.4.3/series/1.2.3.4.3.9423673/instances/1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "eventType": "Microsoft.HealthcareApis.DicomImageUpdated", + "dataVersion": "1", + "metadataVersion": "1", + "eventTime": "2022-09-15T01:14:04.5613214Z", + "id": "d621839d-958b-4142-a638-bb966b4f7dfd", + "data": { + "partitionName": "Microsoft.Default", + "imageStudyInstanceUid": "1.2.3.4.3", + "imageSeriesInstanceUid": "1.2.3.4.3.9423673", + "imageSopInstanceUid": "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "serviceHostName": "{dicom-account}.dicom.azurehealthcareapis.com", + "sequenceNumber": 1 + }, + "specVersion": "1.0" +}` + event := parseEvent(t, requestContent) + + require.NotEmpty(t, event) + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareDicomImageUpdatedEventData](t, event.Data) + + require.Equal(t, "1.2.3.4.3", *healthEvent.ImageStudyInstanceUID) + require.Equal(t, "1.2.3.4.3.9423673", *healthEvent.ImageSeriesInstanceUID) + require.Equal(t, "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", *healthEvent.ImageSopInstanceUID) + require.Equal(t, int64(1), *healthEvent.SequenceNumber) + require.Equal(t, "Microsoft.Default", *healthEvent.PartitionName) +} + +func TestConsumeDicomImageDeletedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.HealthcareApis/workspaces/{workspace-name}", + "subject": "{dicom-account}.dicom.azurehealthcareapis.com/v1/studies/1.2.3.4.3/series/1.2.3.4.3.9423673/instances/1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "eventType": "Microsoft.HealthcareApis.DicomImageDeleted", + "dataVersion": "1", + "metadataVersion": "1", + "eventTime": "2022-09-15T01:14:04.5613214Z", + "id": "d621839d-958b-4142-a638-bb966b4f7dfd", + "data": { + "partitionName": "Microsoft.Default", + "imageStudyInstanceUid": "1.2.3.4.3", + "imageSeriesInstanceUid": "1.2.3.4.3.9423673", + "imageSopInstanceUid": "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "serviceHostName": "{dicom-account}.dicom.azurehealthcareapis.com", + "sequenceNumber": 1 + }, + "specVersion": "1.0" +}` + event := parseEvent(t, requestContent) + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareDicomImageDeletedEventData](t, event.Data) + + require.Equal(t, "1.2.3.4.3", *healthEvent.ImageStudyInstanceUID) + require.Equal(t, "1.2.3.4.3.9423673", *healthEvent.ImageSeriesInstanceUID) + require.Equal(t, "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", *healthEvent.ImageSopInstanceUID) + require.Equal(t, int64(1), *healthEvent.SequenceNumber) + require.Equal(t, "Microsoft.Default", *healthEvent.PartitionName) +} + +// CloudEvent tests + +// Miscellaneous tests + +func TestParsesCloudEventEnvelope(t *testing.T) { + requestContent := "[{\"key\": \"value\", \"id\":\"994bc3f8-c90c-6fc3-9e83-6783db2221d5\",\"source\":\"Subject-0\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"brandNewProperty\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"type\":\"Microsoft.Storage.BlobDeleted\",\"specversion\":\"1.0\", \"dataschema\":\"1.0\", \"subject\":\"subject\", \"datacontenttype\": \"text/plain\", \"time\": \"2017-08-16T01:57:26.005121Z\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + var cloudEvent = events[0] + + require.Equal(t, "994bc3f8-c90c-6fc3-9e83-6783db2221d5", cloudEvent.ID) + require.Equal(t, "Subject-0", cloudEvent.Source) + require.Equal(t, string(azsystemevents.TypeStorageBlobDeleted), cloudEvent.Type) + require.Equal(t, "text/plain", *cloudEvent.DataContentType) + require.Equal(t, "subject", *cloudEvent.Subject) + require.Equal(t, "1.0", *cloudEvent.DataSchema) + require.Equal(t, mustParseTime(t, "2017-08-16T01:57:26.005121Z"), *cloudEvent.Time) + require.Equal(t, "value", cloudEvent.Extensions["key"]) +} + +func TestConsumeCloudEventsWithAdditionalProperties(t *testing.T) { + requestContent := "[{\"key\": \"value\", \"id\":\"994bc3f8-c90c-6fc3-9e83-6783db2221d5\",\"source\":\"Subject-0\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"brandNewProperty\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"type\":\"Microsoft.Storage.BlobDeleted\",\"specversion\":\"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + require.NotEmpty(t, events) + + if events[0].Type == string(azsystemevents.TypeStorageBlobDeleted) { + eventData := deserializeSystemEvent[azsystemevents.StorageBlobDeletedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testfile.txt", *eventData.URL) + } + + require.Equal(t, "value", events[0].Extensions["key"]) +} + +func TestConsumeCloudEventUsingBinaryDataExtensionMethod(t *testing.T) { + messageBody := "{ \"source\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"specversion\": \"1.0\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"type\": \"Microsoft.Storage.BlobDeleted\", \"time\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"brandNewProperty\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }}" + + cloudEvent := parseCloudEvent(t, messageBody) + + require.NotEmpty(t, cloudEvent) + require.Equal(t, string(azsystemevents.TypeStorageBlobDeleted), cloudEvent.Type) + blobDeleted := deserializeSystemEvent[azsystemevents.StorageBlobDeletedEventData](t, cloudEvent.Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testfile.txt", *blobDeleted.URL) +} + +func TestConsumeCloudEventNotWrappedInAnArray(t *testing.T) { + requestContent := "{ \"source\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"specversion\": \"1.0\", \"type\": \"Microsoft.Storage.BlobDeleted\", \"time\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"brandNewProperty\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }}" + + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + require.Equal(t, string(azsystemevents.TypeStorageBlobDeleted), event.Type) + eventData := deserializeSystemEvent[azsystemevents.StorageBlobDeletedEventData](t, event.Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testfile.txt", *eventData.URL) +} diff --git a/sdk/messaging/eventgrid/azsystemevents/system_events3_test.go b/sdk/messaging/eventgrid/azsystemevents/system_events3_test.go new file mode 100644 index 000000000000..04045174a1f5 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/system_events3_test.go @@ -0,0 +1,344 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azsystemevents_test + +import ( + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azsystemevents" + "github.com/stretchr/testify/require" +) + +// AppConfiguration events +func TestConsumeCloudEventAppConfigurationKeyValueDeletedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.AppConfiguration.KeyValueDeleted\",\"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"key\":\"key1\",\"label\":\"label1\",\"etag\":\"etag1\"}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.AppConfigurationKeyValueDeletedEventData](t, events[0].Data) + require.Equal(t, "key1", *sysEvent.Key) +} + +func TestConsumeCloudEventAppConfigurationKeyValueModifiedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.AppConfiguration.KeyValueModified\",\"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"key\":\"key1\",\"label\":\"label1\",\"etag\":\"etag1\"}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.AppConfigurationKeyValueModifiedEventData](t, events[0].Data) + require.Equal(t, "key1", *sysEvent.Key) +} + +func TestConsumeCloudEventAppConfigurationSnapshotCreatedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.AppConfiguration.SnapshotCreated\",\"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"name\":\"Foo\",\"etag\":\"FnUExLaj2moIi4tJX9AXn9sakm0\",\"syncToken\":\"zAJw6V16=Njo1IzUxNjQ2NzM=;sn=5164673\"}}]" + events := parseManyCloudEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.AppConfigurationSnapshotCreatedEventData](t, events[0].Data) + require.Equal(t, "Foo", *sysEvent.Name) + require.Equal(t, "zAJw6V16=Njo1IzUxNjQ2NzM=;sn=5164673", *sysEvent.SyncToken) +} + +func TestConsumeCloudEventAppConfigurationSnapshotModifiedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.AppConfiguration.SnapshotModified\",\"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"name\":\"Foo\",\"etag\":\"FnUExLaj2moIi4tJX9AXn9sakm0\",\"syncToken\":\"zAJw6V16=Njo1IzUxNjQ2NzM=;sn=5164673\"}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.AppConfigurationSnapshotModifiedEventData](t, events[0].Data) + require.Equal(t, "Foo", *sysEvent.Name) + require.Equal(t, "zAJw6V16=Njo1IzUxNjQ2NzM=;sn=5164673", *sysEvent.SyncToken) +} + +// ContainerRegistry events +func TestConsumeCloudEventContainerRegistryImagePushedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.ContainerRegistry/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.ContainerRegistry.ImagePushed\", \"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"id\":\"eventID\",\"timestamp\":\"2018-06-20T12:00:33.6125843-07:00\",\"action\":\"testaction\",\"target\":{\"mediaType\":\"test\",\"size\":20,\"digest\":\"digest1\",\"length\":20,\"repository\":\"test\",\"url\":\"url1\",\"tag\":\"test\"},\"request\":{\"id\":\"id\",\"addr\":\"127.0.0.1\",\"host\":\"test\",\"method\":\"method1\",\"useragent\":\"useragent1\"},\"actor\":{\"name\":\"testactor\"},\"source\":{\"addr\":\"127.0.0.1\",\"instanceID\":\"id\"}}}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerRegistryImagePushedEventData](t, events[0].Data) + require.Equal(t, "127.0.0.1", *sysEvent.Request.Addr) +} + +func TestConsumeCloudEventContainerRegistryImageDeletedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.ContainerRegistry/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.ContainerRegistry.ImageDeleted\", \"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"id\":\"eventID\",\"timestamp\":\"2018-06-20T12:00:33.6125843-07:00\",\"action\":\"testaction\",\"target\":{\"mediaType\":\"test\",\"size\":20,\"digest\":\"digest1\",\"length\":20,\"repository\":\"test\",\"url\":\"url1\",\"tag\":\"test\"},\"request\":{\"id\":\"id\",\"addr\":\"127.0.0.1\",\"host\":\"test\",\"method\":\"method1\",\"useragent\":\"useragent1\"},\"actor\":{\"name\":\"testactor\"},\"source\":{\"addr\":\"127.0.0.1\",\"instanceID\":\"id\"}}}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerRegistryImageDeletedEventData](t, events[0].Data) + require.Equal(t, "testactor", *sysEvent.Actor.Name) +} + +func TestConsumeCloudEventContainerRegistryChartDeletedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.ContainerRegistry/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.ContainerRegistry.ChartDeleted\", \"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"id\":\"id\",\"timestamp\":\"2018-06-20T12:00:33.6125843-07:00\",\"action\":\"action1\",\"target\":{\"mediaType\":\"mediatype1\",\"size\":20,\"digest\":\"digest1\",\"repository\":null,\"tag\":null,\"name\":\"name1\",\"version\":null}}}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerRegistryChartDeletedEventData](t, events[0].Data) + require.Equal(t, "mediatype1", *sysEvent.Target.MediaType) +} + +func TestConsumeCloudEventContainerRegistryChartPushedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.ContainerRegistry/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.ContainerRegistry.ChartPushed\", \"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"id\":\"id\",\"timestamp\":\"2018-06-20T12:00:33.6125843-07:00\",\"action\":\"action1\",\"target\":{\"mediaType\":\"mediatype1\",\"size\":40,\"digest\":\"digest1\",\"repository\":null,\"tag\":null,\"name\":\"name1\",\"version\":null}}}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerRegistryChartPushedEventData](t, events[0].Data) + require.Equal(t, "mediatype1", *sysEvent.Target.MediaType) +} + +// Container service events +func TestConsumeCloudEventContainerServiceSupportEndedEvent(t *testing.T) { + requestContent := ` + { + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster}", + "subject": "{cluster}", + "type": "Microsoft.ContainerService.ClusterSupportEnded", + "time": "2023-03-29T18:00:00.0000000Z", + "id": "1234567890abcdef1234567890abcdef12345678", + "data": { + "kubernetesVersion": "1.23.15" + }, + "specversion": "1.0" + }` + + event := parseCloudEvent(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.ContainerServiceClusterSupportEventData](t, event.Data) + require.Equal(t, "1.23.15", *sysEvent.KubernetesVersion) + + sysEvent2 := deserializeSystemEvent[azsystemevents.ContainerServiceClusterSupportEndedEventData](t, event.Data) + require.Equal(t, "1.23.15", *sysEvent2.KubernetesVersion) +} + +func TestConsumeCloudEventContainerServiceSupportEndingEvent(t *testing.T) { + requestContent := ` + { + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster}", + "subject": "{cluster}", + "type": "Microsoft.ContainerService.ClusterSupportEnding", + "time": "2023-03-29T18:00:00.0000000Z", + "id": "1234567890abcdef1234567890abcdef12345678", + "data": { + "kubernetesVersion": "1.23.15" + }, + "specversion": "1.0" + }` + + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerServiceClusterSupportEventData](t, event.Data) + require.Equal(t, "1.23.15", *sysEvent.KubernetesVersion) + + sysEvent2 := deserializeSystemEvent[azsystemevents.ContainerServiceClusterSupportEndingEventData](t, event.Data) + require.Equal(t, "1.23.15", *sysEvent2.KubernetesVersion) +} + +func TestConsumeCloudEventContainerServiceNodePoolRollingFailed(t *testing.T) { + requestContent := ` + { + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster}", + "subject": "{cluster}", + "type": "Microsoft.ContainerService.NodePoolRollingFailed", + "time": "2023-03-29T18:00:00.0000000Z", + "id": "1234567890abcdef1234567890abcdef12345678", + "data": { + "nodePoolName": "nodepool1" + }, + "specversion": "1.0" + }` + + event := parseCloudEvent(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent.NodePoolName) + + sysEvent2 := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingFailedEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent2.NodePoolName) +} + +func TestConsumeCloudEventContainerServiceNodePoolRollingStarted(t *testing.T) { + requestContent := ` + { + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster}", + "subject": "{cluster}", + "type": "Microsoft.ContainerService.NodePoolRollingStarted", + "time": "2023-03-29T18:00:00.0000000Z", + "id": "1234567890abcdef1234567890abcdef12345678", + "data": { + "nodePoolName": "nodepool1" + }, + "specversion": "1.0" + }` + + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent.NodePoolName) +} + +func TestConsumeCloudEventContainerServiceNodePoolRollingSucceeded(t *testing.T) { + requestContent := ` + { + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster}", + "subject": "{cluster}", + "type": "Microsoft.ContainerService.NodePoolRollingSucceeded", + "time": "2023-03-29T18:00:00.0000000Z", + "id": "1234567890abcdef1234567890abcdef12345678", + "data": { + "nodePoolName": "nodepool1" + }, + "specversion": "1.0" + }` + + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + sysEvent := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent.NodePoolName) + + sysEvent2 := deserializeSystemEvent[azsystemevents.ContainerServiceNodePoolRollingSucceededEventData](t, event.Data) + require.Equal(t, "nodepool1", *sysEvent2.NodePoolName) +} + +// IoTHub Device events +func TestConsumeCloudEventIoTHubDeviceCreatedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"2da5e9b4-4e38-04c1-cc58-9da0b37230c0\", \"source\": \"/SUBSCRIPTIONS/BDF55CDD-8DAB-4CF4-9B2F-C21E8A780472/RESOURCEGROUPS/EGTESTRG/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/EGTESTHUB1\", \"subject\": \"devices/48e44e11-1437-4907-83b1-4a8d7e89859e\", \"type\": \"Microsoft.Devices.DeviceCreated\", \"time\": \"2018-07-03T23:20:07.6532054Z\", \"data\": { \"twin\": { \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\", \"etag\": \"AAAAAAAAAAE=\", \"deviceEtag\": null, \"status\": \"enabled\", \"statusUpdateTime\": \"0001-01-01T00:00:00\", \"connectionState\": \"Disconnected\", \"lastActivityTime\": \"0001-01-01T00:00:00\", \"cloudToDeviceMessageCount\": 0, \"authenticationType\": \"sas\", \"x509Thumbprint\": { \"primaryThumbprint\": null, \"secondaryThumbprint\": null }, \"version\": 2, \"properties\": { \"desired\": { \"$metadata\": { \"$lastUpdated\": \"2018-07-03T23:20:07.6532054Z\" }, \"$version\": 1 }, \"reported\": { \"$metadata\": { \"$lastUpdated\": \"2018-07-03T23:20:07.6532054Z\" }, \"$version\": 1 } } }, \"hubName\": \"EGTESTHUB1\", \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\" }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.IotHubDeviceCreatedEventData](t, events[0].Data) + require.Equal(t, "enabled", *sysEvent.Twin.Status) +} + +func TestConsumeCloudEventIoTHubDeviceDeletedEvent(t *testing.T) { + requestContent := "[ {\"specversion\": \"1.0\", \"id\": \"aaaf95c6-ed99-b307-e321-81d8e4f731a6\", \"source\": \"/SUBSCRIPTIONS/BDF55CDD-8DAB-4CF4-9B2F-C21E8A780472/RESOURCEGROUPS/EGTESTRG/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/EGTESTHUB1\", \"subject\": \"devices/48e44e11-1437-4907-83b1-4a8d7e89859e\", \"type\": \"Microsoft.Devices.DeviceDeleted\", \"time\": \"2018-07-03T23:21:33.2753956Z\", \"data\": { \"twin\": { \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\", \"etag\": \"AAAAAAAAAAI=\", \"deviceEtag\": null, \"status\": \"enabled\", \"statusUpdateTime\": \"0001-01-01T00:00:00\", \"connectionState\": \"Disconnected\", \"lastActivityTime\": \"0001-01-01T00:00:00\", \"cloudToDeviceMessageCount\": 0, \"authenticationType\": \"sas\", \"x509Thumbprint\": { \"primaryThumbprint\": null, \"secondaryThumbprint\": null }, \"version\": 3, \"tags\": { \"testKey\": \"testValue\" }, \"properties\": { \"desired\": { \"$metadata\": { \"$lastUpdated\": \"2018-07-03T23:20:07.6532054Z\" }, \"$version\": 1 }, \"reported\": { \"$metadata\": { \"$lastUpdated\": \"2018-07-03T23:20:07.6532054Z\" }, \"$version\": 1 } } }, \"hubName\": \"EGTESTHUB1\", \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\" }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.IotHubDeviceDeletedEventData](t, events[0].Data) + require.Equal(t, "AAAAAAAAAAI=", *sysEvent.Twin.Etag) +} + +func TestConsumeCloudEventIoTHubDeviceConnectedEvent(t *testing.T) { + requestContent := "[ {\"specversion\": \"1.0\", \"id\": \"fbfd8ee1-cf78-74c6-dbcf-e1c58638ccbd\", \"source\": \"/SUBSCRIPTIONS/BDF55CDD-8DAB-4CF4-9B2F-C21E8A780472/RESOURCEGROUPS/EGTESTRG/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/EGTESTHUB1\", \"subject\": \"devices/48e44e11-1437-4907-83b1-4a8d7e89859e\", \"type\": \"Microsoft.Devices.DeviceConnected\", \"time\": \"2018-07-03T23:20:11.6921933+00:00\", \"data\": { \"deviceConnectionStateEventInfo\": { \"sequenceNumber\": \"000000000000000001D4132452F67CE200000002000000000000000000000001\" }, \"hubName\": \"EGTESTHUB1\", \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\", \"moduleId\": \"\" }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.IotHubDeviceConnectedEventData](t, events[0].Data) + require.Equal(t, "EGTESTHUB1", *sysEvent.HubName) +} + +func TestConsumeCloudEventIoTHubDeviceDisconnectedEvent(t *testing.T) { + requestContent := "[ { \"specversion\": \"1.0\", \"id\": \"877f0b10-a086-98ec-27b8-6ae2dfbf5f67\", \"source\": \"/SUBSCRIPTIONS/BDF55CDD-8DAB-4CF4-9B2F-C21E8A780472/RESOURCEGROUPS/EGTESTRG/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/EGTESTHUB1\", \"subject\": \"devices/48e44e11-1437-4907-83b1-4a8d7e89859e\", \"type\": \"Microsoft.Devices.DeviceDisconnected\", \"time\": \"2018-07-03T23:20:52.646434+00:00\", \"data\": { \"deviceConnectionStateEventInfo\": { \"sequenceNumber\": \"000000000000000001D4132452F67CE200000002000000000000000000000002\" }, \"hubName\": \"EGTESTHUB1\", \"deviceId\": \"48e44e11-1437-4907-83b1-4a8d7e89859e\", \"moduleId\": \"\" }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.IotHubDeviceDisconnectedEventData](t, events[0].Data) + require.Equal(t, "000000000000000001D4132452F67CE200000002000000000000000000000002", *sysEvent.DeviceConnectionStateEventInfo.SequenceNumber) +} + +func TestConsumeCloudEventIoTHubDeviceTelemetryEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"877f0b10-a086-98ec-27b8-6ae2dfbf5f67\", \"source\": \"/SUBSCRIPTIONS/BDF55CDD-8DAB-4CF4-9B2F-C21E8A780472/RESOURCEGROUPS/EGTESTRG/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/EGTESTHUB1\", \"subject\": \"devices/48e44e11-1437-4907-83b1-4a8d7e89859e\", \"type\": \"Microsoft.Devices.DeviceTelemetry\", \"time\": \"2018-07-03T23:20:52.646434+00:00\", \"data\": { \"body\": { \"Weather\": { \"Temperature\": 900 }, \"Location\": \"USA\" }, \"properties\": { \"Status\": \"Active\" }, \"systemProperties\": { \"iothub-content-type\": \"application/json\", \"iothub-content-encoding\": \"utf-8\" } }} ]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.IotHubDeviceTelemetryEventData](t, events[0].Data) + require.Equal(t, "Active", *sysEvent.Properties["Status"]) +} + +// EventGrid events +func TestConsumeCloudEventEventGridSubscriptionValidationEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"source\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"\", \"data\": { \"validationCode\": \"512d38b6-c7b8-40c8-89fe-f46f9e9622b6\", \"validationUrl\": \"https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=B2E34264-7D71-453A-B5FB-B62D0FDC85EE&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1BNqCxBBSSE9OnNSfZM4%2b5H9zDegKMY6uJ%2fO2DFRkwQ%3d\" }, \"type\": \"Microsoft.EventGrid.SubscriptionValidationEvent\", \"time\": \"2018-01-25T22:12:19.4556811Z\", \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.SubscriptionValidationEventData](t, events[0].Data) + require.Equal(t, "512d38b6-c7b8-40c8-89fe-f46f9e9622b6", *sysEvent.ValidationCode) +} + +func TestConsumeCloudEventEventGridSubscriptionDeletedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"source\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"\", \"data\": { \"eventSubscriptionId\": \"/subscriptions/id/resourceGroups/rg/providers/Microsoft.EventGrid/topics/topic1/providers/Microsoft.EventGrid/eventSubscriptions/eventsubscription1\" }, \"type\": \"Microsoft.EventGrid.SubscriptionDeletedEvent\", \"time\": \"2018-01-25T22:12:19.4556811Z\", \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.SubscriptionDeletedEventData](t, events[0].Data) + require.Equal(t, "/subscriptions/id/resourceGroups/rg/providers/Microsoft.EventGrid/topics/topic1/providers/Microsoft.EventGrid/eventSubscriptions/eventsubscription1", *sysEvent.EventSubscriptionID) +} + +func TestConsumeCloudEventEventGridMqttClientCreatedOrUpdatedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"source\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"\", \"data\": { \"createdOn\": \"2023-07-29T01:14:34.2048108Z\", \"updatedOn\": \"2023-07-29T01:14:34.2048108Z\",\"namespaceName\": \"myns\",\"clientName\": \"client1\",\"clientAuthenticationName\": \"client1\",\"state\": \"Enabled\",\"attributes\": {\"attribute1\": \"value1\"} }, \"type\": \"Microsoft.EventGrid.MQTTClientCreatedOrUpdated\", \"time\": \"2018-01-25T22:12:19.4556811Z\", \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.EventGridMQTTClientCreatedOrUpdatedEventData](t, events[0].Data) + require.Equal(t, "client1", *sysEvent.ClientName) + require.Equal(t, "myns", *sysEvent.NamespaceName) + require.Equal(t, "client1", *sysEvent.ClientAuthenticationName) +} + +func TestConsumeCloudEventEventGridMqttClientDeletedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"source\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"\", \"data\": { \"namespaceName\": \"myns\",\"clientName\": \"client1\",\"clientAuthenticationName\": \"client1\" }, \"type\": \"Microsoft.EventGrid.MQTTClientDeleted\", \"time\": \"2018-01-25T22:12:19.4556811Z\", \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.EventGridMQTTClientDeletedEventData](t, events[0].Data) + require.Equal(t, "client1", *sysEvent.ClientName) + require.Equal(t, "myns", *sysEvent.NamespaceName) + require.Equal(t, "client1", *sysEvent.ClientAuthenticationName) +} + +func TestConsumeCloudEventEventGridMqttClientSessionConnectedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"source\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"\", \"data\": { \"namespaceName\": \"myns\",\"clientSessionName\": \"session\",\"clientAuthenticationName\": \"client1\", \"sequenceNumber\": 1 }, \"type\": \"Microsoft.EventGrid.MQTTClientSessionConnected\", \"time\": \"2018-01-25T22:12:19.4556811Z\", \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.EventGridMQTTClientSessionConnectedEventData](t, events[0].Data) + require.Equal(t, "session", *sysEvent.ClientSessionName) + require.Equal(t, "myns", *sysEvent.NamespaceName) + require.Equal(t, "client1", *sysEvent.ClientAuthenticationName) + require.Equal(t, int64(1), *sysEvent.SequenceNumber) +} + +func TestConsumeCloudEventEventGridMqttClientSessionDisconnectedEvent(t *testing.T) { + requestContent := "[{ \"id\": \"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\", \"source\": \"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \"subject\": \"\", \"data\": { \"namespaceName\": \"myns\",\"clientSessionName\": \"session\",\"clientAuthenticationName\": \"client1\", \"sequenceNumber\": 1, \"disconnectionReason\": \"ClientInitiatedDisconnect\" }, \"type\": \"Microsoft.EventGrid.MQTTClientSessionDisconnected\", \"time\": \"2018-01-25T22:12:19.4556811Z\", \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.EventGridMQTTClientSessionDisconnectedEventData](t, events[0].Data) + require.Equal(t, "session", *sysEvent.ClientSessionName) + require.Equal(t, "myns", *sysEvent.NamespaceName) + require.Equal(t, "client1", *sysEvent.ClientAuthenticationName) + require.Equal(t, int64(1), *sysEvent.SequenceNumber) + require.Equal(t, azsystemevents.EventGridMQTTClientDisconnectionReasonClientInitiatedDisconnect, *sysEvent.DisconnectionReason) +} + +// Event Hub Events +func TestConsumeCloudEventEventHubCaptureFileCreatedEvent(t *testing.T) { + requestContent := "[ { \"source\": \"/subscriptions/guid/resourcegroups/rgDataMigrationSample/providers/Microsoft.EventHub/namespaces/tfdatamigratens\", \"subject\": \"eventhubs/hubdatamigration\", \"type\": \"microsoft.EventHUB.CaptureFileCreated\", \"time\": \"2017-08-31T19:12:46.0498024Z\", \"id\": \"14e87d03-6fbf-4bb2-9a21-92bd1281f247\", \"data\": { \"fileUrl\": \"https://tf0831datamigrate.blob.core.windows.net/windturbinecapture/tfdatamigratens/hubdatamigration/1/2017/08/31/19/11/45.avro\", \"fileType\": \"AzureBlockBlob\", \"partitionId\": \"1\", \"sizeInBytes\": 249168, \"eventCount\": 1500, \"firstSequenceNumber\": 2400, \"lastSequenceNumber\": 3899, \"firstEnqueueTime\": \"2017-08-31T19:12:14.674Z\", \"lastEnqueueTime\": \"2017-08-31T19:12:44.309Z\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.EventHubCaptureFileCreatedEventData](t, events[0].Data) + require.Equal(t, "AzureBlockBlob", *sysEvent.FileType) + require.Equal(t, "https://tf0831datamigrate.blob.core.windows.net/windturbinecapture/tfdatamigratens/hubdatamigration/1/2017/08/31/19/11/45.avro", *sysEvent.Fileurl) +} diff --git a/sdk/messaging/eventgrid/azsystemevents/system_events4_test.go b/sdk/messaging/eventgrid/azsystemevents/system_events4_test.go new file mode 100644 index 000000000000..781381267c67 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/system_events4_test.go @@ -0,0 +1,979 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azsystemevents_test + +import ( + "strings" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azsystemevents" + + "github.com/stretchr/testify/require" +) + +// MachineLearningServices events +func TestConsumeCloudEventMachineLearningServicesModelRegisteredEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\":\"/subscriptions/a5fe3bc5-98f0-4c84-affc-a589f54d9b23/resourceGroups/jenns/providers/Microsoft.MachineLearningServices/workspaces/jenns-canary\",\"type\":\"Microsoft.MachineLearningServices.ModelRegistered\",\"source\":\"models/sklearn_regression_model:3\",\"time\":\"2019-10-17T22:23:57.5350054+00:00\",\"id\":\"3b73ee51-bbf4-480d-9112-cfc23b41bfdb\",\"data\":{\"modelName\":\"sklearn_regression_model\",\"modelVersion\":\"3\",\"modelTags\":{\"area\":\"diabetes\",\"type\":\"regression\"},\"modelProperties\":{\"area\":\"test\"}}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MachineLearningServicesModelRegisteredEventData](t, events[0].Data) + require.Equal(t, "sklearn_regression_model", *sysEvent.ModelName) + require.Equal(t, "3", *sysEvent.ModelVersion) + require.Equal(t, "regression", sysEvent.ModelTags.(map[string]any)["type"]) + require.Equal(t, "test", sysEvent.ModelProperties.(map[string]any)["area"]) +} + +func TestConsumeCloudEventMachineLearningServicesModelDeployedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\":\"/subscriptions/a5fe3bc5-98f0-4c84-affc-a589f54d9b23/resourceGroups/jenns/providers/Microsoft.MachineLearningServices/workspaces/jenns-canary\",\"type\":\"Microsoft.MachineLearningServices.ModelDeployed\",\"subject\":\"endpoints/aciservice1\",\"time\":\"2019-10-23T18:20:08.8824474+00:00\",\"id\":\"40d0b167-be44-477b-9d23-a2befba7cde0\",\"data\":{\"serviceName\":\"aciservice1\",\"serviceComputeType\":\"ACI\",\"serviceTags\":{\"mytag\":\"test tag\"},\"serviceProperties\":{\"myprop\":\"test property\"},\"modelIds\":\"my_first_model:1,my_second_model:1\"}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MachineLearningServicesModelDeployedEventData](t, events[0].Data) + require.Equal(t, "aciservice1", *sysEvent.ServiceName) + require.Equal(t, 2, len(strings.Split(*sysEvent.ModelIDs, ","))) +} + +func TestConsumeCloudEventMachineLearningServicesRunCompletedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\":\"/subscriptions/a5fe3bc5-98f0-4c84-affc-a589f54d9b23/resourceGroups/jenns/providers/Microsoft.MachineLearningServices/workspaces/jenns-canary\",\"type\":\"Microsoft.MachineLearningServices.RunCompleted\",\"subject\":\"experiments/0fa9dfaa-cba3-4fa7-b590-23e48548f5c1/runs/AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc\",\"time\":\"2019-10-18T19:29:55.8856038+00:00\",\"id\":\"044ac44d-462c-4043-99eb-d9e01dc760ab\",\"data\":{\"experimentId\":\"0fa9dfaa-cba3-4fa7-b590-23e48548f5c1\",\"experimentName\":\"automl-local-regression\",\"runId\":\"AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc\",\"runType\":\"automl\",\"RunTags\":{\"experiment_status\":\"ModelSelection\",\"experiment_status_descr\":\"Beginning model selection.\"},\"runProperties\":{\"num_iterations\":\"10\",\"target\":\"local\"}}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MachineLearningServicesRunCompletedEventData](t, events[0].Data) + require.Equal(t, "AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc", *sysEvent.RunID) + require.Equal(t, "automl-local-regression", *sysEvent.ExperimentName) +} + +func TestConsumeCloudEventMachineLearningServicesRunStatusChangedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\":\"/subscriptions/a5fe3bc5-98f0-4c84-affc-a589f54d9b23/resourceGroups/jenns/providers/Microsoft.MachineLearningServices/workspaces/jenns-canary\",\"type\":\"Microsoft.MachineLearningServices.RunStatusChanged\",\"subject\":\"experiments/0fa9dfaa-cba3-4fa7-b590-23e48548f5c1/runs/AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc\",\"time\":\"2020-03-09T23:53:04.4579724Z\",\"id\":\"aa8cd7df-fe28-5d5d-9b40-3342dbc2a887\",\"data\":{\"runStatus\": \"Running\",\"experimentId\":\"0fa9dfaa-cba3-4fa7-b590-23e48548f5c1\",\"experimentName\":\"automl-local-regression\",\"runId\":\"AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc\",\"runType\":\"automl\",\"runTags\":{\"experiment_status\":\"ModelSelection\",\"experiment_status_descr\":\"Beginning model selection.\"},\"runProperties\":{\"num_iterations\":\"10\",\"target\":\"local\"}}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MachineLearningServicesRunStatusChangedEventData](t, events[0].Data) + require.Equal(t, "AutoML_ad912b2d-6467-4f32-a616-dbe4af6dd8fc", *sysEvent.RunID) + require.Equal(t, "automl-local-regression", *sysEvent.ExperimentName) + require.Equal(t, "Running", *sysEvent.RunStatus) + require.Equal(t, "automl", *sysEvent.RunType) +} + +func TestConsumeCloudEventMachineLearningServicesDatasetDriftDetectedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\":\"/subscriptions/60582a10-b9fd-49f1-a546-c4194134bba8/resourceGroups/copetersRG/providers/Microsoft.MachineLearningServices/workspaces/driftDemoWS\",\"type\":\"Microsoft.MachineLearningServices.DatasetDriftDetected\",\"subject\":\"datadrift/01d29aa4-e6a4-470a-9ef3-66660d21f8ef/run/01d29aa4-e6a4-470a-9ef3-66660d21f8ef_1571590300380\",\"time\":\"2019-10-20T17:08:08.467191+00:00\",\"id\":\"2684de79-b145-4dcf-ad2e-6a1db798585f\",\"data\":{\"dataDriftId\":\"01d29aa4-e6a4-470a-9ef3-66660d21f8ef\",\"dataDriftName\":\"copetersDriftMonitor3\",\"runId\":\"01d29aa4-e6a4-470a-9ef3-66660d21f8ef_1571590300380\",\"baseDatasetId\":\"3c56d136-0f64-4657-a0e8-5162089a88a3\",\"tarAsSystemEventDatasetId\":\"d7e74d2e-c972-4266-b5fb-6c9c182d2a74\",\"driftCoefficient\":0.8350349068479208,\"startTime\":\"2019-07-04T00:00:00+00:00\",\"endTime\":\"2019-07-05T00:00:00+00:00\"}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MachineLearningServicesDatasetDriftDetectedEventData](t, events[0].Data) + require.Equal(t, "copetersDriftMonitor3", *sysEvent.DataDriftName) +} + +// Maps events +func TestConsumeCloudEventMapsGeofenceEnteredEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.Maps.GeofenceEntered\",\"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"expiredGeofenceGeometryId\":[\"id1\",\"id2\"],\"geometries\":[{\"deviceId\":\"id1\",\"distance\":1.0,\"geometryId\":\"gid1\",\"nearestLat\":72.4,\"nearestLon\":100.4,\"udId\":\"id22\"}],\"invalidPeriodGeofenceGeometryId\":[\"id1\",\"id2\"],\"isEventPublished\":true}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MapsGeofenceEnteredEventData](t, events[0].Data) + require.Equal(t, float32(1.0), *sysEvent.Geometries[0].Distance) +} + +func TestConsumeCloudEventMapsGeofenceExitedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.Maps.GeofenceExited\",\"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"expiredGeofenceGeometryId\":[\"id1\",\"id2\"],\"geometries\":[{\"deviceId\":\"id1\",\"distance\":1.0,\"geometryId\":\"gid1\",\"nearestLat\":72.4,\"nearestLon\":100.4,\"udId\":\"id22\"}],\"invalidPeriodGeofenceGeometryId\":[\"id1\",\"id2\"],\"isEventPublished\":true}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MapsGeofenceExitedEventData](t, events[0].Data) + require.Equal(t, float32(1.0), *sysEvent.Geometries[0].Distance) +} + +func TestConsumeCloudEventMapsGeofenceResultEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"id\": \"56afc886-767b-d359-d59e-0da7877166b2\", \"source\": \"/SUBSCRIPTIONS/ID/RESOURCEGROUPS/rg/PROVIDERS/MICROSOFT.Maps/test1\", \"subject\": \"test1\", \"type\": \"Microsoft.Maps.GeofenceResult\",\"time\": \"2018-01-02T19:17:44.4383997Z\", \"data\": {\"expiredGeofenceGeometryId\":[\"id1\",\"id2\"],\"geometries\":[{\"deviceId\":\"id1\",\"distance\":1.0,\"geometryId\":\"gid1\",\"nearestLat\":72.4,\"nearestLon\":100.4,\"udId\":\"id22\"}],\"invalidPeriodGeofenceGeometryId\":[\"id1\",\"id2\"],\"isEventPublished\":true}}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MapsGeofenceResultEventData](t, events[0].Data) + require.Equal(t, float32(1.0), *sysEvent.Geometries[0].Distance) +} + +// Media Services events +func TestConsumeCloudEventMediaMediaJobStateChangeEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"type\": \"Microsoft.Media.JobStateChange\", \"time\": \"2018-10-12T15:14:20.2412317Z\", \"id\": \"341520d0-dac0-4930-97dd-3085538c624f\", \"data\": { \"previousState\": \"Scheduled\", \"state\": \"Processing\", \"correlationData\": {} }, \"specversion\": \"1.0\"}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobStateChangeEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.State) +} + +func TestConsumeCloudEventMediaJobOutputStateChangeEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"type\": \"Microsoft.Media.JobOutputStateChange\", \"time\": \"2018-10-12T15:14:17.8962704Z\", \"id\": \"8d0305c0-28c0-4cc9-b613-776e4dd31e9a\", \"data\": { \"previousState\": \"Scheduled\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": {\"code\":\"ServiceError\", \"message\":\"error message\", \"category\":\"Service\", \"retry\":\"DoNotRetry\", \"details\":[{\"code\":\"code\", \"message\":\"Service Error Message\"}]}, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 0, \"state\": \"Processing\" }, \"jobCorrelationData\": {} }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputStateChangeEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.Output.GetMediaJobOutput().State) + + outputAsset := sysEvent.Output.(*azsystemevents.MediaJobOutputAsset) + require.Equal(t, "output-2ac2fe75-6557-4de5-ab25-5713b74a6901", *outputAsset.AssetName) +} + +func TestConsumeCloudEventMediaJobScheduledEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"type\": \"Microsoft.Media.JobScheduled\", \"time\": \"2018-10-12T15:14:11.3028183Z\", \"id\": \"9b17dbf0-355d-4fb0-9a73-e76b150858c8\", \"data\": { \"previousState\": \"Queued\", \"state\": \"Scheduled\", \"correlationData\": {} }}]" + + events := parseManyCloudEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobScheduledEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateQueued, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.State) +} + +func TestConsumeCloudEventMediaJobProcessingEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"type\": \"Microsoft.Media.JobProcessing\", \"time\": \"2018-10-12T15:14:20.2412317Z\", \"id\": \"72162c44-c7f4-437a-9592-48b83cec2d18\", \"data\": { \"previousState\": \"Scheduled\", \"state\": \"Processing\", \"correlationData\": {} }}]" + + events := parseManyCloudEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobProcessingEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.State) +} + +func TestConsumeCloudEventMediaJobCancelingEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"type\": \"Microsoft.Media.JobCanceling\", \"time\": \"2018-10-12T15:41:50.5513295Z\", \"id\": \"1f9a488b-abe3-4fca-80b8-aae59bf7f123\", \"data\": { \"previousState\": \"Processing\", \"state\": \"Canceling\", \"correlationData\": {} }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobCancelingEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateCanceling, *sysEvent.State) +} + +func TestConsumeCloudEventMediaJobFinishedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-298338bb-f8d1-4d0f-9fde-544e0ac4d983\", \"type\": \"Microsoft.Media.JobFinished\", \"time\": \"2018-10-01T20:58:26.7886175Z\", \"id\": \"83f8464d-be94-48e5-b67b-46c6199fe28e\", \"data\": { \"outputs\": [ { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-298338bb-f8d1-4d0f-9fde-544e0ac4d983\", \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 100, \"state\": \"Finished\" } ], \"previousState\": \"Processing\", \"state\": \"Finished\", \"correlationData\": {} } }]" + events := parseManyCloudEvents(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobFinishedEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateFinished, *sysEvent.State) + require.Equal(t, 1, len(sysEvent.Outputs)) + + outputAsset := sysEvent.Outputs[0].(*azsystemevents.MediaJobOutputAsset) + + require.Equal(t, azsystemevents.MediaJobStateFinished, *outputAsset.State) + require.Nil(t, outputAsset.Error) + require.Equal(t, int64(100), *outputAsset.Progress) + require.Equal(t, "output-298338bb-f8d1-4d0f-9fde-544e0ac4d983", *outputAsset.AssetName) +} + +func TestConsumeCloudEventMediaJobCanceledEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"type\": \"Microsoft.Media.JobCanceled\", \"time\": \"2018-10-12T15:42:05.6519929Z\", \"id\": \"3fef7871-f916-4980-8a45-e79a2675808b\", \"data\": { \"outputs\": [ { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"error\": {\"code\":\"ServiceError\", \"message\":\"error message\", \"category\":\"Service\", \"retry\":\"DoNotRetry\", \"details\":[{\"code\":\"code\", \"message\":\"Service Error Message\"}]}, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 83, \"state\": \"Canceled\" } ], \"previousState\": \"Canceling\", \"state\": \"Canceled\", \"correlationData\": {} }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobCanceledEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.MediaJobStateCanceling, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateCanceled, *sysEvent.State) + require.Equal(t, 1, len(sysEvent.Outputs)) + + outputAsset := sysEvent.Outputs[0].(*azsystemevents.MediaJobOutputAsset) + + require.Equal(t, azsystemevents.MediaJobStateCanceled, *outputAsset.State) + require.NotEqual(t, int64(100), *outputAsset.Progress) + require.Equal(t, "output-7a8215f9-0f8d-48a6-82ed-1ead772bc221", *outputAsset.AssetName) +} + +func TestConsumeCloudEventMediaJobErroredEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"type\": \"Microsoft.Media.JobErrored\", \"time\": \"2018-10-12T15:29:20.9954767Z\", \"id\": \"2749e9cf-4095-4723-9bc5-df8e15289135\", \"data\": { \"outputs\": [ { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": { \"category\": \"Service\", \"code\": \"ServiceError\", \"details\": [ { \"code\": \"Internal\", \"message\": \"Internal error in initializing the task for processing\" } ], \"message\": \"Fatal service error, please contact support.\", \"retry\": \"DoNotRetry\" }, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 83, \"state\": \"Error\" } ], \"previousState\": \"Processing\", \"state\": \"Error\", \"correlationData\": {} }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobErroredEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateError, *sysEvent.State) + require.Equal(t, 1, len(sysEvent.Outputs)) + + outputAsset := sysEvent.Outputs[0].(*azsystemevents.MediaJobOutputAsset) + + require.Equal(t, azsystemevents.MediaJobStateError, *outputAsset.State) + require.NotEmpty(t, *outputAsset.Error) + require.Equal(t, azsystemevents.MediaJobErrorCategoryService, *outputAsset.Error.Category) + require.Equal(t, azsystemevents.MediaJobErrorCodeServiceError, *outputAsset.Error.Code) +} + +func TestConsumeCloudEventMediaJobOutputCanceledEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"type\": \"Microsoft.Media.JobOutputCanceled\", \"time\": \"2018-10-12T15:42:04.949555Z\", \"id\": \"9297cda2-4a50-4622-a679-c3785d27d512\", \"data\": { \"previousState\": \"Canceling\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"error\": {\"code\":\"ServiceError\", \"message\":\"error message\", \"category\":\"Service\", \"retry\":\"DoNotRetry\", \"details\":[{\"code\":\"code\", \"message\":\"Service Error Message\"}]}, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 83, \"state\": \"Canceled\" }, \"jobCorrelationData\": {} }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputCanceledEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.MediaJobStateCanceling, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateCanceled, *sysEvent.Output.GetMediaJobOutput().State) + require.IsType(t, &azsystemevents.MediaJobOutputAsset{}, sysEvent.Output) +} + +func TestConsumeCloudEventMediaJobOutputCancelingEvent(t *testing.T) { + requestContent := "{ \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"type\": \"Microsoft.Media.JobOutputCanceling\", \"time\": \"2018-10-12T15:42:04.949555Z\", \"id\": \"9297cda2-4a50-4622-a679-c3785d27d512\", \"data\": { \"previousState\": \"Processing\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-7a8215f9-0f8d-48a6-82ed-1ead772bc221\", \"error\": { \"category\": \"Service\", \"code\": \"ServiceError\", \"details\": [ { \"code\": \"Internal\", \"message\": \"Internal error in initializing the task for processing\" } ], \"message\": \"Fatal service error, please contact support.\", \"retry\": \"DoNotRetry\" }, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 83, \"state\": \"Canceling\" }, \"jobCorrelationData\": {} }, \"specversion\": \"1.0\"}" + + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputCancelingEventData](t, event.Data) + + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateCanceling, *sysEvent.Output.GetMediaJobOutput().State) + require.IsType(t, &azsystemevents.MediaJobOutputAsset{}, sysEvent.Output) +} + +func TestConsumeCloudEventMediaJobOutputErroredEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"type\": \"Microsoft.Media.JobOutputErrored\", \"time\": \"2018-10-12T15:29:20.2621252Z\", \"id\": \"bc9e6342-f081-49c2-a579-92f506a622c2\", \"data\": { \"previousState\": \"Processing\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": { \"category\": \"Service\", \"code\": \"ServiceError\", \"details\": [ { \"code\": \"Internal\", \"message\": \"Internal error in initializing the task for processing\" } ], \"message\": \"Fatal service error, please contact support.\", \"retry\": \"DoNotRetry\" }, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 83, \"state\": \"Error\" }, \"jobCorrelationData\": {} }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputErroredEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateError, *sysEvent.Output.GetMediaJobOutput().State) + require.IsType(t, &azsystemevents.MediaJobOutputAsset{}, sysEvent.Output) + require.NotEmpty(t, *sysEvent.Output.GetMediaJobOutput().Error) + require.Equal(t, azsystemevents.MediaJobErrorCategoryService, *sysEvent.Output.GetMediaJobOutput().Error.Category) + require.Equal(t, azsystemevents.MediaJobErrorCodeServiceError, *sysEvent.Output.GetMediaJobOutput().Error.Code) +} + +func TestConsumeCloudEventMediaJobOutputFinishedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"type\": \"Microsoft.Media.JobOutputFinished\", \"time\": \"2018-10-12T15:29:20.2621252Z\", \"id\": \"bc9e6342-f081-49c2-a579-92f506a622c2\", \"data\": { \"previousState\": \"Processing\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 100, \"state\": \"Finished\" }, \"jobCorrelationData\": {} }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputFinishedEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateFinished, *sysEvent.Output.GetMediaJobOutput().State) + require.Equal(t, int64(100), *sysEvent.Output.GetMediaJobOutput().Progress) + + outputAsset := sysEvent.Output.(*azsystemevents.MediaJobOutputAsset) + require.Equal(t, "output-2ac2fe75-6557-4de5-ab25-5713b74a6901", *outputAsset.AssetName) +} + +func TestConsumeCloudEventMediaJobOutputProcessingEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"type\": \"Microsoft.Media.JobOutputProcessing\", \"time\": \"2018-10-12T15:14:17.8962704Z\", \"id\": \"d48eeb0b-2bfa-4265-a2f8-624654c3781c\", \"data\": { \"previousState\": \"Scheduled\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": { \"category\": \"Service\", \"code\": \"ServiceError\", \"details\": [ { \"code\": \"Internal\", \"message\": \"Internal error in initializing the task for processing\" } ], \"message\": \"Fatal service error, please contact support.\", \"retry\": \"DoNotRetry\" }, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 0, \"state\": \"Processing\" }, \"jobCorrelationData\": {} }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputProcessingEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateProcessing, *sysEvent.Output.GetMediaJobOutput().State) + require.IsType(t, &azsystemevents.MediaJobOutputAsset{}, sysEvent.Output) +} + +func TestConsumeCloudEventMediaJobOutputScheduledEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"type\": \"Microsoft.Media.JobOutputScheduled\", \"time\": \"2018-10-12T15:14:11.2244618Z\", \"id\": \"635ca6ea-5306-4590-b2e1-22f172759336\", \"data\": { \"previousState\": \"Queued\", \"output\": { \"@odata.type\": \"#Microsoft.Media.JobOutputAsset\", \"assetName\": \"output-2ac2fe75-6557-4de5-ab25-5713b74a6901\", \"error\": { \"category\": \"Service\", \"code\": \"ServiceError\", \"details\": [ { \"code\": \"Internal\", \"message\": \"Internal error in initializing the task for processing\" } ], \"message\": \"Fatal service error, please contact support.\", \"retry\": \"DoNotRetry\" }, \"label\": \"VideoAnalyzerPreset_0\", \"progress\": 0, \"state\": \"Scheduled\" }, \"jobCorrelationData\": {} }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputScheduledEventData](t, events[0].Data) + require.Equal(t, azsystemevents.MediaJobStateQueued, *sysEvent.PreviousState) + require.Equal(t, azsystemevents.MediaJobStateScheduled, *sysEvent.Output.GetMediaJobOutput().State) + require.IsType(t, &azsystemevents.MediaJobOutputAsset{}, sysEvent.Output) +} + +func TestConsumeCloudEventMediaJobOutputProgressEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"transforms/VideoAnalyzerTransform/jobs/job-2ac2fe75-6557-4de5-ab25-5713b74a6981\", \"type\": \"Microsoft.Media.JobOutputProgress\", \"time\": \"2018-10-12T15:14:11.2244618Z\", \"id\": \"635ca6ea-5306-4590-b2e1-22f172759336\", \"data\": { \"jobCorrelationData\": { \"Field1\": \"test1\", \"Field2\": \"test2\" }, \"label\": \"TestLabel\", \"progress\": 50 }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaJobOutputProgressEventData](t, events[0].Data) + + require.Equal(t, "TestLabel", *sysEvent.Label) + require.Equal(t, int64(50), *sysEvent.Progress) + require.Equal(t, "test1", *sysEvent.JobCorrelationData["Field1"]) + require.Equal(t, "test2", *sysEvent.JobCorrelationData["Field2"]) +} + +func TestConsumeCloudEventMediaLiveEventEncoderConnectedEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"type\": \"Microsoft.Media.LiveEventEncoderConnected\", \"time\": \"2018-10-12T15:52:04.2013501Z\", \"id\": \"3d1f5b26-c466-47e7-927b-900985e0c5d5\", \"data\": { \"ingestUrl\": \"rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59\", \"streamId\": \"Mystream1\", \"encoderIp\": \"\", \"encoderPort\": \"3557\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventEncoderConnectedEventData](t, events[0].Data) + + require.Equal(t, "rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59", *sysEvent.IngestURL) + require.Equal(t, "Mystream1", *sysEvent.StreamID) + require.Equal(t, "", *sysEvent.EncoderIP) + require.Equal(t, "3557", *sysEvent.EncoderPort) +} + +func TestConsumeCloudEventMediaLiveEventConnectionRejectedEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"type\": \"Microsoft.Media.LiveEventConnectionRejected\", \"time\": \"2018-10-12T15:52:04.2013501Z\", \"id\": \"3d1f5b26-c466-47e7-927b-900985e0c5d5\", \"data\": { \"ingestUrl\": \"rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59\", \"streamId\": \"Mystream1\", \"encoderIp\": \"\", \"encoderPort\": \"3557\", \"resultCode\": \"MPE_INGEST_CODEC_NOT_SUPPORTED\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventConnectionRejectedEventData](t, events[0].Data) + + require.Equal(t, "rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59", *sysEvent.IngestURL) + require.Equal(t, "Mystream1", *sysEvent.StreamID) + require.Equal(t, "", *sysEvent.EncoderIP) + require.Equal(t, "3557", *sysEvent.EncoderPort) +} + +func TestConsumeCloudEventMediaLiveEventEncoderDisconnectedEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"type\": \"Microsoft.Media.LiveEventEncoderDisconnected\", \"time\": \"2018-10-12T15:52:19.8982128Z\", \"id\": \"e4b55140-42d2-4c24-b08e-9aa12f1587fc\", \"data\": { \"ingestUrl\": \"rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59\", \"streamId\": \"Mystream1\", \"encoderIp\": \"\", \"encoderPort\": \"3557\", \"resultCode\": \"MPE_CLIENT_TERMINATED_SESSION\" }, \"specversion\": \"1.0\"}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventEncoderDisconnectedEventData](t, events[0].Data) + + require.Equal(t, "MPE_CLIENT_TERMINATED_SESSION", *sysEvent.ResultCode) + + require.Equal(t, "rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59", *sysEvent.IngestURL) + require.Equal(t, "Mystream1", *sysEvent.StreamID) + require.Equal(t, "", *sysEvent.EncoderIP) + require.Equal(t, "3557", *sysEvent.EncoderPort) +} + +func TestConsumeCloudEventMediaLiveEventIncomingStreamReceivedEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"type\": \"Microsoft.Media.LiveEventIncomingStreamReceived\", \"time\": \"2018-10-12T15:52:16.5726463Z\", \"id\": \"eb688fa1-5a19-4703-8aeb-6a65a09790da\", \"data\": { \"ingestUrl\": \"rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59\", \"trackType\": \"audio\", \"trackName\": \"audio_160000\", \"bitrate\": 160000, \"encoderIp\": \"\", \"encoderPort\": \"3557\", \"timestamp\": \"66\", \"duration\": \"1950\", \"timescale\": \"1000\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventIncomingStreamReceivedEventData](t, events[0].Data) + + require.Equal(t, "rtmp://liveevent-ec9d26a8.channel.media.azure.net:1935/live/cb5540b10a5646218c1328be95050c59", *sysEvent.IngestURL) + require.Equal(t, "", *sysEvent.EncoderIP) + require.Equal(t, "3557", *sysEvent.EncoderPort) + require.Equal(t, "audio", *sysEvent.TrackType) + require.Equal(t, "audio_160000", *sysEvent.TrackName) + require.Equal(t, int64(160000), *sysEvent.Bitrate) + require.Equal(t, "66", *sysEvent.Timestamp) + require.Equal(t, "1950", *sysEvent.Duration) + require.Equal(t, "1000", *sysEvent.Timescale) +} + +func TestConsumeCloudEventMediaLiveEventIncomingStreamsOutOfSyncEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"type\": \"Microsoft.Media.LiveEventIncomingStreamsOutOfSync\", \"time\": \"2018-10-12T15:52:37.3710102Z\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"minLastTimestamp\": \"10999\", \"typeOfStreamWithMinLastTimestamp\": \"video\", \"maxLastTimestamp\": \"100999\", \"typeOfStreamWithMaxLastTimestamp\": \"audio\", \"timescaleOfMinLastTimestamp\": \"1000\", \"timescaleOfMaxLastTimestamp\": \"1000\" }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventIncomingStreamsOutOfSyncEventData](t, events[0].Data) + + require.Equal(t, "10999", *sysEvent.MinLastTimestamp) + require.Equal(t, "video", *sysEvent.TypeOfStreamWithMinLastTimestamp) + require.Equal(t, "100999", *sysEvent.MaxLastTimestamp) + require.Equal(t, "audio", *sysEvent.TypeOfStreamWithMaxLastTimestamp) + require.Equal(t, "1000", *sysEvent.TimescaleOfMinLastTimestamp) + require.Equal(t, "1000", *sysEvent.TimescaleOfMaxLastTimestamp) +} + +func TestConsumeCloudEventMediaLiveEventIncomingVideoStreamsOutOfSyncEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"type\": \"Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync\", \"time\": \"2018-10-12T15:52:37.3710102Z\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"firstTimestamp\": \"10999\", \"firstDuration\": \"2000\", \"secondTimestamp\": \"100999\", \"secondDuration\": \"2000\", \"timescale\": \"1000\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventIncomingVideoStreamsOutOfSyncEventData](t, events[0].Data) + + require.Equal(t, "10999", *sysEvent.FirstTimestamp) + require.Equal(t, "2000", *sysEvent.FirstDuration) + require.Equal(t, "100999", *sysEvent.SecondTimestamp) + require.Equal(t, "2000", *sysEvent.SecondDuration) + require.Equal(t, "1000", *sysEvent.Timescale) +} + +func TestConsumeCloudEventMediaLiveEventIncomingDataChunkDroppedEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"type\": \"Microsoft.Media.LiveEventIncomingDataChunkDropped\", \"time\": \"2018-10-12T15:52:37.3710102Z\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"timestamp\": \"8999\", \"trackType\": \"video\", \"trackName\": \"video1\", \"bitrate\": 2500000, \"timescale\": \"1000\", \"resultCode\": \"FragmentDrop_OverlapTimestamp\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventIncomingDataChunkDroppedEventData](t, events[0].Data) + + require.Equal(t, "8999", *sysEvent.Timestamp) + require.Equal(t, "video", *sysEvent.TrackType) + require.Equal(t, "video1", *sysEvent.TrackName) + require.Equal(t, int64(2500000), *sysEvent.Bitrate) + require.Equal(t, "1000", *sysEvent.Timescale) + require.Equal(t, "FragmentDrop_OverlapTimestamp", *sysEvent.ResultCode) +} + +func TestConsumeCloudEventMediaLiveEventIngestHeartbeatEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"type\": \"Microsoft.Media.LiveEventIngestHeartbeat\", \"time\": \"2018-10-12T15:52:37.3710102Z\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"trackType\": \"video\", \"trackName\": \"video\", \"bitrate\": 2500000, \"incomingBitrate\": 500726, \"lastTimestamp\": \"11999\", \"timescale\": \"1000\", \"overlapCount\": 0, \"discontinuityCount\": 0, \"nonincreasingCount\": 0, \"unexpectedBitrate\": true, \"state\": \"Running\", \"healthy\": false }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventIngestHeartbeatEventData](t, events[0].Data) + + require.Equal(t, "video", *sysEvent.TrackType) + require.Equal(t, "video", *sysEvent.TrackName) + require.Equal(t, int64(2500000), *sysEvent.Bitrate) + require.Equal(t, int64(500726), *sysEvent.IncomingBitrate) + require.Equal(t, "11999", *sysEvent.LastTimestamp) + require.Equal(t, "1000", *sysEvent.Timescale) + require.Zero(t, *sysEvent.OverlapCount) + require.Zero(t, *sysEvent.DiscontinuityCount) + require.Zero(t, *sysEvent.NonincreasingCount) + require.True(t, *sysEvent.UnexpectedBitrate) + require.Equal(t, "Running", *sysEvent.State) + require.False(t, *sysEvent.Healthy) +} + +func TestConsumeCloudEventMediaLiveEventTrackDiscontinuityDetectedEvent(t *testing.T) { + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/{subscription id}/resourceGroups/{resource group}/providers/Microsoft.Media/mediaservices/{account name}\", \"subject\": \"liveEvent/liveevent-ec9d26a8\", \"type\": \"Microsoft.Media.LiveEventTrackDiscontinuityDetected\", \"time\": \"2018-10-12T15:52:37.3710102Z\", \"id\": \"d84727e2-d9c0-4a21-a66b-8d23f06b3e06\", \"data\": { \"trackType\": \"video\", \"trackName\": \"video\", \"bitrate\": 2500000, \"previousTimestamp\": \"10999\", \"newTimestamp\": \"14999\", \"timescale\": \"1000\", \"discontinuityGap\": \"4000\" }}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.MediaLiveEventTrackDiscontinuityDetectedEventData](t, events[0].Data) + + require.Equal(t, "video", *sysEvent.TrackType) + require.Equal(t, "video", *sysEvent.TrackName) + require.Equal(t, int64(2500000), *sysEvent.Bitrate) + require.Equal(t, "10999", *sysEvent.PreviousTimestamp) + require.Equal(t, "14999", *sysEvent.NewTimestamp) + require.Equal(t, "1000", *sysEvent.Timescale) + require.Equal(t, "4000", *sysEvent.DiscontinuityGap) +} + +// Resource Manager (Azure Subscription/Resource Group) events +func TestConsumeCloudEventResourceWriteSuccessEvent(t *testing.T) { + requestContent := `[ { "source":"/subscriptions/{subscription-id}", "subject":"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "type":"Microsoft.Resources.ResourceWriteSuccess", "time":"2017-08-16T03:54:38.2696833Z", "id":"25b3b0d0-d79b-44d5-9963-440d4e6a9bba", "data": { "authorization":{}, "claims":{}, "correlationId":"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6", "httpRequest":{}, "resourceProvider":"Microsoft.EventGrid", "resourceUri":"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501", "operationName":"Microsoft.EventGrid/eventSubscriptions/write", "status":"Succeeded", "subscriptionId":"{subscription-id}", "tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47" }, "specversion": "1.0" }]` + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ResourceWriteSuccessEventData](t, events[0].Data) + + require.Equal(t, "72f988bf-86f1-41af-91ab-2d7cd011db47", *sysEvent.TenantID) +} + +func TestConsumeCloudEventResourceWriteFailureEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.Resources.ResourceWriteFailure\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"authorization\":{}, \"claims\":{}, \"correlationId\":\"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"operationName\":\"Microsoft.EventGrid/eventSubscriptions/write\", \"status\":\"Succeeded\", \"subscriptionId\":\"{subscription-id}\", \"tenantId\":\"72f988bf-86f1-41af-91ab-2d7cd011db47\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + + sysEvent := deserializeSystemEvent[azsystemevents.ResourceWriteFailureEventData](t, events[0].Data) + require.Equal(t, "72f988bf-86f1-41af-91ab-2d7cd011db47", *sysEvent.TenantID) +} + +func TestConsumeCloudEventResourceWriteCancelEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.Resources.ResourceWriteCancel\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"authorization\":{}, \"claims\":{}, \"correlationId\":\"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"operationName\":\"Microsoft.EventGrid/eventSubscriptions/write\", \"status\":\"Succeeded\", \"subscriptionId\":\"{subscription-id}\", \"tenantId\":\"72f988bf-86f1-41af-91ab-2d7cd011db47\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ResourceWriteCancelEventData](t, events[0].Data) + require.Equal(t, "72f988bf-86f1-41af-91ab-2d7cd011db47", *sysEvent.TenantID) +} + +func TestConsumeCloudEventResourceDeleteSuccessEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.Resources.ResourceDeleteSuccess\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"authorization\":{}, \"claims\":{}, \"correlationId\":\"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"operationName\":\"Microsoft.EventGrid/eventSubscriptions/write\", \"status\":\"Succeeded\", \"subscriptionId\":\"{subscription-id}\", \"tenantId\":\"72f988bf-86f1-41af-91ab-2d7cd011db47\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ResourceDeleteSuccessEventData](t, events[0].Data) + require.Equal(t, "72f988bf-86f1-41af-91ab-2d7cd011db47", *sysEvent.TenantID) +} + +func TestConsumeCloudEventResourceDeleteFailureEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.Resources.ResourceDeleteFailure\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"authorization\":{}, \"claims\":{}, \"correlationId\":\"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"operationName\":\"Microsoft.EventGrid/eventSubscriptions/write\", \"status\":\"Succeeded\", \"subscriptionId\":\"{subscription-id}\", \"tenantId\":\"72f988bf-86f1-41af-91ab-2d7cd011db47\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ResourceDeleteFailureEventData](t, events[0].Data) + require.Equal(t, "72f988bf-86f1-41af-91ab-2d7cd011db47", *sysEvent.TenantID) +} + +func TestConsumeCloudEventResourceDeleteCancelEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.Resources.ResourceDeleteCancel\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"authorization\":{}, \"claims\":{}, \"correlationId\":\"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"operationName\":\"Microsoft.EventGrid/eventSubscriptions/write\", \"status\":\"Succeeded\", \"subscriptionId\":\"{subscription-id}\", \"tenantId\":\"72f988bf-86f1-41af-91ab-2d7cd011db47\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ResourceDeleteCancelEventData](t, events[0].Data) + require.Equal(t, "72f988bf-86f1-41af-91ab-2d7cd011db47", *sysEvent.TenantID) +} + +func TestConsumeCloudEventResourceActionSuccessEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.Resources.ResourceActionSuccess\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"authorization\":{}, \"claims\":{}, \"correlationId\":\"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"operationName\":\"Microsoft.EventGrid/eventSubscriptions/write\", \"status\":\"Succeeded\", \"subscriptionId\":\"{subscription-id}\", \"tenantId\":\"72f988bf-86f1-41af-91ab-2d7cd011db47\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ResourceActionSuccessEventData](t, events[0].Data) + require.Equal(t, "72f988bf-86f1-41af-91ab-2d7cd011db47", *sysEvent.TenantID) +} + +func TestConsumeCloudEventResourceActionFailureEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.Resources.ResourceActionFailure\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"authorization\":{}, \"claims\":{}, \"correlationId\":\"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"operationName\":\"Microsoft.EventGrid/eventSubscriptions/write\", \"status\":\"Succeeded\", \"subscriptionId\":\"{subscription-id}\", \"tenantId\":\"72f988bf-86f1-41af-91ab-2d7cd011db47\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ResourceActionFailureEventData](t, events[0].Data) + require.Equal(t, "72f988bf-86f1-41af-91ab-2d7cd011db47", *sysEvent.TenantID) +} + +func TestConsumeCloudEventResourceActionCancelEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.Resources.ResourceActionCancel\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"authorization\":{}, \"claims\":{}, \"correlationId\":\"54ef1e39-6a82-44b3-abc1-bdeb6ce4d3c6\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"operationName\":\"Microsoft.EventGrid/eventSubscriptions/write\", \"status\":\"Succeeded\", \"subscriptionId\":\"{subscription-id}\", \"tenantId\":\"72f988bf-86f1-41af-91ab-2d7cd011db47\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ResourceActionCancelEventData](t, events[0].Data) + require.Equal(t, "72f988bf-86f1-41af-91ab-2d7cd011db47", *sysEvent.TenantID) +} + +// ServiceBus events +func TestConsumeCloudEventServiceBusActiveMessagesAvailableWithNoListenersEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/id/resourcegroups/rg/providers/Microsoft.ServiceBus/namespaces/testns1\", \"subject\": \"topics/topic1/subscriptions/sub1\", \"type\": \"Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners\", \"time\": \"2018-02-14T05:12:53.4133526Z\", \"id\": \"dede87b0-3656-419c-acaf-70c95ddc60f5\", \"data\": { \"namespaceName\": \"testns1\", \"requestUri\": \"https://testns1.servicebus.windows.net/t1/subscriptions/sub1/messages/head\", \"entityType\": \"subscriber\", \"queueName\": \"queue1\", \"topicName\": \"topic1\", \"subscriptionName\": \"sub1\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ServiceBusActiveMessagesAvailableWithNoListenersEventData](t, events[0].Data) + require.Equal(t, "testns1", *sysEvent.NamespaceName) +} + +func TestConsumeCloudEventServiceBusDeadletterMessagesAvailableWithNoListenersEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/id/resourcegroups/rg/providers/Microsoft.ServiceBus/namespaces/testns1\", \"subject\": \"topics/topic1/subscriptions/sub1\", \"type\": \"Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListeners\", \"time\": \"2018-02-14T05:12:53.4133526Z\", \"id\": \"dede87b0-3656-419c-acaf-70c95ddc60f5\", \"data\": { \"namespaceName\": \"testns1\", \"requestUri\": \"https://testns1.servicebus.windows.net/t1/subscriptions/sub1/messages/head\", \"entityType\": \"subscriber\", \"queueName\": \"queue1\", \"topicName\": \"topic1\", \"subscriptionName\": \"sub1\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.ServiceBusDeadletterMessagesAvailableWithNoListenersEventData](t, events[0].Data) + require.Equal(t, "testns1", *sysEvent.NamespaceName) +} + +// Storage events +func TestConsumeCloudEventStorageBlobCreatedEvent(t *testing.T) { + requestContent := "[ { \"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Storage/storageAccounts/myaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/file1.txt\", \"type\": \"Microsoft.Storage.BlobCreated\", \"time\": \"2017-08-16T01:57:26.005121Z\", \"id\": \"602a88ef-0001-00e6-1233-1646070610ea\", \"data\": { \"api\": \"PutBlockList\", \"clientRequestId\": \"799304a4-bbc5-45b6-9849-ec2c66be800a\", \"requestId\": \"602a88ef-0001-00e6-1233-164607000000\", \"eTag\": \"0x8D4E44A24ABE7F1\", \"contentType\": \"text/plain\", \"contentLength\": 447, \"blobType\": \"BlockBlob\", \"url\": \"https://myaccount.blob.core.windows.net/testcontainer/file1.txt\", \"sequencer\": \"00000000000000EB000000000000C65A\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobCreatedEventData](t, events[0].Data) + require.Equal(t, "https://myaccount.blob.core.windows.net/testcontainer/file1.txt", *sysEvent.URL) +} + +func TestConsumeCloudEventStorageBlobDeletedEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"type\": \"Microsoft.Storage.BlobDeleted\", \"time\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteBlob\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"contentType\": \"text/plain\", \"blobType\": \"BlockBlob\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobDeletedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testfile.txt", *sysEvent.URL) +} + +func TestConsumeCloudEventStorageBlobRenamedEvent(t *testing.T) { + requestContent := "[ { \"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Storage/storageAccounts/myaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testfile.txt\", \"type\": \"Microsoft.Storage.BlobRenamed\", \"time\": \"2017-08-16T01:57:26.005121Z\", \"id\": \"602a88ef-0001-00e6-1233-1646070610ea\", \"data\": { \"api\": \"RenameFile\", \"clientRequestId\": \"799304a4-bbc5-45b6-9849-ec2c66be800a\", \"requestId\": \"602a88ef-0001-00e6-1233-164607000000\", \"eTag\": \"0x8D4E44A24ABE7F1\", \"destinationUrl\": \"https://myaccount.blob.core.windows.net/testcontainer/testfile.txt\", \"sequencer\": \"00000000000000EB000000000000C65A\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobRenamedEventData](t, events[0].Data) + require.Equal(t, "https://myaccount.blob.core.windows.net/testcontainer/testfile.txt", *sysEvent.DestinationURL) +} + +func TestConsumeCloudEventStorageDirectoryCreatedEvent(t *testing.T) { + requestContent := "[ { \"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Storage/storageAccounts/myaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"type\": \"Microsoft.Storage.DirectoryCreated\", \"time\": \"2017-08-16T01:57:26.005121Z\", \"id\": \"602a88ef-0001-00e6-1233-1646070610ea\", \"data\": { \"api\": \"CreateDirectory\", \"clientRequestId\": \"799304a4-bbc5-45b6-9849-ec2c66be800a\", \"requestId\": \"602a88ef-0001-00e6-1233-164607000000\", \"eTag\": \"0x8D4E44A24ABE7F1\", \"url\": \"https://myaccount.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"00000000000000EB000000000000C65A\" }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageDirectoryCreatedEventData](t, events[0].Data) + require.Equal(t, "https://myaccount.blob.core.windows.net/testcontainer/testDir", *sysEvent.URL) +} + +func TestConsumeCloudEventStorageDirectoryDeletedEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"type\": \"Microsoft.Storage.DirectoryDeleted\", \"time\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"DeleteDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageDirectoryDeletedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testDir", *sysEvent.URL) +} + +func TestConsumeCloudEventStorageDirectoryRenamedEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"type\": \"Microsoft.Storage.DirectoryRenamed\", \"time\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"RenameDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"destinationUrl\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageDirectoryRenamedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testDir", *sysEvent.DestinationURL) +} + +func TestConsumeCloudEventStorageAsyncOperationInitiatedEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"type\": \"Microsoft.Storage.AsyncOperationInitiated\", \"time\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"RenameDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"specversion\": \"1.0\"}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageAsyncOperationInitiatedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testDir", *sysEvent.URL) +} + +func TestConsumeCloudEventStorageBlobTierChangedEvent(t *testing.T) { + requestContent := "[{ \"source\": \"/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount\", \"subject\": \"/blobServices/default/containers/testcontainer/blobs/testDir\", \"type\": \"Microsoft.Storage.BlobTierChanged\", \"time\": \"2017-11-07T20:09:22.5674003Z\", \"id\": \"4c2359fe-001e-00ba-0e04-58586806d298\", \"data\": { \"api\": \"RenameDirectory\", \"requestId\": \"4c2359fe-001e-00ba-0e04-585868000000\", \"url\": \"https://example.blob.core.windows.net/testcontainer/testDir\", \"sequencer\": \"0000000000000281000000000002F5CA\", \"storageDiagnostics\": { \"batchId\": \"b68529f3-68cd-4744-baa4-3c0498ec19f0\" } }, \"specversion\": \"1.0\"}]" + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.StorageBlobTierChangedEventData](t, events[0].Data) + require.Equal(t, "https://example.blob.core.windows.net/testcontainer/testDir", *sysEvent.URL) +} + +// App Service events +func TestConsumeCloudEventWebAppUpdatedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.AppUpdated\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebAppUpdatedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebBackupOperationStartedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.BackupOperationStarted\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebBackupOperationStartedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebBackupOperationCompletedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.BackupOperationCompleted\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebBackupOperationCompletedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebBackupOperationFailedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.BackupOperationFailed\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebBackupOperationFailedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebRestoreOperationStartedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.RestoreOperationStarted\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebRestoreOperationStartedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebRestoreOperationCompletedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.RestoreOperationCompleted\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebRestoreOperationCompletedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebRestoreOperationFailedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.RestoreOperationFailed\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebRestoreOperationFailedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebSlotSwapStartedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.SlotSwapStarted\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebSlotSwapStartedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebSlotSwapCompletedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"specversion\": \"1.0\", \"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.SlotSwapCompleted\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"}}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebSlotSwapCompletedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebSlotSwapFailedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.SlotSwapFailed\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"}, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebSlotSwapFailedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebSlotSwapWithPreviewStartedEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.SlotSwapWithPreviewStarted\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"}, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebSlotSwapWithPreviewStartedEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebSlotSwapWithPreviewCancelledEvent(t *testing.T) { + siteName := "testSite01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/sites/testSite01\", \"subject\": \"/Microsoft.Web/sites/testSite01\",\"type\": \"Microsoft.Web.SlotSwapWithPreviewCancelled\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appEventTypeDetail\": { \"action\": \"Restarted\"},\"name\": \"testSite01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"}, \"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebSlotSwapWithPreviewCancelledEventData](t, events[0].Data) + require.Equal(t, siteName, *sysEvent.Name) +} + +func TestConsumeCloudEventWebAppServicePlanUpdatedEvent(t *testing.T) { + planName := "testPlan01" + requestContent := "[{\"source\": \"/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/testrg/providers/Microsoft.Web/serverfarms/testPlan01\", \"subject\": \"/Microsoft.Web/serverfarms/testPlan01\",\"type\": \"Microsoft.Web.AppServicePlanUpdated\", \"time\": \"2017-08-16T01:57:26.005121Z\",\"id\": \"602a88ef-0001-00e6-1233-1646070610ea\",\"data\": { \"appServicePlanEventTypeDetail\": { \"stampKind\": \"Public\",\"action\": \"Updated\",\"status\": \"Started\" },\"name\": \"testPlan01\",\"clientRequestId\": \"ce636635-2b81-4981-a9d4-cec28fb5b014\",\"correlationRequestId\": \"61baa426-c91f-4e58-b9c6-d3852c4d88d\",\"requestId\": \"0a4d5b5e-7147-482f-8e21-4219aaacf62a\",\"address\": \"/subscriptions/ef90e930-9d7f-4a60-8a99-748e0eea69de/resourcegroups/egcanarytest/providers/Microsoft.Web/sites/egtestapp/restart?api-version=2016-03-01\",\"verb\": \"POST\"},\"specversion\": \"1.0\",\"specversion\": \"1.0\"}]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.WebAppServicePlanUpdatedEventData](t, events[0].Data) + require.Equal(t, planName, *sysEvent.Name) +} + +// Policy Insights +func TestConsumeCloudEventPolicyInsightsPolicyStateChangedEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.PolicyInsights.PolicyStateChanged\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.PolicyInsightsPolicyStateChangedEventData](t, events[0].Data) + require.Equal(t, "4c2359fe-001e-00ba-0e04-585868000000", *sysEvent.PolicyDefinitionID) +} + +func TestConsumeCloudEventPolicyInsightsPolicyStateCreatedEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.PolicyInsights.PolicyStateCreated\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.PolicyInsightsPolicyStateCreatedEventData](t, events[0].Data) + require.Equal(t, "4c2359fe-001e-00ba-0e04-585868000000", *sysEvent.PolicyDefinitionID) +} + +func TestConsumeCloudEventPolicyInsightsPolicyStateDeletedEvent(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"type\":\"Microsoft.PolicyInsights.PolicyStateDeleted\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"timestamp\":\"2017-08-16T03:54:38.2696833Z\", \"policyDefinitionId\":\"4c2359fe-001e-00ba-0e04-585868000000\", \"httpRequest\":{}, \"resourceProvider\":\"Microsoft.EventGrid\", \"resourceUri\":\"/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.EventGrid/eventSubscriptions/LogicAppdd584bdf-8347-49c9-b9a9-d1f980783501\", \"subscriptionId\":\"{subscription-id}\" }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.PolicyInsightsPolicyStateDeletedEventData](t, events[0].Data) + require.Equal(t, "4c2359fe-001e-00ba-0e04-585868000000", *sysEvent.PolicyDefinitionID) +} + +// Communication events +func TestConsumeCloudEventAcsRecordingFileStatusUpdatedEventData(t *testing.T) { + requestContent := "[ { \"source\":\"/subscriptions/{subscription-id}\", \"subject\":\"/recording/call/{call-id}/recordingId/{recording-id}\", \"type\":\"Microsoft.Communication.RecordingFileStatusUpdated\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"recordingStorageInfo\": { \"recordingChunks\": [ { \"documentId\": \"0-eus-d12-801b3f3fc462fe8a01e6810cbff729b8\", \"index\": 0, \"endReason\": \"SessionEnded\", \"contentLocation\": \"https://storage.asm.skype.com/v1/objects/0-eus-d12-801b3f3fc462fe8a01e6810cbff729b8/content/video\", \"metadataLocation\": \"https://storage.asm.skype.com/v1/objects/0-eus-d12-801b3f3fc462fe8a01e6810cbff729b8/content/acsmetadata\" }]}, \"recordingChannelType\": \"Mixed\", \"recordingContentType\": \"Audio\", \"recordingFormatType\": \"Mp3\"}, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + sysEvent := deserializeSystemEvent[azsystemevents.AcsRecordingFileStatusUpdatedEventData](t, events[0].Data) + + // TODO: rename, it seems? + // require.Equal(t, azsystemevents.RecordingChannelTypeMixed, sysEvent.ChannelType) + // require.Equal(t, azsystemevents.RecordingContentTypeAudio, sysEvent.ContentType) + // require.Equal(t, azsystemevents.RecordingFormatTypeMp3, sysEvent.FormatType) + + // back compat + require.Equal(t, azsystemevents.RecordingChannelTypeMixed, *sysEvent.RecordingChannelType) + require.Equal(t, azsystemevents.RecordingContentTypeAudio, *sysEvent.RecordingContentType) + require.Equal(t, azsystemevents.RecordingFormatTypeMp3, *sysEvent.RecordingFormatType) +} + +func TestConsumeCloudEventAcsEmailDeliveryReportReceivedEvent(t *testing.T) { + requestContent := `{ + "id": "5f04f77c-2a6a-43bd-9b74-576a64c01f9e", + "source": "/subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}", + "subject": "sender/test2@contoso.org/message/950850f5-bcdf-4315-b77a-6447cf56fac9", + "data": { + "sender": "test2@contoso.org", + "recipient": "test1@contoso.com", + "messageId": "950850f5-bcdf-4315-b77a-6447cf56fac9", + "status": "Delivered", + "deliveryStatusDetails": { + "statusMessage": "DestinationMailboxFull" + }, + "deliveryAttemptTimeStamp": "2023-02-09T19:46:12.2480265+00:00" + }, + "type": "Microsoft.Communication.EmailDeliveryReportReceived", + "time": "2023-02-09T19:46:12.2478002Z", + "specversion": "1.0" + }` + + event := parseCloudEvent(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.AcsEmailDeliveryReportReceivedEventData](t, event.Data) + require.Equal(t, "test2@contoso.org", *sysEvent.Sender) + require.Equal(t, "test1@contoso.com", *sysEvent.Recipient) + require.Equal(t, azsystemevents.AcsEmailDeliveryReportStatusDelivered, *sysEvent.Status) + require.Equal(t, "DestinationMailboxFull", *sysEvent.DeliveryStatusDetails.StatusMessage) + require.Equal(t, mustParseTime(t, "2023-02-09T19:46:12.2480265+00:00"), *sysEvent.DeliveryAttemptTimestamp) +} + +func TestConsumeCloudEventAcsIncomingCallEvent(t *testing.T) { + requestContent := `{ + "id": "e80026e7-e298-46ba-bc42-dab0eda92581", + "source": "/subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}", + "subject": "/caller/{caller-id}/recipient/{recipient-id}", + "data": { + "to": { + "kind": "communicationUser", + "rawId": "{recipient-id}", + "communicationUser": { + "id": "{recipient-id}" + } + }, + "from": { + "kind": "communicationUser", + "rawId": "{caller-id}", + "communicationUser": { + "id": "{caller-id}" + } + }, + "serverCallId": "{server-call-id}", + "callerDisplayName": "VOIP Caller", + "customContext": { + "sipHeaders": { + "userToUser": "616d617a6f6e5f6368696;encoding=hex", + "X-MS-Custom-myheader1": "35567842", + "X-MS-Custom-myheader2": "customsipheadervalue" + }, + "voipHeaders": { + "customHeader": "customValue" + } + }, + "incomingCallContext": "{incoming-call-contextValue}", + "correlationId": "correlationId" + }, + "type": "Microsoft.Communication.IncomingCall", + "specversion": "1.0", + "time": "2023-04-04T17:18:42.5542219Z" + }` + + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + sysEvent := deserializeSystemEvent[azsystemevents.AcsIncomingCallEventData](t, event.Data) + + require.Equal(t, "{recipient-id}", *sysEvent.ToCommunicationIdentifier.CommunicationUser.ID) + require.Equal(t, "{caller-id}", *sysEvent.FromCommunicationIdentifier.CommunicationUser.ID) + require.Equal(t, "VOIP Caller", *sysEvent.CallerDisplayName) + require.Equal(t, "616d617a6f6e5f6368696;encoding=hex", *sysEvent.CustomContext.SipHeaders["userToUser"]) + require.Equal(t, "35567842", *sysEvent.CustomContext.SipHeaders["X-MS-Custom-myheader1"]) + require.Equal(t, "customsipheadervalue", *sysEvent.CustomContext.SipHeaders["X-MS-Custom-myheader2"]) + require.Equal(t, "customValue", *sysEvent.CustomContext.VoipHeaders["customHeader"]) + require.Equal(t, "{incoming-call-contextValue}", *sysEvent.IncomingCallContext) + require.Equal(t, "correlationId", *sysEvent.CorrelationID) +} + +func TestConsumeCloudEventAcsRouterJobClassificationFailedEvent(t *testing.T) { + requestContent := `{ + "id": "e80026e7-e298-46ba-bc42-dab0eda92581", + "source": "/subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}", + "subject": "job/{job-id}/channel/{channel-id}/classificationpolicy/{classificationpolicy-id}", + "data": { + "errors": [ + { + "code": "Failure", + "message": "Classification failed due to ", + "target": null, + "innererror": { + "code": "InnerFailure", + "message": "Classification failed due to ", + "target": null}, + "details": null + } + ], + "jobId": "7f1df17b-570b-4ae5-9cf5-fe6ff64cc712", + "channelReference": "test-abc", + "channelId": "FooVoiceChannelId", + "classificationPolicyId": "test-policy", + "labels": { + "Locale": "en-us", + "Segment": "Enterprise", + "Token": "FooToken" + }, + "tags": { + "Locale": "en-us", + "Segment": "Enterprise", + "Token": "FooToken" + } + }, + "type": "Microsoft.Communication.RouterJobClassificationFailed", + "specversion": "1.0", + "time": "2022-02-17T00:55:25.1736293Z" + }` + + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + + sysEvent := deserializeSystemEvent[azsystemevents.AcsRouterJobClassificationFailedEventData](t, event.Data) + + var errors = sysEvent.Errors + require.Equal(t, 1, len(errors)) + require.Equal(t, "Failure", *errors[0].Code) + require.Equal(t, "Classification failed due to ", *errors[0].Message) +} diff --git a/sdk/messaging/eventgrid/azsystemevents/system_events5_test.go b/sdk/messaging/eventgrid/azsystemevents/system_events5_test.go new file mode 100644 index 000000000000..c32a46be1e7b --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/system_events5_test.go @@ -0,0 +1,576 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azsystemevents_test + +import ( + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azsystemevents" + + "github.com/stretchr/testify/require" +) + +func TestConsumeCloudEventAcsRouterJobQueuedEvent(t *testing.T) { + requestContent := `{ + "id": "b6d8687a-5a1a-42ae-b8b5-ff7ec338c872", + "source": "/subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}", + "subject": "job/{job-id}/channel/{channel-id}/queue/{queue-id}", + "data": { + "jobId": "7f1df17b-570b-4ae5-9cf5-fe6ff64cc712", + "channelReference": "test-abc", + "channelId": "FooVoiceChannelId", + "queueId": "625fec06-ab81-4e60-b780-f364ed96ade1", + "priority": 1, + "labels": { + "Locale": "en-us", + "Segment": "Enterprise", + "Token": "FooToken" + }, + "tags": { + "Locale": "en-us", + "Segment": "Enterprise", + "Token": "FooToken" + }, + "requestedWorkerSelectors": [ + { + "key": "string", + "labelOperator": "Equal", + "value": 5, + "ttlSeconds": 1000 + } + ], + "attachedWorkerSelectors": [ + { + "key": "string", + "labelOperator": "Equal", + "value": 5, + "ttlSeconds": 1000, + "state": "active" + } + ] + }, + "type": "Microsoft.Communication.RouterJobQueued", + "specversion": "1.0", + "time": "2022-02-17T00:55:25.1736293Z" + }` + + event := parseCloudEvent(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.AcsRouterJobQueuedEventData](t, event.Data) + + var selectors = sysEvent.AttachedWorkerSelectors + require.Equal(t, 1, len(selectors)) + require.Equal(t, float32(1000), *selectors[0].TimeToLive) + + require.Equal(t, azsystemevents.AcsRouterLabelOperatorEqual, *selectors[0].LabelOperator) + // TODO: might have been a field rename? + //require.Equal(t, azsystemevents.AcsRouterLabelOperatorEqual, selectors[0].Operator) + + require.Equal(t, azsystemevents.AcsRouterWorkerSelectorStateActive, *selectors[0].State) + // TODO: might have been a field rename? + //require.Equal(t, azsystemevents.AcsRouterWorkerSelectorStateActive, selectors[0].SelectorState) +} + +func TestConsumeCloudEventAcsRouterJobReceivedEvent(t *testing.T) { + requestContent := `{ + "id": "acdf8fa5-8ab4-4a65-874a-c1d2a4a97f2e", + "source": "/subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}", + "subject": "job/{job-id}/channel/{channel-id}", + "data": { + "jobId": "7f1df17b-570b-4ae5-9cf5-fe6ff64cc712", + "channelReference": "test-abc", + "jobStatus": "PendingClassification", + "channelId": "FooVoiceChannelId", + "classificationPolicyId": "test-policy", + "queueId": "queue-id", + "priority": 0, + "labels": { + "Locale": "en-us", + "Segment": "Enterprise", + "Token": "FooToken" + }, + "tags": { + "Locale": "en-us", + "Segment": "Enterprise", + "Token": "FooToken" + }, + "requestedWorkerSelectors": [ + { + "key": "string", + "labelOperator": "equal", + "value": 5, + "ttlSeconds": 36 + } + ], + "scheduledOn": "2007-03-28T19:13:50+00:00", + "unavailableForMatching": false + }, + "type": "Microsoft.Communication.RouterJobReceived", + "specversion": "1.0", + "time": "2022-02-17T00:55:25.1736293Z" + }` + + // TODO: formatting for the time is different - not ISO. + // "scheduledOn": "3/28/2007 7:13:50 PM +00:00", + + event := parseCloudEvent(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.AcsRouterJobReceivedEventData](t, event.Data) + require.Equal(t, azsystemevents.AcsRouterJobStatusPendingClassification, *sysEvent.JobStatus) + + // TODO: don't have a .Status field? + //require.Equal(t, Azure.Messaging.EventGrid.azsystemevents.AcsRouterJobStatus.PendingClassification, sysEvent.Status) +} + +// Health Data Services events +func TestConsumeCloudEventFhirResourceCreatedEvent(t *testing.T) { + requestContent := "[ { \"source\": \"/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.HealthcareApis/workspaces/{workspace-name}\", \"subject\":\"{fhir-account}.fhir.azurehealthcareapis.com/Patient/e0a1f743-1a70-451f-830e-e96477163902\", \"type\":\"Microsoft.HealthcareApis.FhirResourceCreated\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"resourceType\": \"Patient\", \"resourceFhirAccount\": \"{fhir-account}.fhir.azurehealthcareapis.com\", \"resourceFhirId\": \"e0a1f743-1a70-451f-830e-e96477163902\", \"resourceVersionId\": 1 }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareFhirResourceCreatedEventData](t, events[0].Data) + require.Equal(t, azsystemevents.HealthcareFhirResourceTypePatient, *healthEvent.FhirResourceType) + require.Equal(t, "{fhir-account}.fhir.azurehealthcareapis.com", *healthEvent.FhirServiceHostName) + require.Equal(t, "e0a1f743-1a70-451f-830e-e96477163902", *healthEvent.FhirResourceID) + require.Equal(t, int64(1), *healthEvent.FhirResourceVersionID) +} + +func TestConsumeCloudEventFhirResourceUpdatedEvent(t *testing.T) { + requestContent := "[ { \"source\": \"/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.HealthcareApis/workspaces/{workspace-name}\", \"subject\":\"{fhir-account}.fhir.azurehealthcareapis.com/Patient/e0a1f743-1a70-451f-830e-e96477163902\", \"type\":\"Microsoft.HealthcareApis.FhirResourceUpdated\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"resourceType\": \"Patient\", \"resourceFhirAccount\": \"{fhir-account}.fhir.azurehealthcareapis.com\", \"resourceFhirId\": \"e0a1f743-1a70-451f-830e-e96477163902\", \"resourceVersionId\": 1 }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + require.NotEmpty(t, events) + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareFhirResourceUpdatedEventData](t, events[0].Data) + + require.Equal(t, azsystemevents.HealthcareFhirResourceTypePatient, *healthEvent.FhirResourceType) + require.Equal(t, "{fhir-account}.fhir.azurehealthcareapis.com", *healthEvent.FhirServiceHostName) + require.Equal(t, "e0a1f743-1a70-451f-830e-e96477163902", *healthEvent.FhirResourceID) + require.Equal(t, int64(1), *healthEvent.FhirResourceVersionID) +} + +func TestConsumeCloudEventFhirResourceDeletedEvent(t *testing.T) { + requestContent := "[ { \"source\": \"/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.HealthcareApis/workspaces/{workspace-name}\", \"subject\":\"{fhir-account}.fhir.azurehealthcareapis.com/Patient/e0a1f743-1a70-451f-830e-e96477163902\", \"type\":\"Microsoft.HealthcareApis.FhirResourceDeleted\", \"time\":\"2017-08-16T03:54:38.2696833Z\", \"id\":\"25b3b0d0-d79b-44d5-9963-440d4e6a9bba\", \"data\": { \"resourceType\": \"Patient\", \"resourceFhirAccount\": \"{fhir-account}.fhir.azurehealthcareapis.com\", \"resourceFhirId\": \"e0a1f743-1a70-451f-830e-e96477163902\", \"resourceVersionId\": 1 }, \"specversion\": \"1.0\" }]" + + events := parseManyCloudEvents(t, requestContent) + + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareFhirResourceDeletedEventData](t, events[0].Data) + + require.NotNil(t, healthEvent) + require.Equal(t, azsystemevents.HealthcareFhirResourceTypePatient, *healthEvent.FhirResourceType) + require.Equal(t, "{fhir-account}.fhir.azurehealthcareapis.com", *healthEvent.FhirServiceHostName) + require.Equal(t, "e0a1f743-1a70-451f-830e-e96477163902", *healthEvent.FhirResourceID) + require.Equal(t, int64(1), *healthEvent.FhirResourceVersionID) +} + +func TestConsumeCloudEventDicomImageCreatedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.HealthcareApis/workspaces/{workspace-name}", + "subject": "{dicom-account}.dicom.azurehealthcareapis.com/v1/studies/1.2.3.4.3/series/1.2.3.4.3.9423673/instances/1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "type": "Microsoft.HealthcareApis.DicomImageCreated", + "time": "2022-09-15T01:14:04.5613214Z", + "id": "d621839d-958b-4142-a638-bb966b4f7dfd", + "data": { + "partitionName": "Microsoft.Default", + "imageStudyInstanceUid": "1.2.3.4.3", + "imageSeriesInstanceUid": "1.2.3.4.3.9423673", + "imageSopInstanceUid": "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "serviceHostName": "{dicom-account}.dicom.azurehealthcareapis.com", + "sequenceNumber": 1 + }, + "specversion": "1.0" +}` + event := parseCloudEvent(t, requestContent) + + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareDicomImageCreatedEventData](t, event.Data) + + require.NotNil(t, healthEvent) + require.Equal(t, "1.2.3.4.3", *healthEvent.ImageStudyInstanceUID) + require.Equal(t, "1.2.3.4.3.9423673", *healthEvent.ImageSeriesInstanceUID) + require.Equal(t, "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", *healthEvent.ImageSopInstanceUID) + require.Equal(t, int64(1), *healthEvent.SequenceNumber) + require.Equal(t, "Microsoft.Default", *healthEvent.PartitionName) +} + +func TestConsumeCloudEventDicomImageUpdatedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.HealthcareApis/workspaces/{workspace-name}", + "subject": "{dicom-account}.dicom.azurehealthcareapis.com/v1/studies/1.2.3.4.3/series/1.2.3.4.3.9423673/instances/1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "type": "Microsoft.HealthcareApis.DicomImageUpdated", + "time": "2022-09-15T01:14:04.5613214Z", + "id": "d621839d-958b-4142-a638-bb966b4f7dfd", + "data": { + "partitionName": "Microsoft.Default", + "imageStudyInstanceUid": "1.2.3.4.3", + "imageSeriesInstanceUid": "1.2.3.4.3.9423673", + "imageSopInstanceUid": "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "serviceHostName": "{dicom-account}.dicom.azurehealthcareapis.com", + "sequenceNumber": 1 + }, + "specversion": "1.0" +}` + event := parseCloudEvent(t, requestContent) + + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareDicomImageUpdatedEventData](t, event.Data) + + require.NotNil(t, healthEvent) + require.Equal(t, "1.2.3.4.3", *healthEvent.ImageStudyInstanceUID) + require.Equal(t, "1.2.3.4.3.9423673", *healthEvent.ImageSeriesInstanceUID) + require.Equal(t, "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", *healthEvent.ImageSopInstanceUID) + require.Equal(t, int64(1), *healthEvent.SequenceNumber) + require.Equal(t, "Microsoft.Default", *healthEvent.PartitionName) +} + +func TestConsumeCloudEventDicomImageDeletedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.HealthcareApis/workspaces/{workspace-name}", + "subject": "{dicom-account}.dicom.azurehealthcareapis.com/v1/studies/1.2.3.4.3/series/1.2.3.4.3.9423673/instances/1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "type": "Microsoft.HealthcareApis.DicomImageDeleted", + "time": "2022-09-15T01:14:04.5613214Z", + "id": "d621839d-958b-4142-a638-bb966b4f7dfd", + "data": { + "partitionName": "Microsoft.Default", + "imageStudyInstanceUid": "1.2.3.4.3", + "imageSeriesInstanceUid": "1.2.3.4.3.9423673", + "imageSopInstanceUid": "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", + "serviceHostName": "{dicom-account}.dicom.azurehealthcareapis.com", + "sequenceNumber": 1 + }, + "specversion": "1.0" +}` + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + healthEvent := deserializeSystemEvent[azsystemevents.HealthcareDicomImageDeletedEventData](t, event.Data) + require.NotNil(t, healthEvent) + require.Equal(t, "1.2.3.4.3", *healthEvent.ImageStudyInstanceUID) + require.Equal(t, "1.2.3.4.3.9423673", *healthEvent.ImageSeriesInstanceUID) + require.Equal(t, "1.3.6.1.4.1.45096.2.296485376.2210.1633373143.864442", *healthEvent.ImageSopInstanceUID) + require.Equal(t, int64(1), *healthEvent.SequenceNumber) + require.Equal(t, "Microsoft.Default", *healthEvent.PartitionName) +} + +// APIM +func TestConsumeCloudEventGatewayApiAddedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}", + "subject": "/gateways/{gateway-name}/apis/example-api", + "type": "Microsoft.ApiManagement.GatewayAPIAdded", + "time": "2021-07-02T00:47:47.8536532Z", + "id": "92c502f2-a966-42a7-a428-d3b319844544", + "data": { + "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/gateways/{gateway-name}/apis/example-api" + }, + "specversion": "1.0" + }` + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + apimEvent := deserializeSystemEvent[azsystemevents.APIManagementGatewayAPIAddedEventData](t, event.Data) + require.Equal(t, "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/gateways/{gateway-name}/apis/example-api", *apimEvent.ResourceURI) +} + +func TestConsumeCloudEventGatewayApiRemovedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}", + "subject": "/gateways/{gateway-name}/apis/example-api", + "type": "Microsoft.ApiManagement.GatewayAPIRemoved", + "time": "2021-07-02T00:47:47.8536532Z", + "id": "92c502f2-a966-42a7-a428-d3b319844544", + "data": { + "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/gateways/{gateway-name}/apis/example-api" + }, + "specversion": "1.0" + }` + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + apimEvent := deserializeSystemEvent[azsystemevents.APIManagementGatewayAPIRemovedEventData](t, event.Data) + require.Equal(t, "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/gateways/{gateway-name}/apis/example-api", *apimEvent.ResourceURI) +} + +func TestConsumeCloudEventCertificateAuthorityCreatedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}", + "subject": "/gateways/{gateway-name}/apis/example-api", + "type": "Microsoft.ApiManagement.GatewayCertificateAuthorityCreated", + "time": "2021-07-02T00:47:47.8536532Z", + "id": "92c502f2-a966-42a7-a428-d3b319844544", + "data": { + "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/gateways/{gateway-name}/apis/example-api" + }, + "specversion": "1.0" + }` + event := parseCloudEvent(t, requestContent) + + apimEvent := deserializeSystemEvent[azsystemevents.APIManagementGatewayCertificateAuthorityCreatedEventData](t, event.Data) + require.Equal(t, "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/gateways/{gateway-name}/apis/example-api", *apimEvent.ResourceURI) +} + +func TestConsumeCloudEventCertificateAuthorityDeletedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}", + "subject": "/gateways/{gateway-name}/apis/example-api", + "type": "Microsoft.ApiManagement.GatewayCertificateAuthorityDeleted", + "time": "2021-07-02T00:47:47.8536532Z", + "id": "92c502f2-a966-42a7-a428-d3b319844544", + "data": { + "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/gateways/{gateway-name}/apis/example-api" + }, + "specversion": "1.0" + }` + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + apimEvent := deserializeSystemEvent[azsystemevents.APIManagementGatewayCertificateAuthorityDeletedEventData](t, event.Data) + require.Equal(t, "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/gateways/{gateway-name}/apis/example-api", *apimEvent.ResourceURI) +} + +func TestConsumeCloudEventCertificateAuthorityUpdatedEvent(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}", + "subject": "/gateways/{gateway-name}/apis/example-api", + "type": "Microsoft.ApiManagement.GatewayCertificateAuthorityUpdated", + "time": "2021-07-02T00:47:47.8536532Z", + "id": "92c502f2-a966-42a7-a428-d3b319844544", + "data": { + "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/gateways/{gateway-name}/apis/example-api" + }, + "specversion": "1.0" + }` + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + apimEvent := deserializeSystemEvent[azsystemevents.APIManagementGatewayCertificateAuthorityUpdatedEventData](t, event.Data) + require.Equal(t, "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/gateways/{gateway-name}/apis/example-api", *apimEvent.ResourceURI) +} + +// DataBox + +func TestConsumeCloudEventDataBoxCopyCompleted(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.DataBox/jobs/{your-resource}", + "subject": "/jobs/{your-resource}", + "type": "Microsoft.DataBox.CopyCompleted", + "time": "2022-10-16T02:51:26.4248221Z", + "id": "759c892a-a628-4e48-a116-2e1d54c555ce", + "data": { + "serialNumber": "SampleSerialNumber", + "stageName": "CopyCompleted", + "stageTime": "2022-10-12T19:38:08.0218897Z" + }, + "specversion": "1.0" + }` + + event := parseCloudEvent(t, requestContent) + + dataBoxEvent := deserializeSystemEvent[azsystemevents.DataBoxCopyCompletedEventData](t, event.Data) + + require.Equal(t, "SampleSerialNumber", *dataBoxEvent.SerialNumber) + require.Equal(t, azsystemevents.DataBoxStageNameCopyCompleted, *dataBoxEvent.StageName) + require.Equal(t, mustParseTime(t, "2022-10-12T19:38:08.0218897Z"), *dataBoxEvent.StageTime) +} + +func TestConsumeCloudEventDataBoxCopyStarted(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.DataBox/jobs/{your-resource}", + "subject": "/jobs/{your-resource}", + "type": "Microsoft.DataBox.CopyStarted", + "time": "2022-10-16T02:51:26.4248221Z", + "id": "759c892a-a628-4e48-a116-2e1d54c555ce", + "data": { + "serialNumber": "SampleSerialNumber", + "stageName": "CopyStarted", + "stageTime": "2022-10-12T19:38:08.0218897Z" + }, + "specversion": "1.0" + }` + + event := parseCloudEvent(t, requestContent) + + dataBoxEvent := deserializeSystemEvent[azsystemevents.DataBoxCopyStartedEventData](t, event.Data) + + require.Equal(t, "SampleSerialNumber", *dataBoxEvent.SerialNumber) + require.Equal(t, azsystemevents.DataBoxStageNameCopyStarted, *dataBoxEvent.StageName) + require.Equal(t, mustParseTime(t, "2022-10-12T19:38:08.0218897Z"), *dataBoxEvent.StageTime) +} + +func TestConsumeCloudEventDataBoxOrderCompleted(t *testing.T) { + requestContent := `{ + "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.DataBox/jobs/{your-resource}", + "subject": "/jobs/{your-resource}", + "type": "Microsoft.DataBox.OrderCompleted", + "time": "2022-10-16T02:51:26.4248221Z", + "id": "759c892a-a628-4e48-a116-2e1d54c555ce", + "data": { + "serialNumber": "SampleSerialNumber", + "stageName": "OrderCompleted", + "stageTime": "2022-10-12T19:38:08.0218897Z" + }, + "specversion": "1.0" + }` + + event := parseCloudEvent(t, requestContent) + + dataBoxEvent := deserializeSystemEvent[azsystemevents.DataBoxOrderCompletedEventData](t, event.Data) + + require.Equal(t, "SampleSerialNumber", *dataBoxEvent.SerialNumber) + require.Equal(t, azsystemevents.DataBoxStageNameOrderCompleted, *dataBoxEvent.StageName) + require.Equal(t, mustParseTime(t, "2022-10-12T19:38:08.0218897Z"), *dataBoxEvent.StageTime) +} + +// Resource Notifications + +func TestConsumeCloudEventHealthResourcesAvailiabilityStatusChangedEvent(t *testing.T) { + requestContent := `{ + "id": "1fb6fa94-d965-4306-abeq-4810f0774e97", + "source": "/subscriptions/{subscription-id}", + "subject": "/subscriptions/{subscription-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}", + "data": { + "resourceInfo": { + "id": "/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/{rg-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}/providers/Microsoft.ResourceHealth/availabilityStatuses/{event-id}", + "name": "{event-id}", + "type": "Microsoft.ResourceHealth/availabilityStatuses", + "properties": { + "targetResourceId": "/subscriptions/{subscription-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}", + "targetResourceType": "Microsoft.Compute/virtualMachines", + "occurredTime": "2023-07-24T19:20:37.9245071Z", + "previousAvailabilityState": "Unavailable", + "availabilityState": "Available" + } + }, + "operationalInfo": { + "resourceEventTime": "2023-07-24T19:20:37.9245071Z" + }, + "apiVersion": "2023-12-01" + }, + "type": "Microsoft.ResourceNotifications.HealthResources.AvailabilityStatusChanged", + "specversion": "1.0", + "time": "2023-07-24T19:20:37.9245071Z" + }` + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + availabilityStatusChangedEventData := deserializeSystemEvent[azsystemevents.ResourceNotificationsHealthResourcesAvailabilityStatusChangedEventData](t, event.Data) + + require.Equal(t, "{event-id}", *availabilityStatusChangedEventData.ResourceDetails.Name) + require.Equal(t, + "/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/{rg-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}/providers/Microsoft.ResourceHealth/availabilityStatuses/{event-id}", + *availabilityStatusChangedEventData.ResourceDetails.ID) +} + +func TestConsumeCloudEventResourceDeletedEvent(t *testing.T) { + requestContent := `{ + "id": "d4611260-d179-4f86-b196-3a9d4128be2d", + "source": "/subscriptions/{subscription-id}", + "subject": "/subscriptions/{subscription-id}/resourceGroups/{rg-name}/providers/Microsoft.Storage/storageAccounts/{storageAccount-name}", + "data": { + "resourceInfo": { + "id": "/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/{rg-name}/providers/Microsoft.Storage/storageAccounts/{storageAccount-name}", + "name": "storageAccount-name", + "type": "Microsoft.Storage/storageAccounts" + }, + "operationalInfo": { + "resourceEventTime": "2023-07-28T20:11:36.6347858Z" + } + }, + "type": "Microsoft.ResourceNotifications.Resources.Deleted", + "specversion": "1.0", + "time": "2023-07-28T20:11:36.6347858Z" + }` + event := parseCloudEvent(t, requestContent) + + require.NotEmpty(t, event) + sysEvent := deserializeSystemEvent[azsystemevents.ResourceNotificationsResourceManagementDeletedEventData](t, event.Data) + + require.Equal(t, + "/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/{rg-name}/providers/Microsoft.Storage/storageAccounts/{storageAccount-name}", + *sysEvent.ResourceDetails.ID) +} + +func TestConsumeCloudEventResourceCreatedOrUpdatedEvent(t *testing.T) { + requestContent := `{ + "id": "4eef929a-a65c-47dd-93e2-46b8c17c6c17", + "source": "/subscriptions/{subscription-id}", + "subject": "/subscriptions/{subscription-id}/resourceGroups/{rg-name}/providers/Microsoft.Storage/storageAccounts/{storageAccount-name}", + "data": { + "resourceInfo": { + "tags": {}, + "id": "/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/{rg-name}/providers/Microsoft.Storage/storageAccounts/{storageAccount-name}", + "name": "StorageAccount-name", + "type": "Microsoft.Storage/storageAccounts", + "location": "eastus", + "properties": { + "privateEndpointConnections": [], + "minimumTlsVersion": "TLS1_2", + "allowBlobPublicAccess": 1, + "allowSharedKeyAccess": 1, + "networkAcls": { + "bypass": "AzureServices", + "virtualNetworkRules": [], + "ipRules": [], + "defaultAction": "Allow" + }, + "supportsHttpsTrafficOnly": 1, + "encryption": { + "requireInfrastructureEncryption": 0, + "services": { + "file": { + "keyType": "Account", + "enabled": 1, + "lastEnabledTime": "2023-07-28T20:12:50.6380308Z" + }, + "blob": { + "keyType": "Account", + "enabled": 1, + "lastEnabledTime": "2023-07-28T20:12:50.6380308Z" + } + }, + "keySource": "Microsoft.Storage" + }, + "accessTier": "Hot", + "provisioningState": "Succeeded", + "creationTime": "2023-07-28T20:12:50.4661564Z", + "primaryEndpoints": { + "dfs": "https://{storageAccount-name}.dfs.core.windows.net/", + "web": "https://{storageAccount-name}.z13.web.core.windows.net/", + "blob": "https://{storageAccount-name}.blob.core.windows.net/", + "queue": "https://{storageAccount-name}.queue.core.windows.net/", + "table": "https://{storageAccount-name}.table.core.windows.net/", + "file": "https://{storageAccount-name}.file.core.windows.net/" + }, + "primaryLocation": "eastus", + "statusOfPrimary": "available", + "secondaryLocation": "westus", + "statusOfSecondary": "available", + "secondaryEndpoints": { + "dfs": "https://{storageAccount-name} -secondary.dfs.core.windows.net/", + "web": "https://{storageAccount-name}-secondary.z13.web.core.windows.net/", + "blob": "https://{storageAccount-name}-secondary.blob.core.windows.net/", + "queue": "https://{storageAccount-name}-secondary.queue.core.windows.net/", + "table": "https://{storageAccount-name}-secondary.table.core.windows.net/" + } + } + }, + "operationalInfo": { + "resourceEventTime": "2023-07-28T20:13:10.8418063Z" + }, + "apiVersion": "2019-06-01" + }, + "type": "Microsoft.ResourceNotifications.Resources.CreatedOrUpdated", + "specversion": "1.0", + "time": "2023-07-28T20:13:10.8418063Z" + }` + event := parseCloudEvent(t, requestContent) + + sysEvent := deserializeSystemEvent[azsystemevents.ResourceNotificationsResourceManagementCreatedOrUpdatedEventData](t, event.Data) + + require.Equal(t, + "/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/{rg-name}/providers/Microsoft.Storage/storageAccounts/{storageAccount-name}", + *sysEvent.ResourceDetails.ID) +} diff --git a/sdk/messaging/eventgrid/azsystemevents/system_events_test.go b/sdk/messaging/eventgrid/azsystemevents/system_events_test.go new file mode 100644 index 000000000000..8a1e9a4cc531 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/system_events_test.go @@ -0,0 +1,115 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azsystemevents_test + +import ( + "encoding/json" + "fmt" + "log" + "os" + "strings" + "testing" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azsystemevents" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/messaging" + "github.com/joho/godotenv" + "github.com/stretchr/testify/require" +) + +var testVars = struct { + BlobURL string + QueueURL string + ConnectionString string + QueueName string + SkipReason string +}{} + +func TestMain(m *testing.M) { + var missingVars []string + + getVar := func(name string) string { + v := os.Getenv(name) + + if v == "" { + missingVars = append(missingVars, name) + } + + return v + } + + if err := godotenv.Load(".env"); err != nil { + log.Printf("Failed to load .env file: %s", err) + } + + // os.Setenv("AZURE_CLIENT_ID", getVar("AZSYSTEMEVENTS_CLIENT_ID")) + // os.Setenv("AZURE_CLIENT_SECRET", getVar("AZSYSTEMEVENTS_CLIENT_SECRET")) + // os.Setenv("AZURE_TENANT_ID", getVar("AZSYSTEMEVENTS_TENANT_ID")) + + testVars.BlobURL = getVar("STORAGE_ACCOUNT_BLOB") + testVars.QueueURL = getVar("STORAGE_ACCOUNT_QUEUE") + testVars.QueueName = getVar("STORAGE_QUEUE_NAME") + + if len(missingVars) > 0 { + testVars.SkipReason = fmt.Sprintf("WARNING: integration tests disabled, environment variables missing (%s)", strings.Join(missingVars, ",")) + } + + os.Exit(m.Run()) +} + +func parseManyEvents(t *testing.T, str string) []azsystemevents.EventGridEvent { + var events []azsystemevents.EventGridEvent + + err := json.Unmarshal(([]byte)(str), &events) + require.NoError(t, err) + + return events +} + +func parseEvent(t *testing.T, str string) azsystemevents.EventGridEvent { + var event *azsystemevents.EventGridEvent + + err := json.Unmarshal(([]byte)(str), &event) + require.NoError(t, err) + + return *event +} + +func parseManyCloudEvents(t *testing.T, str string) []messaging.CloudEvent { + var events []messaging.CloudEvent + + err := json.Unmarshal(([]byte)(str), &events) + require.NoError(t, err) + + return events +} + +func parseCloudEvent(t *testing.T, str string) messaging.CloudEvent { + var event *messaging.CloudEvent + + err := json.Unmarshal(([]byte)(str), &event) + require.NoError(t, err) + + return *event +} + +func deserializeSystemEvent[T any](t *testing.T, payload any) T { + var val *T + + err := json.Unmarshal(payload.([]byte), &val) + require.NoError(t, err) + + return *val +} + +func mustParseTime(t *testing.T, str string) time.Time { + tm, err := time.Parse(time.RFC3339Nano, str) + require.NoError(t, err) + + return tm +} diff --git a/sdk/messaging/eventgrid/azsystemevents/test-resources.bicep b/sdk/messaging/eventgrid/azsystemevents/test-resources.bicep new file mode 100644 index 000000000000..27bd1e92356b --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/test-resources.bicep @@ -0,0 +1,10 @@ +// This is a placeholder file to trigger environment variable setting via New-TestResources.ps1 + +@description('The base resource name.') +param baseName string = resourceGroup().name + +@description('Which Azure Region to deploy the resource to. Defaults to the resource group location.') +param location string = resourceGroup().location + +@description('The principal to assign the role to. This is application object id.') +param testApplicationOid string diff --git a/sdk/messaging/eventgrid/azsystemevents/time_rfc3339.go b/sdk/messaging/eventgrid/azsystemevents/time_rfc3339.go new file mode 100644 index 000000000000..0ca566efde97 --- /dev/null +++ b/sdk/messaging/eventgrid/azsystemevents/time_rfc3339.go @@ -0,0 +1,111 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package azsystemevents + +import ( + "encoding/json" + "fmt" + "reflect" + "regexp" + "strings" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}