Skip to content
Merged
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: 4 additions & 16 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,16 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
**/requirements*.txt
**/test-requirements*.txt

- name: Install dependencies
run: pip install -r test-requirements.txt --upgrade pip

- if: matrix.python-version == '3.10'
name: Run Flake8
run: flake8 . --count --show-source --statistics

- if: matrix.python-version == '3.10'
name: Run Black
run: black . --check

- if: matrix.python-version == '3.10'
name: Run isort
run: isort . --profile black --diff --check-only

- if: matrix.python-version == '3.10'
name: Run autoflake
run: autoflake --exclude=__init__.py --remove-unused-variables --remove-all-unused-imports --quiet --check-diff --recursive .
name: Run `ruff`
run: ruff check

- name: Run tests and collect coverage
run: pytest --cov-fail-under 60 --cov openfga_sdk
Expand Down Expand Up @@ -84,7 +72,7 @@ jobs:
python-version: "3.10"
cache: "pip"
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
**/requirements*.txt
**/test-requirements*.txt

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ venv/
.venv/
.python-version
.pytest_cache
.ruff_cache
test/__pycache__/

# Translations
Expand Down
1 change: 1 addition & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ test/*
.gitlab-ci.yml
.travis.yml
tox.ini
setup.cfg
2 changes: 1 addition & 1 deletion .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ openfga_sdk/telemetry/metrics.py
openfga_sdk/telemetry/telemetry.py
openfga_sdk/telemetry/utilities.py
openfga_sdk/validation.py
pyproject.toml
requirements.txt
setup.cfg
setup.py
test-requirements.txt
test/_/configuration_test.py
Expand Down
15 changes: 15 additions & 0 deletions example/example1/example1.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
# ruff: noqa: E402

"""
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 os
import sys
import uuid

from dotenv import load_dotenv


sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
sys.path.insert(0, sdk_path)

Expand Down
15 changes: 8 additions & 7 deletions example/example1/setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
"""
Python SDK for OpenFGA
Python SDK for OpenFGA

API version: 0.1
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://discord.gg/8naAwJfWN6
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
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.
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

from setuptools import find_packages, setup


NAME = "example1"
VERSION = "0.0.1"
REQUIRES = ["openfga-sdk >= 0.9.1"]
Expand Down
27 changes: 21 additions & 6 deletions example/opentelemetry/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# ruff: noqa: E402

"""
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 os
import sys

from operator import attrgetter
from random import randint
from typing import Any
Expand All @@ -15,6 +30,7 @@
)
from opentelemetry.sdk.resources import SERVICE_NAME, Resource


# For usage convenience of this example, we will import the OpenFGA SDK from the parent directory.
sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
sys.path.insert(0, sdk_path)
Expand Down Expand Up @@ -199,16 +215,15 @@ async def main():
print(f"Making {checks_requests} checks ...", end=" ")
for _ in range(checks_requests):
try:
allowed = app().unpack(
await fga_client.check(
body=ClientCheckRequest(
user="user:anne", relation="owner", object="folder:foo"
),
await fga_client.check(
body=ClientCheckRequest(
user="user:anne", relation="owner", object="folder:foo"
),
"allowed",
)

except FgaValidationException as error:
print(f"Checked failed due to validation exception: {error}")

print("Done!")


Expand Down
15 changes: 8 additions & 7 deletions example/opentelemetry/setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
"""
Python SDK for OpenFGA
Python SDK for OpenFGA

API version: 0.1
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://discord.gg/8naAwJfWN6
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
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.
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

from setuptools import find_packages, setup


NAME = "openfga-opentelemetry-example"
VERSION = "0.0.1"
REQUIRES = [""]
Expand Down
20 changes: 18 additions & 2 deletions example/streamed-list-objects/asynchronous.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
# ruff: noqa: E402

"""
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 os
import sys

from operator import attrgetter
from typing import Any

from dotenv import load_dotenv


sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
sys.path.insert(0, sdk_path)

Expand Down Expand Up @@ -72,7 +88,7 @@ async def main():
)
print(f"Created temporary authorization model ({model})")

print(f"Writing 100 mock tuples to store.")
print("Writing 100 mock tuples to store.")

# Write mock data
writes = []
Expand Down Expand Up @@ -111,7 +127,7 @@ async def main():
try:
await fga_client.delete_store()
print(f"Deleted temporary store ({store})")
except:
except Exception:
pass

print("Finished.")
Expand Down
15 changes: 8 additions & 7 deletions example/streamed-list-objects/setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
"""
Python SDK for OpenFGA
Python SDK for OpenFGA

API version: 0.1
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://discord.gg/8naAwJfWN6
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
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.
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

from setuptools import find_packages, setup


NAME = "openfga-streamed-list-objects-example"
VERSION = "0.0.1"
REQUIRES = [""]
Expand Down
20 changes: 18 additions & 2 deletions example/streamed-list-objects/synchronous.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# ruff: noqa: E402

"""
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 os
import sys

from operator import attrgetter
from typing import Any

from dotenv import load_dotenv


sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
sys.path.insert(0, sdk_path)

Expand Down Expand Up @@ -69,7 +85,7 @@ def main():
)
print(f"Created temporary authorization model ({model})")

print(f"Writing 100 mock tuples to store.")
print("Writing 100 mock tuples to store.")

# Write mock data
writes = []
Expand Down Expand Up @@ -108,7 +124,7 @@ def main():
try:
fga_client.delete_store()
print(f"Deleted temporary store ({store})")
except:
except Exception:
pass

print("Finished.")
Expand Down
Loading