From ec283f7c4b7f104d0557fc9cb910d66c9a6dbd6a Mon Sep 17 00:00:00 2001 From: Sohan <1119120+sohanmaheshwar@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:30:37 +0100 Subject: [PATCH] Update example.js Added a code snippet for the LookupResources API --- examples/v1/example.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/examples/v1/example.js b/examples/v1/example.js index 8008d34..6f3d08a 100644 --- a/examples/v1/example.js +++ b/examples/v1/example.js @@ -1,4 +1,5 @@ import { v1 } from '@authzed/authzed-node'; +const { promises: promiseClient } = client; // access client.promises // set up it on localhost like this: // const client = v1.NewClient('mytokenhere', 'localhost:50051', 1); const client = v1.NewClient('mytokenhere'); @@ -82,3 +83,26 @@ console.log( checkResult.permissionship === v1.CheckPermissionResponse_Permissionship.HAS_PERMISSION ); + +// Lookup Resources + +const lookupResourcesRequest = v1.LookupResourcesRequest.create({ + consistency: v1.Consistency.create({ + requirement: { + oneofKind: 'fullyConsistent', + fullyConsistent: true, + }, + }), + resourceObjectType: 'test/document', + permission: 'view', + subject: v1.SubjectReference.create({ + object: v1.ObjectReference.create({ + objectType: 'test/user', + objectId: 'fred', + }), + }), +}); + +const results = await promiseClient.lookupResources(lookupResourcesRequest) + +console.log(results);