authzed / spicedb

Open Source, Google Zanzibar-inspired database for scalably storing and querying fine-grained authorization data
https://authzed.com/docs
Apache License 2.0
5.1k stars 279 forks source link

Not able to import BulkCheckPermission #1728

Closed satishTeachmint closed 9 months ago

satishTeachmint commented 9 months ago

What platforms are affected?

macos

What architectures are affected?

others

What SpiceDB version are you using?

0.12.0

Steps to Reproduce

while importing the following module I'm not able to import those. as they are not defined in init in authzed/api/v1/init.py.

from authzed.api.v1 import (
    BulkCheckPermissionRequest,
    BulkCheckPermissionResponse,
    BulkCheckPermissionRequestItem,
)

even though I define it gives the below error. Please resolve this error.

  File "spicedb_apis.py", line 193, in bulk_permission_check
    resp = client.BulkCheckPermission(BulkCheckPermissionRequest(items=permisions_array))
AttributeError: 'Client' object has no attribute 'BulkCheckPermission'

Expected Result

I can use the following code properly resp = client.BulkCheckPermission(BulkCheckPermissionRequest(items=permisions_array))

Actual Result

getting below error

Traceback (most recent call last):
  File "spicedb_apis.py", line 1, in <module>
    from authzed.api.v1 import (
ImportError: cannot import name 'BulkCheckPermissionRequest' from 'authzed.api.v1' (/Users/satishnaidu/Documents/GitHub/spiceDb/env/lib/python3.7/site-packages/authzed/api/v1/__init__.py)
vroldanbet commented 9 months ago

@satishTeachmint šŸ‘‹šŸ» which versions of SpiceDB and authzed-py are you using? The report indicates SpiceDB 0.12.0, which I assume is not right and you are referring to authzed-py.

I was able to reproduce this when using authzed-py 0.12.0. BulkCheck is available in 0.13.0.

Here is an example that uses it:

from authzed.api.v1 import (
    BulkCheckPermissionRequest,
    BulkCheckPermissionRequestItem,
    Client,
    Consistency,
    ObjectReference, SubjectReference,
)
from grpcutil import insecure_bearer_token_credentials

if __name__ == '__main__':
    client = Client("localhost:50051", insecure_bearer_token_credentials("foobar"))
    req = BulkCheckPermissionRequest(
        consistency=Consistency(fully_consistent=True),
        items=[
            BulkCheckPermissionRequestItem(
                resource=ObjectReference(
                    object_type="book",
                    object_id="1984"
                ),
                permission="view",
                subject=SubjectReference(
                    object=ObjectReference(
                        object_type="user",
                        object_id="jane"
                    ),
                ),
            )
        ],
    )

    resp = client.BulkCheckPermission(req)
    print(resp)