From 53af06cb7465bb90807448d835b505b0ee24501c Mon Sep 17 00:00:00 2001 From: Ryan Quinn Date: Tue, 19 Nov 2024 11:57:56 -0600 Subject: [PATCH] Update Makefile start_time in read changes api Update config/clients/python/template/src/sync/client/client.py.mustache Update config/clients/python/template/src/client/models/read_changes_request.py.mustache Update config/clients/python/template/src/client/models/read_changes_request.py.mustache move ReadChanges start_time to body instead of options in dotNet Update to python readme, dotNet model Readme updates for start_time in changes updates to java start_time in read changes updates to java start_time in read changes updates to java start_time in read changes updates to java start_time in read changes updates to python start_time in read changes updates to python start_time in read changes updates to python start_time in read changes updates to go start_time in read changes updates to go start_time in read changes updates to go start_time in read changes updates to go start_time in read changes Update js start_time in changes request Update js start_time in changes request Update js start_time in changes request Update js start_time in changes request Update js start_time in changes request Adding Java changes for start time on read changes dotnet client options error fix read changes start_time WIP (dotnet) changes start_time for python changes start_time in js WIP changes start_time for go WIP dotNet start_time in read changes WIP Co-Authored-By: Ewan Harris --- Makefile | 2 +- .../dotnet/template/Client/Client.mustache | 4 ++-- .../Model/ClientReadChangesRequest.mustache | 2 ++ .../dotnet/template/OpenFgaClientTests.mustache | 3 ++- .../dotnet/template/README_calling_api.mustache | 3 ++- config/clients/dotnet/template/api_test.mustache | 3 ++- .../go/template/README_calling_api.mustache | 1 + config/clients/go/template/api_test.mustache | 3 +++ config/clients/go/template/client/client.mustache | 2 ++ .../go/template/client/client_test.mustache | 6 ++++++ .../OpenFgaApiIntegrationTest.java.mustache | 2 +- .../java/template/OpenFgaApiTest.java.mustache | 15 ++++++++++----- .../java/template/README_calling_api.mustache | 3 ++- .../client-ClientReadChangesRequest.java.mustache | 12 ++++++++++++ .../template/client-OpenFgaClient.java.mustache | 2 +- .../client-OpenFgaClientTest.java.mustache | 4 +++- .../js/template/README_calling_api.mustache | 3 ++- config/clients/js/template/client.mustache | 4 +++- .../js/template/tests/client.test.ts.mustache | 8 +++++--- .../js/template/tests/helpers/nocks.ts.mustache | 5 +++-- .../js/template/tests/index.test.ts.mustache | 5 +++-- .../python/template/README_calling_api.mustache | 2 +- .../python/template/src/client/client.py.mustache | 1 + .../models/read_changes_request.py.mustache | 10 +++++++++- .../template/src/sync/client/client.py.mustache | 1 + .../python/template/test/api_test.py.mustache | 4 +++- .../template/test/client/client_test.py.mustache | 4 ++-- .../template/test/sync/api_test.py.mustache | 3 ++- .../test/sync/client/client_test.py.mustache | 4 ++-- 29 files changed, 89 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 1c6fdae9..7bc56c6c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Main config OPENFGA_DOCKER_TAG = v1.7.0 -OPEN_API_REF ?= 30477608a587fbebea8940129703c11238530f71 +OPEN_API_REF ?= 7c098f10acd22137c659c407818a4e0880044afe OPEN_API_URL = https://raw.githubusercontent.com/openfga/api/${OPEN_API_REF}/docs/openapiv2/apidocs.swagger.json OPENAPI_GENERATOR_CLI_DOCKER_TAG = v6.4.0 NODE_DOCKER_TAG = 20-alpine diff --git a/config/clients/dotnet/template/Client/Client.mustache b/config/clients/dotnet/template/Client/Client.mustache index 849244c7..34909bfd 100644 --- a/config/clients/dotnet/template/Client/Client.mustache +++ b/config/clients/dotnet/template/Client/Client.mustache @@ -154,9 +154,9 @@ public class {{appShortName}}Client : IDisposable { * Read Changes - Read the list of historical relationship tuple writes and deletes */ public async Task ReadChanges(ClientReadChangesRequest? body = default, - IClientReadChangesOptions? options = default, + ClientReadChangesOptions? options = default, CancellationToken cancellationToken = default) => - await api.ReadChanges(GetStoreId(options), body?.Type, options?.PageSize, options?.ContinuationToken, cancellationToken); + await api.ReadChanges(GetStoreId(options), body?.Type, options?.PageSize, options?.ContinuationToken, body?.StartTime, cancellationToken); /** * Read - Read tuples previously written to the store (does not evaluate) diff --git a/config/clients/dotnet/template/Client/Model/ClientReadChangesRequest.mustache b/config/clients/dotnet/template/Client/Model/ClientReadChangesRequest.mustache index d6b86858..25401e5e 100644 --- a/config/clients/dotnet/template/Client/Model/ClientReadChangesRequest.mustache +++ b/config/clients/dotnet/template/Client/Model/ClientReadChangesRequest.mustache @@ -7,11 +7,13 @@ namespace {{packageName}}.Client.Model; public interface IClientReadChangesRequest { string Type { get; set; } + DateTime? StartTime {get; set; } } public class ClientReadChangesRequest : IClientReadChangesRequest, IEquatable, IValidatableObject { public string Type { get; set; } + public DateTime? StartTime {get; set; } public bool Equals(ClientReadChangesRequest input) { if (input == null) { diff --git a/config/clients/dotnet/template/OpenFgaClientTests.mustache b/config/clients/dotnet/template/OpenFgaClientTests.mustache index 3ae40459..8f335c67 100644 --- a/config/clients/dotnet/template/OpenFgaClientTests.mustache +++ b/config/clients/dotnet/template/OpenFgaClientTests.mustache @@ -629,9 +629,10 @@ public class {{appShortName}}ClientTests { var type = "repo"; var pageSize = 25; + var startTime = DateTime.Parse("2022-01-01T00:00:00Z"); var continuationToken = "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="; - var response = await fgaClient.ReadChanges(new ClientReadChangesRequest { Type = type }, new ClientReadChangesOptions { + var response = await fgaClient.ReadChanges(new ClientReadChangesRequest { Type = type, StartTime = startTime }, new ClientReadChangesOptions { PageSize = pageSize, ContinuationToken = continuationToken, }); diff --git a/config/clients/dotnet/template/README_calling_api.mustache b/config/clients/dotnet/template/README_calling_api.mustache index 5242aa97..193ad8f6 100644 --- a/config/clients/dotnet/template/README_calling_api.mustache +++ b/config/clients/dotnet/template/README_calling_api.mustache @@ -176,7 +176,8 @@ Reads the list of historical relationship tuple writes and deletes. [API Documentation]({{apiDocsUrl}}#/Relationship%20Tuples/ReadChanges) ```csharp -var body = new ClientReadChangesRequest { Type = "document" }; +var startTime = DateTime.Parse("2022-01-01T00:00:00Z"); +var body = new ClientReadChangesRequest { Type = "document", StartTime = startTime }; var options = new ClientReadChangesOptions { PageSize = 10, ContinuationToken = "...", diff --git a/config/clients/dotnet/template/api_test.mustache b/config/clients/dotnet/template/api_test.mustache index 1fce008f..501d8a09 100644 --- a/config/clients/dotnet/template/api_test.mustache +++ b/config/clients/dotnet/template/api_test.mustache @@ -1672,8 +1672,9 @@ namespace {{testPackageName}}.Api { var type = "repo"; var pageSize = 25; + var startTime = DateTime.Parse("2022-01-01T00:00:00Z"); var continuationToken = "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="; - var response = await {{appCamelCaseName}}Api.ReadChanges(_storeId, type, pageSize, continuationToken); + var response = await {{appCamelCaseName}}Api.ReadChanges(_storeId, type, pageSize, continuationToken, startTime); mockHandler.Protected().Verify( "SendAsync", diff --git a/config/clients/go/template/README_calling_api.mustache b/config/clients/go/template/README_calling_api.mustache index 888495cb..6a5553bb 100644 --- a/config/clients/go/template/README_calling_api.mustache +++ b/config/clients/go/template/README_calling_api.mustache @@ -211,6 +211,7 @@ options := ClientReadChangesOptions{ ContinuationToken: {{packageName}}.PtrString("eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="), // You can rely on the store id set in the configuration or override it for this specific request StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), + StartTime: {{packageName}}.PtrString("2022-01-01T00:00:00Z"), } data, err := fgaClient.ReadChanges(context.Background()).Body(body).Options(options).Execute() diff --git a/config/clients/go/template/api_test.mustache b/config/clients/go/template/api_test.mustache index 4c1ff708..07c7345b 100644 --- a/config/clients/go/template/api_test.mustache +++ b/config/clients/go/template/api_test.mustache @@ -7,6 +7,7 @@ import ( "fmt" "net/http" "testing" + "time" "github.com/jarcoal/httpmock" "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/credentials" @@ -789,9 +790,11 @@ func Test{{appShortName}}Api(t *testing.T) { return resp, nil }, ) + startTime, err := time.Parse(time.RFC3339, "2022-01-01T00:00:00Z") got, response, err := apiClient.{{appShortName}}Api.ReadChanges(context.Background(), "01GXSB9YR785C4FYS3C0RTG7B2"). Type_("repo"). PageSize(25). + StartTime(startTime). ContinuationToken("eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="). Execute() if err != nil { diff --git a/config/clients/go/template/client/client.mustache b/config/clients/go/template/client/client.mustache index 203ce42b..a12a9355 100644 --- a/config/clients/go/template/client/client.mustache +++ b/config/clients/go/template/client/client.mustache @@ -7,6 +7,7 @@ import ( "fmt" "math" _nethttp "net/http" + "time" fgaSdk "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}" "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/credentials" @@ -1125,6 +1126,7 @@ type SdkClientReadChangesRequestInterface interface { type ClientReadChangesRequest struct { Type string `json:"type,omitempty"` + StartTime time.Time `json:"start_time,omitempty"` } type ClientReadChangesOptions struct { diff --git a/config/clients/go/template/client/client_test.mustache b/config/clients/go/template/client/client_test.mustache index 6ffb1331..a9430fff 100644 --- a/config/clients/go/template/client/client_test.mustache +++ b/config/clients/go/template/client/client_test.mustache @@ -7,6 +7,7 @@ import ( "fmt" "net/http" "testing" + "time" "github.com/jarcoal/httpmock" "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}" @@ -1038,8 +1039,13 @@ func Test{{appShortName}}Client(t *testing.T) { return resp, nil }, ) + startTime, err := time.Parse(time.RFC3339,"2022-01-01T00:00:00Z") + if err != nil { + t.Fatalf("Failed to parse startTime: %v", err) + } body := ClientReadChangesRequest{ Type: "document", + StartTime: startTime, } options := ClientReadChangesOptions{ContinuationToken: {{packageName}}.PtrString("eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="), PageSize: {{packageName}}.PtrInt32(25)} got, err := fgaClient.ReadChanges(context.Background()).Body(body).Options(options).Execute() diff --git a/config/clients/java/template/OpenFgaApiIntegrationTest.java.mustache b/config/clients/java/template/OpenFgaApiIntegrationTest.java.mustache index 70a74bc8..87455cf6 100644 --- a/config/clients/java/template/OpenFgaApiIntegrationTest.java.mustache +++ b/config/clients/java/template/OpenFgaApiIntegrationTest.java.mustache @@ -272,7 +272,7 @@ public class OpenFgaApiIntegrationTest { // When api.write(storeId, writeRequest).get(); ReadChangesResponse response = - api.readChanges(storeId, null, null, null).get().getData(); + api.readChanges(storeId, null, null, null,null).get().getData(); // Then assertEquals(1, response.getChanges().size()); diff --git a/config/clients/java/template/OpenFgaApiTest.java.mustache b/config/clients/java/template/OpenFgaApiTest.java.mustache index 55c31a47..d0ad5f9f 100644 --- a/config/clients/java/template/OpenFgaApiTest.java.mustache +++ b/config/clients/java/template/OpenFgaApiTest.java.mustache @@ -18,6 +18,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; +import java.time.OffsetDateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -794,9 +795,10 @@ public class OpenFgaApiTest { String type = null; // Input is optional Integer pageSize = null; // Input is optional String continuationToken = null; // Input is optional + OffsetDateTime startTime = null; //Input is optional // When - var response = fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken) + var response = fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken, startTime) .get(); // Then @@ -814,7 +816,7 @@ public class OpenFgaApiTest { @Test public void readChanges_storeIdRequired() throws Exception { // When - var exception = assertThrows(FgaInvalidParameterException.class, () -> fga.readChanges(null, null, null, null) + var exception = assertThrows(FgaInvalidParameterException.class, () -> fga.readChanges(null, null, null, null, null) .get()); // Then @@ -831,10 +833,11 @@ public class OpenFgaApiTest { String type = null; // Input is optional Integer pageSize = null; // Input is optional String continuationToken = null; // Input is optional + OffsetDateTime startTime = null; // Input is optional // When ExecutionException execException = assertThrows( - ExecutionException.class, () -> fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken) + ExecutionException.class, () -> fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken, startTime) .get()); // Then @@ -856,10 +859,11 @@ public class OpenFgaApiTest { String type = null; // Input is optional Integer pageSize = null; // Input is optional String continuationToken = null; // Input is optional + OffsetDateTime startTime = null; // Input is optional // When ExecutionException execException = assertThrows( - ExecutionException.class, () -> fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken) + ExecutionException.class, () -> fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken, startTime) .get()); // Then @@ -880,10 +884,11 @@ public class OpenFgaApiTest { String type = null; // Input is optional Integer pageSize = null; // Input is optional String continuationToken = null; // Input is optional + OffsetDateTime startTime = null; // Input is optional // When ExecutionException execException = assertThrows( - ExecutionException.class, () -> fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken) + ExecutionException.class, () -> fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken, startTime) .get()); // Then diff --git a/config/clients/java/template/README_calling_api.mustache b/config/clients/java/template/README_calling_api.mustache index 8db43f19..22a28c96 100644 --- a/config/clients/java/template/README_calling_api.mustache +++ b/config/clients/java/template/README_calling_api.mustache @@ -193,7 +193,8 @@ Reads the list of historical relationship tuple writes and deletes. > Passing `ClientReadChangesOptions` is optional. All fields of `ClientReadChangesOptions` are optional. ```java -var request = new ClientReadChangesRequest().type("document"); +var startTime = OffsetDateTime.parse("2022-01-01T00:00:00+00:00"); +var request = new ClientReadChangesRequest().type("document").startTime(startTime); var options = new ClientReadChangesOptions() .additionalHeaders(Map.of("Some-Http-Header", "Some value")) .pageSize(10) diff --git a/config/clients/java/template/client-ClientReadChangesRequest.java.mustache b/config/clients/java/template/client-ClientReadChangesRequest.java.mustache index d0c7bb9a..be00cedb 100644 --- a/config/clients/java/template/client-ClientReadChangesRequest.java.mustache +++ b/config/clients/java/template/client-ClientReadChangesRequest.java.mustache @@ -1,15 +1,27 @@ {{>licenseInfo}} package {{clientPackage}}.model; +import java.time.OffsetDateTime; + public class ClientReadChangesRequest { private String type; + private OffsetDateTime startTime; public ClientReadChangesRequest type(String type) { this.type = type; return this; } + public ClientReadChangesRequest startTime(OffsetDateTime startTime) { + this.startTime = startTime; + return this; + } + public String getType() { return type; } + + public OffsetDateTime getStartTime(){ + return startTime; + } } diff --git a/config/clients/java/template/client-OpenFgaClient.java.mustache b/config/clients/java/template/client-OpenFgaClient.java.mustache index 164b9e53..c4001c95 100644 --- a/config/clients/java/template/client-OpenFgaClient.java.mustache +++ b/config/clients/java/template/client-OpenFgaClient.java.mustache @@ -283,7 +283,7 @@ public class OpenFgaClient { var options = readChangesOptions != null ? readChangesOptions : new ClientReadChangesOptions(); var overrides = new ConfigurationOverride().addHeaders(options); return call(() -> api.readChanges( - storeId, request.getType(), options.getPageSize(), options.getContinuationToken(), overrides)) + storeId, request.getType(), options.getPageSize(), options.getContinuationToken(), request.getStartTime(), overrides)) .thenApply(ClientReadChangesResponse::new); } diff --git a/config/clients/java/template/client-OpenFgaClientTest.java.mustache b/config/clients/java/template/client-OpenFgaClientTest.java.mustache index ab5f61aa..d5a98b85 100644 --- a/config/clients/java/template/client-OpenFgaClientTest.java.mustache +++ b/config/clients/java/template/client-OpenFgaClientTest.java.mustache @@ -16,6 +16,7 @@ import {{invokerPackage}}.*; import {{modelPackage}}.*; import java.net.http.HttpClient; import java.time.Duration; +import java.time.OffsetDateTime; import java.util.Collections; import java.util.List; import java.util.ArrayList; @@ -694,13 +695,14 @@ public class OpenFgaClientTest { public void readChanges() throws Exception { // Given String changeType = "repo"; + OffsetDateTime startTime = null; String user = "user:81684243-9356-4421-8fbf-a4f8d36aa31b"; String relation = "viewer"; String object = "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"; String continuationToken = "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ"; - ClientReadChangesRequest request = new ClientReadChangesRequest().type(changeType); + ClientReadChangesRequest request = new ClientReadChangesRequest().type(changeType).startTime(startTime); String getUrl = String.format("https://api.fga.example/stores/%s/changes?type=%s", DEFAULT_STORE_ID, changeType); String responseBody = String.format( diff --git a/config/clients/js/template/README_calling_api.mustache b/config/clients/js/template/README_calling_api.mustache index 3c6321a4..1ac6ff51 100644 --- a/config/clients/js/template/README_calling_api.mustache +++ b/config/clients/js/template/README_calling_api.mustache @@ -152,12 +152,13 @@ Reads the list of historical relationship tuple writes and deletes. ```javascript const type = 'document'; +const startTime = "2022-01-01T00:00:00Z" const options = { pageSize: 25, continuationToken: 'eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==', }; -const response = await fgaClient.readChanges({ type }, options); +const response = await fgaClient.readChanges({ type, startTime }, options); // response.continuation_token = ... // response.changes = [ diff --git a/config/clients/js/template/client.mustache b/config/clients/js/template/client.mustache index c22895be..4b50f674 100644 --- a/config/clients/js/template/client.mustache +++ b/config/clients/js/template/client.mustache @@ -170,6 +170,7 @@ export interface ClientListRelationsResponse { export interface ClientReadChangesRequest { type: string; + startTime?: string; } export type ClientExpandRequest = ExpandRequestTupleKey; @@ -379,13 +380,14 @@ export class {{appShortName}}Client extends BaseAPI { * @param {ClientRequestOpts & PaginationOptions} [options] * @param {number} [options.pageSize] * @param {string} [options.continuationToken] + * @param {string} [body.startTime] * @param {object} [options.headers] - Custom headers to send alongside the request * @param {object} [options.retryParams] - Override the retry parameters for this request * @param {number} [options.retryParams.maxRetry] - Override the max number of retries on each API request * @param {number} [options.retryParams.minWaitInMs] - Override the minimum wait before a retry is initiated */ async readChanges(body?: ClientReadChangesRequest, options: ClientRequestOptsWithStoreId & PaginationOptions = {}): PromiseResult { - return this.api.readChanges(this.getStoreId(options)!, body?.type, options.pageSize, options.continuationToken, options); + return this.api.readChanges(this.getStoreId(options)!, body?.type, options.pageSize, options.continuationToken, body?.startTime, options); } /** diff --git a/config/clients/js/template/tests/client.test.ts.mustache b/config/clients/js/template/tests/client.test.ts.mustache index 573edb47..a817bcd8 100644 --- a/config/clients/js/template/tests/client.test.ts.mustache +++ b/config/clients/js/template/tests/client.test.ts.mustache @@ -249,12 +249,13 @@ describe("{{appTitleCaseName}} Client", () => { it("should properly call the ReadChanges API", async () => { const type = "repo"; const pageSize = 25; + const startTime = "2022-01-01T00:00:00Z"; const continuationToken = "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="; - const scope = nocks.readChanges(baseConfig.storeId!, type, pageSize, continuationToken); + const scope = nocks.readChanges(baseConfig.storeId!, type, pageSize, continuationToken, startTime); expect(scope.isDone()).toBe(false); - const response = await fgaClient.readChanges({ type }, { pageSize, continuationToken }); + const response = await fgaClient.readChanges({ type, startTime }, { pageSize, continuationToken }); expect(scope.isDone()).toBe(true); expect(response).toMatchObject({ changes: expect.arrayContaining([]) }); @@ -263,8 +264,9 @@ describe("{{appTitleCaseName}} Client", () => { it("should properly call the ReadChanges API with no type", async () => { const pageSize = 25; const continuationToken = "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="; + const startTime = "2022-01-01T00:00:00Z"; - const scope = nocks.readChanges(baseConfig.storeId!, "", pageSize, continuationToken); + const scope = nocks.readChanges(baseConfig.storeId!, "", pageSize, continuationToken,""); expect(scope.isDone()).toBe(false); const response = await fgaClient.readChanges(undefined, { pageSize, continuationToken }); diff --git a/config/clients/js/template/tests/helpers/nocks.ts.mustache b/config/clients/js/template/tests/helpers/nocks.ts.mustache index 29662a65..dd3b4d35 100644 --- a/config/clients/js/template/tests/helpers/nocks.ts.mustache +++ b/config/clients/js/template/tests/helpers/nocks.ts.mustache @@ -132,13 +132,14 @@ export const getNocks = ((nock: typeof Nock) => ({ authorization_model: authorizationModel }); }, - readChanges: (storeId: string, type: string, pageSize: number, contToken: string, basePath = defaultConfiguration.getBasePath()) => { + readChanges: (storeId: string, type: string, pageSize: number, contToken: string, startTime: string, basePath = defaultConfiguration.getBasePath()) => { return nock(basePath) .get(`/stores/${storeId}/changes`) .query({ page_size: pageSize, continuation_token: contToken, - ...(type ? { type } : { }) + ...(type ? { type } : { }), + ...(startTime ? {start_time: startTime } :{}) }) .reply(200, { changes: [{ diff --git a/config/clients/js/template/tests/index.test.ts.mustache b/config/clients/js/template/tests/index.test.ts.mustache index 1d9687a7..24423419 100644 --- a/config/clients/js/template/tests/index.test.ts.mustache +++ b/config/clients/js/template/tests/index.test.ts.mustache @@ -801,11 +801,12 @@ describe("{{appTitleCaseName}} SDK", function () { const type = "repo"; const pageSize = 25; const continuationToken = "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="; + const startTime = "2022-01-01T00:00:00Z"; - const scope = nocks.readChanges(baseConfig.storeId!, type, pageSize, continuationToken); + const scope = nocks.readChanges(baseConfig.storeId!, type, pageSize, continuationToken, startTime); expect(scope.isDone()).toBe(false); - const response = await fgaApi.readChanges(baseConfig.storeId!, type, pageSize, continuationToken); + const response = await fgaApi.readChanges(baseConfig.storeId!, type, pageSize, continuationToken, startTime); expect(scope.isDone()).toBe(true); expect(response).toMatchObject({ changes: expect.arrayContaining([]) }); diff --git a/config/clients/python/template/README_calling_api.mustache b/config/clients/python/template/README_calling_api.mustache index 7ba7842f..4d4a580a 100644 --- a/config/clients/python/template/README_calling_api.mustache +++ b/config/clients/python/template/README_calling_api.mustache @@ -247,7 +247,7 @@ options = { "page_size": "25", "continuation_token": "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==" } -body = ClientReadChangesRequest(type="document") +body = ClientReadChangesRequest(type="document", start_time="2022-01-01T00:00:00Z") response = await fga_client.read_changes(body, options) # response.continuation_token = ... diff --git a/config/clients/python/template/src/client/client.py.mustache b/config/clients/python/template/src/client/client.py.mustache index e2daf869..b79f9f11 100644 --- a/config/clients/python/template/src/client/client.py.mustache +++ b/config/clients/python/template/src/client/client.py.mustache @@ -323,6 +323,7 @@ class OpenFgaClient: """ kwargs = options_to_kwargs(options) kwargs["type"] = body.type + kwargs["start_time"] = body.start_time api_response = {{#asyncio}}await {{/asyncio}}self._api.read_changes( **kwargs, ) diff --git a/config/clients/python/template/src/client/models/read_changes_request.py.mustache b/config/clients/python/template/src/client/models/read_changes_request.py.mustache index 63a81bcb..5aafb89a 100644 --- a/config/clients/python/template/src/client/models/read_changes_request.py.mustache +++ b/config/clients/python/template/src/client/models/read_changes_request.py.mustache @@ -5,8 +5,9 @@ class ClientReadChangesRequest: ClientReadChangesRequest encapsulates the parameters required to read changes """ - def __init__(self, type: str): + def __init__(self, type: str, start_time: str=None): self._type = type + self._startTime = start_time @property def type(self): @@ -14,3 +15,10 @@ class ClientReadChangesRequest: Return type """ return self._type + + @property + def start_time(self): + """ + Return startTime + """ + return self._startTime diff --git a/config/clients/python/template/src/sync/client/client.py.mustache b/config/clients/python/template/src/sync/client/client.py.mustache index e8ae0fcd..13df11be 100644 --- a/config/clients/python/template/src/sync/client/client.py.mustache +++ b/config/clients/python/template/src/sync/client/client.py.mustache @@ -309,6 +309,7 @@ class OpenFgaClient: """ kwargs = options_to_kwargs(options) kwargs["type"] = body.type + kwargs["start_time"] = body.start_time api_response = self._api.read_changes( **kwargs, ) diff --git a/config/clients/python/template/test/api_test.py.mustache b/config/clients/python/template/test/api_test.py.mustache index 3fcd3023..a09728da 100644 --- a/config/clients/python/template/test/api_test.py.mustache +++ b/config/clients/python/template/test/api_test.py.mustache @@ -718,10 +718,12 @@ class {{#operations}}Test{{classname}}(IsolatedAsyncioTestCase): # Create an instance of the API class api_instance = open_fga_api.OpenFgaApi(api_client) + # Return a particular version of an authorization model api_response = {{#asyncio}}await {{/asyncio}}api_instance.read_changes( page_size=1, continuation_token="abcdefg", + start_time="2022-01-01T00:00:00+00:00", type="document" ) self.assertIsInstance(api_response, ReadChangesResponse) @@ -737,7 +739,7 @@ class {{#operations}}Test{{classname}}(IsolatedAsyncioTestCase): 'GET', 'http://api.{{sampleApiDomain}}/stores/01H0H015178Y2V4CX10C2KGHF4/changes', headers=ANY, - query_params=[('type', 'document'), ('page_size', 1), ('continuation_token', 'abcdefg') ], + query_params=[('type', 'document'), ('page_size', 1), ('continuation_token', 'abcdefg'), ('start_time', '2022-01-01T00:00:00+00:00') ], _preload_content=ANY, _request_timeout=None ) diff --git a/config/clients/python/template/test/client/client_test.py.mustache b/config/clients/python/template/test/client/client_test.py.mustache index 31a70aca..c6633b64 100644 --- a/config/clients/python/template/test/client/client_test.py.mustache +++ b/config/clients/python/template/test/client/client_test.py.mustache @@ -624,7 +624,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Return a particular version of an authorization model api_response = {{#asyncio}}await {{/asyncio}}api_client.read_changes( - ClientReadChangesRequest("document"), + ClientReadChangesRequest("document","2022-01-01T00:00:00+00:00"), options={"page_size":1, "continuation_token":"abcdefg"} ) @@ -643,7 +643,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes', headers=ANY, query_params=[('type', 'document'), ('page_size', 1), - ('continuation_token', 'abcdefg')], + ('continuation_token', 'abcdefg'), ('start_time', '2022-01-01T00:00:00+00:00')], _preload_content=ANY, _request_timeout=None ) diff --git a/config/clients/python/template/test/sync/api_test.py.mustache b/config/clients/python/template/test/sync/api_test.py.mustache index 5f1616bd..750f49ee 100644 --- a/config/clients/python/template/test/sync/api_test.py.mustache +++ b/config/clients/python/template/test/sync/api_test.py.mustache @@ -728,6 +728,7 @@ class TestOpenFgaApiSync(IsolatedAsyncioTestCase): api_response = api_instance.read_changes( page_size=1, continuation_token="abcdefg", + start_time="2022-01-01T00:00:00+00:00", type="document" ) self.assertIsInstance(api_response, ReadChangesResponse) @@ -743,7 +744,7 @@ class TestOpenFgaApiSync(IsolatedAsyncioTestCase): 'GET', 'http://api.{{sampleApiDomain}}/stores/01H0H015178Y2V4CX10C2KGHF4/changes', headers=ANY, - query_params=[('type', 'document'), ('page_size', 1), ('continuation_token', 'abcdefg') ], + query_params=[('type', 'document'), ('page_size', 1), ('continuation_token', 'abcdefg'), ('start_time', '2022-01-01T00:00:00+00:00')], _preload_content=ANY, _request_timeout=None ) diff --git a/config/clients/python/template/test/sync/client/client_test.py.mustache b/config/clients/python/template/test/sync/client/client_test.py.mustache index 2402bfcf..a8aa2f3e 100644 --- a/config/clients/python/template/test/sync/client/client_test.py.mustache +++ b/config/clients/python/template/test/sync/client/client_test.py.mustache @@ -622,7 +622,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Return a particular version of an authorization model api_response = api_client.read_changes( - ClientReadChangesRequest("document"), + ClientReadChangesRequest("document","2022-01-01T00:00:00+00:00"), options={"page_size":1, "continuation_token":"abcdefg"} ) @@ -641,7 +641,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes', headers=ANY, query_params=[('type', 'document'), ('page_size', 1), - ('continuation_token', 'abcdefg')], + ('continuation_token', 'abcdefg'), ('start_time', '2022-01-01T00:00:00+00:00')], _preload_content=ANY, _request_timeout=None )