-
Notifications
You must be signed in to change notification settings - Fork 24
docs: explain and demonstrate Conditions across the API #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
17a0f39
8e84d8e
114bc2f
04950fc
19f2535
6444f3a
a7aab1d
bb28d6d
645bd3c
7e44c16
07fbd7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,17 @@ message UsersetUser { | |
| ]; | ||
| } | ||
|
|
||
| // RelationshipCondition attaches a condition to a relationship tuple, making the | ||
| // relationship it's attached to conditional: the relationship only holds when the named | ||
| // `Condition`'s CEL expression evaluates to true. | ||
| // | ||
| // `context` on this message is optional and is typically used to pin parameter values that are | ||
| // fixed for the lifetime of the tuple (e.g. `grant_time`/`grant_duration` for a time-limited | ||
| // grant), as opposed to parameters that vary per request (e.g. `current_time`), which are instead | ||
| // supplied via the top-level `context` on Check/ListObjects/ListUsers requests. | ||
| // | ||
| // When a relationship is evaluated, this tuple-level `context` is merged with any request-level | ||
| // `context`; if the same key is present in both, the value from this tuple's `context` wins. | ||
| message RelationshipCondition { | ||
| // A reference (by name) of the relationship condition defined in the authorization model. | ||
| string name = 1 [ | ||
|
|
@@ -102,9 +113,13 @@ message RelationshipCondition { | |
| // Additional context/data to persist along with the condition. | ||
| // The keys must match the parameters defined by the condition, and the value types must | ||
| // match the parameter type definitions. | ||
| google.protobuf.Struct context = 2; | ||
| google.protobuf.Struct context = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "{\"grant_time\": \"2021-10-11T09:00:00Z\", \"grant_duration\": \"1h\"}"}]; | ||
| } | ||
|
|
||
| // TupleKeyWithoutCondition identifies a relationship tuple by its user/relation/object triplet | ||
| // only, with no `RelationshipCondition`. It's used where a condition would be meaningless or | ||
| // ignored: deleting a tuple (`WriteRequestDeletes.tuple_keys`) only needs the triplet to find the | ||
| // matching row, and any `condition` on the delete request itself is ignored by the Write API. | ||
|
Comment on lines
+119
to
+122
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win Delete documentation conflicts with the request schema.
📍 Affects 3 files
🤖 Prompt for AI Agents |
||
| message TupleKeyWithoutCondition { | ||
| string user = 1 [ | ||
| (google.api.field_behavior) = REQUIRED, | ||
|
|
@@ -158,6 +173,11 @@ message TypedWildcard { | |
| ]; | ||
| } | ||
|
|
||
| // TupleKey identifies a relationship tuple by its user/relation/object triplet, optionally with a | ||
| // `condition` that makes the relationship it describes conditional. This is the shape used | ||
| // when writing tuples and when specifying `contextual_tuples`; a stored tuple returned by the Read | ||
| // or ReadChanges APIs is wrapped in a `Tuple`, which pairs a `TupleKey` (including its `condition`, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| // if any) with the tuple's write timestamp. | ||
|
Comment on lines
+176
to
+180
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win ReadChanges returns
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| message TupleKey { | ||
| string user = 1 [ | ||
| (google.api.field_behavior) = REQUIRED, | ||
|
|
@@ -198,6 +218,9 @@ message TupleKey { | |
| RelationshipCondition condition = 4; | ||
| } | ||
|
|
||
| // Tuple pairs a stored relationship (`TupleKey`, including its `condition` if it was written with | ||
| // one) with the timestamp it was written at. This is the shape returned by the Read API; note that | ||
| // Read returns the tuple's condition verbatim without evaluating it. | ||
| message Tuple { | ||
| TupleKey key = 1 [ | ||
| (google.api.field_behavior) = REQUIRED, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition only enforces the expiration boundary, so it also evaluates to true before
grant_time. Since the surrounding text describes a grant that starts atgrant_time, could we usecurrent_time >= grant_time && current_time < grant_time + grant_durationhere (and in the corresponding examples), or revise the wording if pre-start access is intentional?