Skip to content

Commit dd1f1fb

Browse files
Merge branch 'main' into main
2 parents 4d40ab1 + 33a3168 commit dd1f1fb

15 files changed

Lines changed: 2830 additions & 3256 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: PR Title Conventional Commit Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, edited]
6+
branches:
7+
- main
8+
9+
jobs:
10+
validate-pr-title:
11+
name: Validate PR Title
12+
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: read
15+
steps:
16+
- name: PR Conventional Commit Validation
17+
uses: ytanikin/pr-conventional-commits@fda730cb152c05a849d6d84325e50c6182d9d1e9 # v1.5.1
18+
with:
19+
task_types: '["feat","fix","docs","test","refactor","ci","perf","chore","revert"]'
20+
add_label: 'false'
21+

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## [Unreleased](https://github.com/openfga/python-sdk/compare/v0.9.9...HEAD)
44

5+
- feat: add `execute_api_request` and `execute_streamed_api_request` methods to `OpenFgaClient` and `OpenFgaApi` for making arbitrary HTTP requests to any OpenFGA API endpoint with full auth, retry, and telemetry support (#252) - thanks @kcbiradar
6+
7+
### Breaking Changes
8+
9+
- The `_return_http_data_only`, `_preload_content`, `_request_auth`, `async_req`, and `_request_timeout` kwargs have been removed from all `OpenFgaApi` and `SyncOpenFgaApi` endpoint methods. These were internal implementation details not intended for external use. `_return_http_data_only` is now hardcoded to `True`; all endpoint methods return the deserialized response object directly. Users relying on `_with_http_info` methods returning a `(data, status, headers)` tuple should use `execute_api_request` instead.
10+
511
### [0.9.9](https://github.com/openfga/python-sdk/compare/v0.9.8...v0.9.9) (2025-12-09)
612
- feat: improve error messaging (#245)
713

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ This is an autogenerated python SDK for OpenFGA. It provides a wrapper around th
4848
- [Read Assertions](#read-assertions)
4949
- [Write Assertions](#write-assertions)
5050
- [Retries](#retries)
51+
- [Calling Other Endpoints](#calling-other-endpoints)
5152
- [API Endpoints](#api-endpoints)
5253
- [Models](#models)
5354
- [OpenTelemetry](#opentelemetry)
@@ -1260,6 +1261,96 @@ body = [ClientAssertion(
12601261
response = await fga_client.write_assertions(body, options)
12611262
```
12621263

1264+
### Calling Other Endpoints
1265+
1266+
In certain cases you may want to call other APIs not yet wrapped by the SDK. You can do so by using the `execute_api_request` method available on the `OpenFgaClient`. It allows you to make raw HTTP calls to any OpenFGA endpoint by specifying the HTTP method, path, body, query parameters, and path parameters, while still honoring the client configuration (authentication, telemetry, retries, and error handling).
1267+
1268+
For streaming endpoints (e.g. `streamed-list-objects`), use `execute_streamed_api_request` instead. It returns an `AsyncIterator` (or `Iterator` in the sync client) that yields one parsed JSON object per chunk.
1269+
1270+
This is useful when:
1271+
- You want to call a new endpoint that is not yet supported by the SDK
1272+
- You are using an earlier version of the SDK that doesn't yet support a particular endpoint
1273+
- You have a custom endpoint deployed that extends the OpenFGA API
1274+
1275+
#### Example: Calling a Custom Endpoint with POST
1276+
1277+
```python
1278+
# Call a custom endpoint using path parameters
1279+
response = await fga_client.execute_api_request(
1280+
operation_name="CustomEndpoint", # For telemetry/logging
1281+
method="POST",
1282+
path="/stores/{store_id}/custom-endpoint",
1283+
path_params={"store_id": FGA_STORE_ID},
1284+
body={
1285+
"user": "user:bob",
1286+
"action": "custom_action",
1287+
"resource": "resource:123",
1288+
},
1289+
query_params={
1290+
"page_size": 20,
1291+
},
1292+
)
1293+
1294+
# Access the response data
1295+
if response.status == 200:
1296+
result = response.json()
1297+
print(f"Response: {result}")
1298+
```
1299+
1300+
#### Example: Calling an existing endpoint with GET
1301+
1302+
```python
1303+
# Get a list of stores with query parameters
1304+
stores_response = await fga_client.execute_api_request(
1305+
operation_name="ListStores",
1306+
method="GET",
1307+
path="/stores",
1308+
query_params={
1309+
"page_size": 10,
1310+
"continuation_token": "eyJwayI6...",
1311+
},
1312+
)
1313+
1314+
stores = stores_response.json()
1315+
print("Stores:", stores)
1316+
```
1317+
1318+
#### Example: Calling a Streaming Endpoint
1319+
1320+
```python
1321+
# Stream objects visible to a user
1322+
async for chunk in fga_client.execute_streamed_api_request(
1323+
operation_name="StreamedListObjects",
1324+
method="POST",
1325+
path="/stores/{store_id}/streamed-list-objects",
1326+
path_params={"store_id": FGA_STORE_ID},
1327+
body={
1328+
"type": "document",
1329+
"relation": "viewer",
1330+
"user": "user:anne",
1331+
"authorization_model_id": FGA_MODEL_ID,
1332+
},
1333+
):
1334+
# Each chunk has the shape {"result": {"object": "..."}} or {"error": {...}}
1335+
if "result" in chunk:
1336+
print(chunk["result"]["object"]) # e.g. "document:roadmap"
1337+
```
1338+
1339+
#### Example: Using Path Parameters
1340+
1341+
Path parameters are specified in the path using `{param_name}` syntax and must all be provided explicitly via `path_params` (URL-encoded automatically):
1342+
1343+
```python
1344+
response = await fga_client.execute_api_request(
1345+
operation_name="GetAuthorizationModel",
1346+
method="GET",
1347+
path="/stores/{store_id}/authorization-models/{model_id}",
1348+
path_params={
1349+
"store_id": "your-store-id",
1350+
"model_id": "your-model-id",
1351+
},
1352+
)
1353+
```
12631354

12641355
### Retries
12651356

0 commit comments

Comments
 (0)