-
Notifications
You must be signed in to change notification settings - Fork 394
Add support for batch processing in Add-PnPFileSensitivityLabel cmdlet #5095
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
Conversation
There was a problem hiding this 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
Batchparameter 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); |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
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.
| using var response = GraphRequestHelper.PostHttpContent(requestUrl, content); | |
| using var response = GraphRequestHelper.PostHttpContent(requestUrl, content); |
| Dictionary<string, string> headers = new() | ||
| { | ||
| { "Content-Type", "application/json" } | ||
| }; | ||
|
|
||
| Batch.Context.Web.WithHeaders(headers).ExecuteRequestBatch( |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
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.
| Dictionary<string, string> headers = new() | |
| { | |
| { "Content-Type", "application/json" } | |
| }; | |
| Batch.Context.Web.WithHeaders(headers).ExecuteRequestBatch( | |
| Batch.Context.Web.ExecuteRequestBatch( |
…roved clarity and efficiency
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
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