Skip to content

chore(docs): add Resource constructor helpers and update examples#301

Merged
marythought merged 9 commits intomainfrom
chore/resource-constructor-docs
Apr 24, 2026
Merged

chore(docs): add Resource constructor helpers and update examples#301
marythought merged 9 commits intomainfrom
chore/resource-constructor-docs

Conversation

@marythought
Copy link
Copy Markdown
Contributor

@marythought marythought commented Apr 21, 2026

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):

Test plan

  • npm run build passes
  • Visual review of rendered authorization page
  • CI checks pass

🤖 Generated with Claude Code

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.

@marythought marythought requested review from a team as code owners April 21, 2026 15:45
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Warning

Rate limit exceeded

@marythought has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 17 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 44 minutes and 17 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a945d314-12f6-472e-b466-7b3c14d4b585

📥 Commits

Reviewing files that changed from the base of the PR and between a6c255b and 4634556.

📒 Files selected for processing (2)
  • docs/sdks/authorization.mdx
  • docs/sdks/tdf.mdx
📝 Walkthrough

Walkthrough

Added documentation for Resource helpers and replaced manual proto/object constructions in GetDecision/GetDecisionBulk examples with language-specific constructors across Go, Java, and JavaScript; added a Go manual EntityChain example and a Go-only TDFObject type reference.

Changes

Cohort / File(s) Summary
Authorization SDK docs
docs/sdks/authorization.mdx
Added a new Resource section (attribute-value FQNs vs registered resource value FQNs); introduced language-specific Resource helper APIs and “without helpers” manual construction examples; added a Go manual EntityChain/Entity example; updated parameter tables and type reference links.
GetDecision examples
code_samples/authorization/get_decision.mdx
Rewrote Go/Java/JavaScript samples to use SDK helper constructors for EntityIdentifier and Resource (e.g., ForAttributeValues, EntityIdentifiers.forClientId, Resources.forAttributeValues); removed verbose manual proto/object assembly and adjusted imports/comments.
TDF docs (Go)
docs/sdks/tdf.mdx
Turned CreateTDF return signature into a link to a new Go-only TDFObject Type Reference and documented its Manifest() and Size() methods; clarified cross-language return differences.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • elizabethhealy
  • pflynn-virtru
  • jp-ayyappan

Poem

🐰 I hopped through lines of docs today,
Swapped long proto tales for helpers at play.
Go, Java, JS now skip the nested maze,
FQNs prance neatly in simpler arrays,
A tiny hop — the examples cheer, hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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 changes: adding Resource constructor helpers documentation and updating code examples across multiple files to use these helpers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 chore/resource-constructor-docs

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.

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 introduces SDK helper functions for resource construction in Go, Java, and JavaScript, updating the authorization documentation and examples to use these helpers instead of manual construction. The review feedback highlights the need to clarify ephemeralId handling for immutable Java objects, maintain consistent notation in the resource variants table, and update related external code samples for consistency.

Comment thread docs/sdks/authorization.mdx Outdated
Comment thread docs/sdks/authorization.mdx Outdated
Comment thread docs/sdks/authorization.mdx
@github-actions
Copy link
Copy Markdown
Contributor

📄 Preview deployed to https://opentdf-docs-pr-301.surge.sh

Base automatically changed from chore/entity-identifier-helpers-docs to main April 21, 2026 15:55
@marythought marythought force-pushed the chore/resource-constructor-docs branch from 2374648 to 0273065 Compare April 21, 2026 15:56
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
docs/sdks/authorization.mdx (2)

238-241: Java varargs notation uses Go-style trailing ....

In the Java helper table (and the summary table at line 314), the signatures are rendered as Resources.forAttributeValues(fqns...). Trailing ... after the argument name is Go/C# spread/variadic-call notation; Java varargs are declared as String... fqns and invoked positionally (e.g., forAttributeValues(fqn1, fqn2)). The JavaScript row already uses the correct spread form ...fqns. Consider either matching the actual Java declaration style or dropping the dots in the descriptor cell for consistency.

✏️ Suggested wording
-| `Resources.forAttributeValues(fqns...)` | Resource from attribute value FQNs (e.g. those on a TDF) |
+| `Resources.forAttributeValues(String... fqns)` | Resource from attribute value FQNs (e.g. those on a TDF) |

And at line 314:

-| Attribute values | `ForAttributeValues(fqns...)` | `Resources.forAttributeValues(fqns...)` | `Resources.forAttributeValues(...fqns)` |
+| Attribute values | `ForAttributeValues(fqns...)` | `Resources.forAttributeValues(String... fqns)` | `Resources.forAttributeValues(...fqns)` |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/sdks/authorization.mdx` around lines 238 - 241, The Java helper
signatures in the docs use Go-style trailing dots; update the Java cells for
Resources.forAttributeValues and Resources.forRegisteredResourceValueFqn to use
proper Java varargs/declaration style (e.g., String... fqns or remove the
trailing dots) to match Java syntax and the JavaScript row’s spread
notation—ensure both the helper table (Resources.forAttributeValues(fqns...) /
Resources.forRegisteredResourceValueFqn(fqn)) and the summary table are changed
consistently so Java examples show either "String... fqns" or omit the "..."
after the parameter name.

317-319: Consider demonstrating the "helpers + set ephemeralId" pattern in GetDecisionBulk.

The note correctly tells readers that helpers don't set ephemeralId and suggests two options: set it after construction, or use manual construction. The bulk examples (Go 795-820, Java 890-912, JS 945-968) only show the manual path. For Go/Java it's easy to show the helper + assignment (e.g., r := authorizationv2.ForAttributeValues(...); r.EphemeralId = "resource-1"), which gives readers a less verbose option that matches the rest of the page. Optional — skip if you want to keep the bulk examples self-contained.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/sdks/authorization.mdx` around lines 317 - 319, Add a short example
showing the helper + ephemeralId assignment pattern alongside the manual
construction in the GetDecisionBulk section: locate the bulk examples for Go
(authorizationv2.ForAttributeValues) and Java (the equivalent helper factory),
create a minimal snippet that constructs the request with the helper (e.g.,
assign to variable r) and then sets r.EphemeralId (or r.setEphemeralId(...))
before sending, and place it just before or after the existing manual
construction example so readers see the less-verbose option.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docs/sdks/authorization.mdx`:
- Around line 238-241: The Java helper signatures in the docs use Go-style
trailing dots; update the Java cells for Resources.forAttributeValues and
Resources.forRegisteredResourceValueFqn to use proper Java varargs/declaration
style (e.g., String... fqns or remove the trailing dots) to match Java syntax
and the JavaScript row’s spread notation—ensure both the helper table
(Resources.forAttributeValues(fqns...) /
Resources.forRegisteredResourceValueFqn(fqn)) and the summary table are changed
consistently so Java examples show either "String... fqns" or omit the "..."
after the parameter name.
- Around line 317-319: Add a short example showing the helper + ephemeralId
assignment pattern alongside the manual construction in the GetDecisionBulk
section: locate the bulk examples for Go (authorizationv2.ForAttributeValues)
and Java (the equivalent helper factory), create a minimal snippet that
constructs the request with the helper (e.g., assign to variable r) and then
sets r.EphemeralId (or r.setEphemeralId(...)) before sending, and place it just
before or after the existing manual construction example so readers see the
less-verbose option.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 417df865-74e4-4bdb-9841-40fc4eaae78d

📥 Commits

Reviewing files that changed from the base of the PR and between a8d4f50 and 0273065.

📒 Files selected for processing (1)
  • docs/sdks/authorization.mdx

@marythought marythought force-pushed the chore/resource-constructor-docs branch 2 times, most recently from 6f7f83e to ed8e7c4 Compare April 22, 2026 18:18
@marythought marythought changed the base branch from main to docs/sdk-version-annotations April 22, 2026 18:18
@marythought marythought force-pushed the docs/sdk-version-annotations branch from 1288ba1 to 8a15c03 Compare April 22, 2026 19:40
Base automatically changed from docs/sdk-version-annotations to main April 22, 2026 19:40
marythought and others added 4 commits April 22, 2026 12:52
Add `_, _ = client, context.Background()` to Go setup blocks so they
compile without unused variable/import errors. Add "Without helpers"
collapsible section to Go EntityIdentifier tab matching Java and JS.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document the new Resource helper functions (ForAttributeValues,
ForRegisteredResourceValueFqn) for Go, Java, and JavaScript SDKs.
Update GetDecision examples to use the helpers instead of verbose
manual proto construction.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
- Fix Java varargs notation in helper tables (fqns... → String... fqns)
- Add authorizationv2 package prefix to Go entries in summary table
- Clarify ephemeralId note for Java's immutable protos (.toBuilder())
- Update code_samples/authorization/get_decision.mdx to use helpers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
Go SDK v0.17.0, Java SDK v0.14.0, JS SDK v0.15.0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@marythought marythought force-pushed the chore/resource-constructor-docs branch from ed8e7c4 to af074e2 Compare April 22, 2026 20:09
…urns

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/sdks/authorization.mdx`:
- Around line 362-371: The example uses the wrong client variable—replace
platformClient with the documented platform variable in the call to
platform.v2.authorization.getDecision so the snippet matches the page setup;
keep the Resources.forAttributeValues usage as-is and ensure the context still
imports Resources and calls platform.v2.authorization.getDecision with the same
options.
- Around line 140-168: Remove the duplicated "Without helpers (manual proto
construction)" details block that repeats the Go example for constructing an
authorizationv2.GetDecisionRequest with an
authorizationv2.EntityIdentifier/EntityChain; specifically delete the repeated
<details> block containing the GetDecisionRequest example and the manual
Entity.EmailAddress/EntityChain example (symbols: GetDecisionRequest,
EntityIdentifier, EntityIdentifier_EntityChain, entity.EntityChain,
entity.Entity, Entity_EmailAddress, Entity_CATEGORY_SUBJECT) so the Go tab only
shows the single, original manual-construction example.

In `@docs/sdks/tdf.mdx`:
- Around line 1272-1285: The Type Reference overview at the top of the docs
omits the new TDFObject entry; update the overview list to include TDFObject so
readers can find its Type Reference alongside KASInfo, PolicyObject, Manifest,
and AssertionConfig. Locate the top-of-page overview where Type Reference items
are enumerated and add "TDFObject" (referencing the CreateTDF return type and
methods Manifest() and Size()) so the summary and any table of contents reflect
the new type.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d709d4d4-b489-46a8-b109-bccac7bd4239

📥 Commits

Reviewing files that changed from the base of the PR and between 6f7f83e and c15945a.

📒 Files selected for processing (3)
  • code_samples/authorization/get_decision.mdx
  • docs/sdks/authorization.mdx
  • docs/sdks/tdf.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • code_samples/authorization/get_decision.mdx

Comment thread docs/sdks/authorization.mdx Outdated
Comment thread docs/sdks/authorization.mdx
Comment thread docs/sdks/tdf.mdx
marythought and others added 4 commits April 22, 2026 14:08
…bles

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace `_, _ = client, context.Background()` with
`ctx := context.Background()` so the setup block defines the `ctx`
variable used by all subsequent Go snippets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…verview

- Remove duplicate "Without helpers" details block in Go EntityIdentifier section
- Fix JS Resource example to use `platform` instead of `platformClient`
- Add TDFObject to Type Reference overview in tdf.mdx

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread code_samples/authorization/get_decision.mdx
@marythought marythought merged commit a82f860 into main Apr 24, 2026
10 checks passed
@marythought marythought deleted the chore/resource-constructor-docs branch April 24, 2026 16:58
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.

3 participants