Skip to content

docs(sdk): update Go authorization samples to use EntityIdentifier helpers#269

Draft
marythought wants to merge 5 commits intomainfrom
DSPX-2594-entity-identifier-helpers
Draft

docs(sdk): update Go authorization samples to use EntityIdentifier helpers#269
marythought wants to merge 5 commits intomainfrom
DSPX-2594-entity-identifier-helpers

Conversation

@marythought
Copy link
Copy Markdown
Contributor

@marythought marythought commented Mar 31, 2026

Summary

  • Updates V2 Go code samples in get_decision.mdx and get_entitlements.mdx to use the new sdk.ForClientID() helper instead of manual 4-level proto nesting
  • Also updates the entitlements sample to use the v2 API (AuthorizationV2) instead of v1

Depends on opentdf/platform#3232.

Test plan

  • Docs site builds successfully
  • Code samples render correctly in the authorization pages

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated Go authorization examples to use the newer authorization flow, simplified entity identification with a helper, clarified usage with inline comments, and adjusted entitlement example calls.
  • New Features
    • Added a SortDirection enum to the policy selectors schema with unspecified, ascending, and descending options.

…lpers

Simplifies the V2 Go code samples for GetDecision and GetEntitlements by
using the new sdk.ForClientID helper instead of manual proto nesting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@marythought marythought requested review from a team as code owners March 31, 2026 21:09
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5a9021de-1b4e-40d0-8f7f-590b9cec77d6

📥 Commits

Reviewing files that changed from the base of the PR and between b8468f5 and 87bccd7.

📒 Files selected for processing (2)
  • code_samples/authorization/get_decision.mdx
  • code_samples/authorization/get_entitlements.mdx
✅ Files skipped from review due to trivial changes (2)
  • code_samples/authorization/get_entitlements.mdx
  • code_samples/authorization/get_decision.mdx

📝 Walkthrough

Walkthrough

Updated two Go authorization sample files to use v2 helpers and SDK call variants (replacing manual entity chain construction with sdk.EntityIdentifierForClientID("opentdf"), updating resource and decision references); added an OpenAPI component policy.SortDirection enum.

Changes

Cohort / File(s) Summary
Authorization samples
code_samples/authorization/get_decision.mdx, code_samples/authorization/get_entitlements.mdx
Switched Go examples to v2 authorization usage: removed separate entity construction, use sdk.EntityIdentifierForClientID("opentdf") helper; adjusted import aliases and resource/decision types to authorization.*; changed SDK call from client.Authorization.GetEntitlements(...) to client.AuthorizationV2.GetEntitlements(...) in the entitlements sample; added inline helper comments.
Policy selectors schema
specs/policy/selectors.openapi.yaml
Added new OpenAPI schema policy.SortDirection (type: string) with enum values SORT_DIRECTION_UNSPECIFIED, SORT_DIRECTION_ASC, SORT_DIRECTION_DESC.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hopped through code with nimble paws,

Swapped chains for a helper—no more cause,
Decisions and resources align in tune,
Enums march under a silver moon,
🥕 Hooray—this hop fixes the prune!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the pull request - updating Go authorization code samples to use EntityIdentifier helper functions instead of manual proto nesting.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch DSPX-2594-entity-identifier-helpers

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

❌ Surge preview build failed — no preview was deployed. Check the workflow logs for details.

Once the build passes, the preview will be at: https://opentdf-docs-pr-269.surge.sh

Common cause: If the build failed on vendored YAML validation, run the following locally and commit the result:

npm run update-vendored-yaml
git add specs/
git commit -m "chore(deps): update vendored OpenAPI specs"

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the authorization code samples to use the v2 API and simplifies entity identification by using SDK helper functions like sdk.ForClientID. I have no feedback to provide.

marythought and others added 4 commits March 31, 2026 17:06
Updates Go authorization samples to use the new EntityIdentifier helpers
from the authorizationv2 package — no extra import needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
Uses `authorization` instead of `authorizationv2` as the import alias
for cleaner calling convention: authorization.ForClientID("opentdf").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
The helpers moved from the authorization/v2 proto package to the sdk
package and were renamed (e.g., ForClientID → EntityIdentifierForClientID).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
@marythought marythought marked this pull request as draft April 2, 2026 21:22
@marythought
Copy link
Copy Markdown
Contributor Author

draft pending ADR decision on which pattern to use for sustainability 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant