diff --git a/openfga_sdk/client/client.py b/openfga_sdk/client/client.py index b48a3ec..4766f60 100644 --- a/openfga_sdk/client/client.py +++ b/openfga_sdk/client/client.py @@ -107,8 +107,8 @@ def set_heading_if_not_set( def options_to_kwargs( - options: dict[str, int | str | dict[str, int | str]] | None = None, -) -> dict[str, int | str | dict[str, int | str]]: + options: dict[str, int | str | bool | dict[str, int | str]] | None = None, +) -> dict[str, int | str | bool | dict[str, int | str]]: """ Return kwargs with continuation_token and page_size """ @@ -124,6 +124,8 @@ def options_to_kwargs( kwargs["_headers"] = options["headers"] if options.get("retry_params"): kwargs["_retry_params"] = options["retry_params"] + if options.get("async_req") is not None: + kwargs["async_req"] = options["async_req"] return kwargs diff --git a/openfga_sdk/sync/client/client.py b/openfga_sdk/sync/client/client.py index c736dae..efd723d 100644 --- a/openfga_sdk/sync/client/client.py +++ b/openfga_sdk/sync/client/client.py @@ -107,8 +107,8 @@ def set_heading_if_not_set( def options_to_kwargs( - options: dict[str, int | str | dict[str, int | str]] | None = None, -) -> dict[str, int | str | dict[str, int | str]]: + options: dict[str, int | str | bool | dict[str, int | str]] | None = None, +) -> dict[str, int | str | bool | dict[str, int | str]]: """ Return kwargs with continuation_token and page_size """ @@ -124,6 +124,8 @@ def options_to_kwargs( kwargs["_headers"] = options["headers"] if options.get("retry_params"): kwargs["_retry_params"] = options["retry_params"] + if options.get("async_req") is not None: + kwargs["async_req"] = options["async_req"] return kwargs diff --git a/test/client/client_test.py b/test/client/client_test.py index 9850b5d..3d9ea85 100644 --- a/test/client/client_test.py +++ b/test/client/client_test.py @@ -246,6 +246,33 @@ async def test_list_stores_with_name(self, mock_request): _request_timeout=ANY, ) + @patch.object(rest.RESTClientObject, "request") + async def test_list_stores_with_async_req(self, mock_request): + """Test that async_req option is correctly propagated to the API call""" + response_body = json.dumps( + { + "stores": [], + "continuation_token": "", + } + ) + + mock_request.return_value = mock_response(response_body, 200) + configuration = self.configuration + + async with OpenFgaClient(configuration) as api_client: + with patch.object( + api_client._api, "list_stores", wraps=api_client._api.list_stores + ) as mock_api_list_stores: + await api_client.list_stores( + options={ + "async_req": True, + } + ) + + mock_api_list_stores.assert_called_once_with( + async_req=True, + ) + @patch.object(rest.RESTClientObject, "request") async def test_create_store(self, mock_request): """Test case for create_store diff --git a/test/sync/client/client_test.py b/test/sync/client/client_test.py index ec2686a..b1df025 100644 --- a/test/sync/client/client_test.py +++ b/test/sync/client/client_test.py @@ -246,6 +246,33 @@ def test_list_stores_with_name(self, mock_request): _request_timeout=ANY, ) + @patch.object(rest.RESTClientObject, "request") + def test_list_stores_with_async_req(self, mock_request): + """Test that async_req option is correctly propagated to the API call""" + response_body = json.dumps( + { + "stores": [], + "continuation_token": "", + } + ) + + mock_request.return_value = mock_response(response_body, 200) + configuration = self.configuration + + with OpenFgaClient(configuration) as api_client: + with patch.object( + api_client._api, "list_stores", wraps=api_client._api.list_stores + ) as mock_api_list_stores: + api_client.list_stores( + options={ + "async_req": True, + } + ) + + mock_api_list_stores.assert_called_once_with( + async_req=True, + ) + @patch.object(rest.RESTClientObject, "request") def test_create_store(self, mock_request): """Test case for create_store