Skip to content

Commit ba3e013

Browse files
committed
chore(sync): sync with generator
Generated from openfga/sdk-generator@3bcfe05
1 parent 89a0a97 commit ba3e013

1 file changed

Lines changed: 72 additions & 69 deletions

File tree

README.md

Lines changed: 72 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ This is an autogenerated Java SDK for OpenFGA. It provides a wrapper around the
4646
- [Assertions](#assertions)
4747
- [Read Assertions](#read-assertions)
4848
- [Write Assertions](#write-assertions)
49-
- [Retries](#retries)
5049
- [Calling Other Endpoints](#calling-other-endpoints)
50+
- [Retries](#retries)
5151
- [API Endpoints](#api-endpoints)
5252
- [Models](#models)
5353
- [OpenTelemetry](#opentelemetry)
@@ -1114,74 +1114,6 @@ fgaClient.writeAssertions(assertions, options).get();
11141114
```
11151115

11161116

1117-
### Retries
1118-
1119-
The SDK implements RFC 9110 compliant retry behavior with support for the `Retry-After` header. By default, the SDK will automatically retry failed requests up to **3 times** with delay calculation (maximum allowable: 15 retries).
1120-
1121-
#### Retry Behavior
1122-
1123-
**Rate Limiting (429 errors):** Always retried regardless of HTTP method.
1124-
1125-
**Server Errors (5xx):** All requests are retried on 5xx errors (except 501 Not Implemented) regardless of HTTP method:
1126-
- **All operations** (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS): Always retried on 5xx errors with delay calculation
1127-
1128-
#### Delay Calculation
1129-
1130-
1. **Retry-After header present**: Uses the server-specified delay (supports both integer seconds and HTTP-date formats)
1131-
2. **No Retry-After header**: Uses exponential backoff with jitter (base delay: 2^retryCount * 100ms, capped at 120 seconds)
1132-
3. **Minimum delay**: Respects the configured `minimumRetryDelay` as a floor value
1133-
1134-
#### Configuration
1135-
1136-
Customize retry behavior using the `ClientConfiguration` builder. The SDK enforces a maximum of 15 retries to prevent accidental server overload:
1137-
1138-
**⚠️ Breaking Changes:**
1139-
- Configuration validation now prevents setting `maxRetries` above 15
1140-
- `FgaError` now exposes the `Retry-After` header value via `getRetryAfterHeader()`
1141-
1142-
```java
1143-
import com.fasterxml.jackson.databind.ObjectMapper;
1144-
import dev.openfga.sdk.api.client.OpenFgaClient;
1145-
import dev.openfga.sdk.api.configuration.ClientConfiguration;
1146-
import java.net.http.HttpClient;
1147-
1148-
public class Example {
1149-
public static void main(String[] args) throws Exception {
1150-
var config = new ClientConfiguration()
1151-
.apiUrl(System.getenv("FGA_API_URL")) // If not specified, will default to "http://localhost:8080"
1152-
.storeId(System.getenv("FGA_STORE_ID")) // Not required when calling createStore() or listStores()
1153-
.authorizationModelId(System.getenv("FGA_MODEL_ID")) // Optional, can be overridden per request
1154-
.maxRetries(3) // retry up to 3 times on API requests (default: 3, maximum: 15)
1155-
.minimumRetryDelay(Duration.ofMillis(100)); // minimum wait time between retries in milliseconds (default: 100ms)
1156-
1157-
var fgaClient = new OpenFgaClient(config);
1158-
var response = fgaClient.readAuthorizationModels().get();
1159-
}
1160-
}
1161-
```
1162-
1163-
#### Error Handling with Retry Information
1164-
1165-
When handling errors, you can access the `Retry-After` header value for debugging or custom retry logic:
1166-
1167-
```java
1168-
try {
1169-
var response = fgaClient.check(request).get();
1170-
} catch (ExecutionException e) {
1171-
if (e.getCause() instanceof FgaError) {
1172-
FgaError error = (FgaError) e.getCause();
1173-
1174-
// Access Retry-After header if present
1175-
String retryAfter = error.getRetryAfterHeader();
1176-
if (retryAfter != null) {
1177-
System.out.println("Server requested retry after: " + retryAfter + " seconds");
1178-
}
1179-
1180-
System.out.println("Error: " + error.getMessage());
1181-
}
1182-
}
1183-
```
1184-
11851117
### Calling Other Endpoints
11861118

11871119
The API Executor provides direct HTTP access to OpenFGA endpoints not yet wrapped by the SDK. It maintains the SDK's client configuration including authentication, telemetry, retries, and error handling.
@@ -1288,6 +1220,77 @@ For a complete working example, see [examples/api-executor](examples/api-executo
12881220
See [docs/ApiExecutor.md](docs/ApiExecutor.md) for complete API reference and examples for both `ApiExecutor` and `StreamingApiExecutor`.
12891221

12901222

1223+
1224+
### Retries
1225+
1226+
The SDK implements RFC 9110 compliant retry behavior with support for the `Retry-After` header. By default, the SDK will automatically retry failed requests up to **3 times** with delay calculation (maximum allowable: 15 retries).
1227+
1228+
#### Retry Behavior
1229+
1230+
**Rate Limiting (429 errors):** Always retried regardless of HTTP method.
1231+
1232+
**Server Errors (5xx):** All requests are retried on 5xx errors (except 501 Not Implemented) regardless of HTTP method:
1233+
- **All operations** (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS): Always retried on 5xx errors with delay calculation
1234+
1235+
#### Delay Calculation
1236+
1237+
1. **Retry-After header present**: Uses the server-specified delay (supports both integer seconds and HTTP-date formats)
1238+
2. **No Retry-After header**: Uses exponential backoff with jitter (base delay: 2^retryCount * 100ms, capped at 120 seconds)
1239+
3. **Minimum delay**: Respects the configured `minimumRetryDelay` as a floor value
1240+
1241+
#### Configuration
1242+
1243+
Customize retry behavior using the `ClientConfiguration` builder. The SDK enforces a maximum of 15 retries to prevent accidental server overload:
1244+
1245+
**⚠️ Breaking Changes:**
1246+
- Configuration validation now prevents setting `maxRetries` above 15
1247+
- `FgaError` now exposes the `Retry-After` header value via `getRetryAfterHeader()`
1248+
1249+
```java
1250+
import com.fasterxml.jackson.databind.ObjectMapper;
1251+
import dev.openfga.sdk.api.client.OpenFgaClient;
1252+
import dev.openfga.sdk.api.configuration.ClientConfiguration;
1253+
import java.net.http.HttpClient;
1254+
1255+
public class Example {
1256+
public static void main(String[] args) throws Exception {
1257+
var config = new ClientConfiguration()
1258+
.apiUrl(System.getenv("FGA_API_URL")) // If not specified, will default to "http://localhost:8080"
1259+
.storeId(System.getenv("FGA_STORE_ID")) // Not required when calling createStore() or listStores()
1260+
.authorizationModelId(System.getenv("FGA_MODEL_ID")) // Optional, can be overridden per request
1261+
.maxRetries(3) // retry up to 3 times on API requests (default: 3, maximum: 15)
1262+
.minimumRetryDelay(Duration.ofMillis(100)); // minimum wait time between retries in milliseconds (default: 100ms)
1263+
1264+
var fgaClient = new OpenFgaClient(config);
1265+
var response = fgaClient.readAuthorizationModels().get();
1266+
}
1267+
}
1268+
```
1269+
1270+
#### Error Handling with Retry Information
1271+
1272+
When handling errors, you can access the `Retry-After` header value for debugging or custom retry logic:
1273+
1274+
```java
1275+
try {
1276+
var response = fgaClient.check(request).get();
1277+
} catch (ExecutionException e) {
1278+
if (e.getCause() instanceof FgaError) {
1279+
FgaError error = (FgaError) e.getCause();
1280+
1281+
// Access Retry-After header if present
1282+
String retryAfter = error.getRetryAfterHeader();
1283+
if (retryAfter != null) {
1284+
System.out.println("Server requested retry after: " + retryAfter + " seconds");
1285+
}
1286+
1287+
System.out.println("Error: " + error.getMessage());
1288+
}
1289+
}
1290+
```
1291+
1292+
1293+
12911294
### API Endpoints
12921295

12931296
| Method | HTTP request | Description |

0 commit comments

Comments
 (0)