Skip to content

Commit ccfe7a6

Browse files
committed
feat!: request via python
Ability to do batch check, write and list relations No longer supports python 3.9
1 parent 68ba5e1 commit ccfe7a6

24 files changed

Lines changed: 3352 additions & 31 deletions

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["3.9", "3.10"]
14+
python-version: ["3.10", "3.11"]
1515
steps:
1616
- uses: actions/checkout@v3
1717
- name: Set up Python ${{ matrix.python-version }}

.openapi-generator-ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ test/*
33
!test/__init__.py
44
!test/test_open_fga_api.py
55
!test/test_credentials.py
6+
!test/test_openfga_client.py
67
.gitlab-ci.yml
78
.travis.yml
89
tox.ini

.openapi-generator/FILES

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ openfga_sdk/__init__.py
7171
openfga_sdk/api/__init__.py
7272
openfga_sdk/api/open_fga_api.py
7373
openfga_sdk/api_client.py
74+
openfga_sdk/client/__init__.py
75+
openfga_sdk/client/batch_check_response.py
76+
openfga_sdk/client/check_request_body.py
77+
openfga_sdk/client/client_tuple.py
78+
openfga_sdk/client/client_write_request.py
79+
openfga_sdk/client/client_write_response.py
80+
openfga_sdk/client/configuration.py
81+
openfga_sdk/client/expand_request_body.py
82+
openfga_sdk/client/list_objects_request_body.py
83+
openfga_sdk/client/list_relations_request_body.py
84+
openfga_sdk/client/openfga_client.py
85+
openfga_sdk/client/read_changes_body.py
86+
openfga_sdk/client/single_write_response.py
87+
openfga_sdk/client/write_transaction.py
7488
openfga_sdk/configuration.py
7589
openfga_sdk/credentials.py
7690
openfga_sdk/exceptions.py
@@ -137,3 +151,4 @@ test-requirements.txt
137151
test/__init__.py
138152
test/test_credentials.py
139153
test/test_open_fga_api.py
154+
test/test_openfga_client.py

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ Class | Method | HTTP request | Description
661661
*OpenFgaApi* | [**delete_store**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#delete_store) | **DELETE** /stores/{store_id} | Delete a store
662662
*OpenFgaApi* | [**expand**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#expand) | **POST** /stores/{store_id}/expand | Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship
663663
*OpenFgaApi* | [**get_store**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#get_store) | **GET** /stores/{store_id} | Get a store
664-
*OpenFgaApi* | [**list_objects**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#list_objects) | **POST** /stores/{store_id}/list-objects | Get all objects of the given type that the user has a relation with
664+
*OpenFgaApi* | [**list_objects**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#list_objects) | **POST** /stores/{store_id}/list-objects | List all objects of the given type that the user has a relation with
665665
*OpenFgaApi* | [**list_stores**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#list_stores) | **GET** /stores | List all stores
666666
*OpenFgaApi* | [**read**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#read) | **POST** /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules
667667
*OpenFgaApi* | [**read_assertions**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#read_assertions) | **GET** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID

docs/OpenFgaApi.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Method | HTTP request | Description
99
[**delete_store**](OpenFgaApi.md#delete_store) | **DELETE** /stores/{store_id} | Delete a store
1010
[**expand**](OpenFgaApi.md#expand) | **POST** /stores/{store_id}/expand | Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship
1111
[**get_store**](OpenFgaApi.md#get_store) | **GET** /stores/{store_id} | Get a store
12-
[**list_objects**](OpenFgaApi.md#list_objects) | **POST** /stores/{store_id}/list-objects | Get all objects of the given type that the user has a relation with
12+
[**list_objects**](OpenFgaApi.md#list_objects) | **POST** /stores/{store_id}/list-objects | List all objects of the given type that the user has a relation with
1313
[**list_stores**](OpenFgaApi.md#list_stores) | **GET** /stores | List all stores
1414
[**read**](OpenFgaApi.md#read) | **POST** /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules
1515
[**read_assertions**](OpenFgaApi.md#read_assertions) | **GET** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID
@@ -417,9 +417,9 @@ No authorization required
417417
# **list_objects**
418418
> ListObjectsResponse list_objects(body)
419419
420-
Get all objects of the given type that the user has a relation with
420+
List all objects of the given type that the user has a relation with
421421

422-
The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is, it will be used to decide the underlying implementation used. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). Note: If you have `and` or `but not` in your model while using ListObjects, checkout the [caveats](https://openfga.dev/docs/interacting/relationship-queries#caveats-and-when-not-to-use-it-3).
422+
The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is, it will be used to decide the underlying implementation used. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. Note: If you have `and` or `but not` in your model while using ListObjects, checkout the [caveats](https://openfga.dev/docs/interacting/relationship-queries#caveats-and-when-not-to-use-it-3).
423423

424424
### Example
425425

@@ -456,7 +456,7 @@ async with openfga_sdk.ApiClient(configuration) as api_client:
456456
body = openfga_sdk.ListObjectsRequest() # ListObjectsRequest |
457457

458458
try:
459-
# Get all objects of the given type that the user has a relation with
459+
# List all objects of the given type that the user has a relation with
460460
api_response = await api_instance.api_instance.list_objects(body)
461461
pprint(api_response)
462462
except ApiException as e:

openfga_sdk/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
__version__ = "0.1.1"
1818

19+
from openfga_sdk.client.openfga_client import OpenFgaClient
20+
from openfga_sdk.client.configuration import ClientConfiguration
21+
1922
# import apis into sdk package
2023
from openfga_sdk.api.open_fga_api import OpenFgaApi
2124

0 commit comments

Comments
 (0)