Skip to content

Commit

Permalink
docs: replace readable names with uuid (#146)
Browse files Browse the repository at this point in the history
* docs:replace readable names with uuid

* Update CONTRIBUTING.md

---------

Co-authored-by: sccalabr <[email protected]>
  • Loading branch information
ryanpq and sccalabr authored Nov 15, 2024
1 parent 6bd5567 commit 17fd63c
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 104 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Updated to include support for [OpenFGA 0.3.0](https://github.com/openfga/openfg

Changes:
- [BREAKING] feat(list-objects)!: response has been changed to include the object type
e.g. response that was `{"object_ids":["roadmap"]}`, will now be `{"objects":["document:roadmap"]}`
e.g. response that was `{"object_ids":["roadmap"]}`, will now be `{"objects":["document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"]}`

Fixes:
- [BREAKING] fix(models): update interfaces that had incorrectly optional fields to make them required
Expand Down
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,13 @@ Reads the relationship tuples stored in the database. It does not evaluate nor e
body := ClientReadRequest{
User: openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"),
Relation: openfga.PtrString("viewer"),
Object: openfga.PtrString("document:roadmap"),
Object: openfga.PtrString("document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"),
}

// Find all relationship tuples where a certain user has a relationship as any relation to a certain document
body := ClientReadRequest{
User: openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"),
Object: openfga.PtrString("document:roadmap"),
Object: openfga.PtrString("document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"),
}

// Find all relationship tuples where a certain user is a viewer of any document
Expand All @@ -478,7 +478,7 @@ body := ClientReadRequest{

// Find all relationship tuples where any user has a relationship as any relation with a particular document
body := ClientReadRequest{
Object: openfga.PtrString("document:roadmap"),
Object: openfga.PtrString("document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"),
}

// Read all stored relationship tuples
Expand Down Expand Up @@ -511,16 +511,16 @@ body := ClientWriteRequest{
Writes: &[]ClientTupleKey{ {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
}, {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:budget",
Object: "document:0192ab2d-d36e-7cb3-a4a8-5d1d67a300c5",
} },
Deletes: &[]ClientTupleKeyWithoutCondition{ {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "writer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
} }
}

Expand All @@ -544,16 +544,16 @@ body := ClientWriteRequest{
Writes: &[]ClientTupleKey{ {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
}, {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:budget",
Object: "document:0192ab2d-d36e-7cb3-a4a8-5d1d67a300c5",
} },
Deletes: &[]ClientTupleKeyWithoutCondition{ {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "writer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
} }
}

Expand Down Expand Up @@ -601,11 +601,11 @@ Check if a user has a particular relation with an object.
body := ClientCheckRequest{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
ContextualTuples: &[]ClientTupleKey{ {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "editor",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
} },
}

Expand Down Expand Up @@ -639,29 +639,29 @@ options := ClientBatchCheckOptions{
body := ClientBatchCheckBody{ {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
ContextualTuples: &[]ClientTupleKey{ {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "editor",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
} },
}, {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "admin",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
ContextualTuples: &[]ClientTupleKey{ {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "editor",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
} },
}, {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "creator",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
}, {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "deleter",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
} }

data, err := fgaClient.BatchCheck(context.Background()).Body(requestBody).Options(options).Execute()
Expand All @@ -672,11 +672,11 @@ data = [{
Request: {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
ContextualTuples: [{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "editor",
Object: "document:roadmap"
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"
}]
},
HttpResponse: ...
Expand All @@ -685,11 +685,11 @@ data = [{
Request: {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "admin",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
ContextualTuples: [{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "editor",
Object: "document:roadmap"
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"
}]
},
HttpResponse: ...
Expand All @@ -698,7 +698,7 @@ data = [{
Request: {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "creator",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
},
HttpResponse: ...,
Error: <FgaError ...>
Expand All @@ -707,7 +707,7 @@ data = [{
Request: {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "deleter",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
}},
HttpResponse: ...,
]
Expand All @@ -729,11 +729,11 @@ options := ClientExpandOptions{
}
body := ClientExpandRequest{
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
}
data, err := fgaClient.Expand(context.Background()).Body(requestBody).Options(options).Execute()

// data.Tree.Root = {"name":"document:roadmap#viewer","leaf":{"users":{"users":["user:81684243-9356-4421-8fbf-a4f8d36aa31b","user:f52a4f7a-054d-47ff-bb6e-3ac81269988f"]}}}
// data.Tree.Root = {"name":"document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a#viewer","leaf":{"users":{"users":["user:81684243-9356-4421-8fbf-a4f8d36aa31b","user:f52a4f7a-054d-47ff-bb6e-3ac81269988f"]}}}
```

#### List Objects
Expand All @@ -760,15 +760,15 @@ body := ClientListObjectsRequest{
}, {
User: "folder:product",
Relation: "parent",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
} },
}
data, err := fgaClient.ListObjects(context.Background()).
Body(requestBody).
Options(options).
Execute()

// data.Objects = ["document:roadmap"]
// data.Objects = ["document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"]
```

#### List Relations
Expand All @@ -786,12 +786,12 @@ options := ClientListRelationsOptions{
}
body := ClientListRelationsRequest{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
Relations: []string{"can_view", "can_edit", "can_delete", "can_rename"},
ContextualTuples: &[]ClientTupleKey{ {
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "editor",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
} },
}
data, err := fgaClient.ListRelations(context.Background()).
Expand Down Expand Up @@ -837,7 +837,7 @@ requestBody := ClientListUsersRequest{
}, {
User: "folder:product",
Relation: "parent",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
}},
Context: &map[string]interface{}{"ViewCount": 100},
}
Expand Down Expand Up @@ -886,7 +886,7 @@ requestBody := ClientWriteAssertionsRequest{
ClientAssertion{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "can_view",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
Expectation: true,
},
}
Expand Down
34 changes: 17 additions & 17 deletions api_open_fga_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func TestOpenFgaApi(t *testing.T) {
TupleKey: CheckRequestTupleKey{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
},
AuthorizationModelId: PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
}
Expand Down Expand Up @@ -591,7 +591,7 @@ func TestOpenFgaApi(t *testing.T) {
TupleKeys: []TupleKey{{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
}},
},
AuthorizationModelId: PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
Expand Down Expand Up @@ -637,7 +637,7 @@ func TestOpenFgaApi(t *testing.T) {
TupleKeys: []TupleKeyWithoutCondition{{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
}},
},
AuthorizationModelId: PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
Expand Down Expand Up @@ -672,7 +672,7 @@ func TestOpenFgaApi(t *testing.T) {
t.Run("Expand", func(t *testing.T) {
test := TestDefinition{
Name: "Expand",
JsonResponse: `{"tree":{"root":{"name":"document:roadmap#viewer","union":{"nodes":[{"name": "document:roadmap#viewer","leaf":{"users":{"users":["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]}}}]}}}}`,
JsonResponse: `{"tree":{"root":{"name":"document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a#viewer","union":{"nodes":[{"name": "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a#viewer","leaf":{"users":{"users":["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]}}}]}}}}`,
ResponseStatus: 200,
Method: "POST",
RequestPath: "expand",
Expand All @@ -681,7 +681,7 @@ func TestOpenFgaApi(t *testing.T) {
requestBody := ExpandRequest{
TupleKey: ExpandRequestTupleKey{
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
},
AuthorizationModelId: PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
}
Expand Down Expand Up @@ -720,7 +720,7 @@ func TestOpenFgaApi(t *testing.T) {
t.Run("Read", func(t *testing.T) {
test := TestDefinition{
Name: "Read",
JsonResponse: `{"tuples":[{"key":{"user":"user:81684243-9356-4421-8fbf-a4f8d36aa31b","relation":"viewer","object":"document:roadmap"},"timestamp": "2000-01-01T00:00:00Z"}]}`,
JsonResponse: `{"tuples":[{"key":{"user":"user:81684243-9356-4421-8fbf-a4f8d36aa31b","relation":"viewer","object":"document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"},"timestamp": "2000-01-01T00:00:00Z"}]}`,
ResponseStatus: 200,
Method: "POST",
RequestPath: "read",
Expand All @@ -730,7 +730,7 @@ func TestOpenFgaApi(t *testing.T) {
TupleKey: &ReadRequestTupleKey{
User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"),
Relation: PtrString("viewer"),
Object: PtrString("document:roadmap"),
Object: PtrString("document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"),
},
}

Expand Down Expand Up @@ -772,7 +772,7 @@ func TestOpenFgaApi(t *testing.T) {
t.Run("ReadChanges", func(t *testing.T) {
test := TestDefinition{
Name: "ReadChanges",
JsonResponse: `{"changes":[{"tuple_key":{"user":"user:81684243-9356-4421-8fbf-a4f8d36aa31b","relation":"viewer","object":"document:roadmap"},"operation":"TUPLE_OPERATION_WRITE","timestamp": "2000-01-01T00:00:00Z"}],"continuation_token":"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="}`,
JsonResponse: `{"changes":[{"tuple_key":{"user":"user:81684243-9356-4421-8fbf-a4f8d36aa31b","relation":"viewer","object":"document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"},"operation":"TUPLE_OPERATION_WRITE","timestamp": "2000-01-01T00:00:00Z"}],"continuation_token":"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="}`,
ResponseStatus: 200,
Method: "GET",
RequestPath: "changes",
Expand Down Expand Up @@ -820,7 +820,7 @@ func TestOpenFgaApi(t *testing.T) {
t.Run("ListObjects", func(t *testing.T) {
test := TestDefinition{
Name: "ListObjects",
JsonResponse: `{"objects":["document:roadmap"]}`,
JsonResponse: `{"objects":["document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"]}`,
ResponseStatus: 200,
Method: "POST",
RequestPath: "list-objects",
Expand All @@ -839,7 +839,7 @@ func TestOpenFgaApi(t *testing.T) {
}, {
User: "folder:product",
Relation: "parent",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
}},
},
}
Expand Down Expand Up @@ -912,7 +912,7 @@ func TestOpenFgaApi(t *testing.T) {
}, {
User: "folder:product",
Relation: "parent",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
}},
Context: &map[string]interface{}{"ViewCount": 100},
}
Expand Down Expand Up @@ -978,7 +978,7 @@ func TestOpenFgaApi(t *testing.T) {
TupleKey: CheckRequestTupleKey{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
},
}

Expand Down Expand Up @@ -1042,7 +1042,7 @@ func TestOpenFgaApi(t *testing.T) {
TupleKey: CheckRequestTupleKey{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
},
}

Expand Down Expand Up @@ -1099,7 +1099,7 @@ func TestOpenFgaApi(t *testing.T) {
TupleKey: CheckRequestTupleKey{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
},
}

Expand Down Expand Up @@ -1163,7 +1163,7 @@ func TestOpenFgaApi(t *testing.T) {
TupleKey: CheckRequestTupleKey{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
},
}

Expand Down Expand Up @@ -1234,7 +1234,7 @@ func TestOpenFgaApi(t *testing.T) {
TupleKey: CheckRequestTupleKey{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
},
}

Expand Down Expand Up @@ -1295,7 +1295,7 @@ func TestOpenFgaApi(t *testing.T) {
TupleKey: CheckRequestTupleKey{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation: "viewer",
Object: "document:roadmap",
Object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
},
}

Expand Down
Loading

0 comments on commit 17fd63c

Please sign in to comment.