From 45830336aa40db65b9b2a7ac8195a249e36e4007 Mon Sep 17 00:00:00 2001 From: openfga-releaser-bot Date: Thu, 3 Dec 2026 15:19:28 +0000 Subject: [PATCH] chore(sync): sync with generator Generated from openfga/sdk-generator@24c92bad8babb17353776452eda81df787f13a70 --- README.md | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index b2c95b5..512bb3b 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ This is an autogenerated python SDK for OpenFGA. It provides a wrapper around th - [Relationship Queries](#relationship-queries) - [Check](#check) - [Batch Check](#batch-check) + - [Merge equivalent checks](#merge-equivalent-checks) - [Client Batch Check](#client-batch-check) - [Expand](#expand) - [List Objects](#list-objects) @@ -967,12 +968,12 @@ response = await fga_client.batch_check(ClientBatchCheckRequest(checks=checks), ###### Merge equivalent checks -If you set `merge_equivalent_checks` to `True` in the options, the SDK sends checks that will get the same answer only once, then copies that answer back to each of them. You still get one result for every check you passed in. +Set `merge_equivalent_checks` to `True` to send equivalent checks only once. The SDK copies the result, including any error, back to every check in the group. -Two kinds of checks are merged: +The SDK can merge checks with the same user, object, context, and contextual tuples in two cases. -- Checks on a relation that is an alias of another one. With `define can_view: viewer`, a check on `can_view` and a check on `viewer` with the same user, object, context and contextual tuples become one check on `viewer`. Chains like `define can_share: can_view` are followed too. -- Exact repeats, with the same user, relation, object, context and contextual tuples. +- The checks use the same relation. +- One relation is an alias of the other, such as `define can_view: viewer`, or the relations resolve to the same relation through aliases. ```python options = { @@ -981,31 +982,18 @@ options = { "merge_equivalent_checks": True, } response = await fga_client.batch_check(ClientBatchCheckRequest(checks=checks), options) -# response.checks_sent is how many checks were sent to the server, or None when the option is off ``` -The option is off by default. Leaving it out or setting it to `None` keeps it off. Any other value that isn't a bool, like `"true"`, fails with a validation error. +`response.checks_sent` is the number of checks the SDK actually sent to the server. Compare it with the number of checks you passed in to see how many were merged. It's `None` when the option is off. -To find aliases, the SDK reads the authorization model the first time it needs it and keeps it in memory, so create the client once and reuse it. Each client keeps up to 32 models and drops the least recently used one. The call fails before any check is sent when: +The option is off by default. -- no authorization model ID is set -- the model or the store doesn't exist -- the SDK can't get an access token, after retrying as usual. The checks need the same token, so the call would fail with the option off too. -- the credentials can't read the model (a 401 or 403). If your credentials can only run checks, leave the option off. - -Calls running at the same time share one read, sent with the headers of the call that started it. If your calls pass different credentials in `headers`, a call can fail with the 401 or 403 of another call's read. - -If reading the model fails for another reason, such as a 429, a 5xx or a timeout, the SDK logs a warning and sends the checks without merging them. It doesn't retry this read, even if you set `retry_params`, so a failed read costs one request. The next call reads the model again. - -Compared with leaving the option off, a call: - -- makes one extra request the first time the client needs a model, to read it. Later calls use the copy in memory, and calls running at the same time share one read. -- spends a little time grouping the checks and copying the answers back. This happens in memory and is small next to a request. -- sends fewer checks when some of them merge, so the checks themselves can finish sooner. - -Each client reads each model once, unless it uses more than 32 models. Some services rate limit model reads much lower than checks, so if many clients start at the same time, some may get a 429. Those clients send checks unmerged and read the model again on each call until a read succeeds. - -If a merged check returns an error, every check it stands for gets that error. Correlation IDs must match `^[\w\d-]{1,36}$` (ASCII), and missing ones are generated. For metrics, see `fga-client.batch_check.*` and `fga-client.model_cache.lookup` in [OpenTelemetry](docs/opentelemetry.md). +- Set `merge_equivalent_checks` to `False` or `None` to leave it off. Values other than `True`, `False`, or `None` fail validation. +- Set an authorization model ID and use credentials that can read the model. A missing model or store, a model read that returns 401 or 403, or failure to obtain an access token fails the batch before sending any checks. +- Reuse the client to avoid extra model reads. Each client caches up to 32 models, evicts the least recently used model when the cache is full, and reads an evicted model again when needed. Concurrent calls for the same uncached model share one read using the headers from the call that started it. +- If a model read times out or returns an error such as 429 or 5xx, the SDK logs a warning and sends the checks unmerged. It skips retries for that read and tries again the next time it needs the model. +- Provide unique correlation IDs that match `^[\w\d-]{1,36}$` (ASCII), or leave them unset and let the SDK generate them. +- For batch check and model cache metrics, see [OpenTelemetry](docs/opentelemetry.md). ##### Client Batch Check @@ -1431,8 +1419,6 @@ If a request fails with a 429 or 5xx error from the server, or with a network er Network errors are retried for writes too, and the timeout applies to each attempt. A write that timed out may still have been applied, so its retry can fail as a duplicate unless the [conflict options](#conflict-options-for-write-operations) are set to `IGNORE`. In the async client, aiohttp's own resend of GET, PUT and DELETE requests after a dropped connection is turned off, so `retry_params` is the only retry policy. aiohttp 3.10.x has no switch for it, so on that version such a request can be sent once more than `max_retry` allows. -The SDK honors `Retry-After` delay seconds or HTTP dates up to 30 minutes. Unparseable or out-of-range values fall back to exponential backoff. In the sync client, urllib3's own `Retry-After` handling is disabled unless you set `Configuration.retries`. - To customize this behavior, create a `RetryParams` object and assign values to the `max_retry` and `min_wait_in_ms` constructor parameters. `max_retry` determines the maximum number of retries (up to 15), while `min_wait_in_ms` sets the minimum wait time between retries in milliseconds. Apply your custom retry values by passing the object to the `ClientConfiguration` constructor's `retry_params` parameter.