Skip to content

Commit

Permalink
Merge pull request #919 from Permify/docs
Browse files Browse the repository at this point in the history
docs: udpate bundle service sections content
  • Loading branch information
EgeAytin authored Dec 4, 2023
2 parents 53b26f1 + 5710304 commit 8f90820
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/docs/api-overview/bundle/write-bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The "Write Bundle" API is designed for handling data in a multi-tenant applicati
|----------|----------|---------|---------|-------------------------------------------------------------------------------------------|
| [x] | tenant_id | string | identifier of the tenant, if you are not using multi-tenancy (have only one tenant) use pre-inserted tenant `t1` for this field. |
| [x] | name | string | unique name identifying the bundle. |
| [x] | operations | object | Represent actions that can be performed on data, such as adding or deleting relationships or attributes when certain events occur. |
| [x] | arguments | string[] | Parameters that will be used in the operations |

<Tabs>
<TabItem value="go" label="Go">
Expand Down
76 changes: 76 additions & 0 deletions docs/docs/data-bundles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
id: bundle
title: Bundle Service
sidebar_label: Data Bundles
slug: /getting-started/examples
---

We introduce a new services to model how relationships and attributes are created and deleted when actions occur on resources. Managing these data centrally promises better transparency and consistent modeling.

## How Bundles Works

Let's examine how Bundles operates with basic example.

Let's say you want to model how data will be created when an organization created in your application. For this purpose, you can utilize the [WriteBundle](./api-overview/bundle/write-bundle.md) API endpoint. This API enables users to define or update data bundles, each distinguished by a unique name.

Here's an example body for WriteBundle in this scenario:

```json
"bundles": [
{
"name": "organization_created"
"arguments": [
"creatorID",
"organizationID"
],
"operations": [
{
"relationships_write": [
"organization:{{.organizationID}}#admin@user:{{.creatorID}}",
"organization:{{.organizationID}}#manager@user:{{.creatorID}}",
],
"attributes_write": [
"organization:{{.organizationID}}$public|boolean:false",
],
},
],
},
],
```

Operations represent actions that can be performed on relationships and attributes, such as adding or deleting relationships when certain events occur.

Let's say user:564 creates an organization:789 in your application. According to your authorization logic, this will result in the creation of several authorization data, including relational tuples and attributes, respectively.

* organization:789#admin@user:564
* organization:789#manager@user:564
* organization:789$public|boolean:false

Instead of using the [WriteData](./api-overview/data/write-data.md) endpoint, you can utilize [RunBundle](./api-overview/data/run-bundle.md) to create this data by simply providing specific identifiers.

An example request of [RunBundle](./api-overview/data/run-bundle.md) for this scenario:

```json
POST /bundle
BODY
{
"name": "project_created",
"arguments": {
"creatorID": "564",
"organizationID": "789",
}
}
```

This will result in the creation of the following data in Permify:

* organization:789#admin@user:564
* organization:789#manager@user:564
* organization:789$public|boolean:false

## Endpoints

- [WriteBundle](./api-overview/bundle/write-bundle.md)
- [RunBundle](./api-overview/data/run-bundle.md)
- [DeleteBundle](./api-overview/bundle/delete-bundle.md)
- [ReadBundle](./api-overview/bundle/read-bundle.md)
5 changes: 2 additions & 3 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ module.exports = {
type: 'category',
label: 'Bundle Service',
link: {
type: "generated-index",
title: "Bundle Service",
slug: "/api-overview/bundle",
type: "doc",
id: "bundle",
},
items: [
"api-overview/bundle/write-bundle",
Expand Down

0 comments on commit 8f90820

Please sign in to comment.