From d35fef537d3c4fd9ed600fd34e423085d5affdb9 Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Thu, 25 May 2023 17:03:14 -0400 Subject: [PATCH] release: v0.2.0 - OpenFgaClient with batch_check, list_relations and more --- CHANGELOG.md | 15 +++++++++++++++ VERSION.txt | 2 +- openfga_sdk/__init__.py | 2 +- openfga_sdk/api_client.py | 2 +- openfga_sdk/configuration.py | 2 +- openfga_sdk/credentials.py | 2 +- setup.py | 2 +- test/test_credentials.py | 2 +- test/test_open_fga_api.py | 4 ++-- 9 files changed, 24 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4691b1b..9450183 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## v0.2.0 + +### [0.2.0](https://github.com/openfga/python-sdk/compare/v0.1.1...v0.2.0) (2023-05-25) + +Changes: +- [BREAKING] feat!: `schema_version` is now required when calling `write_authorization_model` +- [BREAKING] chore!: drop support for python < 3.10 +- feat(client): add OpenFgaClient wrapper see [docs](https://github.com/openfga/python-sdk/tree/main#readme), see the `v0.1.1` docs for [the OpenFgaApi docs](https://github.com/openfga/python-sdk/tree/v0.1.1#readme) +- feat(client): implement `batch_check` to check multiple tuples in parallel +- feat(client): implement `list_relations` to check in one call whether a user has multiple relations to an objects +- feat(client): add support for a non-transactional `write` +- feat(validation): ensure storeId and authorizationModelId are in valid ulid format +- chore(config): bump default max retries to `15` +- chore(deps): upgrade dependencies + ## v0.1.1 ### [0.1.1](https://github.com/openfga/python-sdk/compare/v0.1.0...v0.1.1) (2023-01-17) diff --git a/VERSION.txt b/VERSION.txt index 17e51c3..0ea3a94 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.1.1 +0.2.0 diff --git a/openfga_sdk/__init__.py b/openfga_sdk/__init__.py index 7023883..2045c3a 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.1.1" +__version__ = "0.2.0" 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 5b0bd96..49c054b 100644 --- a/openfga_sdk/api_client.py +++ b/openfga_sdk/api_client.py @@ -92,7 +92,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.cookie = cookie # Set default User-Agent. self.user_agent = 'openfga-sdk {sdkId}/{packageVersion}'.replace( - '{sdkId}', 'python').replace('{packageVersion}', '0.1.1') + '{sdkId}', 'python').replace('{packageVersion}', '0.2.0') self.client_side_validation = configuration.client_side_validation async def __aenter__(self): diff --git a/openfga_sdk/configuration.py b/openfga_sdk/configuration.py index 629e5e6..98265e5 100644 --- a/openfga_sdk/configuration.py +++ b/openfga_sdk/configuration.py @@ -439,7 +439,7 @@ def to_debug_report(self): "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: 0.1\n"\ - "SDK Package Version: 0.1.1".\ + "SDK Package Version: 0.2.0".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self): diff --git a/openfga_sdk/credentials.py b/openfga_sdk/credentials.py index 571c3e0..9c45425 100644 --- a/openfga_sdk/credentials.py +++ b/openfga_sdk/credentials.py @@ -215,7 +215,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.1.1'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.2.0'}) raw_response = await client.POST(token_url, headers=headers, body=body) if 200 <= raw_response.status <= 299: try: diff --git a/setup.py b/setup.py index aecedb6..73342e1 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "openfga-sdk" -VERSION = "0.1.1" +VERSION = "0.2.0" # To install the library, run the following # # python setup.py install diff --git a/test/test_credentials.py b/test/test_credentials.py index a914568..2952aa0 100644 --- a/test/test_credentials.py +++ b/test/test_credentials.py @@ -219,7 +219,7 @@ async def test_get_authentication_obtain_client_credentials(self, mock_request): self.assertGreaterEqual(credential._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.1.1'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.2.0'}) 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 a3d827d..db48ebe 100644 --- a/test/test_open_fga_api.py +++ b/test/test_open_fga_api.py @@ -1174,7 +1174,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 expectedHeader = urllib3.response.HTTPHeaderDict( - {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.1.1', 'Authorization': 'Bearer TOKEN1'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.2.0', 'Authorization': 'Bearer TOKEN1'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check', @@ -1217,7 +1217,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 expectedHeader = urllib3.response.HTTPHeaderDict( - {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.1.1', 'Custom Header': 'custom value'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.2.0', 'Custom Header': 'custom value'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check',