From a27a6d45f69f241ffafb0ff0b6e67f0aaa66befb Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Fri, 9 Jan 2026 20:45:26 +0530 Subject: [PATCH 1/2] Revert "chore: make streamed list objects client methods private (#264)" This reverts commit 944ecd803141b5793d0e6f85e0278bddae58daa0. --- README.md | 46 +++++++++++++++++++++++++++ client/client.go | 19 +++++++++-- client/streaming_test.go | 12 +++---- example/streamed_list_objects/main.go | 11 ------- 4 files changed, 68 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 372830b..7b14c95 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ This is an autogenerated Go SDK for OpenFGA. It provides a wrapper around the [O - [Batch Check](#batch-check) - [Expand](#expand) - [List Objects](#list-objects) + - [Streamed List Objects](#streamed-list-objects) - [List Relations](#list-relations) - [List Users](#list-users) - [Assertions](#assertions) @@ -912,6 +913,51 @@ data, err := fgaClient.ListObjects(context.Background()). // data.Objects = ["document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"] ``` + +##### Streamed List Objects + +List objects of a particular type that the user has access to, using the streaming API. + +The Streamed ListObjects API is very similar to the ListObjects API, with two key differences: +1. **Streaming Results**: Instead of collecting all objects before returning a response, it streams them to the client as they are collected. +2. **No Pagination Limit**: Returns all results without the 1000-object limit of the standard ListObjects API. + +This is particularly useful when querying **computed relations** that may return large result sets. + +[API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/StreamedListObjects) + +```golang +options := ClientStreamedListObjectsOptions{ + // You can rely on the model id set in the configuration or override it for this specific request + AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"), +} + +body := ClientStreamedListObjectsRequest{ + User: "user:anne", + Relation: "can_read", + Type: "document", +} + +response, err := fgaClient.StreamedListObjects(context.Background()).Body(body).Options(options).Execute() +if err != nil { + // .. Handle error +} +defer response.Close() + +// Consume objects from the stream +var objects []string +for obj := range response.Objects { + objects = append(objects, obj.Object) +} + +// Check for any errors during streaming +if err := <-response.Errors; err != nil { + // .. Handle streaming error +} + +// objects = ["document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"] +``` + #### List Relations List the relations a user has on an object. diff --git a/client/client.go b/client/client.go index dac9341..aa5ad2e 100644 --- a/client/client.go +++ b/client/client.go @@ -439,6 +439,19 @@ type SdkClient interface { */ ListUsersExecute(r SdkClientListUsersRequestInterface) (*ClientListUsersResponse, error) + /* + * StreamedListObjects Stream all objects of the given type that the user has a relation with + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return SdkClientStreamedListObjectsRequestInterface + */ + StreamedListObjects(ctx _context.Context) SdkClientStreamedListObjectsRequestInterface + + /* + * StreamedListObjectsExecute executes the StreamedListObjects request and returns a channel + * @return *ClientStreamedListObjectsResponse + */ + StreamedListObjectsExecute(request SdkClientStreamedListObjectsRequestInterface) (*ClientStreamedListObjectsResponse, error) + /* Assertions */ /* @@ -3340,7 +3353,7 @@ func (r *ClientStreamedListObjectsResponse) Close() { } } -func (client *OpenFgaClient) streamedListObjects(ctx _context.Context) SdkClientStreamedListObjectsRequestInterface { +func (client *OpenFgaClient) StreamedListObjects(ctx _context.Context) SdkClientStreamedListObjectsRequestInterface { return &SdkClientStreamedListObjectsRequest{ Client: client, ctx: ctx, @@ -3372,7 +3385,7 @@ func (request *SdkClientStreamedListObjectsRequest) Body(body ClientStreamedList } func (request *SdkClientStreamedListObjectsRequest) Execute() (*ClientStreamedListObjectsResponse, error) { - return request.Client.streamedListObjectsExecute(request) + return request.Client.StreamedListObjectsExecute(request) } func (request *SdkClientStreamedListObjectsRequest) GetContext() _context.Context { @@ -3387,7 +3400,7 @@ func (request *SdkClientStreamedListObjectsRequest) GetOptions() *ClientStreamed return request.options } -func (client *OpenFgaClient) streamedListObjectsExecute(request SdkClientStreamedListObjectsRequestInterface) (*ClientStreamedListObjectsResponse, error) { +func (client *OpenFgaClient) StreamedListObjectsExecute(request SdkClientStreamedListObjectsRequestInterface) (*ClientStreamedListObjectsResponse, error) { if request.GetBody() == nil { return nil, FgaRequiredParamError{param: "body"} } diff --git a/client/streaming_test.go b/client/streaming_test.go index b0a7e1a..d687742 100644 --- a/client/streaming_test.go +++ b/client/streaming_test.go @@ -56,7 +56,7 @@ func TestClientStreamedListObjects_Success(t *testing.T) { ctx := context.Background() - response, err := client.streamedListObjects(ctx). + response, err := client.StreamedListObjects(ctx). Body(ClientStreamedListObjectsRequest{ Type: "document", Relation: "viewer", @@ -115,7 +115,7 @@ func TestClientStreamedListObjects_WithOptions(t *testing.T) { ctx := context.Background() consistency := openfga.CONSISTENCYPREFERENCE_HIGHER_CONSISTENCY - response, err := client.streamedListObjects(ctx). + response, err := client.StreamedListObjects(ctx). Body(ClientStreamedListObjectsRequest{ Type: "document", Relation: "viewer", @@ -162,7 +162,7 @@ func TestClientStreamedListObjects_ErrorHandling(t *testing.T) { ctx := context.Background() - _, err = client.streamedListObjects(ctx). + _, err = client.StreamedListObjects(ctx). Body(ClientStreamedListObjectsRequest{ Type: "document", Relation: "viewer", @@ -187,7 +187,7 @@ func TestClientStreamedListObjects_NoStoreId(t *testing.T) { ctx := context.Background() - _, err = client.streamedListObjects(ctx). + _, err = client.StreamedListObjects(ctx). Body(ClientStreamedListObjectsRequest{ Type: "document", Relation: "viewer", @@ -230,7 +230,7 @@ func TestClientStreamedListObjects_CustomBufferSize(t *testing.T) { ctx := context.Background() customBufferSize := 50 - response, err := client.streamedListObjects(ctx). + response, err := client.StreamedListObjects(ctx). Body(ClientStreamedListObjectsRequest{ Type: "document", Relation: "viewer", @@ -297,7 +297,7 @@ func TestClientStreamedListObjects_DefaultBufferSize(t *testing.T) { ctx := context.Background() zeroBufferSize := 0 - response, err := client.streamedListObjects(ctx). + response, err := client.StreamedListObjects(ctx). Body(ClientStreamedListObjectsRequest{ Type: "document", Relation: "viewer", diff --git a/example/streamed_list_objects/main.go b/example/streamed_list_objects/main.go index d701789..fe19dba 100644 --- a/example/streamed_list_objects/main.go +++ b/example/streamed_list_objects/main.go @@ -1,15 +1,5 @@ -// NOTE: This example is currently commented out because streamedListObjects is not publicly accessible -// in the client layer. It may be made public in a future release. - package main -func main() { - // Example temporarily disabled - streamedListObjects is not publicly accessible -} - -/* -// Original example code (commented out): - import ( "context" "encoding/json" @@ -209,4 +199,3 @@ func handleError(err error) { } os.Exit(1) } -*/ From b7ad623226e82d9e37b0d4cdc908bef5306296ce Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Fri, 9 Jan 2026 21:01:44 +0530 Subject: [PATCH 2/2] feat: add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cd287e..dfc57d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - feat: add generic `ToPtr[T any](v T) *T` function for creating pointers to any type - deprecation: `PtrBool`, `PtrInt`, `PtrInt32`, `PtrInt64`, `PtrFloat32`, `PtrFloat64`, `PtrString`, and `PtrTime` are now deprecated in favor of the generic `ToPtr` function - chore: add a top-level makefile in go-sdk to simplify running tests and linters: (#250) +- feat: add support for StreamedListObjects endpoint (#271) ## v0.7.3