class OnenoteEntityHierarchyModel
A model class representing OneNote entities with hierarchical properties such as notebooks, sections, and pages, providing access to display name, creation/modification metadata, and identity information.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/entity_hierarchy_model.py
7 - 39
simple
Purpose
This class extends OnenoteEntitySchemaObjectModel to provide a common interface for OneNote hierarchical entities (notebooks, sections, pages). It encapsulates metadata about entity creation, modification, and display properties. The class provides read-only access to identity information (who created/modified the entity) and timestamps, making it suitable for tracking entity lifecycle and ownership in OneNote operations.
Source Code
class OnenoteEntityHierarchyModel(OnenoteEntitySchemaObjectModel):
@property
def display_name(self):
# type: () -> Optional[str]
"""The name of the section."""
return self.properties.get("displayName", None)
@property
def created_by(self):
# type: () -> IdentitySet
"""Identity of the user, device, and application which created the item. Read-only."""
return self.properties.get("createdBy", IdentitySet())
@property
def last_modified_by(self):
"""Identity of the user, device, and application which created the item. Read-only."""
return self.properties.get("lastModifiedBy", IdentitySet())
@property
def last_modified_datetime(self):
"""Gets date and time the item was last modified."""
return self.properties.get("lastModifiedDateTime", None)
def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {
"createdBy": self.created_by,
"lastModifiedBy": self.last_modified_by,
}
default_value = property_mapping.get(name, None)
return super(OnenoteEntityHierarchyModel, self).get_property(
name, default_value
)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
OnenoteEntitySchemaObjectModel | - |
Parameter Details
bases: Inherits from OnenoteEntitySchemaObjectModel, which provides the base properties dictionary and schema object functionality for OneNote entities
Return Value
Instantiation returns an OnenoteEntityHierarchyModel object that provides property-based access to OneNote entity metadata. Properties return specific types: display_name returns Optional[str], created_by and last_modified_by return IdentitySet objects, last_modified_datetime returns a datetime value or None, and get_property returns the requested property value with optional default.
Class Interface
Methods
@property display_name() -> Optional[str]
property
Purpose: Returns the display name of the OneNote entity (section, notebook, or page)
Returns: Optional string containing the display name, or None if not set
@property created_by() -> IdentitySet
property
Purpose: Returns identity information about who created the entity
Returns: IdentitySet object containing user, device, and application identity information of the creator. Returns empty IdentitySet if not available.
@property last_modified_by() -> IdentitySet
property
Purpose: Returns identity information about who last modified the entity
Returns: IdentitySet object containing user, device, and application identity information of the last modifier. Returns empty IdentitySet if not available.
@property last_modified_datetime() -> Any
property
Purpose: Returns the date and time when the entity was last modified
Returns: Datetime value representing when the entity was last modified, or None if not available
get_property(name: str, default_value: Any = None) -> Any
Purpose: Retrieves a property value by name with special handling for identity properties and custom default values
Parameters:
name: The name of the property to retrieve (e.g., 'displayName', 'createdBy', 'lastModifiedBy')default_value: Optional default value to return if property is not found. If None, special defaults are used for 'createdBy' and 'lastModifiedBy' (returns IdentitySet objects)
Returns: The property value if found, or the default_value. For 'createdBy' and 'lastModifiedBy' without explicit defaults, returns the corresponding IdentitySet property value
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
properties |
dict | Inherited dictionary from parent class that stores all entity properties including displayName, createdBy, lastModifiedBy, and lastModifiedDateTime | instance |
Dependencies
typingoffice365.directory.permissions.identity_setoffice365.onenote.entity_schema_object_model
Required Imports
from typing import Optional
from office365.directory.permissions.identity_set import IdentitySet
from office365.onenote.entity_schema_object_model import OnenoteEntitySchemaObjectModel
Usage Example
# Assuming you have a OneNote entity data dictionary
from office365.onenote.entity_hierarchy_model import OnenoteEntityHierarchyModel
from office365.directory.permissions.identity_set import IdentitySet
# Create an instance (typically done internally by the SDK)
entity = OnenoteEntityHierarchyModel()
# Access properties
name = entity.display_name # Get the display name
creator = entity.created_by # Get IdentitySet of creator
modifier = entity.last_modified_by # Get IdentitySet of last modifier
last_modified = entity.last_modified_datetime # Get last modification timestamp
# Use get_property method for flexible property access
created_by_info = entity.get_property('createdBy') # Returns IdentitySet
custom_prop = entity.get_property('customProperty', 'default_value') # With default
Best Practices
- This class is designed for read-only access to OneNote entity metadata; properties should not be modified directly
- The class relies on a properties dictionary inherited from the parent class; ensure this is properly initialized before accessing properties
- When using get_property, be aware that 'createdBy' and 'lastModifiedBy' have special handling that returns IdentitySet objects by default
- All identity-related properties (created_by, last_modified_by) return IdentitySet objects, which may be empty if not populated
- The display_name property may return None if not set in the underlying properties dictionary
- This class is typically instantiated by the Office365 SDK when fetching OneNote entities, not manually by end users
- Always check for None values when accessing optional properties like display_name and last_modified_datetime
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class OnenoteEntityBaseModel 82.8% similar
-
class OnenoteEntitySchemaObjectModel 81.3% similar
-
class Notebook 80.0% similar
-
class Onenote 71.4% similar
-
class SectionGroup 70.0% similar