From ee8c02f91538cc8c87a754802841272c9b77ebb6 Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Thu, 11 Jan 2024 10:49:27 -0500 Subject: [PATCH] release(v0.4.0): with conditions and breaking changes --- CHANGELOG.md | 45 +++++++++++++++++++++++++++++++ VERSION.txt | 2 +- example/example1/requirements.txt | 2 +- openfga_sdk/__init__.py | 2 +- openfga_sdk/api_client.py | 2 +- openfga_sdk/configuration.py | 2 +- openfga_sdk/oauth2.py | 2 +- openfga_sdk/sync/api_client.py | 2 +- openfga_sdk/sync/oauth2.py | 2 +- setup.py | 2 +- test/test_oauth2.py | 2 +- test/test_oauth2_sync.py | 2 +- test/test_open_fga_api.py | 4 +-- test/test_open_fga_api_sync.py | 4 +-- 14 files changed, 60 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c0f464..e2e479b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,50 @@ # Changelog +## v0.4.0 + +### [0.4.0](https://github.com/openfga/python-sdk/compare/v0.3.4...v0.4.0) (2024-01-11) + +- feat: support for [conditions](https://openfga.dev/blog/conditional-tuples-announcement) +- chore!: use latest API interfaces for type info +- chore: add [example project](./example) +- chore: dependency updates + +BREAKING CHANGES: +Note: This release comes with substantial breaking changes, especially to the interfaces due to the protobuf changes in the last release. + +While the http interfaces did not break (you can still use `v0.3.3` SDK with a `v1.3.8+` server), +the grpc interface did and this caused a few changes in the interfaces of the SDK. + +If you are using `OpenFgaClient`, the changes required should be smaller, if you are using `OpenFgaApi` a bit more changes will be needed. + +You will have to modify some parts of your code, but we hope this will be to the better as a lot of the parameters are now correctly marked as required, +and so the Pointer-to-String conversion is no longer needed. + +Some of the changes to expect: +- The following request interfaces changed: + - `CheckRequest`: the `TupleKey` field is now of interface `CheckRequestTupleKey`, you can also now pass in `Context` + - `ExpandRequest`: the `TupleKey` field is now of interface `ExpandRequestTupleKey` + - `ReadRequest`: the `TupleKey` field is now of interface `ReadRequestTupleKey` + - `WriteRequest`: now takes `WriteRequestWrites` and `WriteRequestDeletes`, the latter of which accepts `TupleKeyWithoutCondition` + - And more +- The following interfaces had fields that were optional are are now required: + - `CreateStoreResponse` + - `GetStoreResponse` + - `ListStoresResponse` + - `ListObjectsResponse` + - `ReadChangesResponse` + - `ReadResponse` + - `AuthorizationModel` + - And more + +Take a look at the changes in models in https://github.com/openfga/python-sdk/commit/9ed1f70d64db71451de2eb26e330bbd511625c5c and https://github.com/openfga/python-sdk/pull/59/files for more. + +## v0.3.4 + +### [0.3.4](https://github.com/openfga/python-sdk/compare/v0.3.3...v0.3.4) (2024-01-09) + +Note: `v0.3.4` has been re-released as `v0.4.0` due to breaking changes + ## v0.3.3 ### [0.3.3](https://github.com/openfga/python-sdk/compare/v0.3.2...v0.3.3) (2024-01-02) diff --git a/VERSION.txt b/VERSION.txt index 42045ac..1d0ba9e 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.3.4 +0.4.0 diff --git a/example/example1/requirements.txt b/example/example1/requirements.txt index 49a1d3a..a0faf30 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.4 +openfga-sdk==0.4.0 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 4d810c4..c9dfa90 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.4" +__version__ = "0.4.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 db154a6..072500d 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.4' +DEFAULT_USER_AGENT = 'openfga-sdk python/0.4.0' def random_time(loop_count, min_wait_in_ms): diff --git a/openfga_sdk/configuration.py b/openfga_sdk/configuration.py index 29ca7dd..1e9df8b 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.4".\ + "SDK Package Version: 0.4.0".\ 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 055dc93..3d3a6db 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.4'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.4.0'}) 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 963aa4d..cdb59b1 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.4' +DEFAULT_USER_AGENT = 'openfga-sdk python/0.4.0' def random_time(loop_count, min_wait_in_ms): diff --git a/openfga_sdk/sync/oauth2.py b/openfga_sdk/sync/oauth2.py index e8bb124..18bd12a 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.4'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.4.0'}) 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 f17772c..3f762af 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.4" +VERSION = "0.4.0" # To install the library, run the following # # python setup.py install diff --git a/test/test_oauth2.py b/test/test_oauth2.py index cec9c36..620fe0e 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.4'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.4.0'}) 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 1643bc6..62d6e4a 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.4'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk (python) 0.4.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 503fa4c..eaebc2c 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.4', 'Authorization': 'Bearer TOKEN1'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.4.0', '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.4', 'Custom Header': 'custom value'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.4.0', '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 faeebb6..546a959 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.4', 'Authorization': 'Bearer TOKEN1'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.4.0', '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.4', 'Custom Header': 'custom value'}) + {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.4.0', 'Custom Header': 'custom value'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check',