Hello, Ory Community! I have a QQ regarding Ory K...
# ory-copilot
f
Hello, Ory Community! I have a QQ regarding Ory Keto. I could not find the answer in the documentation. Is it possible to convert this RTS to the OPL definition?
Copy code
Group:system-update-website-status#members@65b950c6-f88d-453b-b050-54e256e57bf4
Website:*#updateStatus@(Group:system-update-website-status#members)
Copy code
import { Namespace, Context } from "@ory/keto-namespace-types";

class User implements Namespace {}

class Group implements Namespace {
    related: {
        members: User[];
    };
}

class Website implements Namespace {
    related: {
        owners: User[];
    };

    permits = {
        view: (ctx: Context) => this.related.owners.includes(ctx.subject),

        // updateStatus: (ctx: Context) => ???,
    };
}
Oops, wrong channel!
@chilly-king-10285
b
Sorry @fancy-waitress-14213, I'm not sure what you mean. Please try again. 👋
f
@chilly-king-10285 Is it possible to convert this RTS to the OPL definition?
Copy code
Group:system-update-website-status#members@65b950c6-f88d-453b-b050-54e256e57bf4
Website:*#updateStatus@(Group:system-update-website-status#members)
Copy code
import { Namespace, Context } from "@ory/keto-namespace-types";

class User implements Namespace {}

class Group implements Namespace {
    related: {
        members: User[];
    };
}

class Website implements Namespace {
    related: {
        owners: User[];
    };

    permits = {
        view: (ctx: Context) => this.related.owners.includes(ctx.subject),

        // updateStatus: (ctx: Context) => ???,
    };
}
b
A message from kapa.ai
Sure, you can define the
updateStatus
permission in the
Website
class using the Ory Permission Language (OPL). The permission would check if the subject is a member of the
system-update-website-status
group. Here's how you can do it:
Copy code
typescript import { Namespace, Context, SubjectSet } from "@ory/keto-namespace-types";  class User implements Namespace {}  class Group implements Namespace {     related: {         members: User[];     }; }  class Website implements Namespace {     related: {         owners: User[];         updateStatus: SubjectSet<Group, "members">[];     };      permits = {         view: (ctx: Context): boolean => this.related.owners.includes(ctx.subject),         updateStatus: (ctx: Context): boolean => this.related.updateStatus.includes(ctx.subject),     }; }
In this code, the
updateStatus
relation in the
Website
class is defined as a
SubjectSet
of
Group
and
"members"
. The
updateStatus
permission checks if the subject is included in the
updateStatus
relation. Please note that this is a simplified example and you might need to adjust it according to your specific use case. For more information on how to define permissions in OPL, you can refer to the [Ory Keto documentation](https://www.ory.sh/docs/keto/modeling/create-permission-model#define-permissions-in-the-opl).
A message from kapa.ai
Sure, you can define the
updateStatus
permission in the
Website
class using the Ory Permission Language (OPL). The permission would check if the subject is a member of the
system-update-website-status
group. Here's how you can do it:
Copy code
typescript import { Namespace, Context, SubjectSet } from "@ory/keto-namespace-types";  class User implements Namespace {}  class Group implements Namespace {     related: {         members: User[];     }; }  class Website implements Namespace {     related: {         owners: User[];         updateStatus: SubjectSet<Group, "members">[];     };      permits = {         view: (ctx: Context): boolean => this.related.owners.includes(ctx.subject),         updateStatus: (ctx: Context): boolean => this.related.updateStatus.includes(ctx.subject),     }; }
In this code, the
updateStatus
relation in the
Website
class is defined as a
SubjectSet
of
Group
and
"members"
. The
updateStatus
permission checks if the subject is included in the
updateStatus
relation. Please note that this is a simplified example and you might need to adjust it according to your specific use case. For more information on how to define permissions in OPL, you can refer to the [Ory Keto documentation](https://www.ory.sh/docs/keto/modeling/create-permission-model#define-permissions-in-the-opl).