Skip to content

Role Management

aureldent edited this page Jul 17, 2019 · 1 revision

Role

You can easly create, modify, delete or list roles on your instance with the sdk.

List roles

roles = api.get_call("role", "list", instance=site_id)

Create a specific role

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

Authorizations

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.

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

Update a role

To update a role the recommanded way is the following:

  1. get it
  2. change/add the informations you want
  3. 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)