diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore index e86b5f6c..2d6e1835 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,12 @@ 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/exceptions.py +openfga_sdk/rest.py \ No newline at end of file diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 06aeac2a..12e588d4 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,8 @@ 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/constants.py openfga_sdk/models/__init__.py openfga_sdk/models/aborted_message_response.py openfga_sdk/models/any.py @@ -236,42 +188,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 241e40b8..b4e60809 100644 --- a/openfga_sdk/__init__.py +++ b/openfga_sdk/__init__.py @@ -1,22 +1,9 @@ -""" -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. -""" - -__version__ = "0.9.7" - 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, @@ -144,6 +131,8 @@ ) +__version__ = SDK_VERSION + __all__ = [ "OpenFgaClient", "ClientConfiguration", diff --git a/openfga_sdk/api_client.py b/openfga_sdk/api_client.py index c3aa7ecc..baa73eea 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 @@ -28,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, @@ -39,9 +32,6 @@ from openfga_sdk.telemetry.attributes import TelemetryAttribute, TelemetryAttributes -DEFAULT_USER_AGENT = "openfga-sdk python/0.9.7" - - def random_time(loop_count, min_wait_in_ms) -> float: """ Helper function to return the time (in s) to wait before retry @@ -258,7 +248,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 +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 > 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/__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 8ffbfc32..daed0894 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 @@ -45,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, @@ -76,10 +70,6 @@ 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" - - def _chuck_array(array, max_size): """ Helper function to chuck array into arrays of max_size @@ -714,7 +704,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 +763,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 +773,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/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 96bf4153..9620a612 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 @@ -18,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 ( @@ -44,7 +39,12 @@ 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 +54,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 +71,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 @@ -543,7 +543,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..a39c73ab --- /dev/null +++ b/openfga_sdk/constants.py @@ -0,0 +1,93 @@ +""" +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 Final + + +# Version of the OpenFGA Python SDK. +SDK_VERSION: Final[str] = "0.9.7" + +# User agent used in HTTP requests. +USER_AGENT: Final[str] = "openfga-sdk python/0.9.7" + +# 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 + +# 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 + +# 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" 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 b7a03dc1..61b6aabc 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 @@ -21,6 +9,7 @@ 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 @@ -90,7 +79,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/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 17b76752..1a070216 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 @@ -26,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, @@ -38,9 +31,6 @@ from openfga_sdk.telemetry.attributes import TelemetryAttribute, TelemetryAttributes -DEFAULT_USER_AGENT = "openfga-sdk python/0.9.7" - - def random_time(loop_count, min_wait_in_ms) -> float: """ Helper function to return the time (in s) to wait before retry @@ -257,7 +247,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 +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 > 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/__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 09784a99..84a8b023 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 @@ -44,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, @@ -77,10 +71,6 @@ 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" - - def _chuck_array(array, max_size): """ Helper function to chuck array into arrays of max_size @@ -711,7 +701,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 +760,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 +770,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..b8707396 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 @@ -21,6 +9,7 @@ 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 @@ -90,7 +79,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/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 02bf147f..ccdf92c4 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 @@ -22,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, @@ -1782,7 +1771,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 +1825,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 +2073,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 +2132,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/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/constants_consistency_test.py b/test/constants_consistency_test.py new file mode 100644 index 00000000..c6386801 --- /dev/null +++ b/test/constants_consistency_test.py @@ -0,0 +1,50 @@ +"""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 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 ( + DEFAULT_MAX_RETRY, + DEFAULT_MIN_WAIT_IN_MS, + MAX_BACKOFF_TIME_IN_SEC, + SAMPLE_BASE_DOMAIN, + SDK_VERSION, + USER_AGENT, +) +from openfga_sdk.sync.api_client import DEFAULT_USER_AGENT as SYNC_DEFAULT_USER_AGENT + + +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/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 5886efd7..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 @@ -18,6 +6,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 +73,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 +299,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 +354,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 +409,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 +464,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 +522,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 +581,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/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 a0099810..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 @@ -17,6 +5,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 +73,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 +131,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 +190,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..ac09ac75 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 @@ -21,6 +9,7 @@ import openfga_sdk.sync 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, @@ -1728,47 +1717,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", + ), + ) + + api_response = api_instance.check( + body=body, + ) - self.assertIsInstance(api_response, CheckResponse) - mock_request.assert_called() - self.assertEqual(mock_request.call_count, 5) + 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): @@ -1845,7 +1832,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 +1886,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 +1943,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 +2000,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 } 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