Platform roles¶
Goal: grant a user access under an existing platform role (or adjust who can manage that role) so they can call Amorphic APIs with the right permissions. Read the current membership, add the user if missing, then write the update back.
APIs used here¶
AmorphicApiClient.management_api—get_role,update_role
Read and update role membership¶
Fetch the role so you see who is already attached, then update
users_attached (and optionally role_managers) without dropping existing
members. That is how you onboard someone onto a role used by the dataset and AI
snippets on these pages.
from openapi_client.models.update_role_info import UpdateRoleInfo
mgmt_api = client.management_api
role = mgmt_api.get_role(id=role_id, role_id=role_id)
users_attached = list(role.users_attached or [])
role_managers = list(role.role_managers or [])
if user_id not in users_attached:
users_attached.append(user_id)
update = UpdateRoleInfo()
update.users_attached = users_attached
update.role_managers = role_managers
mgmt_api.update_role(
id=role_id,
role_id=role_id,
update_role_info=update,
)