Role

The Role resource can be used to fetch roles information. This can be done by using the API Methods included in the class.

Each role fetched by an API Method is represented by an instance of the Role class that is returned to the user.

API Methods

disruptive.Role.get_role(role, **kwargs)

Gets a role specified by its name.

Parameters:
  • role (str) – Name of the role.

  • **kwargs (Any) – Arbitrary keyword arguments. See the Configuration page.

Returns:

role – Object representing the specified role.

Return type:

Role

Examples

>>> # Fetch information about the project.developer role.
>>> role = dt.Role.get_role(dt.Role.PROJECT_DEVELOPER)
disruptive.Role.list_roles(**kwargs)

List all available roles.

Parameters:

**kwargs (Any) – Arbitrary keyword arguments. See the Configuration page.

Returns:

roles – List of objects each representing a role.

Return type:

list[Role]

Examples

>>> # Fetch information about all available roles.
>>> roles = dt.Role.list_roles()

Class

class disruptive.Role(role)

Represents a role.

When a role response is received, the content is unpacked and the related attributes are updated.

Variables:
  • role (str) – Name of the role.

  • display_name (str) – Display name of the role.

  • description (str) – Description of what the role entails.

  • permissions (list[str]) – List of permissions provided with the role.

  • raw (dict[str, str]) – Unmodified API response JSON.

Type Constants

The Role class contains a string constant for each available role.

Role.PROJECT_USER = 'project.user'
Role.PROJECT_DEVELOPER = 'project.developer'
Role.PROJECT_ADMIN = 'project.admin'
Role.ORGANIZATION_ADMIN = 'organization.admin'
Role.ROLES = ['project.user', 'project.developer', 'project.admin', 'organization.admin']

This can be a useful alternative to writing the strings directly.

# Add a new developer member to the specified project.
dt.Project.add_member(
    project_id='<PROJECT_ID>',
    email='<EMAIL_ADDRESS>',
    roles=[dt.Role.PROJECT_DEVELOPER],
)