feat(sdk): add ergonomic Resource constructors for authorization#3337
feat(sdk): add ergonomic Resource constructors for authorization#3337marythought merged 2 commits intomainfrom
Conversation
Add ForAttributeValues and ForRegisteredResourceValueFqn helpers to reduce boilerplate when building Resource objects for authorization calls. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
📝 WalkthroughWalkthroughAdds two new helper constructor functions ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Document the behavior of ForAttributeValues() called with no arguments, which produces a Resource with a nil FQN slice. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
|
## Summary - Add `### Resource` section documenting helper functions for all 3 SDKs (`ForAttributeValues`, `ForRegisteredResourceValueFqn`) - Add `<SdkVersion>` annotations with minimum SDK versions: Go v0.17.0, Java v0.14.0, JS v0.15.0 - Update GetDecision examples (Go, Java, JS) to use helpers instead of verbose proto construction - Update Type Reference Resource section with tabbed helper examples - Add note about `ephemeralId` not being set by helpers (relevant for GetDecisionBulk) Based on #303 (SdkVersion component + EntityIdentifier annotations). **Companion PRs (SDK implementations):** - Go: opentdf/platform#3337 - Java: opentdf/java-sdk#354 - JavaScript: opentdf/web-sdk#921 ## Test plan - [ ] `npm run build` passes - [ ] Visual review of rendered authorization page - [ ] CI checks pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Enhanced authorization docs with a new Resource section describing attribute-value and registered-resource formats, plus language-specific helper APIs and “without helpers” manual examples. * Updated GetDecision/GetDecisionBulk/GetEntitlements parameter docs to link entity/resource types and note Resource helper usage. * Rewrote multi-language GetDecision samples (Go/Java/JavaScript) to use Resource/Entity helper constructors. * Added Go TDFObject type reference and minor Go example ctx initialization updates. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Mary Dickson <mary.dickson@virtru.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
ForAttributeValues(fqns ...string)andForRegisteredResourceValueFqn(fqn string)helpers to the authorization v2 packageEntityIdentifierhelpers (ForEmail,ForClientID, etc.)Before:
After:
Example — GetDecision authorization call:
Test plan
ForAttributeValues(single, multiple, zero FQNs) andForRegisteredResourceValueFqn(valid + empty string)resource.gen.gogolangci-lintpasses with 0 issues🤖 Generated with Claude Code