Skip to content

Commit 4eb5a20

Browse files
authored
feat: regenerate project, schema version is now required in authz models (#12)
1 parent 0434068 commit 4eb5a20

11 files changed

Lines changed: 40 additions & 38 deletions

File tree

.fossa.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ server: https://app.fossa.com
55
project:
66
id: github.com/openfga/python-sdk
77
name: github.com/openfga/python-sdk
8-
link: fga.dev
8+
link: openfga.dev
99
url: github.com/openfga/python-sdk

.openapi-generator/FILES

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
.github/CODEOWNERS
33
.github/ISSUE_TEMPLATES/bug_report.md
44
.github/ISSUE_TEMPLATES/feature_request.md
5-
.github/PULL_REQUEST_TEMPLATE.md
6-
.github/SECURITY.md
75
.github/workflows/main.yaml
86
.github/workflows/semgrep.yaml
97
.gitignore

.openapi-generator/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.3.0
1+
6.4.0

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ async def write_authorization_model():
324324
# Create an instance of the API class
325325
api_client = openfga_sdk.ApiClient(configuration)
326326
api_instance = open_fga_api.OpenFgaApi(api_client)
327-
type_definitions = WriteAuthorizationModelRequest(
327+
body = WriteAuthorizationModelRequest(
328+
schema_version = "1.1",
328329
type_definitions=[
329330
TypeDefinition(
330331
type="user",
@@ -351,8 +352,8 @@ async def write_authorization_model():
351352
],
352353
)
353354

354-
response = await api_instance.write_authorization_model(type_definitions)
355-
# response.authorization_model_id = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"
355+
response = await api_instance.write_authorization_model(body)
356+
# response.authorization_model_id = "01GXSA8YR785C4FYS3C0RTG7B1"
356357
await api_client.close()
357358
```
358359

@@ -373,10 +374,10 @@ async def read_authorization_id():
373374
# Create an instance of the API class
374375
api_client = openfga_sdk.ApiClient(configuration)
375376
api_instance = open_fga_api.OpenFgaApi(api_client)
376-
id = "1uHxCSuTP0VKPYSnkq1pbb1jeZw" # Assuming `1uHxCSuTP0VKPYSnkq1pbb1jeZw` is an id of an existing model
377+
id = "01GXSA8YR785C4FYS3C0RTG7B1" # Assuming `01GXSA8YR785C4FYS3C0RTG7B1` is an id of an existing model
377378

378379
response = await api_instance.read_authorization_model(id)
379-
# response.authorization_model = AuthorizationModel(id='1uHxCSuTP0VKPYSnkq1pbb1jeZw', type_definitions=type_definitions[...])
380+
# response.authorization_model = AuthorizationModel(id='01GXSA8YR785C4FYS3C0RTG7B1', schema_version = '1.1', type_definitions=type_definitions[...])
380381
await api_client.close()
381382
```
382383

@@ -398,7 +399,7 @@ async def read_authorization_models():
398399
api_instance = open_fga_api.OpenFgaApi(api_client)
399400

400401
response = await api_instance.read_authorization_models()
401-
# response.authorization_models = [AuthorizationModel(id='1uHxCSuTP0VKPYSnkq1pbb1jeZw', type_definitions=type_definitions[...], AuthorizationModel(id='GtQpMohWezFmIbyXxVEocOCxxgq', type_definitions=type_definitions[...])]
402+
# response.authorization_models = [AuthorizationModel(id='01GXSA8YR785C4FYS3C0RTG7B1', schema_version = '1.1', type_definitions=type_definitions[...], AuthorizationModel(id='01GXSBM5PVYHCJNRNKXMB4QZTW', schema_version = '1.1', type_definitions=type_definitions[...])]
402403
await api_client.close()
403404
```
404405

@@ -425,7 +426,7 @@ async def check():
425426
relation="viewer",
426427
object="document:roadmap",
427428
),
428-
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
429+
authorization_model_id="01GXSA8YR785C4FYS3C0RTG7B1",
429430
)
430431

431432
response = await api_instance.check(body)
@@ -460,7 +461,7 @@ async def write():
460461
),
461462
],
462463
),
463-
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
464+
authorization_model_id="01GXSA8YR785C4FYS3C0RTG7B1",
464465
)
465466

466467
response = await api_instance.write(body)
@@ -493,7 +494,7 @@ async def delete():
493494
),
494495
],
495496
),
496-
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
497+
authorization_model_id="01GXSA8YR785C4FYS3C0RTG7B1",
497498
)
498499

499500
response = await api_instance.write(body)
@@ -521,7 +522,7 @@ async def expand():
521522
relation="viewer",
522523
object="document:roadmap",
523524
),
524-
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
525+
authorization_model_id="01GXSA8YR785C4FYS3C0RTG7B1",
525526
)
526527

527528
response = await api_instance.expand(body)
@@ -630,7 +631,7 @@ async def list_objects():
630631
api_client = openfga_sdk.ApiClient(configuration)
631632
api_instance = open_fga_api.OpenFgaApi(api_client)
632633
body = ListObjectsRequest(
633-
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
634+
authorization_model_id="01GXSA8YR785C4FYS3C0RTG7B1",
634635
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
635636
relation="viewer",
636637
type="document",
@@ -660,7 +661,7 @@ Class | Method | HTTP request | Description
660661
*OpenFgaApi* | [**delete_store**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#delete_store) | **DELETE** /stores/{store_id} | Delete a store
661662
*OpenFgaApi* | [**expand**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#expand) | **POST** /stores/{store_id}/expand | Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship
662663
*OpenFgaApi* | [**get_store**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#get_store) | **GET** /stores/{store_id} | Get a store
663-
*OpenFgaApi* | [**list_objects**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#list_objects) | **POST** /stores/{store_id}/list-objects | [EXPERIMENTAL] Get all objects of the given type that the user has a relation with
664+
*OpenFgaApi* | [**list_objects**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#list_objects) | **POST** /stores/{store_id}/list-objects | Get all objects of the given type that the user has a relation with
664665
*OpenFgaApi* | [**list_stores**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#list_stores) | **GET** /stores | List all stores
665666
*OpenFgaApi* | [**read**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#read) | **POST** /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules
666667
*OpenFgaApi* | [**read_assertions**](https://github.com/openfga/python-sdk/blob/main/docs/OpenFgaApi.md#read_assertions) | **GET** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID

docs/AuthorizationModel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**id** | **str** | | [optional]
8-
**schema_version** | **str** | | [optional]
8+
**schema_version** | **str** | |
99
**type_definitions** | [**list[TypeDefinition]**](TypeDefinition.md) | | [optional]
1010

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

docs/OpenFgaApi.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Method | HTTP request | Description
99
[**delete_store**](OpenFgaApi.md#delete_store) | **DELETE** /stores/{store_id} | Delete a store
1010
[**expand**](OpenFgaApi.md#expand) | **POST** /stores/{store_id}/expand | Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship
1111
[**get_store**](OpenFgaApi.md#get_store) | **GET** /stores/{store_id} | Get a store
12-
[**list_objects**](OpenFgaApi.md#list_objects) | **POST** /stores/{store_id}/list-objects | [EXPERIMENTAL] Get all objects of the given type that the user has a relation with
12+
[**list_objects**](OpenFgaApi.md#list_objects) | **POST** /stores/{store_id}/list-objects | Get all objects of the given type that the user has a relation with
1313
[**list_stores**](OpenFgaApi.md#list_stores) | **GET** /stores | List all stores
1414
[**read**](OpenFgaApi.md#read) | **POST** /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules
1515
[**read_assertions**](OpenFgaApi.md#read_assertions) | **GET** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID
@@ -417,9 +417,9 @@ No authorization required
417417
# **list_objects**
418418
> ListObjectsResponse list_objects(body)
419419
420-
[EXPERIMENTAL] Get all objects of the given type that the user has a relation with
420+
Get all objects of the given type that the user has a relation with
421421

422-
The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is, it will be used to decide the underlying implementation used. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\")
422+
The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is, it will be used to decide the underlying implementation used. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). Note: If you have `and` or `but not` in your model while using ListObjects, checkout the [caveats](https://openfga.dev/docs/interacting/relationship-queries#caveats-and-when-not-to-use-it-3).
423423

424424
### Example
425425

@@ -456,7 +456,7 @@ async with openfga_sdk.ApiClient(configuration) as api_client:
456456
body = openfga_sdk.ListObjectsRequest() # ListObjectsRequest |
457457

458458
try:
459-
# [EXPERIMENTAL] Get all objects of the given type that the user has a relation with
459+
# Get all objects of the given type that the user has a relation with
460460
api_response = await api_instance.api_instance.list_objects(body)
461461
pprint(api_response)
462462
except ApiException as e:

openfga_sdk/api/open_fga_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,9 @@ async def get_store_with_http_info(self, **kwargs): # noqa: E501
728728
_request_auth=local_var_params.get('_request_auth')))
729729

730730
async def list_objects(self, body, **kwargs): # noqa: E501
731-
"""[EXPERIMENTAL] Get all objects of the given type that the user has a relation with # noqa: E501
731+
"""Get all objects of the given type that the user has a relation with # noqa: E501
732732
733-
The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is, it will be used to decide the underlying implementation used. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\") # noqa: E501
733+
The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is, it will be used to decide the underlying implementation used. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). Note: If you have `and` or `but not` in your model while using ListObjects, checkout the [caveats](https://openfga.dev/docs/interacting/relationship-queries#caveats-and-when-not-to-use-it-3). # noqa: E501
734734
735735
>>> thread = await api.list_objects(body)
736736
@@ -755,9 +755,9 @@ async def list_objects(self, body, **kwargs): # noqa: E501
755755
return await(self.list_objects_with_http_info(body, **kwargs)) # noqa: E501
756756

757757
async def list_objects_with_http_info(self, body, **kwargs): # noqa: E501
758-
"""[EXPERIMENTAL] Get all objects of the given type that the user has a relation with # noqa: E501
758+
"""Get all objects of the given type that the user has a relation with # noqa: E501
759759
760-
The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is, it will be used to decide the underlying implementation used. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\") # noqa: E501
760+
The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is, it will be used to decide the underlying implementation used. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). Note: If you have `and` or `but not` in your model while using ListObjects, checkout the [caveats](https://openfga.dev/docs/interacting/relationship-queries#caveats-and-when-not-to-use-it-3). # noqa: E501
761761
762762
>>> thread = api.list_objects_with_http_info(body)
763763

openfga_sdk/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
9292
self.cookie = cookie
9393
# Set default User-Agent.
9494
self.user_agent = 'openfga-sdk {sdkId}/{packageVersion}'.replace(
95-
'{sdkId}', '').replace('{packageVersion}', '0.1.1')
95+
'{sdkId}', 'python').replace('{packageVersion}', '0.1.1')
9696
self.client_side_validation = configuration.client_side_validation
9797

9898
async def __aenter__(self):

openfga_sdk/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class RetryParams(object):
4242
:param min_wait_in_ms: Minimum wait (in ms) between retry
4343
"""
4444

45-
def __init__(self, max_retry=3, min_wait_in_ms=100):
45+
def __init__(self, max_retry=15, min_wait_in_ms=100):
4646
self._max_retry = max_retry
4747
self._min_wait_in_ms = min_wait_in_ms
4848

openfga_sdk/models/authorization_model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ def __init__(self, id=None, schema_version=None, type_definitions=None, local_va
6262

6363
if id is not None:
6464
self.id = id
65-
if schema_version is not None:
66-
self.schema_version = schema_version
65+
self.schema_version = schema_version
6766
if type_definitions is not None:
6867
self.type_definitions = type_definitions
6968

@@ -106,6 +105,8 @@ def schema_version(self, schema_version):
106105
:param schema_version: The schema_version of this AuthorizationModel. # noqa: E501
107106
:type schema_version: str
108107
"""
108+
if self.local_vars_configuration.client_side_validation and schema_version is None: # noqa: E501
109+
raise ValueError("Invalid value for `schema_version`, must not be `None`") # noqa: E501
109110

110111
self._schema_version = schema_version
111112

0 commit comments

Comments
 (0)