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); } } }