🔍 Code Extractor

class RoleDefinitionCreationInformation

Maturity: 36

A data class that encapsulates properties used to initialize a SharePoint role definition, including name, description, permissions, and display order.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/permissions/roles/definitions/creation_information.py
Lines:
5 - 27
Complexity:
simple

Purpose

This class serves as a data transfer object (DTO) for creating SharePoint role definitions. It inherits from ClientValue and provides a structured way to pass role definition parameters to SharePoint APIs. The class is used when creating custom permission levels or roles in SharePoint, allowing specification of the role's name, description, base permissions, and display order in the SharePoint interface.

Source Code

class RoleDefinitionCreationInformation(ClientValue):
    def __init__(
        self,
        base_permissions=BasePermissions(),
        name=None,
        description=None,
        order=None,
    ):
        """Contains properties that are used as parameters to initialize a role definition.

        :param str name: Specifies the name of the role definition.
        :param str description: Specifies the description of the role definition.
        :param int order: Specifies the order in which roles MUST be displayed in the WFE.
        """
        super(RoleDefinitionCreationInformation, self).__init__()
        self.Name = name
        self.Description = description
        self.BasePermissions = base_permissions
        self.Order = order

    @property
    def entity_type_name(self):
        return "SP.RoleDefinition"

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

base_permissions: A BasePermissions object that defines the permission set for this role. Defaults to an empty BasePermissions() instance. This determines what actions users assigned to this role can perform.

name: A string specifying the name of the role definition. This is the display name that will appear in SharePoint's permission management interface. Can be None initially.

description: A string providing a description of the role definition's purpose and scope. Helps administrators understand what the role is intended for. Can be None initially.

order: An integer specifying the order in which this role should be displayed in the SharePoint Web Front End (WFE). Lower numbers appear first. Can be None initially.

Return Value

Instantiation returns a RoleDefinitionCreationInformation object with the specified properties set. The object can be serialized and sent to SharePoint APIs for role creation. The entity_type_name property returns the string 'SP.RoleDefinition', which identifies the SharePoint entity type.

Class Interface

Methods

__init__(self, base_permissions=BasePermissions(), name=None, description=None, order=None)

Purpose: Initializes a new RoleDefinitionCreationInformation instance with the specified properties for creating a SharePoint role definition

Parameters:

  • base_permissions: BasePermissions object defining the permission set for the role, defaults to empty BasePermissions()
  • name: String name of the role definition, can be None
  • description: String description of the role definition, can be None
  • order: Integer display order for the role in SharePoint WFE, can be None

Returns: None (constructor)

@property entity_type_name(self) -> str property

Purpose: Returns the SharePoint entity type name for role definitions

Returns: String 'SP.RoleDefinition' identifying the SharePoint entity type

Attributes

Name Type Description Scope
Name str or None The name of the role definition as it will appear in SharePoint instance
Description str or None A description explaining the purpose and scope of the role definition instance
BasePermissions BasePermissions The permission set that defines what actions users with this role can perform instance
Order int or None The display order for this role in the SharePoint Web Front End interface instance

Dependencies

  • office365.runtime.client_value
  • office365.sharepoint.permissions.base_permissions

Required Imports

from office365.runtime.client_value import ClientValue
from office365.sharepoint.permissions.base_permissions import BasePermissions

Usage Example

from office365.runtime.client_value import ClientValue
from office365.sharepoint.permissions.base_permissions import BasePermissions
from office365.sharepoint.permissions.role_definition_creation_information import RoleDefinitionCreationInformation

# Create base permissions object
base_perms = BasePermissions()
base_perms.set(PermissionKind.ViewListItems)
base_perms.set(PermissionKind.OpenItems)

# Create role definition information
role_info = RoleDefinitionCreationInformation(
    base_permissions=base_perms,
    name="Custom Viewer",
    description="Can view items but not edit",
    order=100
)

# Access properties
print(role_info.Name)  # Output: Custom Viewer
print(role_info.entity_type_name)  # Output: SP.RoleDefinition

# Typically used with SharePoint context to create role
# ctx.web.role_definitions.add(role_info).execute_query()

Best Practices

  • Always provide a meaningful name and description when creating role definitions to help administrators understand the role's purpose
  • Initialize BasePermissions with appropriate permission flags before passing to the constructor
  • The order parameter should be set thoughtfully to ensure logical grouping of roles in the SharePoint UI
  • This class is immutable after creation in typical usage - set all properties during instantiation
  • Use this class in conjunction with SharePoint context's role_definitions collection to actually create the role in SharePoint
  • Ensure the BasePermissions object is properly configured with the desired permission set before creating the role definition
  • This class inherits from ClientValue, which means it can be serialized for transmission to SharePoint REST APIs

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class GroupCreationInformation_v1 75.5% similar

    A data class that encapsulates information required to create a SharePoint group, including display name, alias, visibility settings, and optional parameters.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/portal/groups/creation_information.py
  • class EventReceiverDefinitionCreationInformation 71.3% similar

    A data class that encapsulates the properties required to create a client-side event receiver definition in SharePoint/Office365.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/eventreceivers/creation_information.py
  • class ListItemCreationInformation 70.0% similar

    A data class that encapsulates the properties required to create a new list item in SharePoint, including file/folder specification, name, and location.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/listitems/creation_information.py
  • class ContentTypeCreationInformation 69.5% similar

    A data transfer object that encapsulates properties required to create a new SharePoint content type, inheriting from ClientValue for serialization support.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/contenttypes/creation_information.py
  • class ViewCreationInformation 69.0% similar

    A data transfer object (DTO) class that encapsulates the properties required to create a new SharePoint list view, inheriting from ClientValue for serialization support.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/views/create_information.py
← Back to Browse