Skip to content

Commit a8f35ef

Browse files
committed
release: v0.1.0 with updated ListObjects response
- Support for OpenFGA v0.3.0 - ListObjects response now includes object type [BREAKING] - Fix models
1 parent 614f0d1 commit a8f35ef

File tree

135 files changed

+212
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+212
-176
lines changed

.fossa.yml

100644100755
File mode changed.

.openapi-generator/FILES

100644100755
File mode changed.

.openapi-generator/VERSION

100644100755
File mode changed.

.snyk

100644100755
File mode changed.

CHANGELOG.md

100644100755
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## v0.1.0
4+
5+
### [0.1.0](https://github.com/openfga/python-sdk/compare/v0.0.1...v0.1.0) (2022-12-14)
6+
7+
Updated to include support for [OpenFGA 0.3.0](https://github.com/openfga/openfga/releases/tag/v0.3.0)
8+
9+
Changes:
10+
- [BREAKING] feat(list-objects)!: response has been changed to include the object type
11+
e.g. response that was `{"object_ids":["roadmap"]}`, will now be `{"objects":["document:roadmap"]}`
12+
13+
Fixes:
14+
- fix(models): update interfaces that had incorrectly optional fields to make them required
15+
16+
317
## v0.0.1
418

519
### [0.0.1](https://github.com/openfga/python-sdk/releases/tag/v0.0.1) (2022-08-31)

CONTRIBUTING.md

100644100755
File mode changed.

LICENSE

100644100755
File mode changed.

NOTICE.txt

100644100755
File mode changed.

README.md

100644100755
Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ async def write_authorization_model():
326326
api_instance = open_fga_api.OpenFgaApi(api_client)
327327
type_definitions = WriteAuthorizationModelRequest(
328328
type_definitions=[
329+
TypeDefinition(
330+
type="user",
331+
),
329332
TypeDefinition(
330333
type="document",
331334
relations=dict(
@@ -349,7 +352,7 @@ async def write_authorization_model():
349352
)
350353

351354
response = await api_instance.write_authorization_model(type_definitions)
352-
# response.id = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"
355+
# response.authorization_model_id = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"
353356
await api_client.close()
354357
```
355358

@@ -419,9 +422,10 @@ async def check():
419422
body = CheckRequest(
420423
tuple_key=TupleKey(
421424
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
422-
relation="admin",
423-
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
425+
relation="viewer",
426+
object="document:roadmap",
424427
),
428+
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
425429
)
426430

427431
response = await api_instance.check(body)
@@ -451,11 +455,12 @@ async def write():
451455
tuple_keys=[
452456
TupleKey(
453457
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
454-
relation="admin",
455-
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
458+
relation="viewer",
459+
object="document:roadmap",
456460
),
457461
],
458462
),
463+
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
459464
)
460465

461466
response = await api_instance.write(body)
@@ -483,11 +488,12 @@ async def delete():
483488
tuple_keys=[
484489
TupleKey(
485490
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
486-
relation="reader",
487-
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
491+
relation="viewer",
492+
object="document:roadmap",
488493
),
489494
],
490495
),
496+
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
491497
)
492498

493499
response = await api_instance.write(body)
@@ -512,13 +518,14 @@ async def expand():
512518
api_instance = open_fga_api.OpenFgaApi(api_client)
513519
body = ExpandRequest(
514520
tuple_key=TupleKey(
515-
relation="admin",
516-
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
521+
relation="viewer",
522+
object="document:roadmap",
517523
),
524+
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
518525
)
519526

520527
response = await api_instance.expand(body)
521-
# response = ExpandResponse({"tree": UsersetTree({"root": Node({"name": "workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6#admin", "leaf": Leaf({"users": Users({"users": ["user:81684243-9356-4421-8fbf-a4f8d36aa31b", "user:f52a4f7a-054d-47ff-bb6e-3ac81269988f"]})})})})})
528+
# response = ExpandResponse({"tree": UsersetTree({"root": Node({"name": "document:roadmap#viewer", "leaf": Leaf({"users": Users({"users": ["user:81684243-9356-4421-8fbf-a4f8d36aa31b", "user:f52a4f7a-054d-47ff-bb6e-3ac81269988f"]})})})})})
522529
await api_client.close()
523530
```
524531

@@ -538,39 +545,42 @@ async def read():
538545
api_client = openfga_sdk.ApiClient(configuration)
539546
api_instance = open_fga_api.OpenFgaApi(api_client)
540547

541-
# Find if a relationship tuple stating that a certain user is an admin on a certain workspace
548+
# Find if a relationship tuple stating that a certain user is a viewer of certain document
542549
body = ReadRequest(
543550
tuple_key=TupleKey(
544551
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
545-
relation="admin",
546-
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
552+
relation="viewer",
553+
object="document:roadmap",
547554
),
548555
)
549556

550-
# Find all relationship tuples where a certain user has a relationship as any relation to a certain workspace
557+
# Find all relationship tuples where a certain user has a relationship as any relation to a certain document
551558
body = ReadRequest(
552559
tuple_key=TupleKey(
553560
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
554-
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
561+
object="document:roadmap",
555562
),
556563
)
557564

558-
# Find all relationship tuples where a certain user is an admin on any workspace
565+
# Find all relationship tuples where a certain user is a viewer of any document
559566
body = ReadRequest(
560567
tuple_key=TupleKey(
561568
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
562-
relation="admin",
563-
object="workspace:",
569+
relation="viewer",
570+
object="document:",
564571
),
565572
)
566573

567-
# Find all relationship tuples where any user has a relationship as any relation with a particular workspace
574+
# Find all relationship tuples where any user has a relationship as any relation with a particular document
568575
body = ReadRequest(
569576
tuple_key=TupleKey(
570-
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
577+
object="document:roadmap",
571578
),
572579
)
573580

581+
// Read all stored relationship tuples
582+
body := ReadRequest()
583+
574584
response = await api_instance.read(body)
575585
# response = ReadResponse({"tuples": [Tuple({"key": TupleKey({"user":"...","relation":"...","object":"..."}), "timestamp": datetime.fromisoformat("...") })]})
576586
await api_client.close()
@@ -593,7 +603,7 @@ async def read_changes():
593603
api_client = openfga_sdk.ApiClient(configuration)
594604
api_instance = open_fga_api.OpenFgaApi(api_client)
595605

596-
type = "workspace"
606+
type = "document"
597607
page_size = 25
598608
continuation_token = "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="
599609

@@ -620,28 +630,23 @@ async def list_objects():
620630
api_client = openfga_sdk.ApiClient(configuration)
621631
api_instance = open_fga_api.OpenFgaApi(api_client)
622632
body = ListObjectsRequest(
623-
authorization_model_id="01GAHCE4YVKPQEKZQHT2R89MQV",
633+
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
624634
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
625-
relation="can_read",
635+
relation="viewer",
626636
type="document",
627637
contextual_tuples=ContextualTupleKeys( # optional
628638
tuple_keys=[
629639
TupleKey(
630640
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
631-
relation="editor",
632-
object="folder:product",
633-
),
634-
TupleKey(
635-
user="folder:product",
636-
relation="parent",
637-
object="document:roadmap",
641+
relation="writer",
642+
object="document:budget",
638643
),
639644
],
640645
),
641646
)
642647

643648
response = await api_instance.list_objects(body)
644-
# response.object_ids = ["roadmap"]
649+
# response.objects = ["document:roadmap"]
645650
await api_client.close()
646651
```
647652

@@ -655,8 +660,8 @@ Class | Method | HTTP request | Description
655660
*OpenFgaApi* | [**delete_store**](docs/OpenFgaApi.md#delete_store) | **DELETE** /stores/{store_id} | Delete a store
656661
*OpenFgaApi* | [**expand**](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
657662
*OpenFgaApi* | [**get_store**](docs/OpenFgaApi.md#get_store) | **GET** /stores/{store_id} | Get a store
658-
*OpenFgaApi* | [**list_objects**](docs/OpenFgaApi.md#list_objects) | **POST** /stores/{store_id}/list-objects | ListObjects lists all of the object ids for objects of the provided type that the given user has a specific relation with.
659-
*OpenFgaApi* | [**list_stores**](docs/OpenFgaApi.md#list_stores) | **GET** /stores | Get all stores
663+
*OpenFgaApi* | [**list_objects**](docs/OpenFgaApi.md#list_objects) | **POST** /stores/{store_id}/list-objects | [EXPERIMENTAL] Get all object ids of the given type that the user has a relation with
664+
*OpenFgaApi* | [**list_stores**](docs/OpenFgaApi.md#list_stores) | **GET** /stores | List all stores
660665
*OpenFgaApi* | [**read**](docs/OpenFgaApi.md#read) | **POST** /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules
661666
*OpenFgaApi* | [**read_assertions**](docs/OpenFgaApi.md#read_assertions) | **GET** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID
662667
*OpenFgaApi* | [**read_authorization_model**](docs/OpenFgaApi.md#read_authorization_model) | **GET** /stores/{store_id}/authorization-models/{id} | Return a particular version of an authorization model
@@ -747,5 +752,3 @@ All changes made to this repo will be overwritten on the next generation, so we
747752
This project is licensed under the Apache-2.0 license. See the [LICENSE](https://github.com/openfga/python-sdk/blob/main/LICENSE) file for more info.
748753

749754
The code in this repo was auto generated by [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) from a template based on the [python legacy template](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/python-legacy), licensed under the [Apache License 2.0](https://github.com/OpenAPITools/openapi-generator/blob/master/LICENSE).
750-
751-

VERSION.txt

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.1
1+
0.1.0

0 commit comments

Comments
 (0)