Skip to content

Conversation

@gautamdsheth
Copy link
Collaborator

Before creating a pull request, make sure that you have read the contribution file located at

https://github.com/pnp/powerShell/blob/dev/CONTRIBUTING.md

Type

  • Bug Fix
  • New Feature
  • Sample

Related Issues?

Fixes #X, partially fixes #Y, mentioned in #Z, etc.

What is in this Pull Request ?

Please describe the changes in the PR.

Guidance

  • You can delete this section when you are submitting the pull request.*
  • Please update this PR information accordingly. We use this as part of our release notes in monthly communications.
  • Please target your PR to Dev branch. If you do not target the Dev branch we will not accept this PR.
Copilot AI review requested due to automatic review settings September 25, 2025 13:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds batch processing support to the Add-PnPFileSensitivityLabel cmdlet, allowing multiple sensitivity label assignments to be queued and executed together in a single Microsoft Graph batch operation for improved performance.

  • Added batch processing capability through a new Batch parameter and parameter sets
  • Refactored the existing single-file processing into separate methods for better code organization
  • Updated documentation to include batch processing examples and parameter information

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Commands/Files/AddFileSensitivityLabel.cs Added batch processing logic with parameter sets, refactored execution flow into separate methods
documentation/Add-PnPFileSensitivityLabel.md Updated syntax, description, and added batch processing example with parameter documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

private void AssignLabelImmediately(string requestUrl, string payloadJson, IFile file)
{
using var content = new StringContent(payloadJson, Encoding.UTF8, "application/json");
using var response = GraphRequestHelper.PostHttpContent(requestUrl, content);
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's trailing whitespace at the end of this line that should be removed for consistency.

Suggested change
using var response = GraphRequestHelper.PostHttpContent(requestUrl, content);
using var response = GraphRequestHelper.PostHttpContent(requestUrl, content);
Copilot uses AI. Check for mistakes.
Comment on lines 78 to 83
Dictionary<string, string> headers = new()
{
{ "Content-Type", "application/json" }
};

Batch.Context.Web.WithHeaders(headers).ExecuteRequestBatch(
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The headers dictionary is created with only a Content-Type header, but this is typically handled automatically by the HTTP client when sending JSON content. Consider removing this manual header setting unless specifically required by the API.

Suggested change
Dictionary<string, string> headers = new()
{
{ "Content-Type", "application/json" }
};
Batch.Context.Web.WithHeaders(headers).ExecuteRequestBatch(
Batch.Context.Web.ExecuteRequestBatch(
Copilot uses AI. Check for mistakes.
@gautamdsheth gautamdsheth merged commit 37cb2fa into dev Sep 25, 2025
5 checks passed
@gautamdsheth gautamdsheth deleted the feat/batch-file-sensi branch October 3, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants