Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ExecuteQueryRetry to Admin commands for improved reliability #3988

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Commands/Admin/SetHomeSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected override void ExecuteCmdlet()
Tenant.RemoveTargetedSite(enumerable.First().SiteId);
AdminContext.ExecuteQueryRetry();
Tenant.AddHomeSite(HomeSiteUrl, 1, null);
AdminContext.ExecuteQuery();
AdminContext.ExecuteQueryRetry();
flag = true;
}
HomeSiteConfigurationParam configurationParam = new()
Expand Down
28 changes: 15 additions & 13 deletions src/Commands/Admin/UnlockSensitivityLabelEncryptedFile.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
using Microsoft.SharePoint.Client;
using PnP.PowerShell.Commands.Base;
using System.Management.Automation;

namespace PnP.PowerShell.Commands.Files
{
[Cmdlet(VerbsCommon.Unlock, "PnPSensitivityLabelEncryptedFile")]
public class UnlockSensitivityLabelEncryptedFile : PnPAdminCmdlet
[Cmdlet(VerbsCommon.Unlock, "PnPSensitivityLabelEncryptedFile")]
public class UnlockSensitivityLabelEncryptedFile : PnPAdminCmdlet
{
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
public string Url = string.Empty;

[Parameter(Mandatory = true)]
public string JustificationText = string.Empty;
protected override void ExecuteCmdlet()
{
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
public string Url = string.Empty;
[Parameter(Mandatory = true)]
public string JustificationText = string.Empty;
protected override void ExecuteCmdlet()
{
// Remove URL decoding from the Url as that will not work. We will encode the + character specifically, because if that is part of the filename, it needs to stay and not be decoded.
Url = Utilities.UrlUtilities.UrlDecode(Url.Replace("+", "%2B"));
// Remove URL decoding from the Url as that will not work. We will encode the + character specifically, because if that is part of the filename, it needs to stay and not be decoded.
Url = Utilities.UrlUtilities.UrlDecode(Url.Replace("+", "%2B"));

Tenant.UnlockSensitivityLabelEncryptedFile(Url, JustificationText);
AdminContext.ExecuteQuery();
}
Tenant.UnlockSensitivityLabelEncryptedFile(Url, JustificationText);
AdminContext.ExecuteQueryRetry();
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/InformationManagement/ResetRetentionLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected override void ExecuteCmdlet()

WriteVerbose($"Clearing retention label on batch {rangeIndex} of items");
Microsoft.SharePoint.Client.CompliancePolicy.SPPolicyStoreProxy.SetComplianceTagOnBulkItems(ClientContext, range, rootUrl + list.RootFolder.ServerRelativeUrl, string.Empty);
ClientContext.ExecuteQuery();
ClientContext.ExecuteQueryRetry();

ItemIds.RemoveRange(0, itemsToProcess);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Commands/InformationManagement/SetRetentionLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ protected override void ExecuteCmdlet()
if (ParameterSetName == ParamSet_BulkItems)
{
PnPContext.Web.LoadAsync(i => i.Url);
list.LoadAsync(i => i.RootFolder);

list.LoadAsync(i => i.RootFolder);

var rootUrl = PnPContext.Web.Url.GetLeftPart(UriPartial.Authority);

Expand All @@ -87,7 +86,7 @@ protected override void ExecuteCmdlet()

WriteVerbose($"Setting retention label to batch {rangeIndex} of items");
Microsoft.SharePoint.Client.CompliancePolicy.SPPolicyStoreProxy.SetComplianceTagOnBulkItems(ClientContext, range, rootUrl + list.RootFolder.ServerRelativeUrl, Label);
ClientContext.ExecuteQuery();
ClientContext.ExecuteQueryRetry();
ItemIds.RemoveRange(0, itemsToProcess);
}
}
Expand Down
Loading