Skip to content

Commit

Permalink
release(v0.4.0): with conditions and breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh committed Jan 11, 2024
1 parent 48dbb61 commit ee8c02f
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 15 deletions.
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.4
0.4.0
2 changes: 1 addition & 1 deletion example/example1/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openfga_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openfga_sdk/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion openfga_sdk/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion openfga_sdk/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion openfga_sdk/sync/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion openfga_sdk/sync/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/test_oauth2_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions test/test_open_fga_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions test/test_open_fga_api_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit ee8c02f

Please sign in to comment.