Skip to content

Commit

Permalink
Add code example for adding a user to a group using the group patch e…
Browse files Browse the repository at this point in the history
…ndpoint
  • Loading branch information
chrisgravel-db committed Apr 10, 2024
1 parent 1c1b11a commit 741e931
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions docs/workspace/iam/groups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,38 @@

.. py:method:: patch(id: str [, operations: Optional[List[Patch]], schemas: Optional[List[PatchSchema]]])
Usage:

.. code-block::
import time
from databricks.sdk import WorkspaceClient
from databricks.sdk.service import iam
w = WorkspaceClient()
group = w.groups.create(display_name=f'sdk-{time.time_ns()}-group')
user = w.users.create(
display_name=f'sdk-{time.time_ns()}-user', user_name=f'sdk-{time.time_ns()}@example.com')
w.groups.patch(
id=group.id,
operations=[
iam.Patch(
op=iam.PatchOp.ADD,
value={"members": [{
"value": user.id,
}]},
)
],
schemas=[iam.PatchSchema.URN_IETF_PARAMS_SCIM_API_MESSAGES_2_0_PATCH_OP],
)
# cleanup
w.users.delete(id=user.id)
w.groups.delete(id=group.id)
Update group details.

Partially updates the details of a group.
Expand All @@ -152,9 +184,6 @@
:param operations: List[:class:`Patch`] (optional)
:param schemas: List[:class:`PatchSchema`] (optional)
The schema of the patch request. Must be ["urn:ietf:params:scim:api:messages:2.0:PatchOp"].




.. py:method:: update(id: str [, display_name: Optional[str], entitlements: Optional[List[ComplexValue]], external_id: Optional[str], groups: Optional[List[ComplexValue]], members: Optional[List[ComplexValue]], meta: Optional[ResourceMeta], roles: Optional[List[ComplexValue]], schemas: Optional[List[GroupSchema]]])
Expand Down

0 comments on commit 741e931

Please sign in to comment.