-
Notifications
You must be signed in to change notification settings - Fork 8
Role Management
aureldent edited this page Jul 17, 2019
·
1 revision
You can easly create, modify, delete or list roles on your instance with the sdk.
roles = api.get_call("role", "list", instance=site_id)
To create a role you need to create an object like the following one
my_role = {
"authorizations": authorizations,
"description": {"fr": "Ma description en francais"},
"instance": site_id,
"feeds": ["518815757015446"],
"name": "My custom role"
}
api.get_call("role", "save", body=my_role)
Here we have:
- authorization: The authorization associated to that role (See below)
- description: A description of the role (can be translated in multiple languages)
- instance: The instance id of the instance where to create that role
- feeds: The ids of the groups that have the rights on that role. At least one is required.
- name: The name of the role
authorization_1 = {
"actions": actions,
"feeds": ["518815757015496"],
"metadata": ["51881575701549"]
}
authorizations = [authorization_1]
- actions: A list of actions (See below)
- feeds: A list of ids of the groups targeted by the given actions
- metadata: A list if ids of the metadatas associated to the givena actions.
action_1 = {
"type": "EDIT",
"name": "PAGE"
}
action_2 = {
"type": "READ",
"name": "PAGE"
}
actions = [action_1, action_2]
- type: The type of action. The accepted types are listed below
FEED GROUP GLOBAL USER NEWS NEWSLETTER COMMUNITY CUSTOM ANALYTICS GAMIFICATION DIRECTORY_ENTRY STYLE MEDIA DIRECTORY POST CUSTOM_CONTENT TUTORIAL TARGET RESELLER MENU INSTANCE ROLE TEMPLATE PAGE METADATA
- name: The name of the action. The accepted names are listed below
READ DROP PUBLISH ADMIN EDIT ARCHIVE DELETE
To update a role the recommanded way is the following:
- get it
- change/add the informations you want
- re-save it.
# Get the role
role = api.get_call("role", "get", uid=role_uid)
# Update it ...
role["name"] = "New role name"
# Save the updated role
api.get_call("role", "save", body=role)