Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
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
tox.ini
setup.cfg
setup.py
requirements.txt
test-requirements.txt
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
89 changes: 1 addition & 88 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
12 changes: 9 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
17 changes: 3 additions & 14 deletions openfga_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -144,6 +131,8 @@
)


__version__ = SDK_VERSION

__all__ = [
"OpenFgaClient",
"ClientConfiguration",
Expand Down
27 changes: 10 additions & 17 deletions openfga_sdk/api_client.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 0 additions & 12 deletions openfga_sdk/client/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 9 additions & 19 deletions openfga_sdk/client/client.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 0 additions & 12 deletions openfga_sdk/client/configuration.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 0 additions & 12 deletions openfga_sdk/client/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading