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
64 changes: 64 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
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://github.com/openfga/python-sdk/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 [OpenFGA Code of Conduct](https://github.com/openfga/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

> v0.2.0

### 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.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Feature request
about: Suggest new functionality for this project.
title: ''
labels: 'feature'
assignees: ''

---

**Please do not report security vulnerabilities here**. See the [Responsible Disclosure Program](https://github.com/openfga/python-sdk/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 [OpenFGA Code of Conduct](https://github.com/openfga/rfcs/blob/main/CODE-OF-CONDUCT.md).

### Describe the problem you'd like to have solved

> A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

### Describe the ideal solution

> A clear and concise description of what you want to happen.

## Alternatives and current workarounds

> A clear and concise description of any alternatives you've considered or any workarounds that are currently in place.

### Additional context

> Add any other context or screenshots about the feature request here.
1 change: 1 addition & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build, Test and Publish

on:
merge_group:
push:
pull_request:
workflow_dispatch:
Expand Down
4 changes: 2 additions & 2 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.fossa.yml
.github/CODEOWNERS
.github/ISSUE_TEMPLATES/bug_report.md
.github/ISSUE_TEMPLATES/feature_request.md
.github/ISSUE_TEMPLATE/bug_report.md
.github/ISSUE_TEMPLATE/feature_request.md
.github/workflows/main.yaml
.github/workflows/semgrep.yaml
.gitignore
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ Reads the relationship tuples stored in the database. It does not evaluate nor e

```python
# Find if a relationship tuple stating that a certain user is a viewer of certain document
body = ReadRequest(
body = TupleKey(
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="viewer",
object="document:roadmap",
Expand All @@ -398,7 +398,7 @@ response = await fga_client.read(body)

```python
# Find all relationship tuples where a certain user has a relationship as any relation to a certain document
body = ReadRequest(
body = TupleKey(
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
object="document:roadmap",
)
Expand All @@ -410,7 +410,7 @@ response = await fga_client.read(body)

```python
# Find all relationship tuples where a certain user is a viewer of any document
body = ReadRequest(
body = TupleKey(
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="viewer",
object="document:",
Expand All @@ -422,7 +422,7 @@ response = await fga_client.read(body)

```python
# Find all relationship tuples where any user has a relationship as any relation with a particular document
body = ReadRequest(
body = TupleKey(
object="document:roadmap",
)

Expand All @@ -432,9 +432,9 @@ response = await fga_client.read(body)

```python
# Read all stored relationship tuples
body = ReadRequest()
body = TupleKey()

response = await fga_client.read(body)
response = await api_instance.read(body)
# response = ReadResponse({"tuples": [Tuple({"key": TupleKey({"user":"...","relation":"...","object":"..."}), "timestamp": datetime.fromisoformat("...") })]})
```

Expand Down
6 changes: 4 additions & 2 deletions openfga_sdk/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
from openfga_sdk.exceptions import ApiValueError, ApiException, FgaValidationException, RateLimitExceededError


DEFAULT_USER_AGENT = 'openfga-sdk python/0.2.0'


def random_time(loop_count, min_wait_in_ms):
"""
Helper function to return the time (in s) to wait before retry
Expand Down Expand Up @@ -91,8 +94,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'openfga-sdk {sdkId}/{packageVersion}'.replace(
'{sdkId}', 'python').replace('{packageVersion}', '0.2.0')
self.user_agent = DEFAULT_USER_AGENT
self.client_side_validation = configuration.client_side_validation

async def __aenter__(self):
Expand Down