protected override void ExecuteCmdlet()
        {
            // NOTE: Currently only supports List Webhooks
            if (ParameterSpecified(nameof(List)))
            {
                // Ensure we didn't get piped in a null, i.e. when running Get-PnPList -Identity "ThisListDoesNotExist" | Get-PnPWebhookSubscriptions
                if (List == null)
                {
                    throw new PSArgumentNullException(nameof(List));
                }

                // Get the list from the currently selected web
                List list = List.GetList(SelectedWeb);
                if (list != null)
                {
                    // Get all the webhook subscriptions for the specified list
                    WriteObject(list.GetWebhookSubscriptions());
                }
                else
                {
                    throw new PSArgumentOutOfRangeException(nameof(List), List.ToString(), string.Format(Resources.ListNotFound, List.ToString()));
                }
            }
            else
            {
                throw new PSNotImplementedException(Resources.WebhooksOnlySupportsLists);
            }
        }
Esempio n. 2
0
        protected override void ExecuteCmdlet()
        {
            var list = List.GetList(SelectedWeb);

            if (list == null)
            {
                throw new PSArgumentException(string.Format(Resources.ListNotFound, List.ToString()));
            }
            if (Identity != null)
            {
                var item = Identity.GetListItem(list);
                if (Force || ShouldContinue(string.Format(Resources.RemoveListItemWithId0, item.Id), Resources.Confirm))
                {
                    if (Recycle)
                    {
                        item.Recycle();
                    }
                    else
                    {
                        item.DeleteObject();
                    }
                    ClientContext.ExecuteQueryRetry();
                }
            }
        }
Esempio n. 3
0
        protected override void ExecuteCmdlet()
        {
            if (ParameterSpecified(nameof(Batch)))
            {
                var list = List.GetList(Batch);

                var id = Identity.GetItemId();
                {
                    if (Recycle)
                    {
                        list.Items.RecycleByIdBatch(Batch.Batch, id.Value);
                    }
                    else
                    {
                        list.Items.DeleteByIdBatch(Batch.Batch, id.Value);
                    }
                }
            }
            else
            {
                var list = List.GetList(CurrentWeb);
                if (list == null)
                {
                    throw new PSArgumentException(string.Format(Resources.ListNotFound, List.ToString()));
                }
                if (Identity != null)
                {
                    var item    = Identity.GetListItem(list);
                    var message = $"{(Recycle ? "Recycle" : "Remove")} list item with id {item.Id}?";
                    if (Force || ShouldContinue(message, Resources.Confirm))
                    {
                        if (Recycle)
                        {
                            item.Recycle();
                        }
                        else
                        {
                            item.DeleteObject();
                        }
                        ClientContext.ExecuteQueryRetry();
                    }
                }
            }
        }