Skip to content

Commit

Permalink
fix: github and migration examples specified directly assignable rela…
Browse files Browse the repository at this point in the history
…tionship (#508)
  • Loading branch information
adriantam authored Aug 29, 2023
1 parent 6586fd4 commit 89b82e6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/content/getting-started/create-store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ from openfga_sdk.client import OpenFgaClient
from openfga_sdk.models.create_store_request import CreateStoreRequest

configuration = openfga_sdk.Configuration(
scheme = os.environ.get('FGA_API_SCHEME')
scheme = os.environ.get('FGA_API_SCHEME'),
api_host = os.environ.get('FGA_API_HOST'),
)

Expand Down
55 changes: 35 additions & 20 deletions docs/content/modeling/advanced/github.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -731,32 +731,47 @@ We express it like this:
schema_version: '1.1',
type_definitions: [
{
admin: {
union: {
child: [
{
this: {},
},
{
tupleToUserset: {
// read all tuples related to tooling as owner
// which returns [{ "user": "organization:contoso", "relation": "owner", "object": "repo:contoso/tooling" }]
tupleset: {
relation: 'owner',
},
// and for each tuple return all usersets that match the following, replacing $TUPLE_USERSET_OBJECT with organization:contoso
// this will return tuples of shape { object: "organization:contoso", "repo_admin", "user": ??? }
computedUserset: {
relation: 'repo_admin',
type: 'repo',
relations: {
admin: {
union: {
child: [
{
this: {},
},
{
tupleToUserset: {
// read all tuples related to tooling as owner
// which returns [{ "user": "organization:contoso", "relation": "owner", "object": "repo:contoso/tooling" }]
tupleset: {
relation: 'owner',
},
// and for each tuple return all usersets that match the following, replacing $TUPLE_USERSET_OBJECT with organization:contoso
// this will return tuples of shape { object: "organization:contoso", "repo_admin", "user": ??? }
computedUserset: {
relation: 'repo_admin',
},
},
},
},
],
],
},
},
},
metadata: {
relations: {
admin: {
directly_related_user_types: [
{ type: 'user' },
{ type: 'team', relation: 'member' },
{ type: 'organization', relation: 'member' },
],
},
},
},
},
],
}} skipVersion={true}
}}
skipVersion={true}
/>

:::info
Expand Down
21 changes: 21 additions & 0 deletions docs/content/modeling/migrating/migrating-relations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ In this scenario, you will migrate the following model:
},
},
},
metadata: {
relations: {
editor: { directly_related_user_types: [{ type: 'user' }] },
},
},
},
{
type: 'user',
Expand Down Expand Up @@ -102,6 +107,11 @@ This is the authorization model that you will want to migrate to:
},
},
},
metadata: {
relations: {
writer: { directly_related_user_types: [{ type: 'user' }] },
},
},
},
{
type: 'user',
Expand Down Expand Up @@ -155,6 +165,12 @@ In the example below, `user:Anne` still has write privileges to the `document:ro
},
},
},
metadata: {
relations: {
editor: { directly_related_user_types: [{ type: 'user' }] },
writer: { directly_related_user_types: [{ type: 'user' }] },
},
},
},
{
type: 'user',
Expand Down Expand Up @@ -277,6 +293,11 @@ After you remove the previous relationship tuples, update your authorization mod
},
},
},
metadata: {
relations: {
writer: { directly_related_user_types: [{ type: 'user' }] },
},
},
},
{
type: 'user',
Expand Down

0 comments on commit 89b82e6

Please sign in to comment.