feat: Added branch support in entry variants#207
Conversation
- **New** - **Branch override for Entry Variants**: `Entry.Variant(uid?, branchUid?)` accepts an optional `branchUid` so a single variant call (`Find`, `Create`, `Update`, `Fetch`, `Delete`) can target a branch other than the `Stack`'s configured one, by overriding the `branch` request header. Passing `null`/whitespace falls back to the Stack's own branch. - **Publish/Unpublish for Entry Variants**: `EntryVariant.Publish`/`PublishAsync` and `EntryVariant.Unpublish`/`UnpublishAsync`, matching the same `PublishUnpublishDetails` contract as `Entry.Publish`/`Unpublish`, and respecting the same branch override.
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
There was a problem hiding this comment.
Pull request overview
Adds branch-targeting support and publish/unpublish capabilities to Entry Variants in the Contentstack Management .NET SDK, enabling variant operations to override the Stack’s configured branch via the branch request header.
Changes:
- Extended
Entry.Variant(uid?, branchUid?)andEntryVariantrequests to optionally override thebranchheader per call. - Added
EntryVariant.Publish/Unpublish(sync + async) using the existingPublishUnpublishDetailscontract. - Updated unit/integration tests and bumped package version + changelog for the release.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Directory.Build.props | Bumps SDK version to 1.1.0. |
| Contentstack.Management.Core/Models/EntryVariant.cs | Stores branch override and applies it to variant CRUD + adds publish/unpublish support. |
| Contentstack.Management.Core/Models/Entry.cs | Adds optional branchUid parameter to Variant(...). |
| Contentstack.Management.Core.Unit.Tests/Mokes/MockHttpHandler.cs | Captures last request headers for branch override assertions. |
| Contentstack.Management.Core.Unit.Tests/Models/EntryVariantTest.cs | Adds unit tests covering branch header override + publish/unpublish behavior. |
| Contentstack.Management.Core.Tests/IntegrationTest/Contentstack021_EntryVariantTest.cs | Adds branch override integration scenarios (branch creation, fetch, fallback, publish). |
| CHANGELOG.md | Documents new 1.1.0 features for entry variants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
1 similar comment
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
| var httpRequest = executionContext.RequestContext.service.CreateHttpRequest( | ||
| null, | ||
| executionContext.RequestContext.config | ||
| ); | ||
| LastRequestUri = httpRequest.RequestUri; | ||
| LastRequestHeaders = executionContext.RequestContext.service.Headers; | ||
| } |
| var httpRequest = executionContext.RequestContext.service.CreateHttpRequest( | ||
| null, | ||
| executionContext.RequestContext.config | ||
| ); | ||
| LastRequestUri = httpRequest.RequestUri; | ||
| LastRequestHeaders = executionContext.RequestContext.service.Headers; | ||
| } |
| AssertLogger.IsTrue( | ||
| response.IsSuccessStatusCode || (int)response.StatusCode >= 400, | ||
| "Expected the SDK to return a well-formed HTTP response for the branch-scoped request", | ||
| "FetchVariantOnExplicitBranch"); |
| AssertLogger.IsTrue( | ||
| response.IsSuccessStatusCode || (int)response.StatusCode >= 400, | ||
| "Expected the SDK to return a well-formed HTTP response for the branch-scoped request", | ||
| "FetchVariantOnExplicitBranchAsync"); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
1 similar comment
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
Entry.Variant(uid?, branchUid?)accepts an optionalbranchUidso a single variant call (Find,Create,Update,Fetch,Delete) can target a branch other than theStack's configured one, by overriding thebranchrequest header. Passingnull/whitespace falls back to the Stack's own branch.EntryVariant.Publish/PublishAsyncandEntryVariant.Unpublish/UnpublishAsync, matching the samePublishUnpublishDetailscontract asEntry.Publish/Unpublish, and respecting the same branch override.