Commit 9e05ca2
feat(sdk): add ergonomic Resource constructors for authorization (#354)
## Summary
- Add `Resources` utility class with `forAttributeValues(String...
fqns)` and `forRegisteredResourceValueFqn(String fqn)` helpers
- Follows the same pattern as `EntityIdentifiers` from #346
- Reduces verbose nested protobuf builder chains to single-line calls
**Before:**
```java
Resource.newBuilder()
.setAttributeValues(
Resource.AttributeValues.newBuilder()
.addFqns("https://example.com/attr/department/value/finance"))
.build();
```
**After:**
```java
Resources.forAttributeValues("https://example.com/attr/department/value/finance");
```
**Example — GetDecision authorization call:**
```java
import io.opentdf.platform.sdk.EntityIdentifiers;
import io.opentdf.platform.sdk.Resources;
GetDecisionRequest request = GetDecisionRequest.newBuilder()
.setEntityIdentifier(EntityIdentifiers.forEmail("user@company.com"))
.setAction(Action.newBuilder().setName("decrypt"))
.setResource(Resources.forAttributeValues(
"https://company.com/attr/clearance/value/confidential",
"https://company.com/attr/department/value/finance"))
.build();
GetDecisionResponse resp = sdk.getServices()
.authorization()
.getDecision(request)
.get();
```
## Test plan
- [x] Unit tests for `forAttributeValues` (single, multiple,
empty-string FQN, empty array throws)
- [x] Unit tests for `forRegisteredResourceValueFqn` (valid + empty
string)
- [x] Null safety tests (null array, null element, null fqn all throw
NPE)
- [x] Full SDK test suite passes (157 tests, 0 failures)
- [x] CI checks pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 2c55e31 commit 9e05ca2
2 files changed
Lines changed: 134 additions & 0 deletions
File tree
- sdk/src
- main/java/io/opentdf/platform/sdk
- test/java/io/opentdf/platform/sdk
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
Lines changed: 63 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
0 commit comments