Commit 8483107
feat: Implement server-side BatchCheck using /batch-check endpoint (#150)
* feat: Implement server-side BatchCheck using /batch-check endpoint
Implements server-side batch check functionality to address issue #94.
Changes:
- Add new BatchCheck() method using the server-side /batch-check API endpoint
- Rename existing BatchCheck() to ClientBatchCheck() (fully supported, not deprecated)
- Add ClientBatchCheckRequest, ClientBatchCheckItem models for user-friendly API
- Add ClientBatchCheckResponse, ClientBatchCheckSingleResponse for result mapping
- Add ClientUtils helper methods (UUID correlation ID generation, list chunking, transformations)
- Add MaxBatchSize property to IClientBatchCheckOptions (default: 50)
- Update ListRelations to use renamed ClientBatchCheck method
Features:
- Auto-generates UUID correlation IDs (cross-SDK compatible with JS SDK)
- Validates correlation IDs are unique
- Chunks requests by MaxBatchSize (default: 50 checks per batch)
- Executes batches in parallel with MaxParallelRequests (default: 10)
- Supports all target frameworks (netstandard2.0, net48, net8.0, net9.0)
- Returns empty result for empty checks (matches JS SDK behavior)
- Fail-fast error handling
Tests:
- Add 18 unit tests for new models and utilities
- Update existing tests to use renamed ClientBatchCheck method
- Integration tested against live OpenFGA server
Fixes #94
* fix: Address PR feedback for BatchCheck implementation
Addresses CodeRabbit and CodeQL feedback from PR #150.
Changes:
- Add validation to prevent MaxBatchSize <= 0 and MaxParallelRequests <= 0
- Prevents potential deadlock in NETSTANDARD2.0/NET48 builds
- Throws FgaValidationError with descriptive message
- Create IClientServerBatchCheckOptions for server-side BatchCheck
- Includes MaxBatchSize and MaxParallelRequests properties
- Removes MaxBatchSize from IClientBatchCheckOptions (unused by ClientBatchCheck)
- Removes MaxBatchSize from ClientListRelationsOptions (unused by ListRelations)
- Fix Equals(object) methods to use exact type checking
- Changed from 'is' pattern to obj.GetType() == this.GetType()
- Prevents improper equality checks with subclasses (CodeQL warning)
- Applied to ClientBatchCheckItem, ClientBatchCheckRequest, ClientBatchCheckSingleResponse, ClientBatchCheckResponse
- Update CHANGELOG.md with unreleased features
All fixes validated with no linter errors.
* docs: update BatchCheck README to match JS SDK format
- Update BatchCheck example to show new server-side API
- Use ClientBatchCheckRequest with ClientBatchCheckItem
- Show correlation ID generation and filtering by ID
- Add MaxBatchSize option example
- Simplify example for clarity (2 checks instead of 4)
- Add note about ClientBatchCheck() for older servers
- Align with JS SDK README structure
Addresses feedback from PR #150
* refactor: remove unused ChunkArray method
- Remove ChunkArray<T> method (not used anywhere)
- Keep ChunkList<T> which is actively used by BatchCheck
Addresses feedback from PR #150
* perf: use Enumerable.Chunk for .NET 6+ in ChunkList
- Use built-in Enumerable.Chunk for .NET 6.0 and greater
- Fall back to manual implementation for older frameworks
- Improves performance on modern .NET versions
Addresses feedback from PR #150
* test: add integration test for BatchCheck bulk request ID header
- Verify X-OpenFGA-Client-Bulk-Request-Id header is present
- Validate header value is a valid GUID
- Add missing FgaConstants using statement
- Follows existing header test patterns
Addresses feedback from PR #150
* refactor: use discard for unused mockHandler variable
- Change mockHandler to _ in BatchCheck header test
- Unused variable doesn't need to be captured
- Improves code cleanliness
Addresses code review feedback
* refactor: rename options classes to match Java SDK naming
- Rename ClientServerBatchCheckOptions to ClientBatchCheckOptions
- Create ClientBatchCheckClientOptions for client-side ClientBatchCheck()
- ClientBatchCheckOptions (server-side) has MaxBatchSize + MaxParallelRequests
- ClientBatchCheckClientOptions (client-side) has only MaxParallelRequests
- Update ClientListRelationsOptions to inherit from IClientBatchCheckClientOptions
- Fix README casing: batchCheck -> BatchCheck, correlationId -> CorrelationId
- Update all tests to use correct option types
Addresses PR feedback from @ewanharris and @curfew-marathon
* fix: address PR feedback for BatchCheck implementation
Address review feedback from PR #150:
1. Use hash code constants instead of magic numbers
- Replace hardcoded 9661/9923 with FgaConstants references
- Applied to all GetHashCode() methods in batch check models
2. Reduce code duplication in parallel processing
- Extract ProcessBatchAsync() helper method
- Share logic between NET6+ and older framework paths
3. Update documentation
- Add OpenFGA server v1.8.0+ requirement to CHANGELOG
- Regenerate README with correct examples from updated templates
- Fix response property names and model usage
All tests passing (274/274 on .NET 9.0).
* feat: update equals
* fix: revert unnecessary readme changes
* feat: address comments
---------
Co-authored-by: Anurag Bandyopadhyay <angbpy@gmail.com>1 parent 7fe66c0 commit 8483107
File tree
97 files changed
+1280
-245
lines changed- .openapi-generator
- example/Example1
- src
- OpenFga.Sdk.Test
- ApiClient
- Client
- Configuration
- OpenFga.Sdk
- Api
- Client
- Model
- Utils
- Configuration
- Model
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
97 files changed
+1280
-245
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | | - | |
8 | | - | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
| |||
155 | 154 | | |
156 | 155 | | |
157 | 156 | | |
158 | | - | |
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
| |||
187 | 185 | | |
188 | 186 | | |
189 | 187 | | |
190 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
5 | 15 | | |
6 | 16 | | |
7 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
642 | 643 | | |
643 | 644 | | |
644 | 645 | | |
645 | | - | |
646 | | - | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
647 | 655 | | |
648 | 656 | | |
649 | 657 | | |
| |||
652 | 660 | | |
653 | 661 | | |
654 | 662 | | |
| 663 | + | |
655 | 664 | | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
667 | 681 | | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
679 | 696 | | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
690 | 707 | | |
691 | 708 | | |
692 | 709 | | |
693 | 710 | | |
694 | 711 | | |
695 | 712 | | |
696 | | - | |
| 713 | + | |
| 714 | + | |
697 | 715 | | |
698 | 716 | | |
699 | 717 | | |
700 | 718 | | |
701 | 719 | | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
| 720 | + | |
707 | 721 | | |
708 | 722 | | |
| 723 | + | |
709 | 724 | | |
710 | 725 | | |
711 | 726 | | |
712 | 727 | | |
713 | 728 | | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
| 729 | + | |
719 | 730 | | |
720 | 731 | | |
| 732 | + | |
721 | 733 | | |
722 | 734 | | |
723 | 735 | | |
724 | 736 | | |
725 | 737 | | |
726 | 738 | | |
727 | | - | |
| 739 | + | |
728 | 740 | | |
| 741 | + | |
729 | 742 | | |
730 | 743 | | |
731 | 744 | | |
732 | 745 | | |
733 | 746 | | |
734 | | - | |
735 | | - | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
736 | 796 | | |
737 | 797 | | |
738 | 798 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
236 | | - | |
237 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
246 | 271 | | |
247 | 272 | | |
248 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
16 | 22 | | |
17 | 23 | | |
18 | 24 | | |
| |||
0 commit comments