Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/clients/python/config.overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"pythonMinimumRuntime": "3.10",
"openTelemetryDocumentation": "docs/opentelemetry.md",
"supportsStreamedListObjects": "streamed_list_objects",
"supportsExecuteApiRequest": true,
"files": {
"src/constants.mustache": {
"destinationFilename": "openfga_sdk/constants.py",
Expand Down
40 changes: 19 additions & 21 deletions config/clients/python/patches/open_fga_api.py.patch
Original file line number Diff line number Diff line change
@@ -1,55 +1,53 @@
--- clients/fga-python-sdk/openfga_sdk/api/open_fga_api.py 2022-09-13 14:15:46.000000000 -0400
+++ open_fga_api.py 2022-09-13 14:14:01.000000000 -0400
@@ -229,8 +236,10 @@
--- clients/fga-python-sdk/openfga_sdk/api/open_fga_api.py
+++ open_fga_api.py
@@ -501,13 +501,15 @@
local_var_params=local_var_params,
)

- async def create_store(self, **kwargs):
+ async def create_store(self, body, **kwargs):
"""Create a store

Create a unique OpenFGA store which will be used to store authorization models and relationship tuples.

- >>> thread = await api.create_store()
-
+ >>> thread = await api.create_store(body)

+
+ :param body: (required)
+ :type body: CreateStoreRequest
:param async_req: Whether to execute the request asynchronously.
@@ -216,15 +218,17 @@
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -524,15 +526,17 @@
:rtype: CreateStoreResponse
"""
kwargs["_return_http_data_only"] = True
- return await self.create_store_with_http_info(**kwargs)
+ return await self.create_store_with_http_info(body, **kwargs)

-
- async def create_store_with_http_info(self, **kwargs):
+ return await self.create_store_with_http_info(body, **kwargs)
+
+ async def create_store_with_http_info(self, body, **kwargs):
"""Create a store

Create a unique OpenFGA store which will be used to store authorization models and relationship tuples.

- >>> thread = api.create_store_with_http_info()
-
+ >>> thread = api.create_store_with_http_info(body)

+
+ :param body: (required)
+ :type body: CreateStoreRequest
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
@@ -253,6 +257,8 @@
@@ -561,7 +565,7 @@
local_var_params = locals()

all_params = [

-
+ 'body'
+
]
all_params.extend(
[
@@ -368,3 +370,3 @@
return await (self.api_client.call_api(
- '/stores'.replace('{store_id}', store_id), 'POST',
+ '/stores', 'POST',
path_params,
@@ -1192,3 +1194,3 @@
return await (self.api_client.call_api(
- '/stores'.replace('{store_id}', store_id), 'GET',
+ '/stores', 'GET',
path_params,
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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 `{{appShortName}}Client`. 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).

For streaming endpoints, use `execute_streamed_api_request` instead.

This is useful when:
- You want to call a new endpoint that is not yet supported by the SDK
- You are using an earlier version of the SDK that doesn't yet support a particular endpoint
- You have a custom endpoint deployed that extends the OpenFGA API

#### Example: Calling a Custom Endpoint with POST

```python
# Call a custom endpoint using path parameters
response = await fga_client.execute_api_request(
operation_name="CustomEndpoint", # For telemetry/logging
method="POST",
path="/stores/{store_id}/custom-endpoint",
path_params={"store_id": FGA_STORE_ID},
body={
"user": "user:bob",
"action": "custom_action",
"resource": "resource:123",
},
query_params={
"page_size": 20,
},
)

# Access the response data
if response.status == 200:
result = response.json()
print(f"Response: {result}")
```

#### Example: Calling an existing endpoint with GET

```python
# Get a list of stores with query parameters
stores_response = await fga_client.execute_api_request(
operation_name="ListStores",
method="GET",
path="/stores",
query_params={
"page_size": 10,
"continuation_token": "eyJwayI6...",
},
)

stores = stores_response.json()
print("Stores:", stores)
```

#### Example: Using Path Parameters

Path parameters are specified in the path using `{param_name}` syntax and are replaced with URL-encoded values from the `path_params` dictionary. If `{store_id}` is present in the path and not provided in `path_params`, it will be automatically replaced with the configured store_id:

```python
# Using explicit path parameters
response = await fga_client.execute_api_request(
operation_name="GetAuthorizationModel",
method="GET",
path="/stores/{store_id}/authorization-models/{model_id}",
path_params={
"store_id": "your-store-id",
"model_id": "your-model-id",
},
)

# Using automatic store_id substitution
response = await fga_client.execute_api_request(
operation_name="GetAuthorizationModel",
method="GET",
path="/stores/{store_id}/authorization-models/{model_id}",
path_params={
"model_id": "your-model-id",
},
)
```
Loading
Loading