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

README: break up WriteAuthorizationModelRequest into smaller understandable pieces #29

Open
Tracked by #126
adriantam opened this issue Jun 9, 2023 · 1 comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@adriantam
Copy link
Member

adriantam commented Jun 9, 2023

Currently, the WriteAuthorizationModelRequest object used for (write authorization model)[https://github.com/openfga/python-sdk/blob/main/README.md#write-authorization-model] is large and difficult to understand. Ideally, we want to break it apart into smaller pieces

For example,

body = WriteAuthorizationModelRequest(
    schema_version = "1.1",
    type_definitions=[
        TypeDefinition(
            type="user",
        ),
        TypeDefinition(
            type="document",
            relations=dict(
                writer=Userset(
                    this=dict(),
                ),
                viewer=Userset(
                    union=Usersets(
                        child=[
                            Userset(this=dict()),
                            Userset(computed_userset=ObjectRelation(
                                object="",
                                relation="writer",
                            )),
                        ],
                    ),
                ),
            )
        ),
    ],
)

can be broken up as

user_type =  TypeDefinition(
    type="user",
)
document_type = TypeDefinition(
    type="document",
    relations=dict(
        writer=Userset(
            this=dict(),
        ),
        viewer=Userset(
            union=Usersets(
                child=[
                    Userset(this=dict()),
                    Userset(computed_userset=ObjectRelation(
                        object="",
                        relation="writer",
                     )),
                 ],
            )
        ),
    ),
)
        
body = WriteAuthorizationModelRequest(
    schema_version = "1.1",
    type_definitions=[
        user_type,
        document_type,
    ],
)

(and we break the document type relations into smaller pieces etc.)

The code in question is in

body = WriteAuthorizationModelRequest(

Ideally, we will also fix the SDK generator so that newly generated python SDKs will have the corresponding changes. This is tracked as openfga/sdk-generator#126. However, if that is difficult to do, simply focusing on the Python SDK side https://github.com/openfga/python-sdk/blob/main/README.md will help us as well.

@JRudransh
Copy link
Contributor

Please assign to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

3 participants