Skip to content

Commit cf314ce

Browse files
committed
feat: support List Stores name filter
1 parent 3936955 commit cf314ce

File tree

5 files changed

+244
-26
lines changed

5 files changed

+244
-26
lines changed

CHANGELOG.md

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### [0.9.3](https://github.com/openfga/python-sdk/compare/v0.9.2...v0.9.3) (2025-03-26)
66

7+
- feat: feat: support List Stores name filter (#181)
78
- fix: urllib3 compatibility < v2 (#179)
89

910
### [0.9.2](https://github.com/openfga/python-sdk/compare/v0.9.1...v0.9.2) (2025-03-25)
@@ -87,16 +88,19 @@ Please note that if you use third-party OpenTelemetry tooling to visualize the a
8788
- feat: enhancements to OpenTelemetry support (#120)
8889

8990
Note this introduces some breaking changes to our metrics:
91+
9092
1. `fga-client.request.method` is now in TitleCase to match the naming conventions in the Protos, e.g. `Check`, `ListObjects`, etc..
9193
2. Due to possible high costs for attributes with high cardinality, we are no longer including the following attributes by default:
92-
* `fga-client.user`
93-
* `http.client.request.duration`
94-
* `http.server.request.duration`
94+
95+
- `fga-client.user`
96+
- `http.client.request.duration`
97+
- `http.server.request.duration`
9598
We added configuration options to allow you to set which specific metrics and attributes you care about in case the defaults don't work for your use-case
9699

97100
## v0.6.1
98101

99102
### [0.6.1](https://github.com/openfga/python-sdk/compare/v0.6.0...v0.6.1) (2024-07-31)
103+
100104
- feat: add support for specifying consistency when evaluating or reading (#129)
101105
Note: To use this feature, you need to be running OpenFGA v1.5.7+ with the experimental flag
102106
`enable-consistency-params` enabled. See the [v1.5.7 release notes](https://github.com/openfga/openfga/releases/tag/v1.5.7) for details.
@@ -164,21 +168,22 @@ You will have to modify some parts of your code, but we hope this will be to the
164168
and so the Pointer-to-String conversion is no longer needed.
165169

166170
Some of the changes to expect:
171+
167172
- The following request interfaces changed:
168-
- `CheckRequest`: the `TupleKey` field is now of interface `CheckRequestTupleKey`, you can also now pass in `Context`
169-
- `ExpandRequest`: the `TupleKey` field is now of interface `ExpandRequestTupleKey`
170-
- `ReadRequest`: the `TupleKey` field is now of interface `ReadRequestTupleKey`
171-
- `WriteRequest`: now takes `WriteRequestWrites` and `WriteRequestDeletes`, the latter of which accepts `TupleKeyWithoutCondition`
172-
- And more
173+
- `CheckRequest`: the `TupleKey` field is now of interface `CheckRequestTupleKey`, you can also now pass in `Context`
174+
- `ExpandRequest`: the `TupleKey` field is now of interface `ExpandRequestTupleKey`
175+
- `ReadRequest`: the `TupleKey` field is now of interface `ReadRequestTupleKey`
176+
- `WriteRequest`: now takes `WriteRequestWrites` and `WriteRequestDeletes`, the latter of which accepts `TupleKeyWithoutCondition`
177+
- And more
173178
- The following interfaces had fields that were optional are are now required:
174-
- `CreateStoreResponse`
175-
- `GetStoreResponse`
176-
- `ListStoresResponse`
177-
- `ListObjectsResponse`
178-
- `ReadChangesResponse`
179-
- `ReadResponse`
180-
- `AuthorizationModel`
181-
- And more
179+
- `CreateStoreResponse`
180+
- `GetStoreResponse`
181+
- `ListStoresResponse`
182+
- `ListObjectsResponse`
183+
- `ReadChangesResponse`
184+
- `ReadResponse`
185+
- `AuthorizationModel`
186+
- And more
182187

183188
Take a look at the changes in models in https://github.com/openfga/python-sdk/commit/9ed1f70d64db71451de2eb26e330bbd511625c5c and https://github.com/openfga/python-sdk/pull/59/files for more.
184189

@@ -191,31 +196,36 @@ Note: `v0.3.4` has been re-released as `v0.4.0` due to breaking changes
191196
## v0.3.3
192197

193198
### [0.3.3](https://github.com/openfga/python-sdk/compare/v0.3.2...v0.3.3) (2024-01-02)
199+
194200
- fix: correct type hints for list_relations
195201
- fix: handle empty TupleKey in read
196202
- chore: add example project
197203

198204
## v0.3.2
199205

200206
### [0.3.2](https://github.com/openfga/python-sdk/compare/v0.3.1...v0.3.2) (2023-12-15)
207+
201208
- feat: allow passing ssl certs to client configuration
202209
- feat: setup openfga_sdk.help for bug info
203210

204211
## v0.3.1
205212

206213
### [0.3.1](https://github.com/openfga/python-sdk/compare/v0.3.0...v0.3.1) (2023-12-01)
214+
207215
- chore(deps): reduce min urllib3 to 1.25.11, add dependabot & bump deps
208216

209217
## v0.3.0
210218

211219
### [0.3.0](https://github.com/openfga/python-sdk/compare/v0.2.1...v0.3.0) (2023-11-02)
220+
212221
- feat(client): introduce synchronous OpenFgaClient (https://github.com/openfga/python-sdk/commit/c92b436543e263f2c1af6af15f1c4fda1c9dad21)
213222
- refactor(config): extract oauth2 from credentials, removing logic from credentials configuration (https://github.com/openfga/python-sdk/commit/f91d14b25f86dd3f2e4d48229bb53cc7d9b20f1b)
214223
- feat(client): performance improvements to batch_check (https://github.com/openfga/python-sdk/commit/d8f2d429d2c279c0e56d5ef2a6172df8bfadd82b)
215224

216225
## v0.2.1
217226

218227
### [0.2.1](https://github.com/openfga/python-sdk/compare/v0.2.0...v0.2.1) (2023-09-05)
228+
219229
- fix(client): fix a crash when calling check with contextual tuples (https://github.com/openfga/python-sdk/commit/dded83f9a75dc1f01c1cfbd8385a25654129f78f)
220230
- chore(docs): update README and fix a few typos (https://github.com/openfga/python-sdk/pull/21, https://github.com/openfga/python-sdk/pull/31, https://github.com/openfga/python-sdk/pull/32, https://github.com/openfga/python-sdk/pull/33, https://github.com/openfga/python-sdk/pull/34, https://github.com/openfga/python-sdk/pull/37)
221231

@@ -224,6 +234,7 @@ Note: `v0.3.4` has been re-released as `v0.4.0` due to breaking changes
224234
### [0.2.0](https://github.com/openfga/python-sdk/compare/v0.1.1...v0.2.0) (2023-05-25)
225235

226236
Changes:
237+
227238
- [BREAKING] feat!: `schema_version` is now required when calling `write_authorization_model`
228239
- [BREAKING] chore!: drop support for python < 3.10
229240
- feat(client): add OpenFgaClient wrapper see [docs](https://github.com/openfga/python-sdk/tree/main#readme), see the `v0.1.1` docs for [the OpenFgaApi docs](https://github.com/openfga/python-sdk/tree/v0.1.1#readme)
@@ -247,18 +258,20 @@ Changes:
247258
Updated to include support for [OpenFGA 0.3.0](https://github.com/openfga/openfga/releases/tag/v0.3.0)
248259

249260
Changes:
261+
250262
- [BREAKING] feat(list-objects)!: response has been changed to include the object type
251-
e.g. response that was `{"object_ids":["roadmap"]}`, will now be `{"objects":["document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"]}`
263+
e.g. response that was `{"object_ids":["roadmap"]}`, will now be `{"objects":["document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"]}`
252264

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

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

257269
## v0.0.1
258270

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

261273
Initial OpenFGA Python SDK release
274+
262275
- Support for [OpenFGA](https://github.com/openfga/openfga) API
263276
- CRUD stores
264277
- Create, read & list authorization models

docs/OpenFgaApi.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,11 @@ async with openfga_sdk.ApiClient(configuration) as api_client:
643643
api_instance = openfga_sdk.OpenFgaApi(api_client)
644644
page_size = 56 # int | (optional)
645645
continuation_token = 'continuation_token_example' # str | (optional)
646+
name = 'name_example' # str | The name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated (optional)
646647

647648
try:
648649
# List all stores
649-
api_response = await api_instance.api_instance.list_stores(page_size=page_size, continuation_token=continuation_token)
650+
api_response = await api_instance.api_instance.list_stores(page_size=page_size, continuation_token=continuation_token, name=name)
650651
pprint(api_response)
651652
except ApiException as e:
652653
print("Exception when calling OpenFgaApi->list_stores: %s\n" % e)
@@ -660,6 +661,7 @@ Name | Type | Description | Notes
660661
------------- | ------------- | ------------- | -------------
661662
**page_size** | **int**| | [optional]
662663
**continuation_token** | **str**| | [optional]
664+
**name** | **str**| The name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated | [optional]
663665

664666
### Return type
665667

@@ -777,7 +779,7 @@ No authorization required
777779
778780
Get tuples from the store that matches a query, without following userset rewrite rules
779781

780-
The Read API will return the tuples for a certain store that match a query filter specified in the body of the request. The API doesn't guarantee order by any field. It is different from the `/stores/{store_id}/expand` API in that it only returns relationship tuples that are stored in the system and satisfy the query. In the body: 1. `tuple_key` is optional. If not specified, it will return all tuples in the store. 2. `tuple_key.object` is mandatory if `tuple_key` is specified. It can be a full object (e.g., `type:object_id`) or type only (e.g., `type:`). 3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only. ## Examples ### Query for all objects in a type definition To query for all objects that `user:bob` has `reader` relationship in the `document` type definition, call read API with body of ```json { \"tuple_key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:\" } } ``` The API will return tuples and a continuation token, something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `user:bob` has a `reader` relationship with 1 document `document:2021-budget`. Note that this API, unlike the List Objects API, does not evaluate the tuples in the store. The continuation token will be empty if there are no more tuples to query. ### Query for all stored relationship tuples that have a particular relation and object To query for all users that have `reader` relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`). Note that, even if the model said that all `writers` are also `readers`, the API will not return writers such as `user:anne` because it only returns tuples and does not evaluate them. ### Query for all users with all relationships for a particular document To query for all users that have any relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-05T13:42:12.356Z\" }, { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`) and 1 `writer` (`user:anne`).
782+
The Read API will return the tuples for a certain store that match a query filter specified in the body of the request. The API doesn't guarantee order by any field. It is different from the `/stores/{store_id}/expand` API in that it only returns relationship tuples that are stored in the system and satisfy the query. In the body: 1. `tuple_key` is optional. If not specified, it will return all tuples in the store. 2. `tuple_key.object` is mandatory if `tuple_key` is specified. It can be a full object (e.g., `type:object_id`) or type only (e.g., `type:`). 3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only. If tuple_key.user is specified, it needs to be a full object (e.g., `type:user_id`). ## Examples ### Query for all objects in a type definition To query for all objects that `user:bob` has `reader` relationship in the `document` type definition, call read API with body of ```json { \"tuple_key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:\" } } ``` The API will return tuples and a continuation token, something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `user:bob` has a `reader` relationship with 1 document `document:2021-budget`. Note that this API, unlike the List Objects API, does not evaluate the tuples in the store. The continuation token will be empty if there are no more tuples to query. ### Query for all stored relationship tuples that have a particular relation and object To query for all users that have `reader` relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`). Note that, even if the model said that all `writers` are also `readers`, the API will not return writers such as `user:anne` because it only returns tuples and does not evaluate them. ### Query for all users with all relationships for a particular document To query for all users that have any relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-05T13:42:12.356Z\" }, { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`) and 1 `writer` (`user:anne`).
781783

782784
### Example
783785

0 commit comments

Comments
 (0)