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
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Specify python version
uses: actions/setup-python@v4
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.10'

- name: Setup git
run: ./scripts/setup_git.sh
Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:
working-directory: clients/fga-python-sdk
run: |-
pip install -r requirements.txt

- name: Install Snyk CLI
run: |-
mkdir -p ~/.local/bin
Expand All @@ -243,7 +243,7 @@ jobs:
run: |-
export PATH=$PATH:$HOME/.local/bin
snyk test

- name: Install FOSSA CLI
run: |-
mkdir -p ~/.local/bin
Expand All @@ -267,4 +267,4 @@ jobs:
TAGGING_DISABLE: 1
GITHUB_ORG_ID: ${{ secrets.PYTHON_SDK_GITHUB_ORG_ID }}
GITHUB_REPO_ID: ${{ secrets.PYTHON_SDK_GITHUB_REPO_ID }}
SSH_KEY: ${{ secrets.PYTHON_SDK_SSH_KEY }}
SSH_KEY: ${{ secrets.PYTHON_SDK_SSH_KEY }}
27 changes: 9 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,19 @@ build-client-dotnet:
tag-client-python: test-client-python
make utils-tag-client sdk_language=python

.PHONY: test-client-python
test-client-python: build-client-python
# Need to ignore F401 (unused module), E402 (import not at top of module), E501 (line too long) and W504 (line break after binary operator)
# due to limitations of autopep8 as well as generator.
make run-in-docker sdk_language=python image=python:${PYTHON_DOCKER_TAG} command="/bin/sh -c 'python -m pip install -r test-requirements.txt; python -m unittest test/*'"
make run-in-docker sdk_language=python image=python:${PYTHON_DOCKER_TAG} command="/bin/sh -c 'python -m pip install -r test-requirements.txt; python -m flake8 --ignore F401,E402,E501,W504 openfga_sdk'"
make run-in-docker sdk_language=python image=python:${PYTHON_DOCKER_TAG} command="/bin/sh -c 'python -m pip install -r test-requirements.txt; python -m flake8 --ignore E501 test'"

.PHONY: build-client-python
build-client-python:
make build-client sdk_language=python tmpdir=${TMP_DIR}
sed -i -e "s|\"key\": |key=|g" ${CLIENTS_OUTPUT_DIR}/fga-python-sdk/docs/OpenFgaApi.md
sed -i -e "s|from openfga_sdk.model.tuple_keys import TupleKeys|from openfga_sdk.model.tuple_key import TupleKey\nfrom openfga_sdk.model.tuple_keys import TupleKeys|g" ${CLIENTS_OUTPUT_DIR}/fga-python-sdk/docs/OpenFgaApi.md
rm -rf ${CLIENTS_OUTPUT_DIR}/fga-python-sdk/docs/OpenFgaApi.md-e
# The return value is falsely marked as not found
sed -i -e "s|-> 'relations':|-> 'relations': # noqa: F821|g" ${CLIENTS_OUTPUT_DIR}/fga-python-sdk/openfga_sdk/model/type_definition.py
rm -rf ${CLIENTS_OUTPUT_DIR}/fga-python-sdk/openfga_sdk/model/type_definition.py-e
# Need to apply patch to override create_store documentation and body
make run-in-docker sdk_language=python image=busybox:${BUSYBOX_DOCKER_TAG} command="/bin/sh -c 'patch -p1 /module/docs/OpenFgaApi.md /config/clients/python/patches/OpenFgaApi.md.patch'"
make build-client sdk_language=python tmpdir=${TMP_DIR} library="--library asyncio"
make run-in-docker sdk_language=python image=busybox:${BUSYBOX_DOCKER_TAG} command="/bin/sh -c 'patch -p1 /module/openfga_sdk/api/open_fga_api.py /config/clients/python/patches/open_fga_api.py.patch'"
make run-in-docker sdk_language=python image=busybox:${BUSYBOX_DOCKER_TAG} command="/bin/sh -c 'patch -p1 /module/docs/OpenFgaApi.md /config/clients/python/patches/OpenFgaApi.md.patch'"
make run-in-docker sdk_language=python image=python:${PYTHON_DOCKER_TAG} command="/bin/sh -c 'python -m pip install autopep8; autopep8 --in-place --ignore E402 --recursive openfga_sdk; autopep8 --in-place --recursive test'"

.PHONY: test-client-python
test-client-python: build-client-python
make run-in-docker sdk_language=python image=python:${PYTHON_DOCKER_TAG} command="/bin/sh -c 'python -m pip install -r test-requirements.txt; python -m unittest test/*'"
make run-in-docker sdk_language=python image=python:${PYTHON_DOCKER_TAG} command="/bin/sh -c 'python -m pip install -r test-requirements.txt; python -m flake8 --ignore F401,E402,E501,W504 openfga_sdk'"
# Need to ignore E402 (import order) to avoid circular dependency
make run-in-docker sdk_language=python image=python:${PYTHON_DOCKER_TAG} command="/bin/sh -c 'python -m pip install autopep8; autopep8 --in-place --ignore E402 --recursive openfga_sdk; autopep8 --in-place --recursive test'"
make run-in-docker sdk_language=python image=python:${PYTHON_DOCKER_TAG} command="/bin/sh -c 'python -m pip install -r test-requirements.txt; python -m flake8 --ignore E501 test'"

.PHONY: run-in-docker
run-in-docker:
Expand Down Expand Up @@ -176,6 +166,7 @@ build-client: build-openapi
openapitools/openapi-generator-cli:${OPENAPI_GENERATOR_CLI_DOCKER_TAG} generate \
-i /docs/openapi/openfga.openapiv2.json \
--http-user-agent='openfga-sdk (${sdk_language}) {packageVersion}' \
${library} \
-o /clients/fga-${sdk_language}-sdk \
-c /config/config.json \
-g `cat ./config/clients/${sdk_language}/generator.txt`
Expand Down
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ This is the main generator responsible for generating the OpenFGA SDKs from the

## Table of Contents

- [About OpenFGA](#about)
- [Resources](#resources)
- [Currently Supported SDKs](#currently-supported-sdks)
- [Getting Started](#getting-started)
- [Requirements](#requirements)
- [Usage](#usage)
- [Adding a New SDK](#adding-a-new-sdk)
- [Uploading the SDK](#uploading-the-sdk)
- [Publishing the SDK](#publishingopen-sourcing-the-sdk)
- [Contributing](#contributing)
- [License](#license)
- [OpenFGA Client SDK Generator](#openfga-client-sdk-generator)
- [Table of Contents](#table-of-contents)
- [About](#about)
- [Resources](#resources)
- [Currently Supported SDKs](#currently-supported-sdks)
- [Getting Started](#getting-started)
- [Requirements](#requirements)
- [Usage](#usage)
- [Adding a new SDK](#adding-a-new-sdk)
- [Using the setup script](#using-the-setup-script)
- [Manually](#manually)
- [Uploading the SDK](#uploading-the-sdk)
- [Publishing/Open Sourcing the SDK](#publishingopen-sourcing-the-sdk)
- [GitHub Action Secrets](#github-action-secrets)
- [Contributing](#contributing)
- [Author](#author)
- [License](#license)

## About

Expand All @@ -42,6 +48,7 @@ OpenFGA is designed to make it easy for application builders to model their perm
| Javascript | [openfga/js-sdk](https://github.com/openfga/js-sdk) | [@openfga/sdk](https://www.npmjs.com/package/@auth0/fga) on npm |
| Go | [openfga/go-sdk](https://github.com/openfga/go-sdk) | - |
| .NET | [openfga/dotnet-sdk](https://github.com/openfga/dotnet-sdk) | [OpenFga.Sdk](https://www.nuget.org/packages/OpenFga.Sdk) on nuget |
| PYTHON | [openfga/python](https://github.com/openfga/python-sdk) | [openfga-sdk](https://pypi.org/project/openfga-sdk) on PyPI |

## Getting Started

Expand All @@ -67,6 +74,7 @@ git clone git@github.com:openfga/sdk-generator.git
git clone git@github.com:openfga/go-sdk.git clients/fga-go-sdk
git clone git@github.com:openfga/js-sdk.git clients/fga-js-sdk
git clone git@github.com:openfga/dotnet-sdk.git clients/fga-dotnet-sdk
git clone git@github.com:openfga/python-sdk.git clients/fga-python-sdk
```

3. Build and test the client sdks
Expand Down
1 change: 0 additions & 1 deletion config/clients/python/.openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ test/*
!test/__init__.py
!test/test_open_fga_api.py
!test/test_credentials.py
!test/test_model_utils.py
.gitlab-ci.yml
.travis.yml
tox.ini
10 changes: 2 additions & 8 deletions config/clients/python/config.overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"packageVersion": "0.0.1",
"packageDescription": "Python SDK for OpenFGA",
"packageDetailedDescription": "This is an autogenerated python SDK for OpenFGA. It provides a wrapper around the [OpenFGA API definition](https://openfga.dev/api).",
"infoName": "OpenFGA",
"infoEmail": "community@openfga.dev",
"files": {
".github/workflows/main.yaml": {
},
Expand All @@ -16,14 +18,6 @@
"credentials_test.mustache": {
"destinationFilename": "test/test_credentials.py",
"templateType": "SupportingFiles"
},
"exceptions_specific.mustache": {
"destinationFilename": "openfga_sdk/exceptions_specific.py",
"templateType": "SupportingFiles"
},
"model_utils_test.mustache": {
"destinationFilename": "test/test_model_utils.py",
"templateType": "SupportingFiles"
}
}
}
2 changes: 1 addition & 1 deletion config/clients/python/generator.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python
python-legacy
34 changes: 15 additions & 19 deletions config/clients/python/patches/OpenFgaApi.md.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- OpenFgaApi.md 2022-08-24 15:36:22.000000000 -0400
+++ OpenFgaApi.md.changes 2022-08-24 16:27:28.000000000 -0400
@@ -126,7 +126,7 @@
--- clients/fga-python-sdk/docs/OpenFgaApi.md 2022-09-13 15:41:02.000000000 -0400
+++ OpenFgaApi.md 2022-09-13 15:39:58.000000000 -0400
@@ -103,7 +103,7 @@
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **create_store**
Expand All @@ -9,40 +9,36 @@

Create a store

@@ -148,12 +148,10 @@
# To configure the configuration
# host is mandatory
# api_scheme is optional and default to https
-# store_id is mandatory
# See configuration.py for a list of all supported configuration parameters.
@@ -125,7 +125,6 @@
configuration = openfga_sdk.Configuration(
scheme = "https",
api_host = "api.fga.example",
- store_id = 'YOUR_STORE_ID',
)


@@ -162,7 +160,6 @@
@@ -134,7 +133,6 @@
configuration = openfga_sdk.Configuration(
scheme = "https",
api_host = "api.fga.example",
- store_id = 'YOUR_STORE_ID',
credentials = credentials
)

@@ -174,7 +171,10 @@
# example passing only required values which don't have defaults set
@@ -142,10 +140,11 @@
async with openfga_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openfga_sdk.OpenFgaApi(api_client)
+ body = openfga_sdk.CreateStoreRequest() # CreateStoreRequest |

try:
# Create a store
- api_response = api_instance.create_store()
+ body = CreateStoreRequest(
+ name = "my-store-name",
+ )
+ api_response = api_instance.create_store(body)
- api_response = await api_instance.api_instance.create_store()
+ api_response = await api_instance.api_instance.create_store(body)
pprint(api_response)
except openfga_sdk.ApiException as e:
except ApiException as e:
print("Exception when calling OpenFgaApi->create_store: %s\n" % e)
@@ -185,6 +185,7 @@
@@ -157,6 +156,7 @@

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
Expand Down
93 changes: 65 additions & 28 deletions config/clients/python/patches/open_fga_api.py.patch
Original file line number Diff line number Diff line change
@@ -1,31 +1,68 @@
--- clients/fga-python-sdk/openfga_sdk/api/open_fga_api.py 2022-08-29 14:54:20.000000000 -0400
+++ open_fga_api.py 2022-08-29 14:53:38.000000000 -0400
@@ -975,6 +975,7 @@

def create_store(
self,
+ body,
**kwargs
):
--- clients/fga-python-sdk/openfga_sdk/api/open_fga_api.py 2022-09-13 14:15:46.000000000 -0400
+++ open_fga_api.py 2022-09-13 14:14:01.000000000 -0400
@@ -193,13 +193,15 @@
collection_formats=collection_formats,
_request_auth=local_var_params.get('_request_auth')))

- async def create_store(self, **kwargs): # noqa: E501
+ async def create_store(self, body, **kwargs): # noqa: E501
"""Create a store # noqa: E501
@@ -986,6 +987,8 @@
>>> thread = api.create_store(async_req=True)
>>> result = thread.get()

+ Args:
+ body (CreateStoreRequest):

Keyword Args:
_return_http_data_only (bool): response data without head status
@@ -1049,7 +1052,10 @@
'_content_type')
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['_request_auths'] = kwargs.get('_request_auths', None)
- kwargs['body'] = self.create_store_endpoint._get_store_id()
+
+ kwargs['body'] = \
+ body

Create a unique OpenFGA store which will be used to store authorization models and relationship tuples. # noqa: E501

- >>> thread = await api.create_store()
+ >>> thread = await api.create_store(body)

+ :param body: (required)
+ :type body: CreateStoreRequest
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -216,15 +218,17 @@
:rtype: CreateStoreResponse
"""
kwargs['_return_http_data_only'] = True
- return await(self.create_store_with_http_info(**kwargs)) # noqa: E501
+ return await(self.create_store_with_http_info(body, **kwargs)) # noqa: E501

- async def create_store_with_http_info(self, **kwargs): # noqa: E501
+ async def create_store_with_http_info(self, body, **kwargs): # noqa: E501
"""Create a store # noqa: E501

Create a unique OpenFGA store which will be used to store authorization models and relationship tuples. # noqa: E501

- >>> thread = api.create_store_with_http_info()
+ >>> thread = api.create_store_with_http_info(body)

+ :param body: (required)
+ :type body: CreateStoreRequest
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
@@ -253,6 +257,8 @@

all_params = [

+ 'body'
+
return self.create_store_endpoint.call_with_http_info(**kwargs)
]
all_params.extend(
[
@@ -312,7 +318,7 @@
}

return await(self.api_client.call_api(
- '/stores'.replace('{store_id}', store_id), 'POST',
+ '/stores', 'POST',
path_params,
query_params,
header_params,
@@ -998,7 +1004,7 @@
}

def delete_store(
return await(self.api_client.call_api(
- '/stores'.replace('{store_id}', store_id), 'GET',
+ '/stores', 'GET',
path_params,
query_params,
header_params,
6 changes: 3 additions & 3 deletions config/clients/python/template-source.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"repo": "https://github.com/OpenAPITools/openapi-generator",
"branch": "master",
"commit": "8cd0d38446dae83f28cc98ff79e044349ba2e2b0",
"url": "https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/python",
"docs": "https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/python.md"
"commit": "fea42b547ed61dcfdfc479cab6f68a601ec5adde",
"url": "https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/python-legacy",
"docs": "https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/python-legacy.md"
}
Loading