Skip to content

Commit

Permalink
update eventgrid (Azure#32290)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcturusZhang authored Nov 4, 2022
1 parent 8dae736 commit 7d7e1cf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public static AsyncPageable<EventTypeUnderTopic> GetEventTypesAsync(this ArmClie

var resourceGroupResource = client.GetResourceGroupResource(ResourceGroupResource.CreateResourceIdentifier(scope.SubscriptionId, scope.ResourceGroupName));

return GetExtensionClient(resourceGroupResource).GetEventTypesAsync(scope.ResourceType.Namespace, scope.SubstringAfterProviderNamespace(), scope.Name, cancellationToken);
var parentPart = scope.Parent.SubstringAfterProviderNamespace();
var resourceTypeName = (string.IsNullOrEmpty(parentPart) ? string.Empty : $"{parentPart}/") + scope.ResourceType.GetLastType();

return GetExtensionClient(resourceGroupResource).GetEventTypesAsync(scope.ResourceType.Namespace, resourceTypeName, scope.Name, cancellationToken);
}

/// <summary>
Expand All @@ -50,7 +53,10 @@ public static Pageable<EventTypeUnderTopic> GetEventTypes(this ArmClient client,

var resourceGroupResource = client.GetResourceGroupResource(ResourceGroupResource.CreateResourceIdentifier(scope.SubscriptionId, scope.ResourceGroupName));

return GetExtensionClient(resourceGroupResource).GetEventTypes(scope.ResourceType.Namespace, scope.SubstringAfterProviderNamespace(), scope.Name, cancellationToken);
var parentPart = scope.Parent.SubstringAfterProviderNamespace();
var resourceTypeName = (string.IsNullOrEmpty(parentPart) ? string.Empty : $"{parentPart}/") + scope.ResourceType.GetLastType();

return GetExtensionClient(resourceGroupResource).GetEventTypes(scope.ResourceType.Namespace, resourceTypeName, scope.Name, cancellationToken);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Azure.Core;
using NUnit.Framework;

namespace Azure.ResourceManager.EventGrid.Tests.Unit
{
public class ResourceIdentifierExtensionTests
{
[TestCase("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.EventGrid/parents/parentName", "Microsoft.EventGrid", "parents", "parentName")]
[TestCase("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.EventGrid/parents/parentName/children/childName", "Microsoft.EventGrid", "parents/parentName/children", "childName")]
public void ValidateSplitResourceIdentifierIntoParts(string rawId, string ns, string parentName, string name)
{
var scope = new ResourceIdentifier(rawId);
var parentPart = scope.Parent.SubstringAfterProviderNamespace();
var actualParentName = (string.IsNullOrEmpty(parentPart) ? string.Empty : $"{parentPart}/") + scope.ResourceType.GetLastType();
Assert.AreEqual(ns, scope.ResourceType.Namespace);
Assert.AreEqual(parentName, actualParentName);
Assert.AreEqual(name, scope.Name);
}
}
}

0 comments on commit 7d7e1cf

Please sign in to comment.