Skip to content

Commit

Permalink
release: v0.1.0 with updated ListObjects response
Browse files Browse the repository at this point in the history
- Support for OpenFGA v0.3.0
- ListObjects response now includes object type [BREAKING]
- Fix models
  • Loading branch information
rhamzeh committed Dec 15, 2022
1 parent 614f0d1 commit a8f35ef
Show file tree
Hide file tree
Showing 135 changed files with 212 additions and 176 deletions.
Empty file modified .fossa.yml
100644 → 100755
Empty file.
Empty file modified .openapi-generator/FILES
100644 → 100755
Empty file.
Empty file modified .openapi-generator/VERSION
100644 → 100755
Empty file.
Empty file modified .snyk
100644 → 100755
Empty file.
14 changes: 14 additions & 0 deletions CHANGELOG.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## v0.1.0

### [0.1.0](https://github.com/openfga/python-sdk/compare/v0.0.1...v0.1.0) (2022-12-14)

Updated to include support for [OpenFGA 0.3.0](https://github.com/openfga/openfga/releases/tag/v0.3.0)

Changes:
- [BREAKING] feat(list-objects)!: response has been changed to include the object type
e.g. response that was `{"object_ids":["roadmap"]}`, will now be `{"objects":["document:roadmap"]}`

Fixes:
- fix(models): update interfaces that had incorrectly optional fields to make them required


## v0.0.1

### [0.0.1](https://github.com/openfga/python-sdk/releases/tag/v0.0.1) (2022-08-31)
Expand Down
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified NOTICE.txt
100644 → 100755
Empty file.
73 changes: 38 additions & 35 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ async def write_authorization_model():
api_instance = open_fga_api.OpenFgaApi(api_client)
type_definitions = WriteAuthorizationModelRequest(
type_definitions=[
TypeDefinition(
type="user",
),
TypeDefinition(
type="document",
relations=dict(
Expand All @@ -349,7 +352,7 @@ async def write_authorization_model():
)

response = await api_instance.write_authorization_model(type_definitions)
# response.id = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"
# response.authorization_model_id = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"
await api_client.close()
```

Expand Down Expand Up @@ -419,9 +422,10 @@ async def check():
body = CheckRequest(
tuple_key=TupleKey(
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="admin",
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
relation="viewer",
object="document:roadmap",
),
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
)

response = await api_instance.check(body)
Expand Down Expand Up @@ -451,11 +455,12 @@ async def write():
tuple_keys=[
TupleKey(
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="admin",
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
relation="viewer",
object="document:roadmap",
),
],
),
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
)

response = await api_instance.write(body)
Expand Down Expand Up @@ -483,11 +488,12 @@ async def delete():
tuple_keys=[
TupleKey(
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="reader",
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
relation="viewer",
object="document:roadmap",
),
],
),
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
)

response = await api_instance.write(body)
Expand All @@ -512,13 +518,14 @@ async def expand():
api_instance = open_fga_api.OpenFgaApi(api_client)
body = ExpandRequest(
tuple_key=TupleKey(
relation="admin",
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
relation="viewer",
object="document:roadmap",
),
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
)

response = await api_instance.expand(body)
# 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"]})})})})})
# 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"]})})})})})
await api_client.close()
```

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

# Find if a relationship tuple stating that a certain user is an admin on a certain workspace
# Find if a relationship tuple stating that a certain user is a viewer of certain document
body = ReadRequest(
tuple_key=TupleKey(
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="admin",
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
relation="viewer",
object="document:roadmap",
),
)

# Find all relationship tuples where a certain user has a relationship as any relation to a certain workspace
# Find all relationship tuples where a certain user has a relationship as any relation to a certain document
body = ReadRequest(
tuple_key=TupleKey(
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
object="document:roadmap",
),
)

# Find all relationship tuples where a certain user is an admin on any workspace
# Find all relationship tuples where a certain user is a viewer of any document
body = ReadRequest(
tuple_key=TupleKey(
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="admin",
object="workspace:",
relation="viewer",
object="document:",
),
)

# Find all relationship tuples where any user has a relationship as any relation with a particular workspace
# Find all relationship tuples where any user has a relationship as any relation with a particular document
body = ReadRequest(
tuple_key=TupleKey(
object="workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
object="document:roadmap",
),
)

// Read all stored relationship tuples
body := ReadRequest()

response = await api_instance.read(body)
# response = ReadResponse({"tuples": [Tuple({"key": TupleKey({"user":"...","relation":"...","object":"..."}), "timestamp": datetime.fromisoformat("...") })]})
await api_client.close()
Expand All @@ -593,7 +603,7 @@ async def read_changes():
api_client = openfga_sdk.ApiClient(configuration)
api_instance = open_fga_api.OpenFgaApi(api_client)

type = "workspace"
type = "document"
page_size = 25
continuation_token = "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="

Expand All @@ -620,28 +630,23 @@ async def list_objects():
api_client = openfga_sdk.ApiClient(configuration)
api_instance = open_fga_api.OpenFgaApi(api_client)
body = ListObjectsRequest(
authorization_model_id="01GAHCE4YVKPQEKZQHT2R89MQV",
authorization_model_id="1uHxCSuTP0VKPYSnkq1pbb1jeZw",
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="can_read",
relation="viewer",
type="document",
contextual_tuples=ContextualTupleKeys( # optional
tuple_keys=[
TupleKey(
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="editor",
object="folder:product",
),
TupleKey(
user="folder:product",
relation="parent",
object="document:roadmap",
relation="writer",
object="document:budget",
),
],
),
)

response = await api_instance.list_objects(body)
# response.object_ids = ["roadmap"]
# response.objects = ["document:roadmap"]
await api_client.close()
```

Expand All @@ -655,8 +660,8 @@ Class | Method | HTTP request | Description
*OpenFgaApi* | [**delete_store**](docs/OpenFgaApi.md#delete_store) | **DELETE** /stores/{store_id} | Delete a store
*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
*OpenFgaApi* | [**get_store**](docs/OpenFgaApi.md#get_store) | **GET** /stores/{store_id} | Get a store
*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.
*OpenFgaApi* | [**list_stores**](docs/OpenFgaApi.md#list_stores) | **GET** /stores | Get all stores
*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
*OpenFgaApi* | [**list_stores**](docs/OpenFgaApi.md#list_stores) | **GET** /stores | List all stores
*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
*OpenFgaApi* | [**read_assertions**](docs/OpenFgaApi.md#read_assertions) | **GET** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID
*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
Expand Down Expand Up @@ -747,5 +752,3 @@ All changes made to this repo will be overwritten on the next generation, so we
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.

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).


2 changes: 1 addition & 1 deletion VERSION.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
0.1.0
Empty file modified docs/Any.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion docs/Assertion.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**tuple_key** | [**TupleKey**](TupleKey.md) | | [optional]
**tuple_key** | [**TupleKey**](TupleKey.md) | |
**expectation** | **bool** | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
Empty file modified docs/AuthorizationModel.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion docs/CheckRequest.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**tuple_key** | [**TupleKey**](TupleKey.md) | | [optional]
**tuple_key** | [**TupleKey**](TupleKey.md) | |
**contextual_tuples** | [**ContextualTupleKeys**](ContextualTupleKeys.md) | | [optional]
**authorization_model_id** | **str** | | [optional]
**trace** | **bool** | Defaults to false. Making it true has performance implications. | [optional] [readonly]
Expand Down
Empty file modified docs/CheckResponse.md
100644 → 100755
Empty file.
Empty file modified docs/Computed.md
100644 → 100755
Empty file.
Empty file modified docs/ContextualTupleKeys.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion docs/CreateStoreRequest.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | | [optional]
**name** | **str** | |

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

Expand Down
Empty file modified docs/CreateStoreResponse.md
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions docs/Difference.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**base** | [**Userset**](Userset.md) | | [optional]
**subtract** | [**Userset**](Userset.md) | | [optional]
**base** | [**Userset**](Userset.md) | |
**subtract** | [**Userset**](Userset.md) | |

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

Expand Down
Empty file modified docs/ErrorCode.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion docs/ExpandRequest.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**tuple_key** | [**TupleKey**](TupleKey.md) | | [optional]
**tuple_key** | [**TupleKey**](TupleKey.md) | |
**authorization_model_id** | **str** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
Empty file modified docs/ExpandResponse.md
100644 → 100755
Empty file.
Empty file modified docs/GetStoreResponse.md
100644 → 100755
Empty file.
Empty file modified docs/InternalErrorCode.md
100644 → 100755
Empty file.
Empty file modified docs/InternalErrorMessageResponse.md
100644 → 100755
Empty file.
Empty file modified docs/Leaf.md
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions docs/ListObjectsRequest.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**authorization_model_id** | **str** | | [optional]
**type** | **str** | | [optional]
**relation** | **str** | | [optional]
**user** | **str** | | [optional]
**type** | **str** | |
**relation** | **str** | |
**user** | **str** | |
**contextual_tuples** | [**ContextualTupleKeys**](ContextualTupleKeys.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/ListObjectsResponse.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**object_ids** | **list[str]** | | [optional]
**objects** | **list[str]** | | [optional]

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

Expand Down
Empty file modified docs/ListStoresResponse.md
100644 → 100755
Empty file.
Empty file modified docs/Metadata.md
100644 → 100755
Empty file.
Empty file modified docs/Node.md
100644 → 100755
Empty file.
Empty file modified docs/Nodes.md
100644 → 100755
Empty file.
Empty file modified docs/NotFoundErrorCode.md
100644 → 100755
Empty file.
Empty file modified docs/ObjectRelation.md
100644 → 100755
Empty file.
Loading

0 comments on commit a8f35ef

Please sign in to comment.