From f2f704ab9a10558066e613722519269e40a585dc Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Mon, 6 Nov 2023 17:35:27 -0800 Subject: [PATCH] Fix Tags property (#39776) * Fix Tags property * Generate API and fix model factory --- ...zure.Messaging.EventGrid.netstandard2.0.cs | 4 ++++ .../Customization/EventGridModelFactory.cs | 20 +++++++++++++++++++ ...urceNotificationsResourceUpdatedDetails.cs | 9 +++++++++ .../src/Generated/EventGridModelFactory.cs | 7 ++++--- ...onsResourceUpdatedDetails.Serialization.cs | 15 +++++++++++--- ...urceNotificationsResourceUpdatedDetails.cs | 9 ++++----- .../Azure.Messaging.EventGrid/src/autorest.md | 2 +- .../tests/ConsumeEventTests.cs | 2 +- 8 files changed, 55 insertions(+), 13 deletions(-) diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs index 62e600588c8d2..7685fbbda4e4d 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs @@ -296,6 +296,8 @@ public static partial class EventGridModelFactory public static Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsResourceDeletedEventData ResourceNotificationsResourceDeletedEventData(Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsResourceDeletedDetails resourceDetails = null, Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsOperationalDetails operationalDetails = null) { throw null; } public static Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsResourceManagementCreatedOrUpdatedEventData ResourceNotificationsResourceManagementCreatedOrUpdatedEventData(Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsResourceUpdatedDetails resourceDetails = null, Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsOperationalDetails operationalDetails = null, string apiVersion = null) { throw null; } public static Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsResourceManagementDeletedEventData ResourceNotificationsResourceManagementDeletedEventData(Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsResourceDeletedDetails resourceDetails = null, Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsOperationalDetails operationalDetails = null) { throw null; } + public static Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsResourceUpdatedDetails ResourceNotificationsResourceUpdatedDetails(string id = null, string name = null, string resourceType = null, string location = null, System.Collections.Generic.IReadOnlyDictionary resourceTags = null, System.Collections.Generic.IReadOnlyDictionary properties = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsResourceUpdatedDetails ResourceNotificationsResourceUpdatedDetails(string id = null, string name = null, string resourceType = null, string location = null, string tags = null, System.Collections.Generic.IReadOnlyDictionary properties = null) { throw null; } public static Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsResourceUpdatedEventData ResourceNotificationsResourceUpdatedEventData(Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsResourceUpdatedDetails resourceDetails = null, Azure.Messaging.EventGrid.SystemEvents.ResourceNotificationsOperationalDetails operationalDetails = null, string apiVersion = null) { throw null; } public static Azure.Messaging.EventGrid.SystemEvents.ResourceWriteCancelEventData ResourceWriteCancelEventData(string tenantId = null, string subscriptionId = null, string resourceGroup = null, string resourceProvider = null, string resourceUri = null, string operationName = null, string status = null, string authorization = null, string claims = null, string correlationId = null, string httpRequest = null) { throw null; } @@ -2876,8 +2878,10 @@ internal ResourceNotificationsResourceUpdatedDetails() { } public string Name { get { throw null; } } public System.Collections.Generic.IReadOnlyDictionary Properties { get { throw null; } } public Azure.Core.ResourceIdentifier Resource { get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary ResourceTags { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public string ResourceType { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public string Tags { get { throw null; } } } public partial class ResourceNotificationsResourceUpdatedEventData diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridModelFactory.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridModelFactory.cs index 976de28328180..cb004ff681e21 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridModelFactory.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridModelFactory.cs @@ -675,6 +675,26 @@ public static AcsRouterJobReceivedEventData AcsRouterJobReceivedEventData(string return new AcsRouterJobReceivedEventData(jobId, channelReference, channelId, queueId, labels, tags, status, classificationPolicyId, priority, requestedWorkerSelectors?.ToList(), scheduledOn, unavailableForMatching); } + + /// Initializes a new instance of ResourceNotificationsResourceUpdatedDetails. + /// id of the resource for which the event is being emitted. + /// name of the resource for which the event is being emitted. + /// the type of the resource for which the event is being emitted. + /// the location of the resource for which the event is being emitted. + /// the tags on the resource for which the event is being emitted. + /// properties in the payload of the resource for which the event is being emitted. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static ResourceNotificationsResourceUpdatedDetails ResourceNotificationsResourceUpdatedDetails(string id = null, string name = null, string resourceType = null, string location = null, string tags = null, IReadOnlyDictionary properties = null) + { + properties ??= new Dictionary(); + + return new ResourceNotificationsResourceUpdatedDetails(id, name, resourceType, location, + new Dictionary(), properties) + { + Tags = tags + }; + } } #pragma warning restore CA1054 // URI-like parameters should not be strings } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/ResourceNotificationsResourceUpdatedDetails.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/ResourceNotificationsResourceUpdatedDetails.cs index 6fd511c39de80..bf1a8627a778e 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/ResourceNotificationsResourceUpdatedDetails.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/ResourceNotificationsResourceUpdatedDetails.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System.Collections.Generic; using System.ComponentModel; using Azure.Core; @@ -41,5 +42,13 @@ public ResourceIdentifier Resource /// the location of the resource for which the event is being emitted. [EditorBrowsable(EditorBrowsableState.Never)] public string Location { get; } + + /// the tags on the resource for which the event is being emitted. + [EditorBrowsable(EditorBrowsableState.Never)] + public string Tags { get; internal set; } + + /// the tags on the resource for which the event is being emitted. + [CodeGenMember("Tags")] + public IReadOnlyDictionary ResourceTags { get; } } } \ No newline at end of file diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs index 169664d41482f..028f8fc2e2b63 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs @@ -3033,14 +3033,15 @@ public static HealthcareDicomImageDeletedEventData HealthcareDicomImageDeletedEv /// name of the resource for which the event is being emitted. /// the type of the resource for which the event is being emitted. /// the location of the resource for which the event is being emitted. - /// the tags on the resource for which the event is being emitted. + /// the tags on the resource for which the event is being emitted. /// properties in the payload of the resource for which the event is being emitted. /// A new instance for mocking. - public static ResourceNotificationsResourceUpdatedDetails ResourceNotificationsResourceUpdatedDetails(string id = null, string name = null, string resourceType = null, string location = null, string tags = null, IReadOnlyDictionary properties = null) + public static ResourceNotificationsResourceUpdatedDetails ResourceNotificationsResourceUpdatedDetails(string id = null, string name = null, string resourceType = null, string location = null, IReadOnlyDictionary resourceTags = null, IReadOnlyDictionary properties = null) { + resourceTags ??= new Dictionary(); properties ??= new Dictionary(); - return new ResourceNotificationsResourceUpdatedDetails(id, name, resourceType, location, tags, properties); + return new ResourceNotificationsResourceUpdatedDetails(id, name, resourceType, location, resourceTags, properties); } /// Initializes a new instance of ResourceNotificationsOperationalDetails. diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/ResourceNotificationsResourceUpdatedDetails.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/ResourceNotificationsResourceUpdatedDetails.Serialization.cs index dbb22f1a2a785..a09c983cccc3f 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/ResourceNotificationsResourceUpdatedDetails.Serialization.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/ResourceNotificationsResourceUpdatedDetails.Serialization.cs @@ -23,7 +23,7 @@ internal static ResourceNotificationsResourceUpdatedDetails DeserializeResourceN Optional name = default; Optional type = default; Optional location = default; - Optional tags = default; + Optional> tags = default; Optional> properties = default; foreach (var property in element.EnumerateObject()) { @@ -49,7 +49,16 @@ internal static ResourceNotificationsResourceUpdatedDetails DeserializeResourceN } if (property.NameEquals("tags"u8)) { - tags = property.Value.GetString(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; continue; } if (property.NameEquals("properties"u8)) @@ -74,7 +83,7 @@ internal static ResourceNotificationsResourceUpdatedDetails DeserializeResourceN continue; } } - return new ResourceNotificationsResourceUpdatedDetails(id.Value, name.Value, type.Value, location.Value, tags.Value, Optional.ToDictionary(properties)); + return new ResourceNotificationsResourceUpdatedDetails(id.Value, name.Value, type.Value, location.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties)); } } } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/ResourceNotificationsResourceUpdatedDetails.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/ResourceNotificationsResourceUpdatedDetails.cs index 5d24f3df153a1..1d1d698fa266f 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/ResourceNotificationsResourceUpdatedDetails.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/ResourceNotificationsResourceUpdatedDetails.cs @@ -16,6 +16,7 @@ public partial class ResourceNotificationsResourceUpdatedDetails /// Initializes a new instance of ResourceNotificationsResourceUpdatedDetails. internal ResourceNotificationsResourceUpdatedDetails() { + ResourceTags = new ChangeTrackingDictionary(); Properties = new ChangeTrackingDictionary(); } @@ -24,19 +25,17 @@ internal ResourceNotificationsResourceUpdatedDetails() /// name of the resource for which the event is being emitted. /// the type of the resource for which the event is being emitted. /// the location of the resource for which the event is being emitted. - /// the tags on the resource for which the event is being emitted. + /// the tags on the resource for which the event is being emitted. /// properties in the payload of the resource for which the event is being emitted. - internal ResourceNotificationsResourceUpdatedDetails(string id, string name, string resourceType, string location, string tags, IReadOnlyDictionary properties) + internal ResourceNotificationsResourceUpdatedDetails(string id, string name, string resourceType, string location, IReadOnlyDictionary resourceTags, IReadOnlyDictionary properties) { Id = id; Name = name; ResourceType = resourceType; Location = location; - Tags = tags; + ResourceTags = resourceTags; Properties = properties; } - /// the tags on the resource for which the event is being emitted. - public string Tags { get; } /// properties in the payload of the resource for which the event is being emitted. public IReadOnlyDictionary Properties { get; } } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md b/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md index a1cab0208bc10..3d4f92fa1dd9e 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md @@ -4,7 +4,7 @@ Run `dotnet build /t:GenerateCode` to generate code. ``` yaml title: EventGridClient -require: https://github.com/Azure/azure-rest-api-specs/blob/b7a863f0edae81b8261b7029caf833f2bee2ec99/specification/eventgrid/data-plane/readme.md +require: https://github.com/Azure/azure-rest-api-specs/blob/11bbc2b1df2e915a2227a6a1a48a27b9e67c3311/specification/eventgrid/data-plane/readme.md generation1-convenience-client: true model-factory-for-hlc: - MediaJobOutputAsset diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs index 324fa1e885d5f..53552c7eb3b23 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs @@ -4375,7 +4375,7 @@ public void ConsumeCloudEventResourceCreatedOrUpdatedEvent() ""subject"": ""/subscriptions/{subscription-id}/resourceGroups/{rg-name}/providers/Microsoft.Storage/storageAccounts/{storageAccount-name}"", ""data"": { ""resourceInfo"": { - ""tags"": """", + ""tags"": {}, ""id"": ""/subscriptions/319a9601-1ec0-0000-aebc-8fe82724c81e/resourceGroups/{rg-name}/providers/Microsoft.Storage/storageAccounts/{storageAccount-name}"", ""name"": ""StorageAccount-name"", ""type"": ""Microsoft.Storage/storageAccounts"",