Skip to content

Commit 386df2e

Browse files
authored
Merge branch 'main' into feat/support-write-conflict-options
2 parents f0bc591 + 759afd0 commit 386df2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+284
-966
lines changed

.openapi-generator-ignore

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
git_push.sh
22
test/*
3-
!test/__init__.py
4-
!test/test_open_fga_api.py
5-
!test/test_configuration.py
6-
!test/test_credentials.py
7-
!test/test_client.py
8-
!test/test_client_sync.py
9-
!test/test_open_fga_api_sync.py
10-
!test/test_validation.py
11-
!test/test_oauth2.py
12-
!test/test_oauth2_sync.py
133
.github/workflows/python.yml
144
.gitlab-ci.yml
155
.travis.yml
166
tox.ini
177
setup.cfg
188
setup.py
199
requirements.txt
20-
test-requirements.txt
10+
test-requirements.txt
11+
openfga_sdk/__init__.py
12+
openfga_sdk/api/__init__.py
13+
openfga_sdk/api/open_fga_api
14+
openfga_sdk/sync/open_fga_api.py
15+
openfga_sdk/api_client.py
16+
openfga_sdk/configuration.py
17+
openfga_sdk/exceptions.py
18+
openfga_sdk/rest.py

.openapi-generator/FILES

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
.codecov.yml
2-
.fossa.yml
32
.github/CODEOWNERS
43
.github/ISSUE_TEMPLATE/bug_report.yaml
54
.github/ISSUE_TEMPLATE/config.yaml
65
.github/ISSUE_TEMPLATE/feature_request.yaml
76
.gitignore
8-
.snyk
9-
CHANGELOG.md
107
CONTRIBUTING.md
118
LICENSE
129
README.md
@@ -100,55 +97,8 @@ docs/WriteAuthorizationModelResponse.md
10097
docs/WriteRequest.md
10198
docs/WriteRequestDeletes.md
10299
docs/WriteRequestWrites.md
103-
docs/opentelemetry.md
104-
example/Makefile
105-
example/README.md
106-
example/example1/example1.py
107-
example/example1/requirements.txt
108-
example/example1/setup.cfg
109-
example/example1/setup.py
110-
example/opentelemetry/.env.example
111-
example/opentelemetry/.gitignore
112-
example/opentelemetry/README.md
113-
example/opentelemetry/main.py
114-
example/opentelemetry/requirements.txt
115-
example/opentelemetry/setup.cfg
116-
example/opentelemetry/setup.py
117-
example/streamed-list-objects/README.md
118-
example/streamed-list-objects/example.py
119-
example/streamed-list-objects/model.json
120-
openfga_sdk/__init__.py
121-
openfga_sdk/api/__init__.py
122100
openfga_sdk/api/open_fga_api.py
123-
openfga_sdk/api/open_fga_api_sync.py
124-
openfga_sdk/api_client.py
125-
openfga_sdk/client/__init__.py
126-
openfga_sdk/client/client.py
127-
openfga_sdk/client/configuration.py
128-
openfga_sdk/client/models/__init__.py
129-
openfga_sdk/client/models/assertion.py
130-
openfga_sdk/client/models/batch_check_item.py
131-
openfga_sdk/client/models/batch_check_request.py
132-
openfga_sdk/client/models/batch_check_response.py
133-
openfga_sdk/client/models/batch_check_single_response.py
134-
openfga_sdk/client/models/check_request.py
135-
openfga_sdk/client/models/client_batch_check_response.py
136-
openfga_sdk/client/models/expand_request.py
137-
openfga_sdk/client/models/list_objects_request.py
138-
openfga_sdk/client/models/list_relations_request.py
139-
openfga_sdk/client/models/list_users_request.py
140-
openfga_sdk/client/models/read_changes_request.py
141-
openfga_sdk/client/models/tuple.py
142-
openfga_sdk/client/models/write_conflict_opts.py
143-
openfga_sdk/client/models/write_options.py
144-
openfga_sdk/client/models/write_request.py
145-
openfga_sdk/client/models/write_response.py
146-
openfga_sdk/client/models/write_single_response.py
147-
openfga_sdk/client/models/write_transaction_opts.py
148-
openfga_sdk/configuration.py
149-
openfga_sdk/credentials.py
150-
openfga_sdk/exceptions.py
151-
openfga_sdk/help.py
101+
openfga_sdk/constants.py
152102
openfga_sdk/models/__init__.py
153103
openfga_sdk/models/aborted_message_response.py
154104
openfga_sdk/models/any.py
@@ -238,42 +188,3 @@ openfga_sdk/models/write_authorization_model_response.py
238188
openfga_sdk/models/write_request.py
239189
openfga_sdk/models/write_request_deletes.py
240190
openfga_sdk/models/write_request_writes.py
241-
openfga_sdk/oauth2.py
242-
openfga_sdk/rest.py
243-
openfga_sdk/sync/__init__.py
244-
openfga_sdk/sync/api_client.py
245-
openfga_sdk/sync/client/__init__.py
246-
openfga_sdk/sync/client/client.py
247-
openfga_sdk/sync/oauth2.py
248-
openfga_sdk/sync/rest.py
249-
openfga_sdk/telemetry/__init__.py
250-
openfga_sdk/telemetry/attributes.py
251-
openfga_sdk/telemetry/configuration.py
252-
openfga_sdk/telemetry/counters.py
253-
openfga_sdk/telemetry/histograms.py
254-
openfga_sdk/telemetry/metrics.py
255-
openfga_sdk/telemetry/telemetry.py
256-
openfga_sdk/validation.py
257-
pyproject.toml
258-
test/_/configuration_test.py
259-
test/_/credentials_test.py
260-
test/_/oauth2_test.py
261-
test/_/rest_test.py
262-
test/_/validation_test.py
263-
test/__init__.py
264-
test/api/__init__.py
265-
test/client/__init__.py
266-
test/client/client_test.py
267-
test/sync/__init__.py
268-
test/sync/client/__init__.py
269-
test/sync/client/client_test.py
270-
test/sync/oauth2_test.py
271-
test/sync/open_fga_api_test.py
272-
test/sync/rest_test.py
273-
test/telemetry/attributes_test.py
274-
test/telemetry/configuration_test.py
275-
test/telemetry/counters_test.py
276-
test/telemetry/histograms_test.py
277-
test/telemetry/metrics_test.py
278-
test/telemetry/telemetry_test.py
279-
test/test_open_fga_api.py

CONTRIBUTING.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,23 @@ By participating and contributing to this project, you are expected to uphold ou
2323

2424
### Making Changes
2525

26-
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.
26+
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.
2727

2828
### Opening Issues
2929

3030
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).
3131

32-
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.
32+
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.
33+
34+
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.
35+
36+
**Please do not report security vulnerabilities on the public GitHub issue tracker.**
3337

3438
### Submitting Pull Requests
3539

36-
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.
40+
Feel free to submit a Pull Request against this repository. Please make sure to follow the existing code style and include tests where applicable.
41+
42+
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.
3743

3844
## Getting in touch
3945

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,13 +1409,7 @@ This SDK supports producing metrics that can be consumed as part of an [OpenTele
14091409

14101410
## Contributing
14111411

1412-
### Issues
1413-
1414-
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.
1415-
1416-
### Pull Requests
1417-
1418-
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.
1412+
See [CONTRIBUTING](./CONTRIBUTING.md) for details.
14191413

14201414
## Author
14211415

openfga_sdk/__init__.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
"""
2-
Python SDK for OpenFGA
3-
4-
API version: 1.x
5-
Website: https://openfga.dev
6-
Documentation: https://openfga.dev/docs
7-
Support: https://openfga.dev/community
8-
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
9-
10-
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
11-
"""
12-
13-
__version__ = "0.9.7"
14-
151
from openfga_sdk.api.open_fga_api import OpenFgaApi
162
from openfga_sdk.api_client import ApiClient
173
from openfga_sdk.client.client import OpenFgaClient
184
from openfga_sdk.client.configuration import ClientConfiguration
195
from openfga_sdk.configuration import Configuration
6+
from openfga_sdk.constants import SDK_VERSION
207
from openfga_sdk.exceptions import (
218
ApiAttributeError,
229
ApiException,
@@ -144,6 +131,8 @@
144131
)
145132

146133

134+
__version__ = SDK_VERSION
135+
147136
__all__ = [
148137
"OpenFgaClient",
149138
"ClientConfiguration",

openfga_sdk/api_client.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
"""
2-
Python SDK for OpenFGA
3-
4-
API version: 1.x
5-
Website: https://openfga.dev
6-
Documentation: https://openfga.dev/docs
7-
Support: https://openfga.dev/community
8-
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
9-
10-
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
11-
"""
12-
131
import asyncio
142
import atexit
153
import datetime
@@ -28,6 +16,11 @@
2816

2917
from openfga_sdk import oauth2, rest
3018
from openfga_sdk.configuration import Configuration
19+
from openfga_sdk.constants import (
20+
MAX_BACKOFF_TIME_IN_SEC,
21+
RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC,
22+
)
23+
from openfga_sdk.constants import USER_AGENT as DEFAULT_USER_AGENT
3124
from openfga_sdk.exceptions import (
3225
ApiException,
3326
ApiValueError,
@@ -39,9 +32,6 @@
3932
from openfga_sdk.telemetry.attributes import TelemetryAttribute, TelemetryAttributes
4033

4134

42-
DEFAULT_USER_AGENT = "openfga-sdk python/0.9.7"
43-
44-
4535
def random_time(loop_count, min_wait_in_ms) -> float:
4636
"""
4737
Helper function to return the time (in s) to wait before retry
@@ -258,7 +248,7 @@ async def __call_api(
258248
self.configuration.retry_params is not None
259249
and self.configuration.retry_params.max_wait_in_sec is not None
260250
)
261-
else 120
251+
else MAX_BACKOFF_TIME_IN_SEC
262252
)
263253
if _retry_params is not None:
264254
if _retry_params.max_retry is not None:
@@ -425,7 +415,10 @@ def _parse_retry_after_header(self, headers) -> int:
425415
except ApiException:
426416
wait_time_in_sec = int(retry_after_header)
427417

428-
if wait_time_in_sec > 1800 or wait_time_in_sec < 1:
418+
if (
419+
wait_time_in_sec > RETRY_HEADER_MAX_ALLOWABLE_DURATION_IN_SEC
420+
or wait_time_in_sec < 1
421+
):
429422
raise ValueError("Retry-After header is invalid")
430423

431424
return math.ceil(wait_time_in_sec)

openfga_sdk/client/__init__.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
"""
2-
Python SDK for OpenFGA
3-
4-
API version: 1.x
5-
Website: https://openfga.dev
6-
Documentation: https://openfga.dev/docs
7-
Support: https://openfga.dev/community
8-
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
9-
10-
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
11-
"""
12-
131
from openfga_sdk.client.client import OpenFgaClient
142
from openfga_sdk.client.configuration import ClientConfiguration
153
from openfga_sdk.client.models.check_request import ClientCheckRequest

openfga_sdk/client/client.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
"""
2-
Python SDK for OpenFGA
3-
4-
API version: 1.x
5-
Website: https://openfga.dev
6-
Documentation: https://openfga.dev/docs
7-
Support: https://openfga.dev/community
8-
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
9-
10-
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
11-
"""
12-
131
import asyncio
142
import uuid
153

@@ -45,6 +33,12 @@
4533
construct_write_single_response,
4634
)
4735
from openfga_sdk.client.models.write_transaction_opts import WriteTransactionOpts
36+
from openfga_sdk.constants import (
37+
CLIENT_BULK_REQUEST_ID_HEADER,
38+
CLIENT_MAX_BATCH_SIZE,
39+
CLIENT_MAX_METHOD_PARALLEL_REQUESTS,
40+
CLIENT_METHOD_HEADER,
41+
)
4842
from openfga_sdk.exceptions import (
4943
AuthenticationError,
5044
FgaValidationException,
@@ -76,10 +70,6 @@
7670
from openfga_sdk.validation import is_well_formed_ulid_string
7771

7872

79-
CLIENT_METHOD_HEADER = "X-OpenFGA-Client-Method"
80-
CLIENT_BULK_REQUEST_ID_HEADER = "X-OpenFGA-Client-Bulk-Request-Id"
81-
82-
8373
def _chuck_array(array, max_size):
8474
"""
8575
Helper function to chuck array into arrays of max_size
@@ -736,7 +726,7 @@ async def client_batch_check(
736726
options, CLIENT_BULK_REQUEST_ID_HEADER, str(uuid.uuid4())
737727
)
738728

739-
max_parallel_requests = 10
729+
max_parallel_requests = CLIENT_MAX_METHOD_PARALLEL_REQUESTS
740730
if options is not None and "max_parallel_requests" in options:
741731
if (
742732
isinstance(options["max_parallel_requests"], str)
@@ -795,7 +785,7 @@ async def batch_check(
795785
options, CLIENT_BULK_REQUEST_ID_HEADER, str(uuid.uuid4())
796786
)
797787

798-
max_parallel_requests = 10
788+
max_parallel_requests = CLIENT_MAX_METHOD_PARALLEL_REQUESTS
799789
if options is not None and "max_parallel_requests" in options:
800790
if (
801791
isinstance(options["max_parallel_requests"], str)
@@ -805,7 +795,7 @@ async def batch_check(
805795
elif isinstance(options["max_parallel_requests"], int):
806796
max_parallel_requests = options["max_parallel_requests"]
807797

808-
max_batch_size = 50
798+
max_batch_size = CLIENT_MAX_BATCH_SIZE
809799
if options is not None and "max_batch_size" in options:
810800
if (
811801
isinstance(options["max_batch_size"], str)

openfga_sdk/client/configuration.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
"""
2-
Python SDK for OpenFGA
3-
4-
API version: 1.x
5-
Website: https://openfga.dev
6-
Documentation: https://openfga.dev/docs
7-
Support: https://openfga.dev/community
8-
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
9-
10-
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
11-
"""
12-
131
from openfga_sdk.configuration import Configuration
142
from openfga_sdk.exceptions import FgaValidationException
153
from openfga_sdk.telemetry.attributes import TelemetryAttribute

openfga_sdk/client/models/__init__.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
"""
2-
Python SDK for OpenFGA
3-
4-
API version: 1.x
5-
Website: https://openfga.dev
6-
Documentation: https://openfga.dev/docs
7-
Support: https://openfga.dev/community
8-
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
9-
10-
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
11-
"""
12-
131
from openfga_sdk.client.models.assertion import ClientAssertion
142
from openfga_sdk.client.models.batch_check_item import ClientBatchCheckItem
153
from openfga_sdk.client.models.batch_check_request import ClientBatchCheckRequest

0 commit comments

Comments
 (0)