From c8b312ebdae0fff5d08009ccd1f1299cf54e9a66 Mon Sep 17 00:00:00 2001 From: Magnus Jensen Date: Thu, 25 Apr 2024 13:32:01 +0200 Subject: [PATCH 1/4] fix: order and content of curl rebac api calls --- docs/api/rebac/rebac-api-calls.mdx | 139 +++++++++++++++-------------- 1 file changed, 73 insertions(+), 66 deletions(-) diff --git a/docs/api/rebac/rebac-api-calls.mdx b/docs/api/rebac/rebac-api-calls.mdx index 8e1207d1..0e2e5c24 100644 --- a/docs/api/rebac/rebac-api-calls.mdx +++ b/docs/api/rebac/rebac-api-calls.mdx @@ -25,25 +25,14 @@ https://api.permit.io/v2/schema/{proj_id}/{env_id}/resources/{resource_id}/roles ```bash -curl https://api.permit.io/v2/schema/$permit_project/$permit_env/resources/folder/roles/editor \ - -X PATCH \ +curl https://api.permit.io/v2/schema/$permit_project/$permit_env/resources/repo/roles \ + -X POST \ -H "Authorization: Bearer $permit_sdk_api_key" \ -H "Content-Type: application/json" \ -d '{ - "granted_to": { - "users_with_role": [ - { - "linked_by_relation": "account", - "on_resource": "account", - "role": "admin" - }, - { - "linked_by_relation": "parent", - "on_resource": "folder", - "role": "editor" - } - ] - } + "key": "maintainer", + "name": "Maintainer", + "permissions": ["read", "write"] }' ``` @@ -51,21 +40,10 @@ curl https://api.permit.io/v2/schema/$permit_project/$permit_env/resources/folde ```javascript -await permit.api.resourceRoles.update("folder", "editor", { - granted_to: { - users_with_role: [ - { - linked_by_relation: "account", - on_resource: "account", - role: "admin", - }, - { - linked_by_relation: "parent", - on_resource: "folder", - role: "editor", - }, - ], - }, +await permit.api.resourceRoles.create("repo", { + key: "maintainer", + name: "Maintainer", + permissions: ["read", "write"], }); ``` @@ -83,6 +61,21 @@ https://api.permit.io/v2/schema/{proj_id}/{env_id}/resources/{resource_id}/relat ### Example + + +```bash +curl https://api.permit.io/v2/schema/$permit_project/$permit_env/resources/file/relations \ + -X POST \ + -H "Authorization: Bearer $permit_sdk_api_key" \ + -H "Content-Type: application/json" \ + -d '{ + "key": "parent", + "name": "Parent", + "subject_resource": "folder" + }' +``` + + ```python @@ -101,9 +94,9 @@ await permit.api.resource_relations.create( ```javascript await permit.api.resourceRelations.create("file", { - key: "parent", - name: "Parent", - subject_resource: "folder", + key: "parent", + name: "Parent", + subject_resource: "folder", }); ``` @@ -121,14 +114,28 @@ https://api.permit.io/v2/facts/{proj_id}/{env_id}/resource_instances ### Example - + + +```bash +curl https://api.permit.io/v2/facts/$permit_project/$permit_env/resource_instances \ +-X POST \ +-H "Authorization: Bearer $permit_sdk_api_key" \ +-H "Content-Type: application/json" \ +-d '{ + "resource": "file", + "key": "2023_report", + "tenant": "default" +}' +``` + + ```javascript await permit.api.resourceInstances.create({ - resource: "file", - key: "2023_report", - tenant: "default", + resource: "file", + key: "2023_report", + tenant: "default", }); ``` @@ -145,14 +152,14 @@ await permit.api.resourceInstances.create({ ```bash -curl https://api.permit.io/v2/facts/$permit_project/$permit_env/resource_instances \ +curl https://api.permit.io/v2/facts/$permit_project/$permit_env/role_assignments \ -X POST \ -H "Authorization: Bearer $permit_sdk_api_key" \ -H "Content-Type: application/json" \ -d '{ - "resource": "file", - "key": "2023_report", - "tenant": "default" + "user": "john@acme.com", + "role": "viewer", + "resource_instance": "file:2023_report" }' ``` @@ -161,9 +168,9 @@ curl https://api.permit.io/v2/facts/$permit_project/$permit_env/resource_instanc ```javascript await permit.api.roleAssignments.assign({ - user: "john@acme.com", - role: "viewer", - resource_instance: "file:2023_report", + user: "john@acme.com", + role: "viewer", + resource_instance: "file:2023_report", }); ``` @@ -184,15 +191,15 @@ https://api.permit.io/v2/facts/{proj_id}/{env_id}/relationship_tuples ```bash -curl https://api.permit.io/v2/facts/$permit_project/$permit_env/role_assignments \ - -X POST \ - -H "Authorization: Bearer $permit_sdk_api_key" \ - -H "Content-Type: application/json" \ - -d '{ - "user": "john@acme.com", - "role": "viewer", - "resource_instance": "file:2023_report" - }' +curl https://api.permit.io/v2/facts/$permit_project/$permit_env/relationship_tuples \ +-X POST \ +-H "Authorization: Bearer $permit_sdk_api_key" \ +-H "Content-Type: application/json" \ +-d '{ + "subject": "folder:finance", + "relation": "parent", + "object": "file:2023_report" +}' ``` @@ -200,9 +207,9 @@ curl https://api.permit.io/v2/facts/$permit_project/$permit_env/role_assignments ```javascript await permit.api.relationshipTuples.create({ - subject: "folder:finance", - relation: "parent", - object: "file:2023_report", + subject: "folder:finance", + relation: "parent", + object: "file:2023_report", }); ``` @@ -245,15 +252,15 @@ curl https://api.permit.io/v2/schema/$permit_project/$permit_env/resources/file/ ```javascript await permit.api.resourceRoles.update("file", "editor", { - granted_to: { - users_with_role: [ - { - linked_by_relation: "parent", - on_resource: "folder", - role: "editor", - }, - ], - }, + granted_to: { + users_with_role: [ + { + linked_by_relation: "parent", + on_resource: "folder", + role: "editor", + }, + ], + }, }); ``` From a64e9d48ad7baf2626895037f25769a9e2940a39 Mon Sep 17 00:00:00 2001 From: Zeev Manilovich Date: Sun, 25 Jan 2026 21:19:45 +0200 Subject: [PATCH 2/4] Update docs/api/rebac/rebac-api-calls.mdx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docs/api/rebac/rebac-api-calls.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api/rebac/rebac-api-calls.mdx b/docs/api/rebac/rebac-api-calls.mdx index 0e2e5c24..a97be04a 100644 --- a/docs/api/rebac/rebac-api-calls.mdx +++ b/docs/api/rebac/rebac-api-calls.mdx @@ -192,10 +192,10 @@ https://api.permit.io/v2/facts/{proj_id}/{env_id}/relationship_tuples ```bash curl https://api.permit.io/v2/facts/$permit_project/$permit_env/relationship_tuples \ --X POST \ --H "Authorization: Bearer $permit_sdk_api_key" \ --H "Content-Type: application/json" \ --d '{ + -X POST \ + -H "Authorization: Bearer $permit_sdk_api_key" \ + -H "Content-Type: application/json" \ + -d '{ "subject": "folder:finance", "relation": "parent", "object": "file:2023_report" From f3cd77fccd16f253ade7a62da50faa649e924d22 Mon Sep 17 00:00:00 2001 From: Zeev Manilovich Date: Sun, 25 Jan 2026 21:21:11 +0200 Subject: [PATCH 3/4] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docs/api/rebac/rebac-api-calls.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api/rebac/rebac-api-calls.mdx b/docs/api/rebac/rebac-api-calls.mdx index a97be04a..9072de2e 100644 --- a/docs/api/rebac/rebac-api-calls.mdx +++ b/docs/api/rebac/rebac-api-calls.mdx @@ -118,10 +118,10 @@ https://api.permit.io/v2/facts/{proj_id}/{env_id}/resource_instances ```bash curl https://api.permit.io/v2/facts/$permit_project/$permit_env/resource_instances \ --X POST \ --H "Authorization: Bearer $permit_sdk_api_key" \ --H "Content-Type: application/json" \ --d '{ + -X POST \ + -H "Authorization: Bearer $permit_sdk_api_key" \ + -H "Content-Type: application/json" \ + -d '{ "resource": "file", "key": "2023_report", "tenant": "default" From d34f371f6bce28c401038ae0898da49e64ee006d Mon Sep 17 00:00:00 2001 From: Zeev Manilovich Date: Sun, 25 Jan 2026 21:21:44 +0200 Subject: [PATCH 4/4] Apply suggestions from code review --- docs/api/rebac/rebac-api-calls.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/rebac/rebac-api-calls.mdx b/docs/api/rebac/rebac-api-calls.mdx index 9072de2e..2a297a2b 100644 --- a/docs/api/rebac/rebac-api-calls.mdx +++ b/docs/api/rebac/rebac-api-calls.mdx @@ -125,7 +125,7 @@ curl https://api.permit.io/v2/facts/$permit_project/$permit_env/resource_instanc "resource": "file", "key": "2023_report", "tenant": "default" -}' + }' ```