feat(sdk): add ForAction helper to authorization/v2#3783
Conversation
Add a ForAction(name string) *policy.Action constructor helper so callers can build a GetDecisionRequest's Action field without importing the policy package directly, matching the existing ForToken/ForAttributeValues pattern. Authored in protocol/go/internal/authorization/v2/action.go and copied into the public package via protocol/codegen (action.gen.go). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds ChangesAuthorization action helper
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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:
|
|
|
Codex review: LGTM ✅ No blocking issues from my review. |
Problem
The
authorization/v2package provides ergonomic constructor helpers —ForToken(),ForEmail(),ForAttributeValues(), etc. — so consumers can build aGetDecisionRequestwithout importing internal proto packages. There is no equivalent helper for the request'sActionfield, so callers must import thepolicypackage directly and hand-build the value:This forces an extra import and leaks the
policypackage into consumer code.Change
Add
ForAction(name string) *policy.Action, authored inprotocol/go/internal/authorization/v2/action.goand copied into the public package viaprotocol/codegen(action.gen.go), following the same pattern asentity_identifierandresource.Because
ForActionreturns a*policy.Action(a different proto package), the codegen preserves thepolicyimport and qualifier in the generated file — only the self-referencingauthorizationv2alias is stripped.Testing
make proto-helper-generateregeneratesaction.gen.gogo test ./protocol/go/internal/authorization/v2/...— pass (newaction_test.go)go build/go vet/golangci-lint runonprotocol/goauthz v2 packages — clean🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests