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

feat: add gRPC client utils helpers #657

Merged
merged 1 commit into from
Jul 13, 2021
Merged

feat: add gRPC client utils helpers #657

merged 1 commit into from
Jul 13, 2021

Conversation

zepatrik
Copy link
Member

@zepatrik zepatrik commented Jul 13, 2021

Related issue(s)

closes #554

Extended commit message

Behold! The Keto gRPC client library now has useful helpers that allow you to replace:

- deltas := make([]*acl.RelationTupleDelta, len(tuples))
- for i := range rts {
- 	deltas[i] = &acl.RelationTupleDelta{
- 		Action:        acl.RelationTupleDelta_INSERT,
- 		RelationTuple: rts[i],
- 	}
- }
+ deltas := acl.RelationTupleToDeltas(tuples, acl.RelationTupleDelta_INSERT)

and

- &acl.Subject{Ref: &acl.Subject_Set{Set: &acl.SubjectSet{
- 	Namespace: "directories",
- 	Object:    "/photos",
- 	Relation:  "access",
- }}}
+ acl.NewSubjectSet("directories", "/photos", "access")

and

- &acl.Subject{Ref: &acl.Subject_Id{
- 	Id: "user1",
- }}
+ acl.NewSubjectID("user1")

Enjoy these new treats 🍫 🍭 🍦

@zepatrik zepatrik merged commit 8b18802 into master Jul 13, 2021
@zepatrik zepatrik deleted the grpc-client-utils branch July 13, 2021 14:05
@rauerhans
Copy link

rauerhans commented Nov 14, 2022

It appears these helper methods are not yet published, even though they appear in the official documentation.
This is the latest version you can import github.com/ory/keto/proto/ory/keto/acl/v1alpha1, yet these helpers appear only in the latest github.com/ory/keto/proto/ory/keto/acl/v1alpha2.
This https://www.ory.sh/docs/keto/sdk/go example does already use those.
It's in another package tho:
"github.com/ory/keto/proto/ory/keto/relation_tuples/v1alpha2"

@zepatrik
Copy link
Member Author

github.com/ory/keto/proto/ory/keto/acl/v1alpha2

is the correct version, please use that one. You can also use github.com/ory/keto/proto/ory/keto/acl/v1alpha1 before d29d42c

@rauerhans
Copy link

rauerhans commented Nov 14, 2022

ah okay, so the example from the docs is a tad out of date already, the rest of the reference seems to be already documenting that rts api:
https://www.ory.sh/docs/keto/reference/proto-api
and this seems like a more up to date example:
https://github.com/ory/keto/blob/6c0e1ba87f4d3a355cebd0ea77f28319be2dd606/contrib/docs-code-samples/expand-api-display-access/00-create-tuples/main.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add common helpers to gRPC client package
2 participants