🔍 Code Extractor

class RecentNotebook

Maturity: 48

A data class representing a recently accessed OneNote notebook with display name and navigation links.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/notebooks/recent.py
Lines:
5 - 16
Complexity:
simple

Purpose

RecentNotebook is a lightweight representation of a OneNote notebook that has been recently accessed by a user. It extends ClientValue and provides essential information about the notebook including its display name and links for opening it in different OneNote clients (desktop application or web interface). This class is used in the Microsoft Graph API integration for OneNote to track and provide quick access to recently used notebooks.

Source Code

class RecentNotebook(ClientValue):
    """A recently accessed OneNote notebook. A recentNotebook is similar to a notebook but has fewer properties."""

    def __init__(self, display_name=None, links=RecentNotebookLinks()):
        """
        :param str display_name: The name of the notebook.
        :param RecentNotebookLinks links: Links for opening the notebook.
            The oneNoteClientURL link opens the notebook in the OneNote client, if it's installed.
            The oneNoteWebURL link opens the notebook in OneNote on the web.
        """
        self.displayName = display_name
        self.links = links

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

display_name: The human-readable name of the notebook as it appears in OneNote. This is an optional string parameter that defaults to None if not provided. It represents the title or label that users see when browsing their notebooks.

links: A RecentNotebookLinks object containing URLs for accessing the notebook through different OneNote clients. Defaults to an empty RecentNotebookLinks() instance. This object typically contains oneNoteClientURL (for opening in the desktop client) and oneNoteWebURL (for opening in the web browser).

Return Value

Instantiation returns a RecentNotebook object with two instance attributes: displayName (str or None) and links (RecentNotebookLinks). The object represents a recently accessed notebook and can be used to retrieve notebook information or generate access links. As a ClientValue subclass, it can be serialized for API communication.

Class Interface

Methods

__init__(display_name=None, links=RecentNotebookLinks()) -> None

Purpose: Initializes a new RecentNotebook instance with the provided display name and links

Parameters:

  • display_name: Optional string representing the notebook's display name, defaults to None
  • links: RecentNotebookLinks object containing URLs for accessing the notebook, defaults to empty RecentNotebookLinks()

Returns: None - constructor initializes the instance

Attributes

Name Type Description Scope
displayName str or None The name of the notebook as displayed to users in OneNote interfaces instance
links RecentNotebookLinks Object containing oneNoteClientURL and oneNoteWebURL links for opening the notebook in different OneNote clients instance

Dependencies

  • office365

Required Imports

from office365.onenote.notebooks.recent_links import RecentNotebookLinks
from office365.runtime.client_value import ClientValue

Usage Example

from office365.onenote.notebooks.recent_notebook import RecentNotebook
from office365.onenote.notebooks.recent_links import RecentNotebookLinks

# Create a recent notebook with just a name
notebook1 = RecentNotebook(display_name="My Work Notes")

# Create a recent notebook with name and links
links = RecentNotebookLinks()
notebook2 = RecentNotebook(
    display_name="Project Planning",
    links=links
)

# Access the notebook properties
print(notebook2.displayName)  # Output: Project Planning
print(notebook2.links)  # Output: RecentNotebookLinks object

# Typically used when retrieving recent notebooks from Microsoft Graph API
# The API would populate these objects with data from the service

Best Practices

  • Always provide a meaningful display_name when creating instances manually to ensure notebooks are identifiable
  • Use the default RecentNotebookLinks() constructor unless you have specific link URLs to provide
  • This class is typically instantiated by the Office365 SDK when deserializing API responses rather than manually by developers
  • As a ClientValue subclass, instances can be serialized for API requests and deserialized from API responses
  • The class is immutable by design - attributes should be set during initialization rather than modified after creation
  • When working with the Microsoft Graph API, these objects are usually returned as part of collections from recent notebook queries
  • Ensure proper authentication is configured before attempting to use this class with live OneNote data

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class RecentNotebookLinks 80.7% similar

    A data class representing links for opening a OneNote notebook, containing both client and web URLs for accessing the notebook.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/notebooks/recent_links.py
  • class Notebook 68.2% similar

    Represents a OneNote notebook entity with access to its sections and section groups, providing a hierarchical structure for organizing OneNote content.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/notebooks/notebook.py
  • class Onenote 64.0% similar

    The Onenote class serves as the entry point for accessing Microsoft OneNote resources through the Microsoft Graph API, providing access to notebooks, pages, sections, and other OneNote entities.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/onenote.py
  • class NotebookCollection 63.6% similar

    A collection class for managing OneNote notebooks, providing methods to create, retrieve, and query notebooks within Microsoft 365, SharePoint, or group contexts.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/notebooks/collection.py
  • class CopyNotebookModel 63.4% similar

    CopyNotebookModel is a data model class that inherits from ClientValue, representing a notebook copy operation in the Office365 API context.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/notebooks/copy_notebook_model.py
← Back to Browse