Skip to content

Commit

Permalink
refactor: fix response output and correct sentences to fit list users
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris committed May 7, 2024
1 parent c2e1e91 commit c446273
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
14 changes: 5 additions & 9 deletions docs/content/getting-started/perform-list-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ To obtain the [access token](https://auth0.com/docs/get-started/authentication-a
</TabItem>
</Tabs>

### 02. Calling List Objects API
### 02. Calling List Users API

To return all documents that user `user:anne` has relationship `reader` with:
To return all users of type `users` that have have the `reader` relationship with `document:planning`:

<ListUsersRequestViewer
authorizationModelId="01HVMMBCMGZNT3SED4Z17ECXCA"
Expand All @@ -155,8 +155,8 @@ To return all documents that user `user:anne` has relationship `reader` with:
relation="reader"
userFilterType="user"
expectedResults={{
users: [{ object: { type: "user:anne" } }],
excluded_users: [{ object: { type: "user:beth" } }]
users: [{ object: { type: "user:anne" } }, { object: { type: "user:beth" } }],
excluded_users: []
}}
skipSetup={true}
allowedLanguages={[
Expand All @@ -170,11 +170,7 @@ To return all documents that user `user:anne` has relationship `reader` with:
]}
/>

The result `document:otherdoc` and `document:planning` are the document objects that `user:anne` has `reader` relationship with.

:::caution Warning
The performance characteristics of the ListUsers endpoint vary drastically depending on the model complexity, number of tuples, and the relations it needs to evaluate. Relations with 'and' or 'but not' are more expensive to evaluate than relations with 'or'.
:::
The result `user:anne` and `user:beth` are the `user` objects that have the `reader` relationship with `document:planning`.

## Related Sections

Expand Down
10 changes: 5 additions & 5 deletions src/components/Docs/SnippetViewer/ListUsersRequestViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function listUsersRequestViewer(lang: SupportedLanguage, opts: ListUsersRequestV
} = opts;
const modelId = opts.authorizationModelId ? opts.authorizationModelId : DefaultAuthorizationModelId;

const response = `{"users": [${expectedResults.users.map((r) => JSON.stringify(r)).join(', ')}],"excluded_users":[${expectedResults.users.map((r) => JSON.stringify(r)).join(', ')}]}`;
const response = `{"users": [${expectedResults.users.map((r) => JSON.stringify(r)).join(', ')}],"excluded_users":[${expectedResults.excluded_users.map((r) => JSON.stringify(r)).join(', ')}]}`;

switch (lang) {
case SupportedLanguage.PLAYGROUND:
Expand Down Expand Up @@ -130,8 +130,8 @@ function listUsersRequestViewer(lang: SupportedLanguage, opts: ListUsersRequestV
}, {
authorization_model_id: "${modelId}",
});
// response.getUsers() = ${expectedResults.users.map((u) => JSON.stringify(u)).join(',')}
// response.getExcludedUsers() = ${expectedResults.excluded_users.map((u) => JSON.stringify(u)).join(',')}`;
// response.getUsers() = [${expectedResults.users.map((u) => JSON.stringify(u)).join(',')}]
// response.getExcludedUsers() = p${expectedResults.excluded_users.map((u) => JSON.stringify(u)).join(',')}]`;
case SupportedLanguage.GO_SDK:
/* eslint-disable no-tabs */
return `options := ClientListUsersOptions{
Expand Down Expand Up @@ -179,8 +179,8 @@ data, err := fgaClient.ListUsers(context.Background()).
Options(options).
Execute()
// data.Users = [{ "objects": [${expectedResults.users.map((u) => JSON.stringify(u)).join(', ')}] }]
// data.ExcludedUsers = [{ "objects": [${expectedResults.excluded_users.map((u) => JSON.stringify(u)).join(', ')}] }]`;
// data.Users = [${expectedResults.users.map((u) => JSON.stringify(u)).join(', ')}]
// data.ExcludedUsers = [${expectedResults.excluded_users.map((u) => JSON.stringify(u)).join(', ')}]`;
case SupportedLanguage.DOTNET_SDK:
return `
var options = new ClientWriteOptions {
Expand Down

0 comments on commit c446273

Please sign in to comment.