Skip to content

Commit

Permalink
feat: Introduce synchronous OpenFgaClient (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh authored Oct 27, 2023
2 parents 1c0d545 + 2f313f4 commit c92b436
Show file tree
Hide file tree
Showing 17 changed files with 7,851 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/semgrep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
image: returntocorp/semgrep
if: (github.actor != 'dependabot[bot]' && github.actor != 'snyk-bot')
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.2
- run: semgrep ci
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
5 changes: 5 additions & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ test/*
!test/test_open_fga_api.py
!test/test_credentials.py
!test/test_client.py
!test/test_client_sync.py
!test/test_open_fga_api_sync.py
!test/test_validation.py
!test/test_credentials_sync.py
.github/workflows/python.yml
.gitlab-ci.yml
.travis.yml
tox.ini
11 changes: 11 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ docs/WriteRequest.md
openfga_sdk/__init__.py
openfga_sdk/api/__init__.py
openfga_sdk/api/open_fga_api.py
openfga_sdk/api/open_fga_api_sync.py
openfga_sdk/api_client.py
openfga_sdk/client/__init__.py
openfga_sdk/client/client.py
Expand Down Expand Up @@ -146,12 +147,22 @@ openfga_sdk/models/write_authorization_model_request.py
openfga_sdk/models/write_authorization_model_response.py
openfga_sdk/models/write_request.py
openfga_sdk/rest.py
openfga_sdk/sync/__init__.py
openfga_sdk/sync/api_client.py
openfga_sdk/sync/client/__init__.py
openfga_sdk/sync/client/client.py
openfga_sdk/sync/credentials.py
openfga_sdk/sync/rest.py
openfga_sdk/validation.py
requirements.txt
setup.cfg
setup.py
test-requirements.txt
test/__init__.py
test/test_client.py
test/test_client_sync.py
test/test_credentials.py
test/test_credentials_sync.py
test/test_open_fga_api.py
test/test_open_fga_api_sync.py
test/test_validation.py
2 changes: 1 addition & 1 deletion docs/OpenFgaApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ No authorization required
List all objects of the given type that the user has a relation with

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 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.
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 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. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects.

### Example

Expand Down
4 changes: 2 additions & 2 deletions openfga_sdk/api/open_fga_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ async def get_store_with_http_info(self, **kwargs): # noqa: E501
async def list_objects(self, body, **kwargs): # noqa: E501
"""List all objects of the given type that the user has a relation with # noqa: E501
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 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. # noqa: E501
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 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. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. # noqa: E501
>>> thread = await api.list_objects(body)
Expand All @@ -772,7 +772,7 @@ async def list_objects(self, body, **kwargs): # noqa: E501
async def list_objects_with_http_info(self, body, **kwargs): # noqa: E501
"""List all objects of the given type that the user has a relation with # noqa: E501
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 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. # noqa: E501
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 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. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. # noqa: E501
>>> thread = api.list_objects_with_http_info(body)
Expand Down
1 change: 1 addition & 0 deletions openfga_sdk/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ async def __call_api(
except RateLimitExceededError as e:
if x < max_retry:
await asyncio.sleep(random_time(x, min_wait_in_ms))

continue
e.body = e.body.decode('utf-8') if six.PY3 else e.body
response_type = response_types_map.get(e.status, None)
Expand Down
18 changes: 18 additions & 0 deletions openfga_sdk/sync/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# coding: utf-8

# flake8: noqa
"""
Python SDK for OpenFGA
API version: 0.1
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://discord.gg/8naAwJfWN6
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

from openfga_sdk.sync.client.client import OpenFgaClient
from openfga_sdk.sync.api_client import ApiClient
from openfga_sdk.sync.credentials import Credentials
Loading

0 comments on commit c92b436

Please sign in to comment.