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

Example is wrong: https://github.com/databricks/databricks-sdk-py/blob/main/examples/users/patch_account_users.py #307

Open
mbendana opened this issue Aug 21, 2023 · 0 comments · May be fixed by #431

Comments

@mbendana
Copy link

mbendana commented Aug 21, 2023

Description
The following example seems to have a bug/issue.

Reproduction

import time

from databricks.sdk import AccountClient
from databricks.sdk.service import iam

a = AccountClient()

user = a.users.create(display_name=f'sdk-{time.time_ns()}', user_name=f'sdk-{time.time_ns()}@example.com')

a.users.patch(id=user.id,
              schemas=[iam.PatchSchema.URN_IETF_PARAMS_SCIM_API_MESSAGES_2_0_PATCH_OP],
              operations=[
                  iam.Patch(op=iam.PatchOp.ADD,
                            value=iam.User(roles=[iam.ComplexValue(value="account_admin")]))
              ])

# cleanup
a.users.delete(id=user.id)

Expected behavior
To patch the user. Add the user to the specified role (account_admin).

Debug Logs

raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type User is not JSON serializable

Other Information

  • OS: macOS
  • Version: databricks-sdk 0.6.0

Additional context
The following code works (adding the '.as_dict()' method to the 'iam.User' object):

import time

from databricks.sdk import AccountClient
from databricks.sdk.service import iam

a = AccountClient()

user = a.users.create(display_name=f'sdk-{time.time_ns()}', user_name=f'sdk-{time.time_ns()}@example.com')

a.users.patch(id=user.id,
              schemas=[iam.PatchSchema.URN_IETF_PARAMS_SCIM_API_MESSAGES_2_0_PATCH_OP],
              operations=[
                  iam.Patch(op=iam.PatchOp.ADD,
                            value=iam.User(roles=[iam.ComplexValue(value="account_admin")]).as_dict())
              ])

# cleanup
#a.users.delete(id=user.id)
@MrTeale MrTeale linked a pull request Nov 7, 2023 that will close this issue
3 tasks
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 a pull request may close this issue.

1 participant