Skip to content

Commit 831e959

Browse files
committed
chore: resync generator on latest API commit
changes: - No changes to the client interface - API changes include support for write conflict options API commit: 0ac19aac54f21f3c78970126b84b4c69c6e3b9a2
1 parent ee6c726 commit 831e959

11 files changed

Lines changed: 142 additions & 43 deletions

File tree

.openapi-generator/FILES

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ openfga_sdk/telemetry/metrics.py
253253
openfga_sdk/telemetry/telemetry.py
254254
openfga_sdk/validation.py
255255
pyproject.toml
256-
README.md
257-
test/__init__.py
258256
test/_/configuration_test.py
259257
test/_/credentials_test.py
260258
test/_/oauth2_test.py

docs/OpenFgaApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ No authorization required
12911291
12921292
Add or delete tuples from the store
12931293

1294-
The Write API will transactionally update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. The API will not allow you to write tuples such as `document:2021-budget#viewer@document:2021-budget#viewer`, because they are implicit. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ```
1294+
The Write API will transactionally update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent by default: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. To allow writes when an identical tuple already exists in the database, set `\"on_duplicate\": \"ignore\"` on the `writes` object. To allow deletes when a tuple was already removed from the database, set `\"on_missing\": \"ignore\"` on the `deletes` object. If a Write request contains both idempotent (ignore) and non-idempotent (error) operations, the most restrictive action (error) will take precedence. If a condition fails for a sub-request with an error flag, the entire transaction will be rolled back. This gives developers explicit control over the atomicity of the requests. The API will not allow you to write tuples such as `document:2021-budget#viewer@document:2021-budget#viewer`, because they are implicit. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ], \"on_duplicate\": \"ignore\" }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ], \"on_missing\": \"ignore\" } } ```
12951295

12961296
### Example
12971297

docs/WriteRequestDeletes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**tuple_keys** | [**list[TupleKeyWithoutCondition]**](TupleKeyWithoutCondition.md) | |
8+
**on_missing** | **str** | On 'error', the API returns an error when deleting a tuple that does not exist. On 'ignore', deletes of non-existent tuples are treated as no-ops. | [optional] [default to 'error']
89

910
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1011

docs/WriteRequestWrites.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**tuple_keys** | [**list[TupleKey]**](TupleKey.md) | |
8+
**on_duplicate** | **str** | On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition). | [optional] [default to 'error']
89

910
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1011

openfga_sdk/api/open_fga_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,7 +2667,7 @@ async def streamed_list_objects_with_http_info(self, body, **kwargs):
26672667
async def write(self, body, **kwargs):
26682668
"""Add or delete tuples from the store
26692669
2670-
The Write API will transactionally update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. The API will not allow you to write tuples such as `document:2021-budget#viewer@document:2021-budget#viewer`, because they are implicit. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ```
2670+
The Write API will transactionally update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent by default: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. To allow writes when an identical tuple already exists in the database, set `\"on_duplicate\": \"ignore\"` on the `writes` object. To allow deletes when a tuple was already removed from the database, set `\"on_missing\": \"ignore\"` on the `deletes` object. If a Write request contains both idempotent (ignore) and non-idempotent (error) operations, the most restrictive action (error) will take precedence. If a condition fails for a sub-request with an error flag, the entire transaction will be rolled back. This gives developers explicit control over the atomicity of the requests. The API will not allow you to write tuples such as `document:2021-budget#viewer@document:2021-budget#viewer`, because they are implicit. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ], \"on_duplicate\": \"ignore\" }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ], \"on_missing\": \"ignore\" } } ```
26712671
26722672
>>> thread = await api.write(body)
26732673
@@ -2694,7 +2694,7 @@ async def write(self, body, **kwargs):
26942694
async def write_with_http_info(self, body, **kwargs):
26952695
"""Add or delete tuples from the store
26962696
2697-
The Write API will transactionally update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. The API will not allow you to write tuples such as `document:2021-budget#viewer@document:2021-budget#viewer`, because they are implicit. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ```
2697+
The Write API will transactionally update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent by default: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. To allow writes when an identical tuple already exists in the database, set `\"on_duplicate\": \"ignore\"` on the `writes` object. To allow deletes when a tuple was already removed from the database, set `\"on_missing\": \"ignore\"` on the `deletes` object. If a Write request contains both idempotent (ignore) and non-idempotent (error) operations, the most restrictive action (error) will take precedence. If a condition fails for a sub-request with an error flag, the entire transaction will be rolled back. This gives developers explicit control over the atomicity of the requests. The API will not allow you to write tuples such as `document:2021-budget#viewer@document:2021-budget#viewer`, because they are implicit. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ], \"on_duplicate\": \"ignore\" }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ], \"on_missing\": \"ignore\" } } ```
26982698
26992699
>>> thread = api.write_with_http_info(body)
27002700

openfga_sdk/models/write_request_deletes.py

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,31 @@ class WriteRequestDeletes:
3131
attribute_map (dict): The key is attribute name
3232
and the value is json key in definition.
3333
"""
34-
openapi_types: dict[str, str] = {"tuple_keys": "list[TupleKeyWithoutCondition]"}
35-
36-
attribute_map: dict[str, str] = {"tuple_keys": "tuple_keys"}
37-
38-
def __init__(self, tuple_keys=None, local_vars_configuration=None):
34+
openapi_types: dict[str, str] = {
35+
"tuple_keys": "list[TupleKeyWithoutCondition]",
36+
"on_missing": "str",
37+
}
38+
39+
attribute_map: dict[str, str] = {
40+
"tuple_keys": "tuple_keys",
41+
"on_missing": "on_missing",
42+
}
43+
44+
def __init__(
45+
self, tuple_keys=None, on_missing="error", local_vars_configuration=None
46+
):
3947
"""WriteRequestDeletes - a model defined in OpenAPI"""
4048
if local_vars_configuration is None:
4149
local_vars_configuration = Configuration.get_default_copy()
4250
self.local_vars_configuration = local_vars_configuration
4351

4452
self._tuple_keys = None
53+
self._on_missing = None
4554
self.discriminator = None
4655

4756
self.tuple_keys = tuple_keys
57+
if on_missing is not None:
58+
self.on_missing = on_missing
4859

4960
@property
5061
def tuple_keys(self):
@@ -69,6 +80,39 @@ def tuple_keys(self, tuple_keys):
6980

7081
self._tuple_keys = tuple_keys
7182

83+
@property
84+
def on_missing(self):
85+
"""Gets the on_missing of this WriteRequestDeletes.
86+
87+
On 'error', the API returns an error when deleting a tuple that does not exist. On 'ignore', deletes of non-existent tuples are treated as no-ops.
88+
89+
:return: The on_missing of this WriteRequestDeletes.
90+
:rtype: str
91+
"""
92+
return self._on_missing
93+
94+
@on_missing.setter
95+
def on_missing(self, on_missing):
96+
"""Sets the on_missing of this WriteRequestDeletes.
97+
98+
On 'error', the API returns an error when deleting a tuple that does not exist. On 'ignore', deletes of non-existent tuples are treated as no-ops.
99+
100+
:param on_missing: The on_missing of this WriteRequestDeletes.
101+
:type on_missing: str
102+
"""
103+
allowed_values = ["error", "ignore"]
104+
if (
105+
self.local_vars_configuration.client_side_validation
106+
and on_missing not in allowed_values
107+
):
108+
raise ValueError(
109+
"Invalid value for `on_missing` ({0}), must be one of {1}".format(
110+
on_missing, allowed_values
111+
)
112+
)
113+
114+
self._on_missing = on_missing
115+
72116
def to_dict(self, serialize=False):
73117
"""Returns the model properties as a dict"""
74118
result = {}

openfga_sdk/models/write_request_writes.py

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,31 @@ class WriteRequestWrites:
3131
attribute_map (dict): The key is attribute name
3232
and the value is json key in definition.
3333
"""
34-
openapi_types: dict[str, str] = {"tuple_keys": "list[TupleKey]"}
35-
36-
attribute_map: dict[str, str] = {"tuple_keys": "tuple_keys"}
37-
38-
def __init__(self, tuple_keys=None, local_vars_configuration=None):
34+
openapi_types: dict[str, str] = {
35+
"tuple_keys": "list[TupleKey]",
36+
"on_duplicate": "str",
37+
}
38+
39+
attribute_map: dict[str, str] = {
40+
"tuple_keys": "tuple_keys",
41+
"on_duplicate": "on_duplicate",
42+
}
43+
44+
def __init__(
45+
self, tuple_keys=None, on_duplicate="error", local_vars_configuration=None
46+
):
3947
"""WriteRequestWrites - a model defined in OpenAPI"""
4048
if local_vars_configuration is None:
4149
local_vars_configuration = Configuration.get_default_copy()
4250
self.local_vars_configuration = local_vars_configuration
4351

4452
self._tuple_keys = None
53+
self._on_duplicate = None
4554
self.discriminator = None
4655

4756
self.tuple_keys = tuple_keys
57+
if on_duplicate is not None:
58+
self.on_duplicate = on_duplicate
4859

4960
@property
5061
def tuple_keys(self):
@@ -69,6 +80,39 @@ def tuple_keys(self, tuple_keys):
6980

7081
self._tuple_keys = tuple_keys
7182

83+
@property
84+
def on_duplicate(self):
85+
"""Gets the on_duplicate of this WriteRequestWrites.
86+
87+
On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition).
88+
89+
:return: The on_duplicate of this WriteRequestWrites.
90+
:rtype: str
91+
"""
92+
return self._on_duplicate
93+
94+
@on_duplicate.setter
95+
def on_duplicate(self, on_duplicate):
96+
"""Sets the on_duplicate of this WriteRequestWrites.
97+
98+
On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition).
99+
100+
:param on_duplicate: The on_duplicate of this WriteRequestWrites.
101+
:type on_duplicate: str
102+
"""
103+
allowed_values = ["error", "ignore"]
104+
if (
105+
self.local_vars_configuration.client_side_validation
106+
and on_duplicate not in allowed_values
107+
):
108+
raise ValueError(
109+
"Invalid value for `on_duplicate` ({0}), must be one of {1}".format(
110+
on_duplicate, allowed_values
111+
)
112+
)
113+
114+
self._on_duplicate = on_duplicate
115+
72116
def to_dict(self, serialize=False):
73117
"""Returns the model properties as a dict"""
74118
result = {}

openfga_sdk/sync/oauth2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _obtain_token(self, client):
7070
"""
7171
configuration = self._credentials.configuration
7272

73-
token_url = f"https://{configuration.api_issuer}/oauth/token"
73+
token_url = self._credentials._parse_issuer(configuration.api_issuer)
7474

7575
post_params = {
7676
"client_id": configuration.client_id,

0 commit comments

Comments
 (0)