diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 976edba..0877ea8 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -82,7 +82,6 @@ docs/WriteRequestDeletes.md docs/WriteRequestWrites.md example/Makefile example/README.md -example/example1/auth-model.json example/example1/example1.py example/example1/requirements.txt example/example1/setup.cfg diff --git a/README.md b/README.md index ffc6b30..07be3af 100644 --- a/README.md +++ b/README.md @@ -396,10 +396,7 @@ options = { "authorization_model_id": "01GXSA8YR785C4FYS3C0RTG7B1" } -response = await fga_client.read_authorization_model({ - # You can rely on the model id set in the configuration or override it for this specific request - "authorization_model_id": "01GXSA8YR785C4FYS3C0RTG7B1" -}) +response = await fga_client.read_authorization_model(options) # response.authorization_model = AuthorizationModel(id='01GXSA8YR785C4FYS3C0RTG7B1', schema_version = '1.1', type_definitions=type_definitions[...]) ``` @@ -429,7 +426,7 @@ options = { "page_size": "25", "continuation_token": "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==" } -body = ClientReadChangesRequest(type='document') +body = ClientReadChangesRequest(type="document") response = await fga_client.read_changes(body, options) # response.continuation_token = ... @@ -565,6 +562,11 @@ body = ClientWriteRequest( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="viewer", object="document:roadmap", + ), + ClientTuple( + user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", + relation="viewer", + object="document:budget", condition=RelationshipCondition( name='ViewCountLessThan200', context=dict( @@ -573,11 +575,6 @@ body = ClientWriteRequest( ), ), ), - ClientTuple( - user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", - relation="viewer", - object="document:budget", - ), ], deletes=[ ClientTuple( @@ -641,7 +638,7 @@ body = [ClientCheckRequest( ], context=dict( ViewCount=100 - ), + ) ), ClientCheckRequest( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="admin", @@ -675,9 +672,9 @@ response = await fga_client.batch_check(body, options) # relation: "editor", # object: "document:roadmap" # }], -# context=dict( -# ViewCount=100 -# ), +# context=dict( +# ViewCount=100 +# ) # } # }, { # allowed: false, @@ -798,7 +795,7 @@ Read assertions for a particular authorization model. [API Documentation](https://openfga.dev/api/service#/Assertions/Read%20Assertions) -```csharp +```python options = { # You can rely on the model id set in the configuration or override it for this specific request "authorization_model_id": "01GXSA8YR785C4FYS3C0RTG7B1" @@ -812,7 +809,7 @@ Update the assertions for a particular authorization model. [API Documentation](https://openfga.dev/api/service#/Assertions/Write%20Assertions) -```csharp +```python options = { # You can rely on the model id set in the configuration or override it for this specific request "authorization_model_id": "01GXSA8YR785C4FYS3C0RTG7B1" diff --git a/VERSION.txt b/VERSION.txt index 1c09c74..42045ac 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.3.3 +0.3.4 diff --git a/example/Makefile b/example/Makefile index 161efba..007c2d8 100644 --- a/example/Makefile +++ b/example/Makefile @@ -3,8 +3,11 @@ all: run project_name=example1 openfga_version=latest -run: - python example1/example1.py +setup: + cd "${project_name}/" && pip3 install -r requirements.txt && cd - + +run: setup + python3 "${project_name}/${project_name}.py" run-openfga: docker pull docker.io/openfga/openfga:${openfga_version} && \ diff --git a/example/example1/requirements.txt b/example/example1/requirements.txt index f400ac5..49a1d3a 100644 --- a/example/example1/requirements.txt +++ b/example/example1/requirements.txt @@ -4,7 +4,7 @@ attrs==23.1.0 frozenlist==1.4.1 idna==3.6 multidict==6.0.4 -openfga-sdk==0.3.2 +openfga-sdk==0.3.4 python-dateutil==2.8.2 six==1.16.0 urllib3==2.1.0 diff --git a/openfga_sdk/__init__.py b/openfga_sdk/__init__.py index 554a52d..4d810c4 100644 --- a/openfga_sdk/__init__.py +++ b/openfga_sdk/__init__.py @@ -14,7 +14,7 @@ NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. """ -__version__ = "0.3.3" +__version__ = "0.3.4" from openfga_sdk.client.client import OpenFgaClient from openfga_sdk.client.configuration import ClientConfiguration diff --git a/openfga_sdk/api_client.py b/openfga_sdk/api_client.py index 39fa5a8..db154a6 100644 --- a/openfga_sdk/api_client.py +++ b/openfga_sdk/api_client.py @@ -34,7 +34,7 @@ from openfga_sdk.exceptions import ApiValueError, ApiException, FgaValidationException, RateLimitExceededError -DEFAULT_USER_AGENT = 'openfga-sdk python/0.3.3' +DEFAULT_USER_AGENT = 'openfga-sdk python/0.3.4' def random_time(loop_count, min_wait_in_ms): diff --git a/openfga_sdk/client/client.py b/openfga_sdk/client/client.py index 450f31a..c5e33e1 100644 --- a/openfga_sdk/client/client.py +++ b/openfga_sdk/client/client.py @@ -631,8 +631,8 @@ async def list_relations(self, body: ClientListRelationsRequest, options: dict[s options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ListRelations") options = set_heading_if_not_set(options, CLIENT_BULK_REQUEST_ID_HEADER, str(uuid.uuid4())) - request_body = [construct_check_request( - user=body.user, relation=i, object=body.object, contextual_tuples=body.contextual_tuples, context=body.context) for i in body.relations] + request_body = [construct_check_request(user=body.user, relation=i, object=body.object, + contextual_tuples=body.contextual_tuples, context=body.context) for i in body.relations] result = await self.batch_check(request_body, options) # need to filter with the allowed response result_iterator = filter(_check_allowed, result) diff --git a/openfga_sdk/client/models/list_relations_request.py b/openfga_sdk/client/models/list_relations_request.py index 1372f8c..a38f8ba 100644 --- a/openfga_sdk/client/models/list_relations_request.py +++ b/openfga_sdk/client/models/list_relations_request.py @@ -10,6 +10,7 @@ NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. """ + from openfga_sdk.client.models.tuple import ClientTuple from typing import List diff --git a/openfga_sdk/configuration.py b/openfga_sdk/configuration.py index 739d1e3..29ca7dd 100644 --- a/openfga_sdk/configuration.py +++ b/openfga_sdk/configuration.py @@ -440,7 +440,7 @@ def to_debug_report(self): "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: 0.1\n"\ - "SDK Package Version: 0.3.3".\ + "SDK Package Version: 0.3.4".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self): diff --git a/openfga_sdk/oauth2.py b/openfga_sdk/oauth2.py index fb96fce..055dc93 100644 --- a/openfga_sdk/oauth2.py +++ b/openfga_sdk/oauth2.py @@ -54,7 +54,7 @@ async def _obtain_token(self, client): 'grant_type': "client_credentials", } headers = urllib3.response.HTTPHeaderDict( - {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.3.3'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.3.4'}) raw_response = await client.POST(token_url, headers=headers, body=body) if 200 <= raw_response.status <= 299: try: diff --git a/openfga_sdk/sync/api_client.py b/openfga_sdk/sync/api_client.py index ff1ccda..963aa4d 100644 --- a/openfga_sdk/sync/api_client.py +++ b/openfga_sdk/sync/api_client.py @@ -34,7 +34,7 @@ from openfga_sdk.exceptions import ApiValueError, ApiException, FgaValidationException, RateLimitExceededError -DEFAULT_USER_AGENT = 'openfga-sdk python/0.3.3' +DEFAULT_USER_AGENT = 'openfga-sdk python/0.3.4' def random_time(loop_count, min_wait_in_ms): diff --git a/openfga_sdk/sync/oauth2.py b/openfga_sdk/sync/oauth2.py index d947f48..e8bb124 100644 --- a/openfga_sdk/sync/oauth2.py +++ b/openfga_sdk/sync/oauth2.py @@ -54,7 +54,7 @@ def _obtain_token(self, client): 'grant_type': "client_credentials", } headers = urllib3.response.HTTPHeaderDict( - {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.3.3'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.3.4'}) raw_response = client.POST(token_url, headers=headers, body=body) if 200 <= raw_response.status <= 299: try: diff --git a/setup.py b/setup.py index df210bc..f17772c 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "openfga-sdk" -VERSION = "0.3.3" +VERSION = "0.3.4" # To install the library, run the following # # python setup.py install diff --git a/test/test_oauth2.py b/test/test_oauth2.py index 2d02ddd..cec9c36 100644 --- a/test/test_oauth2.py +++ b/test/test_oauth2.py @@ -82,7 +82,7 @@ async def test_get_authentication_obtain_client_credentials(self, mock_request): self.assertGreaterEqual(client._access_expiry_time, current_time + timedelta(seconds=int(120))) expected_header = urllib3.response.HTTPHeaderDict( - {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.3.3'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.3.4'}) mock_request.assert_called_once_with( 'POST', 'https://www.testme.com/oauth/token', diff --git a/test/test_oauth2_sync.py b/test/test_oauth2_sync.py index c97d466..1643bc6 100644 --- a/test/test_oauth2_sync.py +++ b/test/test_oauth2_sync.py @@ -83,7 +83,7 @@ def test_get_authentication_obtain_client_credentials(self, mock_request): self.assertGreaterEqual(client._access_expiry_time, current_time + timedelta(seconds=int(120))) expected_header = urllib3.response.HTTPHeaderDict( - {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.3.3'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.3.4'}) mock_request.assert_called_once_with( 'POST', 'https://www.testme.com/oauth/token', diff --git a/test/test_open_fga_api.py b/test/test_open_fga_api.py index 468c44b..503fa4c 100644 --- a/test/test_open_fga_api.py +++ b/test/test_open_fga_api.py @@ -1180,7 +1180,7 @@ async def test_check_api_token(self, mock_request): self.assertTrue(api_response.allowed) # Make sure the API was called with the right data expected_headers = urllib3.response.HTTPHeaderDict( - {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.3', 'Authorization': 'Bearer TOKEN1'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.4', 'Authorization': 'Bearer TOKEN1'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check', @@ -1223,7 +1223,7 @@ async def test_check_custom_header(self, mock_request): self.assertTrue(api_response.allowed) # Make sure the API was called with the right data expected_headers = urllib3.response.HTTPHeaderDict( - {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.3', 'Custom Header': 'custom value'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.4', 'Custom Header': 'custom value'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check', diff --git a/test/test_open_fga_api_sync.py b/test/test_open_fga_api_sync.py index b99c9d2..faeebb6 100644 --- a/test/test_open_fga_api_sync.py +++ b/test/test_open_fga_api_sync.py @@ -1181,7 +1181,7 @@ async def test_check_api_token(self, mock_request): self.assertTrue(api_response.allowed) # Make sure the API was called with the right data expected_headers = urllib3.response.HTTPHeaderDict( - {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.3', 'Authorization': 'Bearer TOKEN1'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.4', 'Authorization': 'Bearer TOKEN1'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check', @@ -1224,7 +1224,7 @@ async def test_check_custom_header(self, mock_request): self.assertTrue(api_response.allowed) # Make sure the API was called with the right data expected_headers = urllib3.response.HTTPHeaderDict( - {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.3', 'Custom Header': 'custom value'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.4', 'Custom Header': 'custom value'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check',