From 8489a4a265eeb0ac49b3e2b60cc5383a3e2d8043 Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Wed, 15 Oct 2025 10:09:57 -0400 Subject: [PATCH 1/6] chore: add constants file --- openfga_sdk/__init__.py | 2 +- openfga_sdk/api_client.py | 12 +++++--- openfga_sdk/client/client.py | 16 +++++----- openfga_sdk/configuration.py | 21 ++++++++----- openfga_sdk/constants.py | 49 ++++++++++++++++++++++++++++++ openfga_sdk/oauth2.py | 3 +- openfga_sdk/sync/api_client.py | 10 +++--- openfga_sdk/sync/client/client.py | 16 +++++----- openfga_sdk/sync/oauth2.py | 3 +- test/api/open_fga_api_test.py | 9 +++--- test/constants_consistency_test.py | 42 +++++++++++++++++++++++++ test/oauth2_test.py | 15 ++++----- test/sync/oauth2_test.py | 7 +++-- test/sync/open_fga_api_test.py | 9 +++--- 14 files changed, 162 insertions(+), 52 deletions(-) create mode 100644 openfga_sdk/constants.py create mode 100644 test/constants_consistency_test.py diff --git a/openfga_sdk/__init__.py b/openfga_sdk/__init__.py index 241e40b8..29d51d51 100644 --- a/openfga_sdk/__init__.py +++ b/openfga_sdk/__init__.py @@ -10,7 +10,7 @@ NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. """ -__version__ = "0.9.7" +from openfga_sdk.constants import SDK_VERSION as __version__ from openfga_sdk.api.open_fga_api import OpenFgaApi from openfga_sdk.api_client import ApiClient diff --git a/openfga_sdk/api_client.py b/openfga_sdk/api_client.py index c3aa7ecc..6bf8fc9e 100644 --- a/openfga_sdk/api_client.py +++ b/openfga_sdk/api_client.py @@ -37,9 +37,11 @@ ) from openfga_sdk.telemetry import Telemetry from openfga_sdk.telemetry.attributes import TelemetryAttribute, TelemetryAttributes - - -DEFAULT_USER_AGENT = "openfga-sdk python/0.9.7" +from openfga_sdk.constants import USER_AGENT as DEFAULT_USER_AGENT +from openfga_sdk.constants import ( + MAX_BACKOFF_TIME_IN_SEC, + RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC, +) def random_time(loop_count, min_wait_in_ms) -> float: @@ -258,7 +260,7 @@ async def __call_api( self.configuration.retry_params is not None and self.configuration.retry_params.max_wait_in_sec is not None ) - else 120 + else MAX_BACKOFF_TIME_IN_SEC ) if _retry_params is not None: if _retry_params.max_retry is not None: @@ -425,7 +427,7 @@ def _parse_retry_after_header(self, headers) -> int: except ApiException: wait_time_in_sec = int(retry_after_header) - if wait_time_in_sec > 1800 or wait_time_in_sec < 1: + if wait_time_in_sec > RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC or wait_time_in_sec < 1: raise ValueError("Retry-After header is invalid") return math.ceil(wait_time_in_sec) diff --git a/openfga_sdk/client/client.py b/openfga_sdk/client/client.py index 8ffbfc32..cd5a6330 100644 --- a/openfga_sdk/client/client.py +++ b/openfga_sdk/client/client.py @@ -74,10 +74,12 @@ ) from openfga_sdk.models.write_request import WriteRequest from openfga_sdk.validation import is_well_formed_ulid_string - - -CLIENT_METHOD_HEADER = "X-OpenFGA-Client-Method" -CLIENT_BULK_REQUEST_ID_HEADER = "X-OpenFGA-Client-Bulk-Request-Id" +from openfga_sdk.constants import ( + CLIENT_METHOD_HEADER, + CLIENT_BULK_REQUEST_ID_HEADER, + CLIENT_MAX_METHOD_PARALLEL_REQUESTS, + CLIENT_MAX_BATCH_SIZE, +) def _chuck_array(array, max_size): @@ -714,7 +716,7 @@ async def client_batch_check( options, CLIENT_BULK_REQUEST_ID_HEADER, str(uuid.uuid4()) ) - max_parallel_requests = 10 + max_parallel_requests = CLIENT_MAX_METHOD_PARALLEL_REQUESTS if options is not None and "max_parallel_requests" in options: if ( isinstance(options["max_parallel_requests"], str) @@ -773,7 +775,7 @@ async def batch_check( options, CLIENT_BULK_REQUEST_ID_HEADER, str(uuid.uuid4()) ) - max_parallel_requests = 10 + max_parallel_requests = CLIENT_MAX_METHOD_PARALLEL_REQUESTS if options is not None and "max_parallel_requests" in options: if ( isinstance(options["max_parallel_requests"], str) @@ -783,7 +785,7 @@ async def batch_check( elif isinstance(options["max_parallel_requests"], int): max_parallel_requests = options["max_parallel_requests"] - max_batch_size = 50 + max_batch_size = CLIENT_MAX_BATCH_SIZE if options is not None and "max_batch_size" in options: if ( isinstance(options["max_batch_size"], str) diff --git a/openfga_sdk/configuration.py b/openfga_sdk/configuration.py index 96bf4153..ec869ce9 100644 --- a/openfga_sdk/configuration.py +++ b/openfga_sdk/configuration.py @@ -29,6 +29,13 @@ from openfga_sdk.telemetry.counters import TelemetryCounter from openfga_sdk.telemetry.histograms import TelemetryHistogram from openfga_sdk.validation import is_well_formed_ulid_string +from openfga_sdk.constants import ( + DEFAULT_MAX_RETRY, + DEFAULT_MIN_WAIT_IN_MS, + MAX_BACKOFF_TIME_IN_SEC, + RETRY_MAX_ALLOWED_NUMBER, + SDK_VERSION, +) class RetryParams: @@ -44,7 +51,7 @@ class RetryParams: :param max_wait_in_sec: Maximum wait (in seconds) between retry """ - def __init__(self, max_retry=3, min_wait_in_ms=100, max_wait_in_sec=120): + def __init__(self, max_retry=DEFAULT_MAX_RETRY, min_wait_in_ms=DEFAULT_MIN_WAIT_IN_MS, max_wait_in_sec=MAX_BACKOFF_TIME_IN_SEC): self._max_retry = max_retry self._min_wait_in_ms = min_wait_in_ms self._max_wait_in_sec = max_wait_in_sec @@ -54,9 +61,9 @@ def max_retry(self): """ Return the maximum number of retry """ - if self._max_retry > 15: + if self._max_retry > RETRY_MAX_ALLOWED_NUMBER: raise FgaValidationException( - "RetryParams.max_retry exceeds maximum allowed limit of 15" + f"RetryParams.max_retry exceeds maximum allowed limit of {RETRY_MAX_ALLOWED_NUMBER}" ) return self._max_retry @@ -71,9 +78,9 @@ def max_retry(self, value): "RetryParams.max_retry must be an integer greater than or equal to 0" ) - if value > 15: + if value > RETRY_MAX_ALLOWED_NUMBER: raise FgaValidationException( - "RetryParams.max_retry exceeds maximum allowed limit of 15" + f"RetryParams.max_retry exceeds maximum allowed limit of {RETRY_MAX_ALLOWED_NUMBER}" ) self._max_retry = value @@ -197,7 +204,7 @@ def __init__( | dict[TelemetryAttribute | str, bool] | None, ] - | None, + | None ] | None ) = None, @@ -543,7 +550,7 @@ def to_debug_report(self): f"OS: {sys.platform}\n" f"Python Version: {sys.version}\n" "Version of the API: 1.x\n" - "SDK Package Version: 0.9.7" + f"SDK Package Version: {SDK_VERSION}" ) def get_host_settings(self): diff --git a/openfga_sdk/constants.py b/openfga_sdk/constants.py new file mode 100644 index 00000000..c55c2c64 --- /dev/null +++ b/openfga_sdk/constants.py @@ -0,0 +1,49 @@ +""" +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) + +NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. +""" + +""" +Constants used throughout the OpenFGA Python SDK. +""" + +from typing import Final + +# SDK version information +SDK_VERSION: Final[str] = "0.9.7" # Version of the OpenFGA Python SDK + +# User agent for HTTP requests +USER_AGENT: Final[str] = "openfga-sdk python/0.9.7" # User agent used in HTTP requests + +# Sample API domain for examples +SAMPLE_BASE_DOMAIN: Final[str] = "fga.example" # Example API domain for documentation/tests + +# Retry configuration +RETRY_MAX_ALLOWED_NUMBER: Final[int] = 15 # Maximum allowed number of retries for HTTP requests +DEFAULT_MAX_RETRY: Final[int] = 3 # Default maximum number of retries for HTTP requests +DEFAULT_MIN_WAIT_IN_MS: Final[int] = 100 # Default minimum wait time between retries in milliseconds +MAX_BACKOFF_TIME_IN_SEC: Final[int] = 120 # Maximum backoff time in seconds +RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC: Final[int] = 1800 # Maximum allowable duration for retry headers in seconds + +# Client configuration +CLIENT_MAX_METHOD_PARALLEL_REQUESTS: Final[int] = 10 # Maximum number of parallel requests for a single method +CLIENT_MAX_BATCH_SIZE: Final[int] = 50 # Maximum batch size for batch requests +DEFAULT_CONNECTION_TIMEOUT_IN_MS: Final[int] = 10000 # Default connection timeout in milliseconds + +# Token management +TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC: Final[int] = 300 # Buffer time in seconds before token expiry to consider it expired +TOKEN_EXPIRY_JITTER_IN_SEC: Final[int] = 300 # Jitter time in seconds to add randomness to token expiry checks + +# HTTP headers +CLIENT_METHOD_HEADER: Final[str] = "X-OpenFGA-Client-Method" # Header used to identify the client method +CLIENT_BULK_REQUEST_ID_HEADER: Final[str] = "X-OpenFGA-Client-Bulk-Request-Id" # Header used to identify bulk requests +RETRY_AFTER_HEADER_NAME: Final[str] = "Retry-After" # Standard HTTP header for retry after +RATE_LIMIT_RESET_HEADER_NAME: Final[str] = "X-RateLimit-Reset" # Rate limit reset header name +RATE_LIMIT_RESET_ALT_HEADER_NAME: Final[str] = "X-Rate-Limit-Reset" # Alternative rate limit reset header name diff --git a/openfga_sdk/oauth2.py b/openfga_sdk/oauth2.py index b7a03dc1..8e63e185 100644 --- a/openfga_sdk/oauth2.py +++ b/openfga_sdk/oauth2.py @@ -25,6 +25,7 @@ from openfga_sdk.exceptions import AuthenticationError from openfga_sdk.telemetry.attributes import TelemetryAttributes from openfga_sdk.telemetry.telemetry import Telemetry +from openfga_sdk.constants import USER_AGENT def jitter(loop_count, min_wait_in_ms): @@ -90,7 +91,7 @@ async def _obtain_token(self, client): { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) diff --git a/openfga_sdk/sync/api_client.py b/openfga_sdk/sync/api_client.py index 17b76752..4da154be 100644 --- a/openfga_sdk/sync/api_client.py +++ b/openfga_sdk/sync/api_client.py @@ -36,9 +36,9 @@ from openfga_sdk.sync import oauth2, rest from openfga_sdk.telemetry import Telemetry from openfga_sdk.telemetry.attributes import TelemetryAttribute, TelemetryAttributes - - -DEFAULT_USER_AGENT = "openfga-sdk python/0.9.7" +from openfga_sdk.constants import USER_AGENT as DEFAULT_USER_AGENT +from openfga_sdk.constants import MAX_BACKOFF_TIME_IN_SEC +from openfga_sdk.constants import RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC def random_time(loop_count, min_wait_in_ms) -> float: @@ -257,7 +257,7 @@ def __call_api( self.configuration.retry_params is not None and self.configuration.retry_params.max_wait_in_sec is not None ) - else 120 + else MAX_BACKOFF_TIME_IN_SEC ) if _retry_params is not None: if _retry_params.max_retry is not None: @@ -423,7 +423,7 @@ def _parse_retry_after_header(self, headers) -> int: except ApiException: wait_time_in_sec = int(retry_after_header) - if wait_time_in_sec > 1800 or wait_time_in_sec < 1: + if wait_time_in_sec > RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC or wait_time_in_sec < 1: raise ValueError("Retry-After header is invalid") return math.ceil(wait_time_in_sec) diff --git a/openfga_sdk/sync/client/client.py b/openfga_sdk/sync/client/client.py index 09784a99..35366815 100644 --- a/openfga_sdk/sync/client/client.py +++ b/openfga_sdk/sync/client/client.py @@ -75,10 +75,12 @@ from openfga_sdk.sync.api_client import ApiClient from openfga_sdk.sync.open_fga_api import OpenFgaApi from openfga_sdk.validation import is_well_formed_ulid_string - - -CLIENT_METHOD_HEADER = "X-OpenFGA-Client-Method" -CLIENT_BULK_REQUEST_ID_HEADER = "X-OpenFGA-Client-Bulk-Request-Id" +from openfga_sdk.constants import ( + CLIENT_METHOD_HEADER, + CLIENT_BULK_REQUEST_ID_HEADER, + CLIENT_MAX_METHOD_PARALLEL_REQUESTS, + CLIENT_MAX_BATCH_SIZE, +) def _chuck_array(array, max_size): @@ -711,7 +713,7 @@ def client_batch_check( options, CLIENT_BULK_REQUEST_ID_HEADER, str(uuid.uuid4()) ) - max_parallel_requests = 10 + max_parallel_requests = CLIENT_MAX_METHOD_PARALLEL_REQUESTS if options is not None and "max_parallel_requests" in options: if ( isinstance(options["max_parallel_requests"], str) @@ -770,7 +772,7 @@ def batch_check( options, CLIENT_BULK_REQUEST_ID_HEADER, str(uuid.uuid4()) ) - max_parallel_requests = 10 + max_parallel_requests = CLIENT_MAX_METHOD_PARALLEL_REQUESTS if options is not None and "max_parallel_requests" in options: if ( isinstance(options["max_parallel_requests"], str) @@ -780,7 +782,7 @@ def batch_check( elif isinstance(options["max_parallel_requests"], int): max_parallel_requests = options["max_parallel_requests"] - max_batch_size = 50 + max_batch_size = CLIENT_MAX_BATCH_SIZE if options is not None and "max_batch_size" in options: if ( isinstance(options["max_batch_size"], str) diff --git a/openfga_sdk/sync/oauth2.py b/openfga_sdk/sync/oauth2.py index 5418941f..bc0eb9fc 100644 --- a/openfga_sdk/sync/oauth2.py +++ b/openfga_sdk/sync/oauth2.py @@ -25,6 +25,7 @@ from openfga_sdk.exceptions import AuthenticationError from openfga_sdk.telemetry.attributes import TelemetryAttributes from openfga_sdk.telemetry.telemetry import Telemetry +from openfga_sdk.constants import USER_AGENT def jitter(loop_count, min_wait_in_ms): @@ -90,7 +91,7 @@ def _obtain_token(self, client): { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) diff --git a/test/api/open_fga_api_test.py b/test/api/open_fga_api_test.py index 02bf147f..593d8e3a 100644 --- a/test/api/open_fga_api_test.py +++ b/test/api/open_fga_api_test.py @@ -91,6 +91,7 @@ from openfga_sdk.models.write_request import WriteRequest from openfga_sdk.models.write_request_deletes import WriteRequestDeletes from openfga_sdk.models.write_request_writes import WriteRequestWrites +from openfga_sdk.constants import USER_AGENT store_id = "01H0H015178Y2V4CX10C2KGHF4" @@ -1782,7 +1783,7 @@ async def test_check_api_token(self, mock_request): { "Accept": "application/json", "Content-Type": "application/json", - "User-Agent": "openfga-sdk python/0.9.7", + "User-Agent": USER_AGENT, "Authorization": "Bearer TOKEN1", } ) @@ -1836,7 +1837,7 @@ async def test_check_custom_header(self, mock_request): { "Accept": "application/json", "Content-Type": "application/json", - "User-Agent": "openfga-sdk python/0.9.7", + "User-Agent": USER_AGENT, "Custom Header": "custom value", } ) @@ -2084,7 +2085,7 @@ async def test_check_custom_header_override_default_header(self, mock_request): { "Accept": "application/json", "Content-Type": "application/json", - "User-Agent": "openfga-sdk python/0.9.7", + "User-Agent": USER_AGENT, "X-Custom-Header": "per-request-value", # Should be the per-request value } ) @@ -2143,7 +2144,7 @@ async def test_check_per_request_header_and_default_header_coexist( { "Accept": "application/json", "Content-Type": "application/json", - "User-Agent": "openfga-sdk python/0.9.7", + "User-Agent": USER_AGENT, "X-Default-Header": "default-value", # Default header preserved "X-Per-Request-Header": "per-request-value", # Per-request header added } diff --git a/test/constants_consistency_test.py b/test/constants_consistency_test.py new file mode 100644 index 00000000..194b9482 --- /dev/null +++ b/test/constants_consistency_test.py @@ -0,0 +1,42 @@ +"""Tests to ensure internal modules reference the same constant values. + +Covers: +- Version consistency between openfga_sdk.__version__ and SDK_VERSION constant +- RetryParams default values match exported retry constants1 +- ApiClient (async and sync) user agent constants1 match USER_AGENT constant +- USER_AGENT embeds the SDK_VERSION +""" + +from openfga_sdk import __version__ as package_version, Configuration +from openfga_sdk.api_client import DEFAULT_USER_AGENT as ASYNC_DEFAULT_USER_AGENT # alias in module +from openfga_sdk.sync.api_client import DEFAULT_USER_AGENT as SYNC_DEFAULT_USER_AGENT +from openfga_sdk.constants import ( + SDK_VERSION, + USER_AGENT, + DEFAULT_MAX_RETRY, + DEFAULT_MIN_WAIT_IN_MS, + MAX_BACKOFF_TIME_IN_SEC, SAMPLE_BASE_DOMAIN, +) + + +def test_version_constant_matches_package_version(): + assert package_version == SDK_VERSION, "openfga_sdk.__version__ must match SDK_VERSION constant" + + +def test_retry_params_default_constants_alignment(): + cfg = Configuration(api_url=f"https://api.{SAMPLE_BASE_DOMAIN}") + assert cfg.retry_params.max_retry == DEFAULT_MAX_RETRY + assert cfg.retry_params.min_wait_in_ms == DEFAULT_MIN_WAIT_IN_MS + assert cfg.retry_params.max_wait_in_sec == MAX_BACKOFF_TIME_IN_SEC + + +def test_api_client_user_agent_constant_matches(): + assert ASYNC_DEFAULT_USER_AGENT == USER_AGENT + + +def test_sync_api_client_user_agent_constant_matches(): + assert SYNC_DEFAULT_USER_AGENT == USER_AGENT + + +def test_user_agent_contains_version(): + assert SDK_VERSION in USER_AGENT, "USER_AGENT should embed the SDK version for observability" diff --git a/test/oauth2_test.py b/test/oauth2_test.py index 5886efd7..00dcd59a 100644 --- a/test/oauth2_test.py +++ b/test/oauth2_test.py @@ -18,6 +18,7 @@ from openfga_sdk import rest 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 AuthenticationError from openfga_sdk.oauth2 import OAuth2Client @@ -84,7 +85,7 @@ async def test_get_authentication_obtain_client_credentials(self, mock_request): { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) mock_request.assert_called_once_with( @@ -310,7 +311,7 @@ async def test_get_authentication_keep_full_url(self, mock_request): { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) mock_request.assert_called_once_with( @@ -365,7 +366,7 @@ async def test_get_authentication_add_scheme(self, mock_request): { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) mock_request.assert_called_once_with( @@ -420,7 +421,7 @@ async def test_get_authentication_add_path(self, mock_request): { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) mock_request.assert_called_once_with( @@ -475,7 +476,7 @@ async def test_get_authentication_add_scheme_and_path(self, mock_request): { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) mock_request.assert_called_once_with( @@ -533,7 +534,7 @@ async def test_get_authentication_obtain_client_credentials_with_scopes_list( { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) mock_request.assert_called_once_with( @@ -592,7 +593,7 @@ async def test_get_authentication_obtain_client_credentials_with_scopes_string( { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) mock_request.assert_called_once_with( diff --git a/test/sync/oauth2_test.py b/test/sync/oauth2_test.py index a0099810..180dc3eb 100644 --- a/test/sync/oauth2_test.py +++ b/test/sync/oauth2_test.py @@ -17,6 +17,7 @@ import urllib3 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 AuthenticationError from openfga_sdk.sync import rest @@ -84,7 +85,7 @@ def test_get_authentication_obtain_client_credentials(self, mock_request): { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) mock_request.assert_called_once_with( @@ -142,7 +143,7 @@ def test_get_authentication_obtain_client_credentials_with_scopes_list( { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) mock_request.assert_called_once_with( @@ -201,7 +202,7 @@ def test_get_authentication_obtain_client_credentials_with_scopes_string( { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "openfga-sdk (python) 0.9.7", + "User-Agent": USER_AGENT, } ) mock_request.assert_called_once_with( diff --git a/test/sync/open_fga_api_test.py b/test/sync/open_fga_api_test.py index c8d03ed3..7e0560b2 100644 --- a/test/sync/open_fga_api_test.py +++ b/test/sync/open_fga_api_test.py @@ -19,6 +19,7 @@ import urllib3 import openfga_sdk.sync +from openfga_sdk.constants import USER_AGENT from openfga_sdk.configuration import Configuration from openfga_sdk.credentials import CredentialConfiguration, Credentials @@ -1845,7 +1846,7 @@ def test_check_api_token(self, mock_request): { "Accept": "application/json", "Content-Type": "application/json", - "User-Agent": "openfga-sdk python/0.9.7", + "User-Agent": USER_AGENT, "Authorization": "Bearer TOKEN1", } ) @@ -1899,7 +1900,7 @@ def test_check_custom_header(self, mock_request): { "Accept": "application/json", "Content-Type": "application/json", - "User-Agent": "openfga-sdk python/0.9.7", + "User-Agent": USER_AGENT, "Custom Header": "custom value", } ) @@ -1956,7 +1957,7 @@ def test_check_custom_header_override_default_header(self, mock_request): { "Accept": "application/json", "Content-Type": "application/json", - "User-Agent": "openfga-sdk python/0.9.7", + "User-Agent": USER_AGENT, "X-Custom-Header": "per-request-value", # Should be the per-request value } ) @@ -2013,7 +2014,7 @@ def test_check_per_request_header_and_default_header_coexist(self, mock_request) { "Accept": "application/json", "Content-Type": "application/json", - "User-Agent": "openfga-sdk python/0.9.7", + "User-Agent": USER_AGENT, "X-Default-Header": "default-value", # Default header preserved "X-Per-Request-Header": "per-request-value", # Per-request header added } From a36d78e094f58de91cbd6776a55b21e626fef91d Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Wed, 15 Oct 2025 10:57:23 -0400 Subject: [PATCH 2/6] chore: fix test nesting --- test/sync/open_fga_api_test.py | 74 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/test/sync/open_fga_api_test.py b/test/sync/open_fga_api_test.py index 7e0560b2..d9caf325 100644 --- a/test/sync/open_fga_api_test.py +++ b/test/sync/open_fga_api_test.py @@ -1729,47 +1729,45 @@ def test_500_error(self, mock_request): mock_request.assert_called() self.assertEqual(mock_request.call_count, 1) - @patch.object(rest.RESTClientObject, "request") - def test_500_error_retry(self, mock_request): - """ - Test to ensure 5xx retries are handled properly - """ - response_body = """ - { - "code": "internal_error", - "message": "Internal Server Error" - } - """ - mock_request.side_effect = [ - ServiceException(http_resp=http_mock_response(response_body, 500)), - ServiceException(http_resp=http_mock_response(response_body, 502)), - ServiceException(http_resp=http_mock_response(response_body, 503)), - ServiceException(http_resp=http_mock_response(response_body, 504)), - mock_response(response_body, 200), - ] + @patch.object(rest.RESTClientObject, "request") + def test_500_error_retry(self, mock_request): + """Test to ensure 5xx retries are handled properly""" + response_body = """ +{ + "code": "internal_error", + "message": "Internal Server Error" +} + """ + mock_request.side_effect = [ + ServiceException(http_resp=http_mock_response(response_body, 500)), + ServiceException(http_resp=http_mock_response(response_body, 502)), + ServiceException(http_resp=http_mock_response(response_body, 503)), + ServiceException(http_resp=http_mock_response(response_body, 504)), + mock_response(response_body, 200), + ] - retry = openfga_sdk.configuration.RetryParams(5, 10) - configuration = self.configuration - configuration.store_id = store_id - configuration.retry_params = retry - - with ApiClient(configuration) as api_client: - api_instance = open_fga_api.OpenFgaApi(api_client) - body = CheckRequest( - tuple_key=TupleKey( - object="document:2021-budget", - relation="reader", - user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", - ), - ) + retry = openfga_sdk.configuration.RetryParams(5, 10) + configuration = self.configuration + configuration.store_id = store_id + configuration.retry_params = retry - api_response = api_instance.check( - body=body, - ) + with ApiClient(configuration) as api_client: + api_instance = open_fga_api.OpenFgaApi(api_client) + body = CheckRequest( + tuple_key=TupleKey( + object="document:2021-budget", + relation="reader", + user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", + ), + ) - self.assertIsInstance(api_response, CheckResponse) - mock_request.assert_called() - self.assertEqual(mock_request.call_count, 5) + api_response = api_instance.check( + body=body, + ) + + self.assertIsInstance(api_response, CheckResponse) + mock_request.assert_called() + self.assertEqual(mock_request.call_count, 5) @patch.object(rest.RESTClientObject, "request") def test_501_error_retry(self, mock_request): From 6e874b3bba5726b771aea29dd25d285375455d7a Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Wed, 15 Oct 2025 11:09:04 -0400 Subject: [PATCH 3/6] chore: remove autogenerated code headers from files no longer generated --- openfga_sdk/__init__.py | 12 ------------ openfga_sdk/api_client.py | 12 ------------ openfga_sdk/client/__init__.py | 12 ------------ openfga_sdk/client/client.py | 12 ------------ openfga_sdk/client/configuration.py | 12 ------------ openfga_sdk/client/models/__init__.py | 12 ------------ openfga_sdk/client/models/assertion.py | 13 ------------- openfga_sdk/client/models/batch_check_item.py | 12 ------------ openfga_sdk/client/models/batch_check_request.py | 12 ------------ openfga_sdk/client/models/batch_check_response.py | 12 ------------ .../client/models/batch_check_single_response.py | 12 ------------ openfga_sdk/client/models/check_request.py | 12 ------------ .../client/models/client_batch_check_response.py | 12 ------------ openfga_sdk/client/models/expand_request.py | 12 ------------ openfga_sdk/client/models/list_objects_request.py | 12 ------------ openfga_sdk/client/models/list_relations_request.py | 12 ------------ openfga_sdk/client/models/list_users_request.py | 12 ------------ openfga_sdk/client/models/read_changes_request.py | 13 ------------- openfga_sdk/client/models/tuple.py | 12 ------------ openfga_sdk/client/models/write_request.py | 12 ------------ openfga_sdk/client/models/write_response.py | 12 ------------ openfga_sdk/client/models/write_single_response.py | 12 ------------ openfga_sdk/client/models/write_transaction_opts.py | 13 ------------- openfga_sdk/configuration.py | 12 ------------ openfga_sdk/credentials.py | 12 ------------ openfga_sdk/help.py | 12 ------------ openfga_sdk/oauth2.py | 12 ------------ openfga_sdk/rest.py | 12 ------------ openfga_sdk/sync/__init__.py | 12 ------------ openfga_sdk/sync/api_client.py | 12 ------------ openfga_sdk/sync/client/__init__.py | 11 ----------- openfga_sdk/sync/client/client.py | 12 ------------ openfga_sdk/sync/oauth2.py | 12 ------------ openfga_sdk/sync/rest.py | 12 ------------ openfga_sdk/telemetry/__init__.py | 12 ------------ openfga_sdk/telemetry/attributes.py | 12 ------------ openfga_sdk/telemetry/configuration.py | 12 ------------ openfga_sdk/telemetry/counters.py | 12 ------------ openfga_sdk/telemetry/histograms.py | 12 ------------ openfga_sdk/telemetry/metrics.py | 12 ------------ openfga_sdk/telemetry/telemetry.py | 12 ------------ openfga_sdk/validation.py | 12 ------------ test/__init__.py | 11 ----------- test/api/__init__.py | 11 ----------- test/api/open_fga_api_test.py | 12 ------------ test/client/__init__.py | 11 ----------- test/client/client_test.py | 12 ------------ test/configuration_test.py | 12 ------------ test/credentials_test.py | 12 ------------ test/oauth2_test.py | 12 ------------ test/rest_test.py | 12 ------------ test/sync/__init__.py | 11 ----------- test/sync/client/__init__.py | 11 ----------- test/sync/client/client_test.py | 12 ------------ test/sync/oauth2_test.py | 12 ------------ test/sync/open_fga_api_test.py | 12 ------------ test/sync/rest_test.py | 12 ------------ test/telemetry/attributes_test.py | 12 ------------ test/telemetry/configuration_test.py | 12 ------------ test/telemetry/counters_test.py | 12 ------------ test/telemetry/histograms_test.py | 12 ------------ test/telemetry/metrics_test.py | 12 ------------ test/telemetry/telemetry_test.py | 12 ------------ test/validation_test.py | 12 ------------ 64 files changed, 765 deletions(-) diff --git a/openfga_sdk/__init__.py b/openfga_sdk/__init__.py index 29d51d51..33abecf1 100644 --- a/openfga_sdk/__init__.py +++ b/openfga_sdk/__init__.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.constants import SDK_VERSION as __version__ from openfga_sdk.api.open_fga_api import OpenFgaApi diff --git a/openfga_sdk/api_client.py b/openfga_sdk/api_client.py index 6bf8fc9e..85c5328d 100644 --- a/openfga_sdk/api_client.py +++ b/openfga_sdk/api_client.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import asyncio import atexit import datetime diff --git a/openfga_sdk/client/__init__.py b/openfga_sdk/client/__init__.py index b6d1de38..e654ad27 100644 --- a/openfga_sdk/client/__init__.py +++ b/openfga_sdk/client/__init__.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.client import OpenFgaClient from openfga_sdk.client.configuration import ClientConfiguration from openfga_sdk.client.models.check_request import ClientCheckRequest diff --git a/openfga_sdk/client/client.py b/openfga_sdk/client/client.py index cd5a6330..848f38c5 100644 --- a/openfga_sdk/client/client.py +++ b/openfga_sdk/client/client.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import asyncio import uuid diff --git a/openfga_sdk/client/configuration.py b/openfga_sdk/client/configuration.py index 914cea23..9eae4e8c 100644 --- a/openfga_sdk/client/configuration.py +++ b/openfga_sdk/client/configuration.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.configuration import Configuration from openfga_sdk.exceptions import FgaValidationException from openfga_sdk.telemetry.attributes import TelemetryAttribute diff --git a/openfga_sdk/client/models/__init__.py b/openfga_sdk/client/models/__init__.py index a43a3202..d64a1f6b 100644 --- a/openfga_sdk/client/models/__init__.py +++ b/openfga_sdk/client/models/__init__.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.assertion import ClientAssertion from openfga_sdk.client.models.batch_check_item import ClientBatchCheckItem from openfga_sdk.client.models.batch_check_request import ClientBatchCheckRequest diff --git a/openfga_sdk/client/models/assertion.py b/openfga_sdk/client/models/assertion.py index c8335e20..77c03077 100644 --- a/openfga_sdk/client/models/assertion.py +++ b/openfga_sdk/client/models/assertion.py @@ -1,16 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - - class ClientAssertion: """ ClientAssertion flattens the input necessary for an Assertion diff --git a/openfga_sdk/client/models/batch_check_item.py b/openfga_sdk/client/models/batch_check_item.py index 08340144..4408694d 100644 --- a/openfga_sdk/client/models/batch_check_item.py +++ b/openfga_sdk/client/models/batch_check_item.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.tuple import ClientTuple, convert_tuple_keys from openfga_sdk.models.batch_check_item import BatchCheckItem from openfga_sdk.models.check_request_tuple_key import CheckRequestTupleKey diff --git a/openfga_sdk/client/models/batch_check_request.py b/openfga_sdk/client/models/batch_check_request.py index a988e52b..178e8ce2 100644 --- a/openfga_sdk/client/models/batch_check_request.py +++ b/openfga_sdk/client/models/batch_check_request.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.batch_check_item import ClientBatchCheckItem diff --git a/openfga_sdk/client/models/batch_check_response.py b/openfga_sdk/client/models/batch_check_response.py index 7adb0f2b..bef97aa3 100644 --- a/openfga_sdk/client/models/batch_check_response.py +++ b/openfga_sdk/client/models/batch_check_response.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.batch_check_single_response import ( ClientBatchCheckSingleResponse, ) diff --git a/openfga_sdk/client/models/batch_check_single_response.py b/openfga_sdk/client/models/batch_check_single_response.py index 8f9a6048..caeda273 100644 --- a/openfga_sdk/client/models/batch_check_single_response.py +++ b/openfga_sdk/client/models/batch_check_single_response.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.tuple import ClientTuple from openfga_sdk.models.check_error import CheckError diff --git a/openfga_sdk/client/models/check_request.py b/openfga_sdk/client/models/check_request.py index fdfc56f4..2e4a4faa 100644 --- a/openfga_sdk/client/models/check_request.py +++ b/openfga_sdk/client/models/check_request.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.tuple import ClientTuple diff --git a/openfga_sdk/client/models/client_batch_check_response.py b/openfga_sdk/client/models/client_batch_check_response.py index d4969c9f..a8009f47 100644 --- a/openfga_sdk/client/models/client_batch_check_response.py +++ b/openfga_sdk/client/models/client_batch_check_response.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.check_request import ClientCheckRequest from openfga_sdk.models.check_response import CheckResponse diff --git a/openfga_sdk/client/models/expand_request.py b/openfga_sdk/client/models/expand_request.py index 62b61d05..36a8e4a8 100644 --- a/openfga_sdk/client/models/expand_request.py +++ b/openfga_sdk/client/models/expand_request.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.tuple import ClientTuple diff --git a/openfga_sdk/client/models/list_objects_request.py b/openfga_sdk/client/models/list_objects_request.py index a78f34fe..aff8c16c 100644 --- a/openfga_sdk/client/models/list_objects_request.py +++ b/openfga_sdk/client/models/list_objects_request.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.tuple import ClientTuple diff --git a/openfga_sdk/client/models/list_relations_request.py b/openfga_sdk/client/models/list_relations_request.py index 6873bc60..84743518 100644 --- a/openfga_sdk/client/models/list_relations_request.py +++ b/openfga_sdk/client/models/list_relations_request.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.tuple import ClientTuple diff --git a/openfga_sdk/client/models/list_users_request.py b/openfga_sdk/client/models/list_users_request.py index c4122416..6511b1cf 100644 --- a/openfga_sdk/client/models/list_users_request.py +++ b/openfga_sdk/client/models/list_users_request.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.tuple import ClientTuple from openfga_sdk.models.fga_object import FgaObject from openfga_sdk.models.user_type_filter import UserTypeFilter diff --git a/openfga_sdk/client/models/read_changes_request.py b/openfga_sdk/client/models/read_changes_request.py index a8257d1f..b215a6e9 100644 --- a/openfga_sdk/client/models/read_changes_request.py +++ b/openfga_sdk/client/models/read_changes_request.py @@ -1,16 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - - class ClientReadChangesRequest: """ ClientReadChangesRequest encapsulates the parameters required to read changes diff --git a/openfga_sdk/client/models/tuple.py b/openfga_sdk/client/models/tuple.py index 5979ebb9..ed923278 100644 --- a/openfga_sdk/client/models/tuple.py +++ b/openfga_sdk/client/models/tuple.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.models.relationship_condition import RelationshipCondition from openfga_sdk.models.tuple_key import TupleKey diff --git a/openfga_sdk/client/models/write_request.py b/openfga_sdk/client/models/write_request.py index 0a575297..f88b94c4 100644 --- a/openfga_sdk/client/models/write_request.py +++ b/openfga_sdk/client/models/write_request.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.tuple import ClientTuple, convert_tuple_keys from openfga_sdk.models.write_request_deletes import WriteRequestDeletes from openfga_sdk.models.write_request_writes import WriteRequestWrites diff --git a/openfga_sdk/client/models/write_response.py b/openfga_sdk/client/models/write_response.py index 4e607eb5..361deb63 100644 --- a/openfga_sdk/client/models/write_response.py +++ b/openfga_sdk/client/models/write_response.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.write_single_response import ClientWriteSingleResponse diff --git a/openfga_sdk/client/models/write_single_response.py b/openfga_sdk/client/models/write_single_response.py index b99b901b..ba6db195 100644 --- a/openfga_sdk/client/models/write_single_response.py +++ b/openfga_sdk/client/models/write_single_response.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.client.models.tuple import ClientTuple diff --git a/openfga_sdk/client/models/write_transaction_opts.py b/openfga_sdk/client/models/write_transaction_opts.py index 0e914a53..548ef900 100644 --- a/openfga_sdk/client/models/write_transaction_opts.py +++ b/openfga_sdk/client/models/write_transaction_opts.py @@ -1,16 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - - class WriteTransactionOpts: """ OpenFGA client write transaction info diff --git a/openfga_sdk/configuration.py b/openfga_sdk/configuration.py index ec869ce9..b4c876fd 100644 --- a/openfga_sdk/configuration.py +++ b/openfga_sdk/configuration.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import copy import http import logging diff --git a/openfga_sdk/credentials.py b/openfga_sdk/credentials.py index 9e50a6e9..5cae254a 100644 --- a/openfga_sdk/credentials.py +++ b/openfga_sdk/credentials.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from urllib.parse import urlparse, urlunparse from openfga_sdk.exceptions import ApiValueError diff --git a/openfga_sdk/help.py b/openfga_sdk/help.py index 7a7cd797..ca6bd955 100644 --- a/openfga_sdk/help.py +++ b/openfga_sdk/help.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import json import platform import sys diff --git a/openfga_sdk/oauth2.py b/openfga_sdk/oauth2.py index 8e63e185..389d1645 100644 --- a/openfga_sdk/oauth2.py +++ b/openfga_sdk/oauth2.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import asyncio import json import math diff --git a/openfga_sdk/rest.py b/openfga_sdk/rest.py index c5750705..4621e27d 100644 --- a/openfga_sdk/rest.py +++ b/openfga_sdk/rest.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import io import json import logging diff --git a/openfga_sdk/sync/__init__.py b/openfga_sdk/sync/__init__.py index ad7fb682..11ae6e4c 100644 --- a/openfga_sdk/sync/__init__.py +++ b/openfga_sdk/sync/__init__.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.sync.api_client import ApiClient from openfga_sdk.sync.client.client import OpenFgaClient diff --git a/openfga_sdk/sync/api_client.py b/openfga_sdk/sync/api_client.py index 4da154be..5d53b2ea 100644 --- a/openfga_sdk/sync/api_client.py +++ b/openfga_sdk/sync/api_client.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import atexit import datetime import json diff --git a/openfga_sdk/sync/client/__init__.py b/openfga_sdk/sync/client/__init__.py index 97b78a43..e69de29b 100644 --- a/openfga_sdk/sync/client/__init__.py +++ b/openfga_sdk/sync/client/__init__.py @@ -1,11 +0,0 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" diff --git a/openfga_sdk/sync/client/client.py b/openfga_sdk/sync/client/client.py index 35366815..ef2d0c02 100644 --- a/openfga_sdk/sync/client/client.py +++ b/openfga_sdk/sync/client/client.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import uuid from concurrent.futures import ThreadPoolExecutor diff --git a/openfga_sdk/sync/oauth2.py b/openfga_sdk/sync/oauth2.py index bc0eb9fc..054e1916 100644 --- a/openfga_sdk/sync/oauth2.py +++ b/openfga_sdk/sync/oauth2.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import json import math import random diff --git a/openfga_sdk/sync/rest.py b/openfga_sdk/sync/rest.py index 134c5329..63d90a4a 100644 --- a/openfga_sdk/sync/rest.py +++ b/openfga_sdk/sync/rest.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import io import json import logging diff --git a/openfga_sdk/telemetry/__init__.py b/openfga_sdk/telemetry/__init__.py index e00b0dbd..ba227ec5 100644 --- a/openfga_sdk/telemetry/__init__.py +++ b/openfga_sdk/telemetry/__init__.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.telemetry.attributes import TelemetryAttribute, TelemetryAttributes from openfga_sdk.telemetry.configuration import ( TelemetryConfiguration, diff --git a/openfga_sdk/telemetry/attributes.py b/openfga_sdk/telemetry/attributes.py index 41277d6a..ddda43f2 100644 --- a/openfga_sdk/telemetry/attributes.py +++ b/openfga_sdk/telemetry/attributes.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import time import urllib diff --git a/openfga_sdk/telemetry/configuration.py b/openfga_sdk/telemetry/configuration.py index 4e1bd79f..40958e88 100644 --- a/openfga_sdk/telemetry/configuration.py +++ b/openfga_sdk/telemetry/configuration.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from typing import NamedTuple, Protocol, runtime_checkable from openfga_sdk.telemetry.attributes import TelemetryAttribute, TelemetryAttributes diff --git a/openfga_sdk/telemetry/counters.py b/openfga_sdk/telemetry/counters.py index 03091aa7..7e2e0ae0 100644 --- a/openfga_sdk/telemetry/counters.py +++ b/openfga_sdk/telemetry/counters.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from typing import NamedTuple diff --git a/openfga_sdk/telemetry/histograms.py b/openfga_sdk/telemetry/histograms.py index e12a928d..107ed9b6 100644 --- a/openfga_sdk/telemetry/histograms.py +++ b/openfga_sdk/telemetry/histograms.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from typing import NamedTuple diff --git a/openfga_sdk/telemetry/metrics.py b/openfga_sdk/telemetry/metrics.py index fc1c7cf6..3cc9d739 100644 --- a/openfga_sdk/telemetry/metrics.py +++ b/openfga_sdk/telemetry/metrics.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from opentelemetry.metrics import Counter, Histogram, Meter, get_meter from openfga_sdk.telemetry.attributes import ( diff --git a/openfga_sdk/telemetry/telemetry.py b/openfga_sdk/telemetry/telemetry.py index 7ed9e06a..7a23f55e 100644 --- a/openfga_sdk/telemetry/telemetry.py +++ b/openfga_sdk/telemetry/telemetry.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.telemetry.metrics import TelemetryMetrics diff --git a/openfga_sdk/validation.py b/openfga_sdk/validation.py index 5a047137..c9f96142 100644 --- a/openfga_sdk/validation.py +++ b/openfga_sdk/validation.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import re diff --git a/test/__init__.py b/test/__init__.py index 97b78a43..e69de29b 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -1,11 +0,0 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" diff --git a/test/api/__init__.py b/test/api/__init__.py index 97b78a43..e69de29b 100644 --- a/test/api/__init__.py +++ b/test/api/__init__.py @@ -1,11 +0,0 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" diff --git a/test/api/open_fga_api_test.py b/test/api/open_fga_api_test.py index 593d8e3a..a5f1141e 100644 --- a/test/api/open_fga_api_test.py +++ b/test/api/open_fga_api_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import unittest from datetime import datetime, timedelta, timezone diff --git a/test/client/__init__.py b/test/client/__init__.py index 97b78a43..e69de29b 100644 --- a/test/client/__init__.py +++ b/test/client/__init__.py @@ -1,11 +0,0 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" diff --git a/test/client/client_test.py b/test/client/client_test.py index 614d2745..36029c92 100644 --- a/test/client/client_test.py +++ b/test/client/client_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import copy import json import uuid diff --git a/test/configuration_test.py b/test/configuration_test.py index 5b0af5ca..d3a826bf 100644 --- a/test/configuration_test.py +++ b/test/configuration_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import copy from unittest.mock import Mock diff --git a/test/credentials_test.py b/test/credentials_test.py index d3bc446d..9cf5dcfb 100644 --- a/test/credentials_test.py +++ b/test/credentials_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from unittest import IsolatedAsyncioTestCase import openfga_sdk diff --git a/test/oauth2_test.py b/test/oauth2_test.py index 00dcd59a..56b1efdf 100644 --- a/test/oauth2_test.py +++ b/test/oauth2_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from datetime import datetime, timedelta from unittest import IsolatedAsyncioTestCase from unittest.mock import patch diff --git a/test/rest_test.py b/test/rest_test.py index 343e09de..949828ea 100644 --- a/test/rest_test.py +++ b/test/rest_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import json from unittest.mock import AsyncMock, MagicMock diff --git a/test/sync/__init__.py b/test/sync/__init__.py index 97b78a43..e69de29b 100644 --- a/test/sync/__init__.py +++ b/test/sync/__init__.py @@ -1,11 +0,0 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" diff --git a/test/sync/client/__init__.py b/test/sync/client/__init__.py index 97b78a43..e69de29b 100644 --- a/test/sync/client/__init__.py +++ b/test/sync/client/__init__.py @@ -1,11 +0,0 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" diff --git a/test/sync/client/client_test.py b/test/sync/client/client_test.py index 2713ec8b..f455e992 100644 --- a/test/sync/client/client_test.py +++ b/test/sync/client/client_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import copy import json import uuid diff --git a/test/sync/oauth2_test.py b/test/sync/oauth2_test.py index 180dc3eb..b15fffc3 100644 --- a/test/sync/oauth2_test.py +++ b/test/sync/oauth2_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from datetime import datetime, timedelta from unittest import IsolatedAsyncioTestCase from unittest.mock import patch diff --git a/test/sync/open_fga_api_test.py b/test/sync/open_fga_api_test.py index d9caf325..668e251e 100644 --- a/test/sync/open_fga_api_test.py +++ b/test/sync/open_fga_api_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import unittest from datetime import datetime, timedelta, timezone diff --git a/test/sync/rest_test.py b/test/sync/rest_test.py index ebfe8ec2..2f4c109c 100644 --- a/test/sync/rest_test.py +++ b/test/sync/rest_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import json import ssl diff --git a/test/telemetry/attributes_test.py b/test/telemetry/attributes_test.py index e923c86a..4484c57d 100644 --- a/test/telemetry/attributes_test.py +++ b/test/telemetry/attributes_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import time from unittest.mock import MagicMock diff --git a/test/telemetry/configuration_test.py b/test/telemetry/configuration_test.py index 155cd6cd..7b3761a4 100644 --- a/test/telemetry/configuration_test.py +++ b/test/telemetry/configuration_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.telemetry.attributes import TelemetryAttributes from openfga_sdk.telemetry.configuration import ( TelemetryConfiguration, diff --git a/test/telemetry/counters_test.py b/test/telemetry/counters_test.py index 9ee9a20f..ae5372e6 100644 --- a/test/telemetry/counters_test.py +++ b/test/telemetry/counters_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.telemetry.counters import TelemetryCounter, TelemetryCounters diff --git a/test/telemetry/histograms_test.py b/test/telemetry/histograms_test.py index 73232937..1bcd05a4 100644 --- a/test/telemetry/histograms_test.py +++ b/test/telemetry/histograms_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from openfga_sdk.telemetry.histograms import TelemetryHistogram, TelemetryHistograms diff --git a/test/telemetry/metrics_test.py b/test/telemetry/metrics_test.py index a20677a9..1de3af4c 100644 --- a/test/telemetry/metrics_test.py +++ b/test/telemetry/metrics_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from unittest.mock import MagicMock, patch import pytest diff --git a/test/telemetry/telemetry_test.py b/test/telemetry/telemetry_test.py index 7da388d0..a8424ed9 100644 --- a/test/telemetry/telemetry_test.py +++ b/test/telemetry/telemetry_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - from unittest.mock import patch from openfga_sdk.telemetry.metrics import ( diff --git a/test/validation_test.py b/test/validation_test.py index d27be9a5..4742e226 100644 --- a/test/validation_test.py +++ b/test/validation_test.py @@ -1,15 +1,3 @@ -""" -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) - -NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. -""" - import unittest from openfga_sdk.validation import is_well_formed_ulid_string From 99f7698e5c5892264a998dd18a8ee76e6a3d364b Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Wed, 15 Oct 2025 11:31:12 -0400 Subject: [PATCH 4/6] chore: regenerate and lint cleanup --- .openapi-generator-ignore | 21 ++++--- .openapi-generator/FILES | 88 ------------------------------ CONTRIBUTING.md | 12 +++- README.md | 9 +-- openfga_sdk/__init__.py | 5 +- openfga_sdk/api_client.py | 15 +++-- openfga_sdk/client/client.py | 12 ++-- openfga_sdk/configuration.py | 23 +++++--- openfga_sdk/constants.py | 57 +++++++++++++------ openfga_sdk/oauth2.py | 2 +- openfga_sdk/sync/api_client.py | 13 +++-- openfga_sdk/sync/client/client.py | 12 ++-- openfga_sdk/sync/oauth2.py | 2 +- test/api/open_fga_api_test.py | 2 +- test/constants_consistency_test.py | 24 +++++--- test/sync/open_fga_api_test.py | 2 +- 16 files changed, 128 insertions(+), 171 deletions(-) diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore index e86b5f6c..c9110bcb 100644 --- a/.openapi-generator-ignore +++ b/.openapi-generator-ignore @@ -1,15 +1,5 @@ git_push.sh test/* -!test/__init__.py -!test/test_open_fga_api.py -!test/test_configuration.py -!test/test_credentials.py -!test/test_client.py -!test/test_client_sync.py -!test/test_open_fga_api_sync.py -!test/test_validation.py -!test/test_oauth2.py -!test/test_oauth2_sync.py .github/workflows/python.yml .gitlab-ci.yml .travis.yml @@ -17,4 +7,13 @@ tox.ini setup.cfg setup.py requirements.txt -test-requirements.txt \ No newline at end of file +test-requirements.txt +openfga_sdk/__init__.py +openfga_sdk/api/__init__.py +openfga_sdk/api/open_fga_api +openfga_sdk/sync/open_fga_api.py +openfga_sdk/api_client.py +openfga_sdk/configuration.py +openfga_sdk/constants.py +openfga_sdk/exceptions.py +openfga_sdk/rest.py \ No newline at end of file diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 06aeac2a..59bca6c4 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,12 +1,9 @@ .codecov.yml -.fossa.yml .github/CODEOWNERS .github/ISSUE_TEMPLATE/bug_report.yaml .github/ISSUE_TEMPLATE/config.yaml .github/ISSUE_TEMPLATE/feature_request.yaml .gitignore -.snyk -CHANGELOG.md CONTRIBUTING.md LICENSE README.md @@ -100,53 +97,7 @@ docs/WriteAuthorizationModelResponse.md docs/WriteRequest.md docs/WriteRequestDeletes.md docs/WriteRequestWrites.md -docs/opentelemetry.md -example/Makefile -example/README.md -example/example1/example1.py -example/example1/requirements.txt -example/example1/setup.cfg -example/example1/setup.py -example/opentelemetry/.env.example -example/opentelemetry/.gitignore -example/opentelemetry/README.md -example/opentelemetry/main.py -example/opentelemetry/requirements.txt -example/opentelemetry/setup.cfg -example/opentelemetry/setup.py -example/streamed-list-objects/README.md -example/streamed-list-objects/example.py -example/streamed-list-objects/model.json -openfga_sdk/__init__.py -openfga_sdk/api/__init__.py openfga_sdk/api/open_fga_api.py -openfga_sdk/api/open_fga_api_sync.py -openfga_sdk/api_client.py -openfga_sdk/client/__init__.py -openfga_sdk/client/client.py -openfga_sdk/client/configuration.py -openfga_sdk/client/models/__init__.py -openfga_sdk/client/models/assertion.py -openfga_sdk/client/models/batch_check_item.py -openfga_sdk/client/models/batch_check_request.py -openfga_sdk/client/models/batch_check_response.py -openfga_sdk/client/models/batch_check_single_response.py -openfga_sdk/client/models/check_request.py -openfga_sdk/client/models/client_batch_check_response.py -openfga_sdk/client/models/expand_request.py -openfga_sdk/client/models/list_objects_request.py -openfga_sdk/client/models/list_relations_request.py -openfga_sdk/client/models/list_users_request.py -openfga_sdk/client/models/read_changes_request.py -openfga_sdk/client/models/tuple.py -openfga_sdk/client/models/write_request.py -openfga_sdk/client/models/write_response.py -openfga_sdk/client/models/write_single_response.py -openfga_sdk/client/models/write_transaction_opts.py -openfga_sdk/configuration.py -openfga_sdk/credentials.py -openfga_sdk/exceptions.py -openfga_sdk/help.py openfga_sdk/models/__init__.py openfga_sdk/models/aborted_message_response.py openfga_sdk/models/any.py @@ -236,42 +187,3 @@ openfga_sdk/models/write_authorization_model_response.py openfga_sdk/models/write_request.py openfga_sdk/models/write_request_deletes.py openfga_sdk/models/write_request_writes.py -openfga_sdk/oauth2.py -openfga_sdk/rest.py -openfga_sdk/sync/__init__.py -openfga_sdk/sync/api_client.py -openfga_sdk/sync/client/__init__.py -openfga_sdk/sync/client/client.py -openfga_sdk/sync/oauth2.py -openfga_sdk/sync/rest.py -openfga_sdk/telemetry/__init__.py -openfga_sdk/telemetry/attributes.py -openfga_sdk/telemetry/configuration.py -openfga_sdk/telemetry/counters.py -openfga_sdk/telemetry/histograms.py -openfga_sdk/telemetry/metrics.py -openfga_sdk/telemetry/telemetry.py -openfga_sdk/validation.py -pyproject.toml -test/_/configuration_test.py -test/_/credentials_test.py -test/_/oauth2_test.py -test/_/rest_test.py -test/_/validation_test.py -test/__init__.py -test/api/__init__.py -test/client/__init__.py -test/client/client_test.py -test/sync/__init__.py -test/sync/client/__init__.py -test/sync/client/client_test.py -test/sync/oauth2_test.py -test/sync/open_fga_api_test.py -test/sync/rest_test.py -test/telemetry/attributes_test.py -test/telemetry/configuration_test.py -test/telemetry/counters_test.py -test/telemetry/histograms_test.py -test/telemetry/metrics_test.py -test/telemetry/telemetry_test.py -test/test_open_fga_api.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 47cff816..81d44fff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,17 +23,23 @@ By participating and contributing to this project, you are expected to uphold ou ### Making Changes -When contributing to a repository, the first step is to open an issue on [sdk-generator](https://github.com/openfga/sdk-generator) to discuss the change you wish to make before making them. +When contributing to a repository, the first step is to open [an issue](https://github.com/openfga/python-sdk/issues) to discuss the change you wish to make before making them. ### Opening Issues Before you submit a new issue please make sure to search all open and closed issues. It is possible your feature request/issue has already been answered. Make sure to also check the [OpenFGA discussions](https://github.com/orgs/openfga/discussions). -That repo includes an issue template that will walk through all the places to check before submitting your issue here. Please follow the instructions there to make sure this is not a duplicate issue and that we have everything we need to research and reproduce this problem. +The repo includes an issue template that will walk through all the places to check before submitting your issue here. Please follow the instructions there to make sure this is not a duplicate issue and that we have everything we need to research and reproduce this problem. + +If you have found a bug or if you have a feature request, please report them in the [repo issues](https://github.com/openfga/python-sdk/issues). Cross-SDK bugs and feature requests can be additionally reported in the [sdk-generator repo](https://github.com/openfga/sdk-generator/issues) issues section, where the individual SDK issue is then linked. + +**Please do not report security vulnerabilities on the public GitHub issue tracker.** ### Submitting Pull Requests -While we accept Pull Requests on this repository, the SDKs are autogenerated so please consider additionally submitting your Pull Requests to the [sdk-generator](https://github.com/openfga/sdk-generator) and linking the two PRs together and to the corresponding issue. This will greatly assist the OpenFGA team in being able to give timely reviews as well as deploying fixes and updates to our other SDKs as well. +Feel free to submit a Pull Request against this repository. Please make sure to follow the existing code style and include tests where applicable. + +Some files in this repository are autogenerated. These files have a comment at the top indicating that they are autogenerated and should not be modified directly - the files are usually identified by a header marking them as such, or by their inclusion in [`.openapi-generator/FILES`](./.openapi-generator/FILES). Changes to these files should be made in the [sdk-generator](https://github.com/openfga/sdk-generator) repository in tandem, so please consider additionally submitting your Pull Requests to the [sdk-generator](https://github.com/openfga/sdk-generator) and linking the two PRs together and to the corresponding issue. This will greatly assist the OpenFGA team in being able to give timely reviews as well as deploying fixes and updates to our other SDKs as well. ## Getting in touch diff --git a/README.md b/README.md index 4117d621..e1077632 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ This is an autogenerated python SDK for OpenFGA. It provides a wrapper around th - [Installation](#installation) - [Getting Started](#getting-started) - [Initializing the API Client](#initializing-the-api-client) + - [Custom Headers](#custom-headers) - [Get your Store ID](#get-your-store-id) - [Calling the API](#calling-the-api) - [Stores](#stores) @@ -1365,13 +1366,7 @@ This SDK supports producing metrics that can be consumed as part of an [OpenTele ## Contributing -### Issues - -If you have found a bug or if you have a feature request, please report them on the [sdk-generator repo](https://github.com/openfga/sdk-generator/issues) issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. - -### Pull Requests - -While we accept Pull Requests on this repository, the SDKs are autogenerated so please consider additionally submitting your Pull Requests to the [sdk-generator](https://github.com/openfga/sdk-generator) and linking the two PRs together and to the corresponding issue. This will greatly assist the OpenFGA team in being able to give timely reviews as well as deploying fixes and updates to our other SDKs as well. +See [CONTRIBUTING](./CONTRIBUTING.md) for details. ## Author diff --git a/openfga_sdk/__init__.py b/openfga_sdk/__init__.py index 33abecf1..b4e60809 100644 --- a/openfga_sdk/__init__.py +++ b/openfga_sdk/__init__.py @@ -1,10 +1,9 @@ -from openfga_sdk.constants import SDK_VERSION as __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.configuration import Configuration +from openfga_sdk.constants import SDK_VERSION from openfga_sdk.exceptions import ( ApiAttributeError, ApiException, @@ -132,6 +131,8 @@ ) +__version__ = SDK_VERSION + __all__ = [ "OpenFgaClient", "ClientConfiguration", diff --git a/openfga_sdk/api_client.py b/openfga_sdk/api_client.py index 85c5328d..baa73eea 100644 --- a/openfga_sdk/api_client.py +++ b/openfga_sdk/api_client.py @@ -16,6 +16,11 @@ from openfga_sdk import oauth2, rest 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, @@ -25,11 +30,6 @@ ) from openfga_sdk.telemetry import Telemetry from openfga_sdk.telemetry.attributes import TelemetryAttribute, TelemetryAttributes -from openfga_sdk.constants import USER_AGENT as DEFAULT_USER_AGENT -from openfga_sdk.constants import ( - MAX_BACKOFF_TIME_IN_SEC, - RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC, -) def random_time(loop_count, min_wait_in_ms) -> float: @@ -415,7 +415,10 @@ def _parse_retry_after_header(self, headers) -> int: except ApiException: wait_time_in_sec = int(retry_after_header) - if wait_time_in_sec > RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC or wait_time_in_sec < 1: + if ( + wait_time_in_sec > RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC + or wait_time_in_sec < 1 + ): raise ValueError("Retry-After header is invalid") return math.ceil(wait_time_in_sec) diff --git a/openfga_sdk/client/client.py b/openfga_sdk/client/client.py index 848f38c5..daed0894 100644 --- a/openfga_sdk/client/client.py +++ b/openfga_sdk/client/client.py @@ -33,6 +33,12 @@ construct_write_single_response, ) from openfga_sdk.client.models.write_transaction_opts import WriteTransactionOpts +from openfga_sdk.constants import ( + CLIENT_BULK_REQUEST_ID_HEADER, + CLIENT_MAX_BATCH_SIZE, + CLIENT_MAX_METHOD_PARALLEL_REQUESTS, + CLIENT_METHOD_HEADER, +) from openfga_sdk.exceptions import ( AuthenticationError, FgaValidationException, @@ -62,12 +68,6 @@ ) from openfga_sdk.models.write_request import WriteRequest from openfga_sdk.validation import is_well_formed_ulid_string -from openfga_sdk.constants import ( - CLIENT_METHOD_HEADER, - CLIENT_BULK_REQUEST_ID_HEADER, - CLIENT_MAX_METHOD_PARALLEL_REQUESTS, - CLIENT_MAX_BATCH_SIZE, -) def _chuck_array(array, max_size): diff --git a/openfga_sdk/configuration.py b/openfga_sdk/configuration.py index b4c876fd..9620a612 100644 --- a/openfga_sdk/configuration.py +++ b/openfga_sdk/configuration.py @@ -6,6 +6,13 @@ import urllib3 +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 from openfga_sdk.telemetry.configuration import ( @@ -17,13 +24,6 @@ from openfga_sdk.telemetry.counters import TelemetryCounter from openfga_sdk.telemetry.histograms import TelemetryHistogram from openfga_sdk.validation import is_well_formed_ulid_string -from openfga_sdk.constants import ( - DEFAULT_MAX_RETRY, - DEFAULT_MIN_WAIT_IN_MS, - MAX_BACKOFF_TIME_IN_SEC, - RETRY_MAX_ALLOWED_NUMBER, - SDK_VERSION, -) class RetryParams: @@ -39,7 +39,12 @@ class RetryParams: :param max_wait_in_sec: Maximum wait (in seconds) between retry """ - def __init__(self, max_retry=DEFAULT_MAX_RETRY, min_wait_in_ms=DEFAULT_MIN_WAIT_IN_MS, max_wait_in_sec=MAX_BACKOFF_TIME_IN_SEC): + def __init__( + self, + max_retry=DEFAULT_MAX_RETRY, + min_wait_in_ms=DEFAULT_MIN_WAIT_IN_MS, + max_wait_in_sec=MAX_BACKOFF_TIME_IN_SEC, + ): self._max_retry = max_retry self._min_wait_in_ms = min_wait_in_ms self._max_wait_in_sec = max_wait_in_sec @@ -192,7 +197,7 @@ def __init__( | dict[TelemetryAttribute | str, bool] | None, ] - | None + | None, ] | None ) = None, diff --git a/openfga_sdk/constants.py b/openfga_sdk/constants.py index c55c2c64..ede443b0 100644 --- a/openfga_sdk/constants.py +++ b/openfga_sdk/constants.py @@ -10,12 +10,9 @@ NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. """ -""" -Constants used throughout the OpenFGA Python SDK. -""" - from typing import Final + # SDK version information SDK_VERSION: Final[str] = "0.9.7" # Version of the OpenFGA Python SDK @@ -23,27 +20,53 @@ USER_AGENT: Final[str] = "openfga-sdk python/0.9.7" # User agent used in HTTP requests # Sample API domain for examples -SAMPLE_BASE_DOMAIN: Final[str] = "fga.example" # Example API domain for documentation/tests +SAMPLE_BASE_DOMAIN: Final[str] = ( + "fga.example" # Example API domain for documentation/tests +) # Retry configuration -RETRY_MAX_ALLOWED_NUMBER: Final[int] = 15 # Maximum allowed number of retries for HTTP requests +RETRY_MAX_ALLOWED_NUMBER: Final[int] = ( + 15 # Maximum allowed number of retries for HTTP requests +) DEFAULT_MAX_RETRY: Final[int] = 3 # Default maximum number of retries for HTTP requests -DEFAULT_MIN_WAIT_IN_MS: Final[int] = 100 # Default minimum wait time between retries in milliseconds +DEFAULT_MIN_WAIT_IN_MS: Final[int] = ( + 100 # Default minimum wait time between retries in milliseconds +) MAX_BACKOFF_TIME_IN_SEC: Final[int] = 120 # Maximum backoff time in seconds -RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC: Final[int] = 1800 # Maximum allowable duration for retry headers in seconds +RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC: Final[int] = ( + 1800 # Maximum allowable duration for retry headers in seconds +) # Client configuration -CLIENT_MAX_METHOD_PARALLEL_REQUESTS: Final[int] = 10 # Maximum number of parallel requests for a single method +CLIENT_MAX_METHOD_PARALLEL_REQUESTS: Final[int] = ( + 10 # Maximum number of parallel requests for a single method +) CLIENT_MAX_BATCH_SIZE: Final[int] = 50 # Maximum batch size for batch requests -DEFAULT_CONNECTION_TIMEOUT_IN_MS: Final[int] = 10000 # Default connection timeout in milliseconds +DEFAULT_CONNECTION_TIMEOUT_IN_MS: Final[int] = ( + 10000 # Default connection timeout in milliseconds +) # Token management -TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC: Final[int] = 300 # Buffer time in seconds before token expiry to consider it expired -TOKEN_EXPIRY_JITTER_IN_SEC: Final[int] = 300 # Jitter time in seconds to add randomness to token expiry checks +TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC: Final[int] = ( + 300 # Buffer time in seconds before token expiry to consider it expired +) +TOKEN_EXPIRY_JITTER_IN_SEC: Final[int] = ( + 300 # Jitter time in seconds to add randomness to token expiry checks +) # HTTP headers -CLIENT_METHOD_HEADER: Final[str] = "X-OpenFGA-Client-Method" # Header used to identify the client method -CLIENT_BULK_REQUEST_ID_HEADER: Final[str] = "X-OpenFGA-Client-Bulk-Request-Id" # Header used to identify bulk requests -RETRY_AFTER_HEADER_NAME: Final[str] = "Retry-After" # Standard HTTP header for retry after -RATE_LIMIT_RESET_HEADER_NAME: Final[str] = "X-RateLimit-Reset" # Rate limit reset header name -RATE_LIMIT_RESET_ALT_HEADER_NAME: Final[str] = "X-Rate-Limit-Reset" # Alternative rate limit reset header name +CLIENT_METHOD_HEADER: Final[str] = ( + "X-OpenFGA-Client-Method" # Header used to identify the client method +) +CLIENT_BULK_REQUEST_ID_HEADER: Final[str] = ( + "X-OpenFGA-Client-Bulk-Request-Id" # Header used to identify bulk requests +) +RETRY_AFTER_HEADER_NAME: Final[str] = ( + "Retry-After" # Standard HTTP header for retry after +) +RATE_LIMIT_RESET_HEADER_NAME: Final[str] = ( + "X-RateLimit-Reset" # Rate limit reset header name +) +RATE_LIMIT_RESET_ALT_HEADER_NAME: Final[str] = ( + "X-Rate-Limit-Reset" # Alternative rate limit reset header name +) diff --git a/openfga_sdk/oauth2.py b/openfga_sdk/oauth2.py index 389d1645..61b6aabc 100644 --- a/openfga_sdk/oauth2.py +++ b/openfga_sdk/oauth2.py @@ -9,11 +9,11 @@ import urllib3 from openfga_sdk.configuration import Configuration +from openfga_sdk.constants import USER_AGENT from openfga_sdk.credentials import Credentials from openfga_sdk.exceptions import AuthenticationError from openfga_sdk.telemetry.attributes import TelemetryAttributes from openfga_sdk.telemetry.telemetry import Telemetry -from openfga_sdk.constants import USER_AGENT def jitter(loop_count, min_wait_in_ms): diff --git a/openfga_sdk/sync/api_client.py b/openfga_sdk/sync/api_client.py index 5d53b2ea..1a070216 100644 --- a/openfga_sdk/sync/api_client.py +++ b/openfga_sdk/sync/api_client.py @@ -14,6 +14,11 @@ import openfga_sdk.models 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, @@ -24,9 +29,6 @@ from openfga_sdk.sync import oauth2, rest from openfga_sdk.telemetry import Telemetry from openfga_sdk.telemetry.attributes import TelemetryAttribute, TelemetryAttributes -from openfga_sdk.constants import USER_AGENT as DEFAULT_USER_AGENT -from openfga_sdk.constants import MAX_BACKOFF_TIME_IN_SEC -from openfga_sdk.constants import RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC def random_time(loop_count, min_wait_in_ms) -> float: @@ -411,7 +413,10 @@ def _parse_retry_after_header(self, headers) -> int: except ApiException: wait_time_in_sec = int(retry_after_header) - if wait_time_in_sec > RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC or wait_time_in_sec < 1: + if ( + wait_time_in_sec > RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC + or wait_time_in_sec < 1 + ): raise ValueError("Retry-After header is invalid") return math.ceil(wait_time_in_sec) diff --git a/openfga_sdk/sync/client/client.py b/openfga_sdk/sync/client/client.py index ef2d0c02..84a8b023 100644 --- a/openfga_sdk/sync/client/client.py +++ b/openfga_sdk/sync/client/client.py @@ -32,6 +32,12 @@ construct_write_single_response, ) from openfga_sdk.client.models.write_transaction_opts import WriteTransactionOpts +from openfga_sdk.constants import ( + CLIENT_BULK_REQUEST_ID_HEADER, + CLIENT_MAX_BATCH_SIZE, + CLIENT_MAX_METHOD_PARALLEL_REQUESTS, + CLIENT_METHOD_HEADER, +) from openfga_sdk.exceptions import ( AuthenticationError, FgaValidationException, @@ -63,12 +69,6 @@ from openfga_sdk.sync.api_client import ApiClient from openfga_sdk.sync.open_fga_api import OpenFgaApi from openfga_sdk.validation import is_well_formed_ulid_string -from openfga_sdk.constants import ( - CLIENT_METHOD_HEADER, - CLIENT_BULK_REQUEST_ID_HEADER, - CLIENT_MAX_METHOD_PARALLEL_REQUESTS, - CLIENT_MAX_BATCH_SIZE, -) def _chuck_array(array, max_size): diff --git a/openfga_sdk/sync/oauth2.py b/openfga_sdk/sync/oauth2.py index 054e1916..b8707396 100644 --- a/openfga_sdk/sync/oauth2.py +++ b/openfga_sdk/sync/oauth2.py @@ -9,11 +9,11 @@ import urllib3 from openfga_sdk.configuration import Configuration +from openfga_sdk.constants import USER_AGENT from openfga_sdk.credentials import Credentials from openfga_sdk.exceptions import AuthenticationError from openfga_sdk.telemetry.attributes import TelemetryAttributes from openfga_sdk.telemetry.telemetry import Telemetry -from openfga_sdk.constants import USER_AGENT def jitter(loop_count, min_wait_in_ms): diff --git a/test/api/open_fga_api_test.py b/test/api/open_fga_api_test.py index a5f1141e..ccdf92c4 100644 --- a/test/api/open_fga_api_test.py +++ b/test/api/open_fga_api_test.py @@ -10,6 +10,7 @@ from openfga_sdk import rest 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, @@ -79,7 +80,6 @@ from openfga_sdk.models.write_request import WriteRequest from openfga_sdk.models.write_request_deletes import WriteRequestDeletes from openfga_sdk.models.write_request_writes import WriteRequestWrites -from openfga_sdk.constants import USER_AGENT store_id = "01H0H015178Y2V4CX10C2KGHF4" diff --git a/test/constants_consistency_test.py b/test/constants_consistency_test.py index 194b9482..c6386801 100644 --- a/test/constants_consistency_test.py +++ b/test/constants_consistency_test.py @@ -7,20 +7,26 @@ - USER_AGENT embeds the SDK_VERSION """ -from openfga_sdk import __version__ as package_version, Configuration -from openfga_sdk.api_client import DEFAULT_USER_AGENT as ASYNC_DEFAULT_USER_AGENT # alias in module -from openfga_sdk.sync.api_client import DEFAULT_USER_AGENT as SYNC_DEFAULT_USER_AGENT +from openfga_sdk import Configuration +from openfga_sdk import __version__ as package_version +from openfga_sdk.api_client import ( + DEFAULT_USER_AGENT as ASYNC_DEFAULT_USER_AGENT, +) from openfga_sdk.constants import ( - SDK_VERSION, - USER_AGENT, DEFAULT_MAX_RETRY, DEFAULT_MIN_WAIT_IN_MS, - MAX_BACKOFF_TIME_IN_SEC, SAMPLE_BASE_DOMAIN, + 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 def test_version_constant_matches_package_version(): - assert package_version == SDK_VERSION, "openfga_sdk.__version__ must match SDK_VERSION constant" + assert package_version == SDK_VERSION, ( + "openfga_sdk.__version__ must match SDK_VERSION constant" + ) def test_retry_params_default_constants_alignment(): @@ -39,4 +45,6 @@ def test_sync_api_client_user_agent_constant_matches(): def test_user_agent_contains_version(): - assert SDK_VERSION in USER_AGENT, "USER_AGENT should embed the SDK version for observability" + assert SDK_VERSION in USER_AGENT, ( + "USER_AGENT should embed the SDK version for observability" + ) diff --git a/test/sync/open_fga_api_test.py b/test/sync/open_fga_api_test.py index 668e251e..ac09ac75 100644 --- a/test/sync/open_fga_api_test.py +++ b/test/sync/open_fga_api_test.py @@ -7,9 +7,9 @@ import urllib3 import openfga_sdk.sync -from openfga_sdk.constants 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, From fb4227aac4cbe6105d69d48a5df84e76d27664f1 Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Wed, 15 Oct 2025 18:01:37 -0400 Subject: [PATCH 5/6] chore: fix constants file being ignored --- .openapi-generator-ignore | 1 - .openapi-generator/FILES | 1 + openfga_sdk/constants.py | 123 ++++++++++++++++++++++---------------- 3 files changed, 73 insertions(+), 52 deletions(-) diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore index c9110bcb..2d6e1835 100644 --- a/.openapi-generator-ignore +++ b/.openapi-generator-ignore @@ -14,6 +14,5 @@ openfga_sdk/api/open_fga_api openfga_sdk/sync/open_fga_api.py openfga_sdk/api_client.py openfga_sdk/configuration.py -openfga_sdk/constants.py openfga_sdk/exceptions.py openfga_sdk/rest.py \ No newline at end of file diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 59bca6c4..12e588d4 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -98,6 +98,7 @@ docs/WriteRequest.md docs/WriteRequestDeletes.md docs/WriteRequestWrites.md openfga_sdk/api/open_fga_api.py +openfga_sdk/constants.py openfga_sdk/models/__init__.py openfga_sdk/models/aborted_message_response.py openfga_sdk/models/any.py diff --git a/openfga_sdk/constants.py b/openfga_sdk/constants.py index ede443b0..a39c73ab 100644 --- a/openfga_sdk/constants.py +++ b/openfga_sdk/constants.py @@ -13,60 +13,81 @@ from typing import Final -# SDK version information -SDK_VERSION: Final[str] = "0.9.7" # Version of the OpenFGA Python SDK +# Version of the OpenFGA Python SDK. +SDK_VERSION: Final[str] = "0.9.7" -# User agent for HTTP requests -USER_AGENT: Final[str] = "openfga-sdk python/0.9.7" # User agent used in HTTP requests +# User agent used in HTTP requests. +USER_AGENT: Final[str] = "openfga-sdk python/0.9.7" -# Sample API domain for examples -SAMPLE_BASE_DOMAIN: Final[str] = ( - "fga.example" # Example API domain for documentation/tests -) +# Example API domain for documentation/tests. +SAMPLE_BASE_DOMAIN: Final[str] = "fga.example" + +# API URL used for tests. +TEST_API_URL: Final[str] = f"https://api.{SAMPLE_BASE_DOMAIN}" + +# API Token Issuer URL used for tests. +TEST_ISSUER_URL: Final[str] = f"https://issuer.{SAMPLE_BASE_DOMAIN}" + +# Default API URL. +DEFAULT_API_URL: Final[str] = "http://localhost:8080" # Retry configuration -RETRY_MAX_ALLOWED_NUMBER: Final[int] = ( - 15 # Maximum allowed number of retries for HTTP requests -) -DEFAULT_MAX_RETRY: Final[int] = 3 # Default maximum number of retries for HTTP requests -DEFAULT_MIN_WAIT_IN_MS: Final[int] = ( - 100 # Default minimum wait time between retries in milliseconds -) -MAX_BACKOFF_TIME_IN_SEC: Final[int] = 120 # Maximum backoff time in seconds -RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC: Final[int] = ( - 1800 # Maximum allowable duration for retry headers in seconds -) - -# Client configuration -CLIENT_MAX_METHOD_PARALLEL_REQUESTS: Final[int] = ( - 10 # Maximum number of parallel requests for a single method -) -CLIENT_MAX_BATCH_SIZE: Final[int] = 50 # Maximum batch size for batch requests -DEFAULT_CONNECTION_TIMEOUT_IN_MS: Final[int] = ( - 10000 # Default connection timeout in milliseconds -) + +# Maximum allowed number of retries for HTTP requests. +RETRY_MAX_ALLOWED_NUMBER: Final[int] = 15 + +# Default maximum number of retries for HTTP requests. +DEFAULT_MAX_RETRY: Final[int] = 3 + +# Default minimum wait time between retries in milliseconds. +DEFAULT_MIN_WAIT_IN_MS: Final[int] = 100 + +# Maximum backoff time in seconds. +MAX_BACKOFF_TIME_IN_SEC: Final[int] = 120 + +# Maximum allowable duration for retry headers in seconds. +RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC: Final[int] = 1800 + +# Standard HTTP header for retry-after. +RETRY_AFTER_HEADER_NAME: Final[str] = "Retry-After" + +# Rate limit reset header name. +RATE_LIMIT_RESET_HEADER_NAME: Final[str] = "X-RateLimit-Reset" + +# Alternative rate limit reset header name. +RATE_LIMIT_RESET_ALT_HEADER_NAME: Final[str] = "X-Rate-Limit-Reset" + +# Client methods + +# Maximum number of parallel requests for a single method. +CLIENT_MAX_METHOD_PARALLEL_REQUESTS: Final[int] = 10 + +# Maximum batch size for batch requests. +CLIENT_MAX_BATCH_SIZE: Final[int] = 50 + +# Header used to identify the client method. +CLIENT_METHOD_HEADER: Final[str] = "X-OpenFGA-Client-Method" + +# Header used to identify bulk requests. +CLIENT_BULK_REQUEST_ID_HEADER: Final[str] = "X-OpenFGA-Client-Bulk-Request-Id" + +# Connection options + +# Default timeout for HTTP requests in milliseconds. +DEFAULT_REQUEST_TIMEOUT_IN_MS: Final[int] = 10000 + +# Default connection timeout in milliseconds. +DEFAULT_CONNECTION_TIMEOUT_IN_MS: Final[int] = 10000 # Token management -TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC: Final[int] = ( - 300 # Buffer time in seconds before token expiry to consider it expired -) -TOKEN_EXPIRY_JITTER_IN_SEC: Final[int] = ( - 300 # Jitter time in seconds to add randomness to token expiry checks -) - -# HTTP headers -CLIENT_METHOD_HEADER: Final[str] = ( - "X-OpenFGA-Client-Method" # Header used to identify the client method -) -CLIENT_BULK_REQUEST_ID_HEADER: Final[str] = ( - "X-OpenFGA-Client-Bulk-Request-Id" # Header used to identify bulk requests -) -RETRY_AFTER_HEADER_NAME: Final[str] = ( - "Retry-After" # Standard HTTP header for retry after -) -RATE_LIMIT_RESET_HEADER_NAME: Final[str] = ( - "X-RateLimit-Reset" # Rate limit reset header name -) -RATE_LIMIT_RESET_ALT_HEADER_NAME: Final[str] = ( - "X-Rate-Limit-Reset" # Alternative rate limit reset header name -) + +# Buffer time in seconds before token expiry to consider it expired. +TOKEN_EXPIRY_THRESHOLD_BUFFER_IN_SEC: Final[int] = 300 + +# Jitter time in seconds to add randomness to token expiry checks. +TOKEN_EXPIRY_JITTER_IN_SEC: Final[int] = 300 + +# FGA Response Headers + +# Response header name for query duration in milliseconds. +QUERY_DURATION_HEADER_NAME: Final[str] = "fga-query-duration-ms" From 7eaaf11d8629c6a209f4493fa9c0d1b0aad370ea Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Fri, 24 Oct 2025 11:41:49 -0400 Subject: [PATCH 6/6] chore: fix typo Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- test/constants_consistency_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/constants_consistency_test.py b/test/constants_consistency_test.py index c6386801..1aa7c621 100644 --- a/test/constants_consistency_test.py +++ b/test/constants_consistency_test.py @@ -2,8 +2,8 @@ Covers: - Version consistency between openfga_sdk.__version__ and SDK_VERSION constant -- RetryParams default values match exported retry constants1 -- ApiClient (async and sync) user agent constants1 match USER_AGENT constant +- RetryParams default values match exported retry constants +- ApiClient (async and sync) user agent constants match USER_AGENT constant - USER_AGENT embeds the SDK_VERSION """