Skip to content

Commit edac180

Browse files
Update src/components/Docs/SnippetViewer/StreamedListObjectsRequestViewer.tsx
Co-authored-by: Raghd Hamzeh <raghd.hamzeh@openfga.dev>
1 parent 0f0727f commit edac180

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

src/components/Docs/SnippetViewer/StreamedListObjectsRequestViewer.tsx

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,37 @@ function streamedListObjectsRequestViewer(
2323
case SupportedLanguage.CLI:
2424
return `# Note: Streamed List Objects is not currently supported in the CLI`;
2525
case SupportedLanguage.CURL:
26-
return `# Note: Streamed List Objects requires handling NDJSON streams
27-
# For curl examples, see the API documentation`;
26+
return `curl -X POST $FGA_API_URL/stores/$FGA_STORE_ID/streamed-list-objects \\
27+
-H "Authorization: Bearer $FGA_API_TOKEN" \\ # Not needed if service does not require authorization
28+
-H "content-type: application/json" \\
29+
-d '{
30+
"authorization_model_id": "${modelId}",
31+
"type": "${objectType}",
32+
"relation": "${relation}",
33+
"user":"${user}"${
34+
contextualTuples
35+
? `,
36+
"contextual_tuples": {
37+
"tuple_keys": [${contextualTuples
38+
.map(
39+
(tuple) => `
40+
{"object": "${tuple.object}", "relation": "${tuple.relation}", "user": "${tuple.user}"}`,
41+
)
42+
.join(',')}
43+
]
44+
}`
45+
: ''
46+
}${
47+
context
48+
? `,
49+
"context":${JSON.stringify(context)}`
50+
: ''
51+
}
52+
}'
53+
54+
55+
# Response:
56+
${expectedResults.map((r) => `{"result":{"object":"${r}"}}`).join('\n')}`
2857
case SupportedLanguage.JS_SDK:
2958
return `const objects = [];
3059
for await (const response of fgaClient.streamedListObjects(

0 commit comments

Comments
 (0)