void WritePSEventSubscriptionsList(IEnumerable <EventSubscription> eventSubscriptionsList, bool includeFullEndpointUrl)
        {
            var psEventSubscriptionsList = new List <PSEventSubscription>();

            if (eventSubscriptionsList == null)
            {
                return;
            }

            foreach (EventSubscription eventSubscription in eventSubscriptionsList)
            {
                PSEventSubscriptionListInstance psEventSubscription;

                if (includeFullEndpointUrl &&
                    eventSubscription.Destination is WebHookEventSubscriptionDestination)
                {
                    EventSubscriptionFullUrl fullUrl = this.Client.GetEventSubscriptionFullUrl(eventSubscription.Topic, eventSubscription.Name);
                    psEventSubscription = new PSEventSubscriptionListInstance(eventSubscription, fullUrl.EndpointUrl);
                }
                else
                {
                    psEventSubscription = new PSEventSubscriptionListInstance(eventSubscription);
                }

                psEventSubscriptionsList.Add(psEventSubscription);
            }

            this.WriteObject(psEventSubscriptionsList, true);
        }
        public PSEventSubscriptionListPagedInstance(
            IEnumerable <EventSubscription> eventSubscriptionsList,
            EventGridClient client,
            bool includeFullEndpointUrl,
            string nextLink)
        {
            foreach (EventSubscription eventSubscription in eventSubscriptionsList)
            {
                PSEventSubscriptionListInstance psEventSubscription;

                if (includeFullEndpointUrl && eventSubscription.Destination is WebHookEventSubscriptionDestination)
                {
                    EventSubscriptionFullUrl fullUrl = client.GetEventSubscriptionFullUrl(eventSubscription.Topic, eventSubscription.Name);
                    psEventSubscription = new PSEventSubscriptionListInstance(eventSubscription, fullUrl.EndpointUrl);
                }
                else
                {
                    psEventSubscription = new PSEventSubscriptionListInstance(eventSubscription);
                }

                this.PsEventSubscriptionsList.Add(psEventSubscription);
            }

            this.NextLink = nextLink;
        }
Beispiel #3
0
        void RetrieveAndWriteEventSubscription(string scope, string eventSubscriptionName, bool includeFullEndpointUrl)
        {
            EventSubscription   eventSubscription = this.Client.GetEventSubscription(scope, eventSubscriptionName);
            PSEventSubscription psEventSubscription;

            if (includeFullEndpointUrl &&
                eventSubscription.Destination is WebHookEventSubscriptionDestination)
            {
                EventSubscriptionFullUrl fullUrl = this.Client.GetEventSubscriptionFullUrl(scope, eventSubscriptionName);
                psEventSubscription = new PSEventSubscription(eventSubscription, fullUrl.EndpointUrl);
            }
            else
            {
                psEventSubscription = new PSEventSubscription(eventSubscription);
            }

            this.WriteObject(psEventSubscription);
        }
        public override void ExecuteCmdlet()
        {
            EventSubscriptionFullUrl eventSubscriptionFullUrl = this.Client.GetAzFullUrlForSystemTopicEventSubscription(this.ResourceGroupName, this.SystemTopicName, this.EventSubscriptionName);

            this.WriteObject(eventSubscriptionFullUrl.EndpointUrl, true);
        }
Beispiel #5
0
        public override void ExecuteCmdlet()
        {
            string newNextLink            = null;
            int?   providedTop            = null;
            bool   includeFullEndpointUrl = this.IncludeFullEndpointUrl.IsPresent;

            if (string.IsNullOrEmpty(this.ResourceGroupName))
            {
                throw new ArgumentNullException(
                          this.ResourceGroupName,
                          "Resource Group Name should be specified to retrieve event subscriptions for a system topic");
            }

            if (string.IsNullOrEmpty(this.SystemTopicName))
            {
                throw new ArgumentNullException(
                          this.SystemTopicName,
                          "System topic Name should be specified to retrieve event subscriptions for a system topic");
            }

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

            if (!string.IsNullOrEmpty(this.EventSubscriptionName))
            {
                EventSubscription   eventSubscription = this.Client.GetSystemTopicEventSubscriptiion(this.ResourceGroupName, this.SystemTopicName, this.EventSubscriptionName);
                PSEventSubscription psEventSubscription;

                if (includeFullEndpointUrl &&
                    eventSubscription.Destination is WebHookEventSubscriptionDestination)
                {
                    EventSubscriptionFullUrl fullUrl = this.Client.GetAzFullUrlForSystemTopicEventSubscription(this.ResourceGroupName, this.SystemTopicName, this.EventSubscriptionName);
                    psEventSubscription = new PSEventSubscription(eventSubscription, fullUrl.EndpointUrl);
                }
                else
                {
                    psEventSubscription = new PSEventSubscription(eventSubscription);
                }

                this.WriteObject(psEventSubscription);
            }
            else
            {
                // EventSubscription name was not specified, we need to retrieve a list of
                // event subscriptions based on the provided parameters.
                IEnumerable <EventSubscription> eventSubscriptionsList = null;

                // Other parameters should be null or ignored if this.NextLink is specified.
                if (!string.IsNullOrEmpty(this.NextLink))
                {
                    (eventSubscriptionsList, newNextLink) = this.Client.ListSystemTopicEventSubscriptionsNext(this.NextLink);
                }
                else
                {
                    (eventSubscriptionsList, newNextLink) = this.Client.ListSystemTopicEventSubscriptions(this.ResourceGroupName, this.SystemTopicName, this.ODataQuery, providedTop);
                }

                this.WritePSEventSubscriptionsList(eventSubscriptionsList, includeFullEndpointUrl, newNextLink);
            }
        }