Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: order and content of curl rebac api calls #333

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 73 additions & 66 deletions docs/api/rebac/rebac-api-calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,25 @@ https://api.permit.io/v2/schema/{proj_id}/{env_id}/resources/{resource_id}/roles
<TabItem value="curl" label="cURL">

```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"]
}'
```

</TabItem>
<TabItem value="nodejs" label="Node.js">

```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"],
});
```

Expand All @@ -83,6 +61,21 @@ https://api.permit.io/v2/schema/{proj_id}/{env_id}/resources/{resource_id}/relat
### Example

<Tabs groupId="language">
<TabItem value="curl" label="cURL">

```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"
}'
```

</TabItem>
<TabItem value="python" label="Python">

```python
Expand All @@ -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",
});
```

Expand All @@ -121,14 +114,28 @@ https://api.permit.io/v2/facts/{proj_id}/{env_id}/resource_instances
### Example

<Tabs groupId="language">
<TabItem value="curl" label="cURL"></TabItem>
<TabItem value="curl" label="cURL">

```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"
}'
```

</TabItem>
<TabItem value="nodejs" label="Node.js">

```javascript
await permit.api.resourceInstances.create({
resource: "file",
key: "2023_report",
tenant: "default",
resource: "file",
key: "2023_report",
tenant: "default",
});
```

Expand All @@ -145,14 +152,14 @@ await permit.api.resourceInstances.create({
<TabItem value="curl" label="cURL">

```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": "[email protected]",
"role": "viewer",
"resource_instance": "file:2023_report"
}'
```

Expand All @@ -161,9 +168,9 @@ curl https://api.permit.io/v2/facts/$permit_project/$permit_env/resource_instanc

```javascript
await permit.api.roleAssignments.assign({
user: "[email protected]",
role: "viewer",
resource_instance: "file:2023_report",
user: "[email protected]",
role: "viewer",
resource_instance: "file:2023_report",
});
```

Expand All @@ -184,25 +191,25 @@ https://api.permit.io/v2/facts/{proj_id}/{env_id}/relationship_tuples
<TabItem value="curl" label="cURL">

```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": "[email protected]",
"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"
}'
```

</TabItem>
<TabItem value="nodejs" label="Node.js">

```javascript
await permit.api.relationshipTuples.create({
subject: "folder:finance",
relation: "parent",
object: "file:2023_report",
subject: "folder:finance",
relation: "parent",
object: "file:2023_report",
});
```

Expand Down Expand Up @@ -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",
},
],
},
});
```

Expand Down