Esempio n. 1
0
 public PSDomainTopic(DomainTopic domainTopic)
 {
     this.Id                = domainTopic.Id;
     this.DomainName        = this.GetDomainNameFromDomainTopic(domainTopic);
     this.DomainTopicName   = domainTopic.Name;
     this.Type              = domainTopic.Type;
     this.ResourceGroupName = EventGridUtils.ParseResourceGroupFromId(domainTopic.Id);
     this.ProvisioningState = domainTopic.ProvisioningState;
 }
Esempio n. 2
0
 public override void ExecuteCmdlet()
 {
     // Create a new Event Grid Domain Topic
     if (this.ShouldProcess(this.Name, $"Create a new EventGrid domain topic under domain {this.DomainName} in Resource Group {this.ResourceGroupName}"))
     {
         DomainTopic   domainTopic   = this.Client.CreateDomainTopic(this.ResourceGroupName, this.DomainName, this.Name);
         PSDomainTopic psDomainTopic = new PSDomainTopic(domainTopic);
         this.WriteObject(psDomainTopic);
     }
 }
        public override void ExecuteCmdlet()
        {
            string resourceGroupName = string.Empty;
            string domainName        = string.Empty;
            string domainTopicName   = string.Empty;
            string newNextLink       = null;
            IEnumerable <DomainTopic>        domainTopicsList;
            List <PSDomainTopicListInstance> psDomainTopicsList = new List <PSDomainTopicListInstance>();
            int?providedTop = null;

            if (MyInvocation.BoundParameters.ContainsKey(nameof(this.Top)))
            {
                providedTop = this.Top;
            }

            if (!string.IsNullOrEmpty(this.ResourceId))
            {
                EventGridUtils.GetResourceGroupNameAndDomainNameAndDomainTopicName(this.ResourceId, out resourceGroupName, out domainName, out domainTopicName);
            }
            else
            {
                resourceGroupName = this.ResourceGroupName;
                domainName        = this.DomainName;
                domainTopicName   = this.Name;
            }

            // Other parameters should be null or ignored if this.NextLink is specified.
            if (!string.IsNullOrEmpty(this.NextLink))
            {
                // Get Next page of domain topics.
                (domainTopicsList, newNextLink) = this.Client.ListDomainTopicsByDomainNext(this.NextLink);

                PSDomainTopicListPagedInstance pSDomainTopicListPagedInstance = new PSDomainTopicListPagedInstance(domainTopicsList, newNextLink);
                this.WriteObject(pSDomainTopicListPagedInstance, true);
            }
            else if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(domainName))
            {
                if (!string.IsNullOrEmpty(domainTopicName))
                {
                    // Get details of the Event Grid domain topic
                    DomainTopic   domainTopic   = this.Client.GetDomainTopic(resourceGroupName, domainName, domainTopicName);
                    PSDomainTopic psDomainTopic = new PSDomainTopic(domainTopic);
                    this.WriteObject(psDomainTopic);
                }
                else
                {
                    // List all Event Grid domain topics in the given resource group/domain
                    (domainTopicsList, newNextLink) = this.Client.ListDomainTopicsByDomain(resourceGroupName, domainName, this.ODataQuery, providedTop);
                    PSDomainTopicListPagedInstance pSDomainTopicListPagedInstance = new PSDomainTopicListPagedInstance(domainTopicsList, newNextLink);
                    this.WriteObject(pSDomainTopicListPagedInstance, true);
                }
            }
        }
Esempio n. 4
0
 string GetDomainNameFromDomainTopic(DomainTopic domainTopic)
 {
     string[] tokens = domainTopic.Id.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
     if (tokens.Length == 10)
     {
         return(tokens[7]);
     }
     else
     {
         throw new ArgumentException("Unsupported value for domainTopic Id.");
     }
 }
Esempio n. 5
0
        public async Task <DomainTopic> RegisterDomainTopic(string credentialsAzureSubscriptionId, string credentialsTenantId, string credentialsClientId,
                                                            string domainName, string credentialsClientSecret, string resourceGroupName, string topicName)
        {
            try
            {
                //Management SDKs (Microsoft.Azure.Management.EventGrid)
                EventGridManagementClient managementClient = new EventGridManagementClient(credentials: new CustomLoginCredentials(credentialsTenantId, credentialsClientId, credentialsClientSecret));
                managementClient.SubscriptionId = credentialsAzureSubscriptionId;
                DomainTopic createdTopic = await managementClient.DomainTopics.CreateOrUpdateAsync(resourceGroupName : resourceGroupName,
                                                                                                   domainName : domainName, domainTopicName : topicName);

                return(createdTopic);
            }
            catch (Exception ex)
            {
                _logger?.LogError($"Unknown Exception. Type: {ex.GetType().ToString()} ; Message: {ex.Message} ; Details: {ex.ToString()}");
                return(null);
            }
        }
Esempio n. 6
0
        public void DomainCreateGetUpdateDelete()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                this.InitializeClients(context);

                var location = this.ResourceManagementClient.GetLocationFromProvider();

                var resourceGroup = this.ResourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(EventGridManagementHelper.ResourceGroupPrefix);
                    this.ResourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                var domainName       = TestUtilities.GenerateName(EventGridManagementHelper.DomainPrefix);
                var domainTopicName1 = TestUtilities.GenerateName(EventGridManagementHelper.DomainTopicPrefix);
                var domainTopicName2 = TestUtilities.GenerateName(EventGridManagementHelper.DomainTopicPrefix);

                // Temporarily commenting this out as this is not yet enabled for the new API version
                // var operationsResponse = this.EventGridManagementClient.Operations.List();

                var originalTagsDictionary = new Dictionary <string, string>()
                {
                    { "originalTag1", "originalValue1" },
                    { "originalTag2", "originalValue2" }
                };

                Domain domain = new Domain()
                {
                    Location           = location,
                    Tags               = originalTagsDictionary,
                    InputSchema        = InputSchema.CloudEventSchemaV10,
                    InputSchemaMapping = new JsonInputSchemaMapping()
                    {
                        Topic = new JsonField("myTopicField")
                    }
                };

                var createDomainResponse = this.EventGridManagementClient.Domains.CreateOrUpdateAsync(resourceGroup, domainName, domain).Result;

                Assert.NotNull(createDomainResponse);
                Assert.Equal(createDomainResponse.Name, domainName);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Get the created domain
                var getDomainResponse = this.EventGridManagementClient.Domains.Get(resourceGroup, domainName);
                if (string.Compare(getDomainResponse.ProvisioningState, "Succeeded", true) != 0)
                {
                    TestUtilities.Wait(TimeSpan.FromSeconds(5));
                }

                getDomainResponse = this.EventGridManagementClient.Domains.Get(resourceGroup, domainName);
                Assert.NotNull(getDomainResponse);
                Assert.Equal("Succeeded", getDomainResponse.ProvisioningState, StringComparer.CurrentCultureIgnoreCase);
                Assert.Equal(location, getDomainResponse.Location, StringComparer.CurrentCultureIgnoreCase);
                Assert.Contains(getDomainResponse.Tags, tag => tag.Key == "originalTag1");

                //// Diable test as identity is not part of GA Version yet.
                //// Assert.Null(getDomainResponse.Identity);
                Assert.Null(getDomainResponse.InboundIpRules);

                // Get all domains created within a resourceGroup
                IPage <Domain> domainsInResourceGroupPage = this.EventGridManagementClient.Domains.ListByResourceGroupAsync(resourceGroup).Result;
                var            domainsInResourceGroupList = new List <Domain>();
                if (domainsInResourceGroupPage.Any())
                {
                    domainsInResourceGroupList.AddRange(domainsInResourceGroupPage);
                    var nextLink = domainsInResourceGroupPage.NextPageLink;
                    while (nextLink != null)
                    {
                        domainsInResourceGroupPage = this.EventGridManagementClient.Domains.ListByResourceGroupNextAsync(nextLink).Result;
                        domainsInResourceGroupList.AddRange(domainsInResourceGroupPage);
                        nextLink = domainsInResourceGroupPage.NextPageLink;
                    }
                }

                Assert.NotNull(domainsInResourceGroupList);
                Assert.True(domainsInResourceGroupList.Count() >= 1);
                Assert.Contains(domainsInResourceGroupList, t => t.Name == domainName);
                Assert.True(domainsInResourceGroupList.All(ns => ns.Id.Contains(resourceGroup)));

                IPage <Domain> domainsInResourceGroupPageWithTop = this.EventGridManagementClient.Domains.ListByResourceGroupAsync(resourceGroup, null, 5).Result;
                var            domainsInResourceGroupListWithTop = new List <Domain>();
                if (domainsInResourceGroupPageWithTop.Any())
                {
                    domainsInResourceGroupListWithTop.AddRange(domainsInResourceGroupPageWithTop);
                    var nextLink = domainsInResourceGroupPageWithTop.NextPageLink;
                    while (nextLink != null)
                    {
                        domainsInResourceGroupPageWithTop = this.EventGridManagementClient.Domains.ListByResourceGroupNextAsync(nextLink).Result;
                        domainsInResourceGroupListWithTop.AddRange(domainsInResourceGroupPageWithTop);
                        nextLink = domainsInResourceGroupPageWithTop.NextPageLink;
                    }
                }

                Assert.NotNull(domainsInResourceGroupListWithTop);
                Assert.True(domainsInResourceGroupListWithTop.Count() >= 1);
                Assert.Contains(domainsInResourceGroupListWithTop, t => t.Name == domainName);
                Assert.True(domainsInResourceGroupListWithTop.All(ns => ns.Id.Contains(resourceGroup)));

                // Get all domains created within the subscription irrespective of the resourceGroup
                IPage <Domain> domainsInAzureSubscription     = this.EventGridManagementClient.Domains.ListBySubscriptionAsync(null, 100).Result;
                var            domainsInAzureSubscriptionList = new List <Domain>();
                if (domainsInAzureSubscription.Any())
                {
                    domainsInAzureSubscriptionList.AddRange(domainsInAzureSubscription);
                    var nextLink = domainsInAzureSubscription.NextPageLink;
                    while (nextLink != null)
                    {
                        try
                        {
                            domainsInAzureSubscription = this.EventGridManagementClient.Domains.ListBySubscriptionNextAsync(nextLink).Result;
                            domainsInAzureSubscriptionList.AddRange(domainsInAzureSubscription);
                            nextLink = domainsInAzureSubscription.NextPageLink;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                            break;
                        }
                    }
                }

                Assert.NotNull(domainsInAzureSubscriptionList);
                Assert.True(domainsInAzureSubscriptionList.Count() >= 1);
                Assert.Contains(domainsInAzureSubscriptionList, t => t.Name == domainName);

                var replaceDomainTagsDictionary = new Dictionary <string, string>()
                {
                    { "replacedTag1", "replacedValue1" },
                    { "replacedTag2", "replacedValue2" }
                };

                // Replace the domain
                domain.Tags = replaceDomainTagsDictionary;
                var replaceDomainResponse = this.EventGridManagementClient.Domains.CreateOrUpdateAsync(resourceGroup, domainName, domain).Result;

                Assert.Contains(replaceDomainResponse.Tags, tag => tag.Key == "replacedTag1");
                Assert.DoesNotContain(replaceDomainResponse.Tags, tag => tag.Key == "originalTag1");

                // Update the domain with tags & allow traffic from all ips
                var domainUpdateParameters = new DomainUpdateParameters()
                {
                    Tags = new Dictionary <string, string>()
                    {
                        { "updatedTag1", "updatedValue1" },
                        { "updatedTag2", "updatedValue2" }
                    },
                    PublicNetworkAccess = PublicNetworkAccess.Enabled,
                };

                var updateDomainResponse = this.EventGridManagementClient.Domains.UpdateAsync(resourceGroup, domainName, domainUpdateParameters).Result;
                Assert.Contains(updateDomainResponse.Tags, tag => tag.Key == "updatedTag1");
                Assert.DoesNotContain(updateDomainResponse.Tags, tag => tag.Key == "replacedTag1");
                Assert.True(updateDomainResponse.PublicNetworkAccess == PublicNetworkAccess.Enabled);
                Assert.Null(updateDomainResponse.InboundIpRules);

                // Update the Topic with IP filtering feature
                domain.PublicNetworkAccess = PublicNetworkAccess.Disabled;
                domain.InboundIpRules      = new List <InboundIpRule>();
                domain.InboundIpRules.Add(new InboundIpRule()
                {
                    Action = IpActionType.Allow, IpMask = "12.35.67.98"
                });
                domain.InboundIpRules.Add(new InboundIpRule()
                {
                    Action = IpActionType.Allow, IpMask = "12.35.90.100"
                });
                var updateDomainResponseWithIpFilteringFeature = this.EventGridManagementClient.Domains.CreateOrUpdateAsync(resourceGroup, domainName, domain).Result;
                Assert.False(updateDomainResponseWithIpFilteringFeature.PublicNetworkAccess == PublicNetworkAccess.Enabled);
                Assert.True(updateDomainResponseWithIpFilteringFeature.InboundIpRules.Count() == 2);

                // Create domain topic manually.
                DomainTopic createDomainTopicResponse = this.EventGridManagementClient.DomainTopics.CreateOrUpdateAsync(resourceGroup, domainName, domainTopicName1).Result;

                Assert.NotNull(createDomainTopicResponse);
                Assert.Equal(createDomainTopicResponse.Name, domainTopicName1);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Get the created domain Topic
                var getDomainTopicResponse = this.EventGridManagementClient.DomainTopics.Get(resourceGroup, domainName, domainTopicName1);
                if (string.Compare(getDomainTopicResponse.ProvisioningState, "Succeeded", true) != 0)
                {
                    TestUtilities.Wait(TimeSpan.FromSeconds(5));
                }

                getDomainTopicResponse = this.EventGridManagementClient.DomainTopics.Get(resourceGroup, domainName, domainTopicName1);
                Assert.NotNull(getDomainTopicResponse);
                Assert.Equal("Succeeded", getDomainTopicResponse.ProvisioningState, StringComparer.CurrentCultureIgnoreCase);

                createDomainTopicResponse = this.EventGridManagementClient.DomainTopics.CreateOrUpdateAsync(resourceGroup, domainName, domainTopicName2).Result;

                Assert.NotNull(createDomainTopicResponse);
                Assert.Equal(createDomainTopicResponse.Name, domainTopicName2);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Get the created domain Topic
                getDomainTopicResponse = this.EventGridManagementClient.DomainTopics.Get(resourceGroup, domainName, domainTopicName2);
                if (string.Compare(getDomainTopicResponse.ProvisioningState, "Succeeded", true) != 0)
                {
                    TestUtilities.Wait(TimeSpan.FromSeconds(5));
                }

                getDomainTopicResponse = this.EventGridManagementClient.DomainTopics.Get(resourceGroup, domainName, domainTopicName2);
                Assert.NotNull(getDomainTopicResponse);
                Assert.Equal("Succeeded", getDomainTopicResponse.ProvisioningState, StringComparer.CurrentCultureIgnoreCase);


                // Get all domainTopics created within a resourceGroup
                IPage <DomainTopic> domainTopicsInDomainPage = this.EventGridManagementClient.DomainTopics.ListByDomainAsync(resourceGroup, domainName).Result;
                var domainTopicsInResourceGroupList          = new List <DomainTopic>();
                if (domainTopicsInDomainPage.Any())
                {
                    domainTopicsInResourceGroupList.AddRange(domainTopicsInDomainPage);
                    var nextLink = domainTopicsInDomainPage.NextPageLink;
                    while (nextLink != null)
                    {
                        domainTopicsInDomainPage = this.EventGridManagementClient.DomainTopics.ListByDomainNextAsync(nextLink).Result;
                        domainTopicsInResourceGroupList.AddRange(domainTopicsInDomainPage);
                        nextLink = domainTopicsInDomainPage.NextPageLink;
                    }
                }

                Assert.NotNull(domainTopicsInResourceGroupList);
                Assert.True(domainTopicsInResourceGroupList.Count() == 2);
                Assert.Contains(domainTopicsInResourceGroupList, t => t.Name == domainTopicName1);
                Assert.Contains(domainTopicsInResourceGroupList, t => t.Name == domainTopicName2);
                Assert.True(domainTopicsInResourceGroupList.All(ns => ns.Id.Contains(resourceGroup)));
                Assert.True(domainTopicsInResourceGroupList.All(ns => ns.Id.Contains(domainName)));

                // Delete domainTopics
                this.EventGridManagementClient.DomainTopics.DeleteAsync(resourceGroup, domainName, domainTopicName1).Wait();
                this.EventGridManagementClient.DomainTopics.DeleteAsync(resourceGroup, domainName, domainTopicName2).Wait();

                // Delete domain
                this.EventGridManagementClient.Domains.DeleteAsync(resourceGroup, domainName).Wait();
            }
        }
Esempio n. 7
0
        public void DomainCreateGetUpdateDelete()
        {
            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                this.InitializeClients(context);

                var location = this.ResourceManagementClient.GetLocationFromProvider();

                var resourceGroup = this.ResourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(EventGridManagementHelper.ResourceGroupPrefix);
                    this.ResourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                var domainName       = TestUtilities.GenerateName(EventGridManagementHelper.DomainPrefix);
                var domainTopicName1 = TestUtilities.GenerateName(EventGridManagementHelper.DomainTopicPrefix);
                var domainTopicName2 = TestUtilities.GenerateName(EventGridManagementHelper.DomainTopicPrefix);

                // Temporarily commenting this out as this is not yet enabled for the new API version
                // var operationsResponse = this.EventGridManagementClient.Operations.List();

                var originalTagsDictionary = new Dictionary <string, string>()
                {
                    { "originalTag1", "originalValue1" },
                    { "originalTag2", "originalValue2" }
                };

                Domain domain = new Domain()
                {
                    Location = location,
                    Tags     = originalTagsDictionary
                };

                var createDomainResponse = this.EventGridManagementClient.Domains.CreateOrUpdateAsync(resourceGroup, domainName, domain).Result;

                Assert.NotNull(createDomainResponse);
                Assert.Equal(createDomainResponse.Name, domainName);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Get the created domain
                var getDomainResponse = this.EventGridManagementClient.Domains.Get(resourceGroup, domainName);
                if (string.Compare(getDomainResponse.ProvisioningState, "Succeeded", true) != 0)
                {
                    TestUtilities.Wait(TimeSpan.FromSeconds(5));
                }

                getDomainResponse = this.EventGridManagementClient.Domains.Get(resourceGroup, domainName);
                Assert.NotNull(getDomainResponse);
                Assert.Equal("Succeeded", getDomainResponse.ProvisioningState, StringComparer.CurrentCultureIgnoreCase);
                Assert.Equal(location, getDomainResponse.Location, StringComparer.CurrentCultureIgnoreCase);
                Assert.Contains(getDomainResponse.Tags, tag => tag.Key == "originalTag1");

                // Get all domains created within a resourceGroup
                IPage <Domain> domainsInResourceGroupPage = this.EventGridManagementClient.Domains.ListByResourceGroupAsync(resourceGroup).Result;
                var            domainsInResourceGroupList = new List <Domain>();
                if (domainsInResourceGroupPage.Any())
                {
                    domainsInResourceGroupList.AddRange(domainsInResourceGroupPage);
                    var nextLink = domainsInResourceGroupPage.NextPageLink;
                    while (nextLink != null)
                    {
                        domainsInResourceGroupPage = this.EventGridManagementClient.Domains.ListByResourceGroupNextAsync(nextLink).Result;
                        domainsInResourceGroupList.AddRange(domainsInResourceGroupPage);
                        nextLink = domainsInResourceGroupPage.NextPageLink;
                    }
                }

                Assert.NotNull(domainsInResourceGroupList);
                Assert.True(domainsInResourceGroupList.Count() >= 1);
                Assert.Contains(domainsInResourceGroupList, t => t.Name == domainName);
                Assert.True(domainsInResourceGroupList.All(ns => ns.Id.Contains(resourceGroup)));

                IPage <Domain> domainsInResourceGroupPageWithTop = this.EventGridManagementClient.Domains.ListByResourceGroupAsync(resourceGroup, null, 5).Result;
                var            domainsInResourceGroupListWithTop = new List <Domain>();
                if (domainsInResourceGroupPageWithTop.Any())
                {
                    domainsInResourceGroupListWithTop.AddRange(domainsInResourceGroupPageWithTop);
                    var nextLink = domainsInResourceGroupPageWithTop.NextPageLink;
                    while (nextLink != null)
                    {
                        domainsInResourceGroupPageWithTop = this.EventGridManagementClient.Domains.ListByResourceGroupNextAsync(nextLink).Result;
                        domainsInResourceGroupListWithTop.AddRange(domainsInResourceGroupPageWithTop);
                        nextLink = domainsInResourceGroupPageWithTop.NextPageLink;
                    }
                }

                Assert.NotNull(domainsInResourceGroupListWithTop);
                Assert.True(domainsInResourceGroupListWithTop.Count() >= 1);
                Assert.Contains(domainsInResourceGroupListWithTop, t => t.Name == domainName);
                Assert.True(domainsInResourceGroupListWithTop.All(ns => ns.Id.Contains(resourceGroup)));

                // Get all domains created within the subscription irrespective of the resourceGroup
                IPage <Domain> domainsInAzureSubscription     = this.EventGridManagementClient.Domains.ListBySubscriptionAsync(null, 100).Result;
                var            domainsInAzureSubscriptionList = new List <Domain>();
                if (domainsInAzureSubscription.Any())
                {
                    domainsInAzureSubscriptionList.AddRange(domainsInAzureSubscription);
                    var nextLink = domainsInAzureSubscription.NextPageLink;
                    while (nextLink != null)
                    {
                        try
                        {
                            domainsInAzureSubscription = this.EventGridManagementClient.Domains.ListBySubscriptionNextAsync(nextLink).Result;
                            domainsInAzureSubscriptionList.AddRange(domainsInAzureSubscription);
                            nextLink = domainsInAzureSubscription.NextPageLink;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                }

                Assert.NotNull(domainsInAzureSubscriptionList);
                Assert.True(domainsInAzureSubscriptionList.Count() >= 1);
                Assert.Contains(domainsInAzureSubscriptionList, t => t.Name == domainName);

                var replaceDomainTagsDictionary = new Dictionary <string, string>()
                {
                    { "replacedTag1", "replacedValue1" },
                    { "replacedTag2", "replacedValue2" }
                };

                // Replace the domain
                domain.Tags = replaceDomainTagsDictionary;
                var replaceDomainResponse = this.EventGridManagementClient.Domains.CreateOrUpdateAsync(resourceGroup, domainName, domain).Result;

                Assert.Contains(replaceDomainResponse.Tags, tag => tag.Key == "replacedTag1");
                Assert.DoesNotContain(replaceDomainResponse.Tags, tag => tag.Key == "originalTag1");

                // Update the domain
                var updateDomainTagsDictionary = new Dictionary <string, string>()
                {
                    { "updatedTag1", "updatedValue1" },
                    { "updatedTag2", "updatedValue2" }
                };

                var updateDomainResponse = this.EventGridManagementClient.Domains.UpdateAsync(resourceGroup, domainName, updateDomainTagsDictionary).Result;
                Assert.Contains(updateDomainResponse.Tags, tag => tag.Key == "updatedTag1");
                Assert.DoesNotContain(updateDomainResponse.Tags, tag => tag.Key == "replacedTag1");

                // Create domain topic manually.

                DomainTopic createDomainTopicResponse = this.EventGridManagementClient.DomainTopics.CreateOrUpdateAsync(resourceGroup, domainName, domainTopicName1).Result;

                Assert.NotNull(createDomainTopicResponse);
                Assert.Equal(createDomainTopicResponse.Name, domainTopicName1);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Get the created domain Topic
                var getDomainTopicResponse = this.EventGridManagementClient.DomainTopics.Get(resourceGroup, domainName, domainTopicName1);
                if (string.Compare(getDomainTopicResponse.ProvisioningState, "Succeeded", true) != 0)
                {
                    TestUtilities.Wait(TimeSpan.FromSeconds(5));
                }

                getDomainTopicResponse = this.EventGridManagementClient.DomainTopics.Get(resourceGroup, domainName, domainTopicName1);
                Assert.NotNull(getDomainTopicResponse);
                Assert.Equal("Succeeded", getDomainTopicResponse.ProvisioningState, StringComparer.CurrentCultureIgnoreCase);

                createDomainTopicResponse = this.EventGridManagementClient.DomainTopics.CreateOrUpdateAsync(resourceGroup, domainName, domainTopicName2).Result;

                Assert.NotNull(createDomainTopicResponse);
                Assert.Equal(createDomainTopicResponse.Name, domainTopicName2);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Get the created domain Topic
                getDomainTopicResponse = this.EventGridManagementClient.DomainTopics.Get(resourceGroup, domainName, domainTopicName2);
                if (string.Compare(getDomainTopicResponse.ProvisioningState, "Succeeded", true) != 0)
                {
                    TestUtilities.Wait(TimeSpan.FromSeconds(5));
                }

                getDomainTopicResponse = this.EventGridManagementClient.DomainTopics.Get(resourceGroup, domainName, domainTopicName2);
                Assert.NotNull(getDomainTopicResponse);
                Assert.Equal("Succeeded", getDomainTopicResponse.ProvisioningState, StringComparer.CurrentCultureIgnoreCase);


                // Get all domainTopics created within a resourceGroup
                IPage <DomainTopic> domainTopicsInDomainPage = this.EventGridManagementClient.DomainTopics.ListByDomainAsync(resourceGroup, domainName).Result;
                var domainTopicsInResourceGroupList          = new List <DomainTopic>();
                if (domainTopicsInDomainPage.Any())
                {
                    domainTopicsInResourceGroupList.AddRange(domainTopicsInDomainPage);
                    var nextLink = domainTopicsInDomainPage.NextPageLink;
                    while (nextLink != null)
                    {
                        domainTopicsInDomainPage = this.EventGridManagementClient.DomainTopics.ListByDomainNextAsync(nextLink).Result;
                        domainTopicsInResourceGroupList.AddRange(domainTopicsInDomainPage);
                        nextLink = domainTopicsInDomainPage.NextPageLink;
                    }
                }

                Assert.NotNull(domainTopicsInResourceGroupList);
                Assert.True(domainTopicsInResourceGroupList.Count() == 2);
                Assert.Contains(domainTopicsInResourceGroupList, t => t.Name == domainTopicName1);
                Assert.Contains(domainTopicsInResourceGroupList, t => t.Name == domainTopicName2);
                Assert.True(domainTopicsInResourceGroupList.All(ns => ns.Id.Contains(resourceGroup)));
                Assert.True(domainTopicsInResourceGroupList.All(ns => ns.Id.Contains(domainName)));

                // Delete domainTopics
                this.EventGridManagementClient.DomainTopics.DeleteAsync(resourceGroup, domainName, domainTopicName1).Wait();
                this.EventGridManagementClient.DomainTopics.DeleteAsync(resourceGroup, domainName, domainTopicName2).Wait();

                // Delete domain
                this.EventGridManagementClient.Domains.DeleteAsync(resourceGroup, domainName).Wait();
            }
        }
 public PSDomainTopicListInstance(DomainTopic domainTopic) :
     base(domainTopic)
 {
 }