Skip to content

Commit e56a36f

Browse files
ryanpqewanharris
authored andcommitted
feat: support start_time parameter on read_changes
1 parent 99f45c7 commit e56a36f

File tree

13 files changed

+46
-9
lines changed

13 files changed

+46
-9
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [Unreleased](https://github.com/openfga/python-sdk/compare/v0.8.1...HEAD)
44

55
- feat: remove client-side validation - thanks @GMorris-professional (#155)
6+
- feat: add support for `start_time` parameter in `ReadChanges` endpoint (#156)
67
- fix: change default max retry limit to 3 from 15 - thanks @ovindu-a (#155)
78

89
## v0.8.1

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ options = {
485485
"page_size": "25",
486486
"continuation_token": "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="
487487
}
488-
body = ClientReadChangesRequest(type="document")
488+
body = ClientReadChangesRequest(type="document", start_time="2022-01-01T00:00:00Z")
489489

490490
response = await fga_client.read_changes(body, options)
491491
# response.continuation_token = ...

docs/OpenFgaApi.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1066,10 +1066,11 @@ async with openfga_sdk.ApiClient(configuration) as api_client:
10661066
type = 'type_example' # str | (optional)
10671067
page_size = 56 # int | (optional)
10681068
continuation_token = 'continuation_token_example' # str | (optional)
1069+
start_time = '2013-10-20T19:20:30+01:00' # datetime | Start date and time of changes to read. Format: ISO 8601 timestamp (e.g., 2022-01-01T00:00:00Z) If a continuation_token is provided along side start_time, the continuation_token will take precedence over start_time. (optional)
10691070

10701071
try:
10711072
# Return a list of all the tuple changes
1072-
api_response = await api_instance.api_instance.read_changes(type=type, page_size=page_size, continuation_token=continuation_token)
1073+
api_response = await api_instance.api_instance.read_changes(type=type, page_size=page_size, continuation_token=continuation_token, start_time=start_time)
10731074
pprint(api_response)
10741075
except ApiException as e:
10751076
print("Exception when calling OpenFgaApi->read_changes: %s\n" % e)
@@ -1084,6 +1085,7 @@ Name | Type | Description | Notes
10841085
**type** | **str**| | [optional]
10851086
**page_size** | **int**| | [optional]
10861087
**continuation_token** | **str**| | [optional]
1088+
**start_time** | **datetime**| Start date and time of changes to read. Format: ISO 8601 timestamp (e.g., 2022-01-01T00:00:00Z) If a continuation_token is provided along side start_time, the continuation_token will take precedence over start_time. | [optional]
10871089

10881090
### Return type
10891091

openfga_sdk/api/open_fga_api.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -2051,6 +2051,8 @@ async def read_changes(self, **kwargs):
20512051
:type page_size: int, optional
20522052
:param continuation_token:(optional)
20532053
:type continuation_token: str, optional
2054+
:param start_time: Start date and time of changes to read. Format: ISO 8601 timestamp (e.g., 2022-01-01T00:00:00Z) If a continuation_token is provided along side start_time, the continuation_token will take precedence over start_time.(optional)
2055+
:type start_time: datetime, optional
20542056
:param async_req: Whether to execute the request asynchronously.
20552057
:type async_req: bool, optional
20562058
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -2082,6 +2084,8 @@ async def read_changes_with_http_info(self, **kwargs):
20822084
:type page_size: int, optional
20832085
:param continuation_token:(optional)
20842086
:type continuation_token: str, optional
2087+
:param start_time: Start date and time of changes to read. Format: ISO 8601 timestamp (e.g., 2022-01-01T00:00:00Z) If a continuation_token is provided along side start_time, the continuation_token will take precedence over start_time.(optional)
2088+
:type start_time: datetime, optional
20852089
:param async_req: Whether to execute the request asynchronously.
20862090
:type async_req: bool, optional
20872091
:param _return_http_data_only: response data without head status code
@@ -2109,7 +2113,7 @@ async def read_changes_with_http_info(self, **kwargs):
21092113

21102114
local_var_params = locals()
21112115

2112-
all_params = ["type", "page_size", "continuation_token"]
2116+
all_params = ["type", "page_size", "continuation_token", "start_time"]
21132117
all_params.extend(
21142118
[
21152119
"async_req",
@@ -2153,6 +2157,8 @@ async def read_changes_with_http_info(self, **kwargs):
21532157
query_params.append(
21542158
("continuation_token", local_var_params["continuation_token"])
21552159
)
2160+
if local_var_params.get("start_time") is not None:
2161+
query_params.append(("start_time", local_var_params["start_time"]))
21562162

21572163
header_params = dict(local_var_params.get("_headers", {}))
21582164

openfga_sdk/client/client.py

+1
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ async def read_changes(
347347
"""
348348
kwargs = options_to_kwargs(options)
349349
kwargs["type"] = body.type
350+
kwargs["start_time"] = body.start_time
350351
api_response = await self._api.read_changes(
351352
**kwargs,
352353
)

openfga_sdk/client/models/read_changes_request.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@ class ClientReadChangesRequest:
1616
ClientReadChangesRequest encapsulates the parameters required to read changes
1717
"""
1818

19-
def __init__(self, type: str):
19+
def __init__(self, type: str, start_time: str = None):
2020
self._type = type
21+
self._startTime = start_time
2122

2223
@property
2324
def type(self):
2425
"""
2526
Return type
2627
"""
2728
return self._type
29+
30+
@property
31+
def start_time(self):
32+
"""
33+
Return startTime
34+
"""
35+
return self._startTime

openfga_sdk/models/error_code.py

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class ErrorCode:
9090
INVALID_AUTHORIZATION_MODEL = "invalid_authorization_model"
9191
UNSUPPORTED_SCHEMA_VERSION = "unsupported_schema_version"
9292
CANCELLED = "cancelled"
93+
INVALID_START_TIME = "invalid_start_time"
9394

9495
allowable_values = [
9596
NO_ERROR,
@@ -141,6 +142,7 @@ class ErrorCode:
141142
INVALID_AUTHORIZATION_MODEL,
142143
UNSUPPORTED_SCHEMA_VERSION,
143144
CANCELLED,
145+
INVALID_START_TIME,
144146
]
145147

146148
"""

openfga_sdk/sync/client/client.py

+1
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ def read_changes(
345345
"""
346346
kwargs = options_to_kwargs(options)
347347
kwargs["type"] = body.type
348+
kwargs["start_time"] = body.start_time
348349
api_response = self._api.read_changes(
349350
**kwargs,
350351
)

openfga_sdk/sync/open_fga_api.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -2047,6 +2047,8 @@ def read_changes(self, **kwargs):
20472047
:type page_size: int, optional
20482048
:param continuation_token:(optional)
20492049
:type continuation_token: str, optional
2050+
:param start_time: Start date and time of changes to read. Format: ISO 8601 timestamp (e.g., 2022-01-01T00:00:00Z) If a continuation_token is provided along side start_time, the continuation_token will take precedence over start_time.(optional)
2051+
:type start_time: datetime, optional
20502052
:param async_req: Whether to execute the request asynchronously.
20512053
:type async_req: bool, optional
20522054
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -2078,6 +2080,8 @@ def read_changes_with_http_info(self, **kwargs):
20782080
:type page_size: int, optional
20792081
:param continuation_token:(optional)
20802082
:type continuation_token: str, optional
2083+
:param start_time: Start date and time of changes to read. Format: ISO 8601 timestamp (e.g., 2022-01-01T00:00:00Z) If a continuation_token is provided along side start_time, the continuation_token will take precedence over start_time.(optional)
2084+
:type start_time: datetime, optional
20812085
:param async_req: Whether to execute the request asynchronously.
20822086
:type async_req: bool, optional
20832087
:param _return_http_data_only: response data without head status code
@@ -2105,7 +2109,7 @@ def read_changes_with_http_info(self, **kwargs):
21052109

21062110
local_var_params = locals()
21072111

2108-
all_params = ["type", "page_size", "continuation_token"]
2112+
all_params = ["type", "page_size", "continuation_token", "start_time"]
21092113
all_params.extend(
21102114
[
21112115
"async_req",
@@ -2149,6 +2153,8 @@ def read_changes_with_http_info(self, **kwargs):
21492153
query_params.append(
21502154
("continuation_token", local_var_params["continuation_token"])
21512155
)
2156+
if local_var_params.get("start_time") is not None:
2157+
query_params.append(("start_time", local_var_params["start_time"]))
21522158

21532159
header_params = dict(local_var_params.get("_headers", {}))
21542160

test/api/open_fga_api_test.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,10 @@ async def test_read_changes(self, mock_request):
783783

784784
# Return a particular version of an authorization model
785785
api_response = await api_instance.read_changes(
786-
page_size=1, continuation_token="abcdefg", type="document"
786+
page_size=1,
787+
continuation_token="abcdefg",
788+
start_time="2022-01-01T00:00:00+00:00",
789+
type="document",
787790
)
788791
self.assertIsInstance(api_response, ReadChangesResponse)
789792
changes = TupleChange(
@@ -808,6 +811,7 @@ async def test_read_changes(self, mock_request):
808811
("type", "document"),
809812
("page_size", 1),
810813
("continuation_token", "abcdefg"),
814+
("start_time", "2022-01-01T00:00:00+00:00"),
811815
],
812816
_preload_content=ANY,
813817
_request_timeout=None,

test/client/client_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ async def test_read_changes(self, mock_request):
675675

676676
# Return a particular version of an authorization model
677677
api_response = await api_client.read_changes(
678-
ClientReadChangesRequest("document"),
678+
ClientReadChangesRequest("document", "2022-01-01T00:00:00+00:00"),
679679
options={"page_size": 1, "continuation_token": "abcdefg"},
680680
)
681681

@@ -702,6 +702,7 @@ async def test_read_changes(self, mock_request):
702702
("type", "document"),
703703
("page_size", 1),
704704
("continuation_token", "abcdefg"),
705+
("start_time", "2022-01-01T00:00:00+00:00"),
705706
],
706707
_preload_content=ANY,
707708
_request_timeout=None,

test/sync/client/client_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ def test_read_changes(self, mock_request):
674674

675675
# Return a particular version of an authorization model
676676
api_response = api_client.read_changes(
677-
ClientReadChangesRequest("document"),
677+
ClientReadChangesRequest("document", "2022-01-01T00:00:00+00:00"),
678678
options={"page_size": 1, "continuation_token": "abcdefg"},
679679
)
680680

@@ -701,6 +701,7 @@ def test_read_changes(self, mock_request):
701701
("type", "document"),
702702
("page_size", 1),
703703
("continuation_token", "abcdefg"),
704+
("start_time", "2022-01-01T00:00:00+00:00"),
704705
],
705706
_preload_content=ANY,
706707
_request_timeout=None,

test/sync/open_fga_api_test.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,10 @@ async def test_read_changes(self, mock_request):
787787

788788
# Return a particular version of an authorization model
789789
api_response = api_instance.read_changes(
790-
page_size=1, continuation_token="abcdefg", type="document"
790+
page_size=1,
791+
continuation_token="abcdefg",
792+
start_time="2022-01-01T00:00:00+00:00",
793+
type="document",
791794
)
792795
self.assertIsInstance(api_response, ReadChangesResponse)
793796
changes = TupleChange(
@@ -812,6 +815,7 @@ async def test_read_changes(self, mock_request):
812815
("type", "document"),
813816
("page_size", 1),
814817
("continuation_token", "abcdefg"),
818+
("start_time", "2022-01-01T00:00:00+00:00"),
815819
],
816820
_preload_content=ANY,
817821
_request_timeout=None,

0 commit comments

Comments
 (0)