Skip to content

Commit

Permalink
release(python-sdk): v0.3.2 (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh authored Dec 15, 2023
2 parents a86538c + e027b74 commit 987ca88
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 29 deletions.
6 changes: 6 additions & 0 deletions config/clients/python/CHANGELOG.md.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v0.3.2

### [0.3.2](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/compare/v0.3.1...v0.3.2) (2023-12-15)
- feat: allow passing ssl certs to client configuration
- feat: setup openfga_sdk.help for bug info

## v0.3.1

### [0.3.1](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/compare/v0.3.0...v0.3.1) (2023-12-01)
Expand Down
5 changes: 4 additions & 1 deletion config/clients/python/config.overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"sdkId": "python",
"gitRepoId": "python-sdk",
"packageName": "openfga_sdk",
"packageVersion": "0.3.1",
"packageVersion": "0.3.2",
"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).",
"fossaComplianceNoticeId": "2f8a8629-b46c-435e-b8cd-1174a674fb4b",
Expand Down Expand Up @@ -146,6 +146,9 @@
"oauth2_test_sync.mustache": {
"destinationFilename": "test/test_oauth2_sync.py",
"templateType": "SupportingFiles"
},
"help.py": {
"destinationFilename": "openfga_sdk/help.py"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
name: Report an issue
about: Create a bug report about an existing issue.
title: ''
labels: 'bug'
assignees: ''

---

**Please do not report security vulnerabilities here**. See the [Responsible Disclosure Program](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/blob/main/.github/SECURITY.md).

**Thank you in advance for helping us to improve this library!** Please read through the template below and answer all relevant questions. Your additional work here is greatly appreciated and will help us respond as quickly as possible.

By submitting an issue to this repository, you agree to the terms within the [{{appName}} Code of Conduct](https://{{gitHost}}/{{gitUserId}}/rfcs/blob/main/CODE-OF-CONDUCT.md).

### Description

> Provide a clear and concise description of the issue, including what you expected to happen.

### Version of SDK

```
$ python -m openfga_sdk.help
<paste here>
```

This command is only available on openfga_sdk `v0.3.2` and greater. Otherwise, please provide some basic information about your system.

### Version of OpenFGA (if known)

> v1.1.0

### OpenFGA Flags/Custom Configuration Applicable

> environment:
> - OPENFGA_DATASTORE_ENGINE=postgres
> - OPENFGA_DATASTORE_URI=postgres://postgres:password@postgres:5432/postgres?sslmode=disable
> - OPENFGA_TRACE_ENABLED=true
> - OPENFGA_TRACE_SAMPLE_RATIO=1
> - OPENFGA_TRACE_OTLP_ENDPOINT=otel-collector:4317
> - OPENFGA_METRICS_ENABLE_RPC_HISTOGRAMS=true

### Reproduction

> Detail the steps taken to reproduce this error, what was expected, and whether this issue can be reproduced consistently or if it is intermittent.
>
> 1. Initialize OpenFgaClient with openfga_sdk.ClientConfiguration parameter api_host=127.0.0.1, credentials method client_credentials
> 2. Invoke method read_authorization_models
> 3. See exception thrown

### Sample Code the Produces Issues

>
> ```
> <code snippet>
> ```

### Backtrace (if applicable)

> ```
> <backtrace>
> ```


### Expected behavior
> A clear and concise description of what you expected to happen.

### Additional context
> Add any other context about the problem here.
22 changes: 15 additions & 7 deletions config/clients/python/template/.github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
Expand All @@ -40,9 +43,12 @@ jobs:
needs: [test]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: "3.10"
cache: 'pip'
Expand Down Expand Up @@ -71,9 +77,11 @@ jobs:
needs: [publish]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- uses: Roang-zero1/github-create-release-action@5cf058ddffa6fa04e5cda07c98570c757dc4a0e1
- uses: Roang-zero1/github-create-release-action@57eb9bdce7a964e48788b9e78b5ac766cb684803 # v3.0.1
with:
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+
env:
Expand Down
34 changes: 17 additions & 17 deletions config/clients/python/template/README_initializing.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ from {{packageName}}.credentials import Credentials, CredentialConfiguration

async def main():
configuration = {{packageName}}.ClientConfiguration(
api_scheme = FGA__API_SCHEME, # optional, defaults to "https"
api_host = FGA__API_HOST, # required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}})
store_id = FGA__STORE_ID, # optional, not needed when calling `CreateStore` or `ListStores`
authorization_model_id = FGA__AUTHORIZATION_MODEL_ID, # Optional, can be overridden per request
api_scheme = FGA_API_SCHEME, # optional, defaults to "https"
api_host = FGA_API_HOST, # required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}})
store_id = FGA_STORE_ID, # optional, not needed when calling `CreateStore` or `ListStores`
authorization_model_id = FGA_AUTHORIZATION_MODEL_ID, # Optional, can be overridden per request
credentials = Credentials(
method='api_token',
configuration = CredentialConfiguration(
api_token = FGA__API_TOKEN,
api_token = FGA_API_TOKEN,
)
)
)
Expand All @@ -61,17 +61,17 @@ from {{packageName}}.credentials import Credentials, CredentialConfiguration

async def main():
configuration = {{packageName}}.ClientConfiguration(
api_scheme = FGA__API_SCHEME, # optional, defaults to "https"
api_host = FGA__API_HOST, # required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}})
store_id = FGA__STORE_ID, # optional, not needed when calling `CreateStore` or `ListStores`
authorization_model_id = FGA__AUTHORIZATION_MODEL_ID, # Optional, can be overridden per request
api_scheme = FGA_API_SCHEME, # optional, defaults to "https"
api_host = FGA_API_HOST, # required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}})
store_id = FGA_STORE_ID, # optional, not needed when calling `CreateStore` or `ListStores`
authorization_model_id = FGA_AUTHORIZATION_MODEL_ID, # Optional, can be overridden per request
credentials = Credentials(
method = 'client_credentials',
configuration = CredentialConfiguration(
api_issuer = FGA__API_TOKEN_ISSUER,
api_audience = FGA__API_AUDIENCE,
client_id = FGA__CLIENT_ID,
client_secret = FGA__CLIENT_SECRET,
api_issuer = FGA_API_TOKEN_ISSUER,
api_audience = FGA_API_AUDIENCE,
client_id = FGA_CLIENT_ID,
client_secret = FGA_CLIENT_SECRET,
)
)
)
Expand All @@ -95,10 +95,10 @@ from {{packageName}}.sync import OpenFgaClient

def main():
configuration = {{packageName}}.ClientConfiguration(
api_scheme = FGA__API_SCHEME, # optional, defaults to "https"
api_host = FGA__API_HOST, # required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}})
store_id = FGA__STORE_ID, # optional, not needed when calling `CreateStore` or `ListStores`
authorization_model_id = FGA__AUTHORIZATION_MODEL_ID, # optional, can be overridden per request
api_scheme = FGA_API_SCHEME, # optional, defaults to "https"
api_host = FGA_API_HOST, # required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}})
store_id = FGA_STORE_ID, # optional, not needed when calling `CreateStore` or `ListStores`
authorization_model_id = FGA_AUTHORIZATION_MODEL_ID, # optional, can be overridden per request
)
# Enter a context with an instance of the OpenFgaClient
with OpenFgaClient(configuration) as fga_client:
Expand Down
6 changes: 4 additions & 2 deletions config/clients/python/template/client/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ class ClientConfiguration(Configuration):
store_id=None,
credentials=None,
retry_params=None,
authorization_model_id=None, ):
super().__init__(api_scheme, api_host, store_id, credentials, retry_params)
authorization_model_id=None,
ssl_ca_cert=None,
):
super().__init__(api_scheme, api_host, store_id, credentials, retry_params, ssl_ca_cert=ssl_ca_cert)
self._authorization_model_id = authorization_model_id

def is_valid(self):
Expand Down
93 changes: 93 additions & 0 deletions config/clients/python/template/help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import json
import platform
import sys
from typing import Dict
from collections import OrderedDict

from . import __version__ as openfga_sdk_version

try:
import urllib3

urllib3_version = urllib3.__version__
except ModuleNotFoundError:
urllib3_version = ""

try:
import six

six_version = six.__version__
except ModuleNotFoundError:
six_version = ""

try:
import dateutil

dateutil_version = dateutil.__version__
except ModuleNotFoundError:
dateutil_version = ""

try:
import aiohttp

aiohttp_version = aiohttp.__version__
except ModuleNotFoundError:
aiohttp_version = ""


def info() -> Dict[str, Dict[str, str]]:
"""
Generate information for a bug report.
Based on the requests package help utility module.
"""
try:
platform_info = {
"system": platform.system(),
"release": platform.release(),
}
except OSError:
platform_info = {"system": "Unknown", "release": "Unknown"}

implementation = platform.python_implementation()

if implementation == "CPython":
implementation_version = platform.python_version()
elif implementation == "PyPy":
pypy_version_info = sys.pypy_version_info # type: ignore[attr-defined]
implementation_version = (
f"{pypy_version_info.major}."
f"{pypy_version_info.minor}."
f"{pypy_version_info.micro}"
)
if pypy_version_info.releaselevel != "final":
implementation_version = "".join(
[implementation_version, pypy_version_info.releaselevel]
)
else:
implementation_version = "Unknown"

return OrderedDict(
{
"platform": platform_info,
"implementation": {
"name": implementation,
"version": implementation_version,
},
"openfga_sdk": {"version": openfga_sdk_version},
"dependencies": {
"urllib3": {"version": urllib3_version},
"six": {"version": six_version},
"python-dateutil": {"version": dateutil_version},
"aiohttp": {"version": aiohttp_version},
},
}
)


def main() -> None:
"""Pretty-print the bug information as JSON."""
print(json.dumps(info(), indent=2))


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion config/clients/python/template/requirements.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
six >= 1.16
setuptools >= 69.0.2
setuptools >= 67.7.2
python-dateutil >= 2.8.2
urllib3 >= 1.25.11
aiohttp >= 3.9.1
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ By submitting an issue to this repository, you agree to the terms within the [{{
> A clear and concise description of what you expected to happen.

### Additional context
> Add any other context about the problem here.
> Add any other context about the problem here.

0 comments on commit 987ca88

Please sign in to comment.