diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore index 2d6e183..d7decf7 100644 --- a/.openapi-generator-ignore +++ b/.openapi-generator-ignore @@ -14,5 +14,7 @@ openfga_sdk/api/open_fga_api openfga_sdk/sync/open_fga_api.py openfga_sdk/api_client.py openfga_sdk/configuration.py +openfga_sdk/_version.py openfga_sdk/exceptions.py -openfga_sdk/rest.py \ No newline at end of file +openfga_sdk/rest.py +VERSION.txt diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 12e588d..c0b8278 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -7,7 +7,6 @@ CONTRIBUTING.md LICENSE README.md -VERSION.txt docs/AbortedMessageResponse.md docs/Any.md docs/Assertion.md diff --git a/README.md b/README.md index 72dafa6..6b013a9 100644 --- a/README.md +++ b/README.md @@ -1381,6 +1381,7 @@ response = await fga_client.execute_api_request( ) ``` + ### Retries If a network request fails with a 429 or 5xx error from the server, the SDK will automatically retry the request up to 3 times with a minimum wait time of 100 milliseconds between each attempt. diff --git a/openfga_sdk/__init__.py b/openfga_sdk/__init__.py index 2c99928..b15ca5e 100644 --- a/openfga_sdk/__init__.py +++ b/openfga_sdk/__init__.py @@ -1,10 +1,10 @@ +from openfga_sdk._version import SDK_VERSION from openfga_sdk.api.open_fga_api import OpenFgaApi from openfga_sdk.api_client import ApiClient from openfga_sdk.client.client import OpenFgaClient from openfga_sdk.client.configuration import ClientConfiguration from openfga_sdk.client.models.raw_response import RawResponse from openfga_sdk.configuration import Configuration -from openfga_sdk.constants import SDK_VERSION from openfga_sdk.exceptions import ( ApiAttributeError, ApiException, diff --git a/openfga_sdk/_version.py b/openfga_sdk/_version.py new file mode 100644 index 0000000..faf8926 --- /dev/null +++ b/openfga_sdk/_version.py @@ -0,0 +1,18 @@ +""" +Python SDK for OpenFGA + +API version: 1.x +Website: https://openfga.dev +Documentation: https://openfga.dev/docs +Support: https://openfga.dev/community +License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE) +""" + +from typing import Final + + +# Version of the OpenFGA Python SDK. +SDK_VERSION: Final[str] = "0.10.3" # x-release-please-version + +# User agent used in HTTP requests. +USER_AGENT: Final[str] = f"openfga-sdk python/{SDK_VERSION}" diff --git a/openfga_sdk/api/open_fga_api.py b/openfga_sdk/api/open_fga_api.py index b1a2b1d..124c0e0 100644 --- a/openfga_sdk/api/open_fga_api.py +++ b/openfga_sdk/api/open_fga_api.py @@ -447,7 +447,9 @@ async def batch_check_with_http_info(self, body, **kwargs): local_var_params = locals() - all_params = ["body"] + all_params = [ + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -457,6 +459,7 @@ async def batch_check_with_http_info(self, body, **kwargs): ) local_var_params[key] = val del local_var_params["kwargs"] + # verify the required parameter 'body' is set if ( self.api_client.client_side_validation and local_var_params.get("body") is None @@ -541,7 +544,9 @@ async def check_with_http_info(self, body, **kwargs): local_var_params = locals() - all_params = ["body"] + all_params = [ + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -551,6 +556,7 @@ async def check_with_http_info(self, body, **kwargs): ) local_var_params[key] = val del local_var_params["kwargs"] + # verify the required parameter 'body' is set if ( self.api_client.client_side_validation and local_var_params.get("body") is None @@ -635,7 +641,9 @@ async def create_store_with_http_info(self, body, **kwargs): local_var_params = locals() - all_params = ["body"] + all_params = [ + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -645,6 +653,14 @@ async def create_store_with_http_info(self, body, **kwargs): ) local_var_params[key] = val del local_var_params["kwargs"] + # verify the required parameter 'body' is set + if ( + self.api_client.client_side_validation + and local_var_params.get("body") is None + ): + raise ApiValueError( + "Missing the required parameter `body` when calling `create_store`" + ) return await self._execute( method="POST", path="/stores", @@ -799,7 +815,9 @@ async def expand_with_http_info(self, body, **kwargs): local_var_params = locals() - all_params = ["body"] + all_params = [ + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -809,6 +827,7 @@ async def expand_with_http_info(self, body, **kwargs): ) local_var_params[key] = val del local_var_params["kwargs"] + # verify the required parameter 'body' is set if ( self.api_client.client_side_validation and local_var_params.get("body") is None @@ -975,7 +994,9 @@ async def list_objects_with_http_info(self, body, **kwargs): local_var_params = locals() - all_params = ["body"] + all_params = [ + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -985,6 +1006,7 @@ async def list_objects_with_http_info(self, body, **kwargs): ) local_var_params[key] = val del local_var_params["kwargs"] + # verify the required parameter 'body' is set if ( self.api_client.client_side_validation and local_var_params.get("body") is None @@ -1077,7 +1099,11 @@ async def list_stores_with_http_info(self, **kwargs): local_var_params = locals() - all_params = ["page_size", "continuation_token", "name"] + all_params = [ + "page_size", + "continuation_token", + "name", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -1168,7 +1194,9 @@ async def list_users_with_http_info(self, body, **kwargs): local_var_params = locals() - all_params = ["body"] + all_params = [ + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -1178,6 +1206,7 @@ async def list_users_with_http_info(self, body, **kwargs): ) local_var_params[key] = val del local_var_params["kwargs"] + # verify the required parameter 'body' is set if ( self.api_client.client_side_validation and local_var_params.get("body") is None @@ -1262,7 +1291,9 @@ async def read_with_http_info(self, body, **kwargs): local_var_params = locals() - all_params = ["body"] + all_params = [ + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -1272,6 +1303,7 @@ async def read_with_http_info(self, body, **kwargs): ) local_var_params[key] = val del local_var_params["kwargs"] + # verify the required parameter 'body' is set if ( self.api_client.client_side_validation and local_var_params.get("body") is None @@ -1358,7 +1390,9 @@ async def read_assertions_with_http_info(self, authorization_model_id, **kwargs) local_var_params = locals() - all_params = ["authorization_model_id"] + all_params = [ + "authorization_model_id", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -1451,7 +1485,9 @@ async def read_authorization_model_with_http_info(self, id, **kwargs): local_var_params = locals() - all_params = ["id"] + all_params = [ + "id", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -1548,7 +1584,10 @@ async def read_authorization_models_with_http_info(self, **kwargs): local_var_params = locals() - all_params = ["page_size", "continuation_token"] + all_params = [ + "page_size", + "continuation_token", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -1654,7 +1693,12 @@ async def read_changes_with_http_info(self, **kwargs): local_var_params = locals() - all_params = ["type", "page_size", "continuation_token", "start_time"] + all_params = [ + "type", + "page_size", + "continuation_token", + "start_time", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -1752,7 +1796,9 @@ async def streamed_list_objects_with_http_info(self, body, **kwargs): local_var_params = locals() - all_params = ["body"] + all_params = [ + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -1762,6 +1808,7 @@ async def streamed_list_objects_with_http_info(self, body, **kwargs): ) local_var_params[key] = val del local_var_params["kwargs"] + # verify the required parameter 'body' is set if ( self.api_client.client_side_validation and local_var_params.get("body") is None @@ -1846,7 +1893,9 @@ async def write_with_http_info(self, body, **kwargs): local_var_params = locals() - all_params = ["body"] + all_params = [ + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -1856,6 +1905,7 @@ async def write_with_http_info(self, body, **kwargs): ) local_var_params[key] = val del local_var_params["kwargs"] + # verify the required parameter 'body' is set if ( self.api_client.client_side_validation and local_var_params.get("body") is None @@ -1948,7 +1998,10 @@ async def write_assertions_with_http_info( local_var_params = locals() - all_params = ["authorization_model_id", "body"] + all_params = [ + "authorization_model_id", + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -1965,6 +2018,7 @@ async def write_assertions_with_http_info( raise ApiValueError( "Missing the required parameter `authorization_model_id` when calling `write_assertions`" ) + # verify the required parameter 'body' is set if ( self.api_client.client_side_validation and local_var_params.get("body") is None @@ -2049,7 +2103,9 @@ async def write_authorization_model_with_http_info(self, body, **kwargs): local_var_params = locals() - all_params = ["body"] + all_params = [ + "body", + ] all_params.extend(self._COMMON_PARAMS) for key, val in local_var_params["kwargs"].items(): @@ -2059,6 +2115,7 @@ async def write_authorization_model_with_http_info(self, body, **kwargs): ) local_var_params[key] = val del local_var_params["kwargs"] + # verify the required parameter 'body' is set if ( self.api_client.client_side_validation and local_var_params.get("body") is None diff --git a/openfga_sdk/api_client.py b/openfga_sdk/api_client.py index d4cc632..06edd49 100644 --- a/openfga_sdk/api_client.py +++ b/openfga_sdk/api_client.py @@ -15,12 +15,12 @@ import openfga_sdk.models from openfga_sdk import oauth2, rest +from openfga_sdk._version import USER_AGENT as DEFAULT_USER_AGENT from openfga_sdk.configuration import Configuration from openfga_sdk.constants import ( MAX_BACKOFF_TIME_IN_SEC, RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC, ) -from openfga_sdk.constants import USER_AGENT as DEFAULT_USER_AGENT from openfga_sdk.exceptions import ( ApiException, ApiValueError, diff --git a/openfga_sdk/configuration.py b/openfga_sdk/configuration.py index 9620a61..f543a5d 100644 --- a/openfga_sdk/configuration.py +++ b/openfga_sdk/configuration.py @@ -6,12 +6,12 @@ import urllib3 +from openfga_sdk._version import SDK_VERSION from openfga_sdk.constants import ( DEFAULT_MAX_RETRY, DEFAULT_MIN_WAIT_IN_MS, MAX_BACKOFF_TIME_IN_SEC, RETRY_MAX_ALLOWED_NUMBER, - SDK_VERSION, ) from openfga_sdk.exceptions import ApiValueError, FgaValidationException from openfga_sdk.telemetry.attributes import TelemetryAttribute diff --git a/openfga_sdk/constants.py b/openfga_sdk/constants.py index e003517..2ae7201 100644 --- a/openfga_sdk/constants.py +++ b/openfga_sdk/constants.py @@ -13,13 +13,6 @@ from typing import Final -# Version of the OpenFGA Python SDK. -SDK_VERSION: Final[str] = "0.10.3" # x-release-please-version - -# User agent used in HTTP requests. - -USER_AGENT: Final[str] = "openfga-sdk python/0.10.3" # x-release-please-version - # Example API domain for documentation/tests. SAMPLE_BASE_DOMAIN: Final[str] = "fga.example" diff --git a/openfga_sdk/oauth2.py b/openfga_sdk/oauth2.py index de00961..6b065b2 100644 --- a/openfga_sdk/oauth2.py +++ b/openfga_sdk/oauth2.py @@ -6,11 +6,11 @@ import urllib3 +from openfga_sdk._version import USER_AGENT from openfga_sdk.configuration import Configuration from openfga_sdk.constants import ( TOKEN_EXPIRY_JITTER_IN_SEC, TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC, - USER_AGENT, ) from openfga_sdk.credentials import Credentials from openfga_sdk.exceptions import AuthenticationError diff --git a/openfga_sdk/sync/api_client.py b/openfga_sdk/sync/api_client.py index c688650..0512081 100644 --- a/openfga_sdk/sync/api_client.py +++ b/openfga_sdk/sync/api_client.py @@ -13,12 +13,12 @@ import openfga_sdk.models +from openfga_sdk._version import USER_AGENT as DEFAULT_USER_AGENT from openfga_sdk.configuration import Configuration from openfga_sdk.constants import ( MAX_BACKOFF_TIME_IN_SEC, RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC, ) -from openfga_sdk.constants import USER_AGENT as DEFAULT_USER_AGENT from openfga_sdk.exceptions import ( ApiException, ApiValueError, diff --git a/openfga_sdk/sync/oauth2.py b/openfga_sdk/sync/oauth2.py index d23cc93..8c55746 100644 --- a/openfga_sdk/sync/oauth2.py +++ b/openfga_sdk/sync/oauth2.py @@ -7,11 +7,11 @@ import urllib3 +from openfga_sdk._version import USER_AGENT from openfga_sdk.configuration import Configuration from openfga_sdk.constants import ( TOKEN_EXPIRY_JITTER_IN_SEC, TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC, - USER_AGENT, ) from openfga_sdk.credentials import Credentials from openfga_sdk.exceptions import AuthenticationError diff --git a/release-please-config.json b/release-please-config.json index 32fc5ea..e33d3e2 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -26,7 +26,7 @@ ], "extra-files": [ { "type": "toml", "path": "pyproject.toml", "jsonpath": "$.project.version" }, - { "type": "generic", "path": "openfga_sdk/constants.py" }, + { "type": "generic", "path": "openfga_sdk/_version.py" }, { "type": "generic", "path": "README.md" }, { "type": "generic", "path": "example/example1/setup.py" }, { "type": "generic", "path": "example/example1/requirements.txt" }, diff --git a/test/api/open_fga_api_test.py b/test/api/open_fga_api_test.py index 1ab3479..30f9550 100644 --- a/test/api/open_fga_api_test.py +++ b/test/api/open_fga_api_test.py @@ -9,8 +9,8 @@ import openfga_sdk from openfga_sdk import rest +from openfga_sdk._version import USER_AGENT from openfga_sdk.api import open_fga_api -from openfga_sdk.constants import USER_AGENT from openfga_sdk.credentials import CredentialConfiguration, Credentials from openfga_sdk.exceptions import ( FGA_REQUEST_ID, diff --git a/test/constants_consistency_test.py b/test/constants_consistency_test.py index 1aa7c62..8caed84 100644 --- a/test/constants_consistency_test.py +++ b/test/constants_consistency_test.py @@ -9,6 +9,7 @@ from openfga_sdk import Configuration from openfga_sdk import __version__ as package_version +from openfga_sdk._version import SDK_VERSION, USER_AGENT from openfga_sdk.api_client import ( DEFAULT_USER_AGENT as ASYNC_DEFAULT_USER_AGENT, ) @@ -17,8 +18,6 @@ DEFAULT_MIN_WAIT_IN_MS, MAX_BACKOFF_TIME_IN_SEC, SAMPLE_BASE_DOMAIN, - SDK_VERSION, - USER_AGENT, ) from openfga_sdk.sync.api_client import DEFAULT_USER_AGENT as SYNC_DEFAULT_USER_AGENT diff --git a/test/oauth2_test.py b/test/oauth2_test.py index ffa3e5a..ffe2bbd 100644 --- a/test/oauth2_test.py +++ b/test/oauth2_test.py @@ -7,8 +7,9 @@ import urllib3 from openfga_sdk import rest +from openfga_sdk._version import USER_AGENT from openfga_sdk.configuration import Configuration -from openfga_sdk.constants import TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC, USER_AGENT +from openfga_sdk.constants import TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC from openfga_sdk.credentials import CredentialConfiguration, Credentials from openfga_sdk.exceptions import AuthenticationError from openfga_sdk.oauth2 import OAuth2Client diff --git a/test/sync/oauth2_test.py b/test/sync/oauth2_test.py index 40109fa..d6ebe72 100644 --- a/test/sync/oauth2_test.py +++ b/test/sync/oauth2_test.py @@ -7,8 +7,9 @@ import urllib3 +from openfga_sdk._version import USER_AGENT from openfga_sdk.configuration import Configuration -from openfga_sdk.constants import TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC, USER_AGENT +from openfga_sdk.constants import TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC from openfga_sdk.credentials import CredentialConfiguration, Credentials from openfga_sdk.exceptions import AuthenticationError from openfga_sdk.oauth2_common import _TokenState diff --git a/test/sync/open_fga_api_test.py b/test/sync/open_fga_api_test.py index e38dbe5..ba0b068 100644 --- a/test/sync/open_fga_api_test.py +++ b/test/sync/open_fga_api_test.py @@ -8,8 +8,8 @@ import openfga_sdk.sync +from openfga_sdk._version import USER_AGENT from openfga_sdk.configuration import Configuration -from openfga_sdk.constants import USER_AGENT from openfga_sdk.credentials import CredentialConfiguration, Credentials from openfga_sdk.exceptions import ( FGA_REQUEST_ID,