Skip to content

README: break up WriteAuthorizationModelRequest into smaller understandable pieces #29

Open
@adriantam

Description

@adriantam

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions