diff --git a/openfga_sdk/models/read_response.py b/openfga_sdk/models/read_response.py index f95c8e5..bb3bc81 100644 --- a/openfga_sdk/models/read_response.py +++ b/openfga_sdk/models/read_response.py @@ -103,8 +103,8 @@ def continuation_token(self, continuation_token): :param continuation_token: The continuation_token of this ReadResponse. # noqa: E501 :type continuation_token: str """ - # if self.local_vars_configuration.client_side_validation and continuation_token is None: # noqa: E501 - # raise ValueError("Invalid value for `continuation_token`, must not be `None`") # noqa: E501 + if self.local_vars_configuration.client_side_validation and continuation_token is None: # noqa: E501 + raise ValueError("Invalid value for `continuation_token`, must not be `None`") # noqa: E501 self._continuation_token = continuation_token diff --git a/openfga_sdk/models/tuple_key.py b/openfga_sdk/models/tuple_key.py index 5e65c0a..3524e3f 100644 --- a/openfga_sdk/models/tuple_key.py +++ b/openfga_sdk/models/tuple_key.py @@ -87,11 +87,11 @@ def user(self, user): :param user: The user of this TupleKey. # noqa: E501 :type user: str """ - # if self.local_vars_configuration.client_side_validation and user is None: # noqa: E501 - # raise ValueError("Invalid value for `user`, must not be `None`") # noqa: E501 - # if (self.local_vars_configuration.client_side_validation and - # user is not None and len(user) > 512): - # raise ValueError("Invalid value for `user`, length must be less than or equal to `512`") # noqa: E501 + if self.local_vars_configuration.client_side_validation and user is None: # noqa: E501 + raise ValueError("Invalid value for `user`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + user is not None and len(user) > 512): + raise ValueError("Invalid value for `user`, length must be less than or equal to `512`") # noqa: E501 self._user = user @@ -113,11 +113,11 @@ def relation(self, relation): :param relation: The relation of this TupleKey. # noqa: E501 :type relation: str """ - # if self.local_vars_configuration.client_side_validation and relation is None: # noqa: E501 - # raise ValueError("Invalid value for `relation`, must not be `None`") # noqa: E501 - # if (self.local_vars_configuration.client_side_validation and - # relation is not None and len(relation) > 50): - # raise ValueError("Invalid value for `relation`, length must be less than or equal to `50`") # noqa: E501 + if self.local_vars_configuration.client_side_validation and relation is None: # noqa: E501 + raise ValueError("Invalid value for `relation`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + relation is not None and len(relation) > 50): + raise ValueError("Invalid value for `relation`, length must be less than or equal to `50`") # noqa: E501 self._relation = relation diff --git a/openfga_sdk/sync/client/client.py b/openfga_sdk/sync/client/client.py index be24810..9eb8225 100644 --- a/openfga_sdk/sync/client/client.py +++ b/openfga_sdk/sync/client/client.py @@ -36,6 +36,7 @@ from openfga_sdk.models.list_objects_request import ListObjectsRequest from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse from openfga_sdk.models.read_request import ReadRequest +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.tuple_key import TupleKey from openfga_sdk.models.write_assertions_request import WriteAssertionsRequest from openfga_sdk.models.write_authorization_model_request import WriteAuthorizationModelRequest @@ -331,7 +332,7 @@ def read_changes(self, body: ClientReadChangesRequest, options: dict[str, str] = ) return api_response - def read(self, body: TupleKey, options: dict[str, str] = None): + def read(self, body: ReadRequestTupleKey, options: dict[str, str] = None): """ Read changes for specified type :param body - the tuples we want to read diff --git a/test/test_client.py b/test/test_client.py index f816bbc..17b36aa 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -639,7 +639,8 @@ async def test_read(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -661,7 +662,7 @@ async def test_read(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -692,7 +693,8 @@ async def test_read_empty_options(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -700,7 +702,7 @@ async def test_read_empty_options(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client async with OpenFgaClient(configuration) as api_client: - body = TupleKey( + body = ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -713,7 +715,7 @@ async def test_read_empty_options(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -744,7 +746,8 @@ async def test_read_empty_body(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -752,7 +755,7 @@ async def test_read_empty_body(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client async with OpenFgaClient(configuration) as api_client: - body = TupleKey() + body = ReadRequestTupleKey() api_response = await api_client.read( body=body, options={} @@ -761,7 +764,7 @@ async def test_read_empty_body(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', diff --git a/test/test_client_sync.py b/test/test_client_sync.py index d5c1ca1..80a5701 100644 --- a/test/test_client_sync.py +++ b/test/test_client_sync.py @@ -48,6 +48,7 @@ from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse from openfga_sdk.models.read_authorization_models_response import ReadAuthorizationModelsResponse from openfga_sdk.models.read_changes_response import ReadChangesResponse +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.read_response import ReadResponse from openfga_sdk.models.store import Store from openfga_sdk.models.tuple import Tuple @@ -638,7 +639,8 @@ def test_read(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -646,7 +648,7 @@ def test_read(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client with OpenFgaClient(configuration) as api_client: - body = TupleKey( + body = ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -660,7 +662,7 @@ def test_read(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -691,7 +693,8 @@ def test_read_empty_options(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -699,7 +702,7 @@ def test_read_empty_options(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client with OpenFgaClient(configuration) as api_client: - body = TupleKey( + body = ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -712,7 +715,7 @@ def test_read_empty_options(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -743,7 +746,8 @@ def test_read_empty_body(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -751,7 +755,7 @@ def test_read_empty_body(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client with OpenFgaClient(configuration) as api_client: - body = TupleKey() + body = ReadRequestTupleKey() api_response = api_client.read( body=body, options={} @@ -760,7 +764,7 @@ def test_read_empty_body(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', diff --git a/test/test_open_fga_api.py b/test/test_open_fga_api.py index 4dc886a..e181ce0 100644 --- a/test/test_open_fga_api.py +++ b/test/test_open_fga_api.py @@ -50,6 +50,7 @@ from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse from openfga_sdk.models.read_changes_response import ReadChangesResponse from openfga_sdk.models.read_request import ReadRequest +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.read_response import ReadResponse from openfga_sdk.models.store import Store from openfga_sdk.models.tuple import Tuple @@ -411,7 +412,8 @@ async def test_read(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -420,7 +422,7 @@ async def test_read(self, mock_request): async with openfga_sdk.ApiClient(configuration) as api_client: api_instance = open_fga_api.OpenFgaApi(api_client) body = ReadRequest( - tuple_key=TupleKey( + tuple_key=ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -435,7 +437,7 @@ async def test_read(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', diff --git a/test/test_open_fga_api_sync.py b/test/test_open_fga_api_sync.py index 129c41d..8f05e2a 100644 --- a/test/test_open_fga_api_sync.py +++ b/test/test_open_fga_api_sync.py @@ -51,6 +51,7 @@ from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse from openfga_sdk.models.read_changes_response import ReadChangesResponse from openfga_sdk.models.read_request import ReadRequest +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.read_response import ReadResponse from openfga_sdk.models.store import Store from openfga_sdk.models.tuple import Tuple @@ -412,7 +413,8 @@ async def test_read(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -421,7 +423,7 @@ async def test_read(self, mock_request): with ApiClient(configuration) as api_client: api_instance = open_fga_api.OpenFgaApi(api_client) body = ReadRequest( - tuple_key=TupleKey( + tuple_key=ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -436,7 +438,7 @@ async def test_read(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST',