class PageLinks
A data class representing links for opening a OneNote page in different contexts (native client and web browser).
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/pages/links.py
5 - 17
simple
Purpose
PageLinks is a value object that encapsulates two types of URLs for accessing a OneNote page: one for opening in the OneNote native client application and another for opening in a web browser. It inherits from ClientValue, making it suitable for serialization and transmission in API requests/responses within the Office365 SDK. This class is typically used as part of OneNote page metadata to provide multiple access points to the same page content.
Source Code
class PageLinks(ClientValue):
"""Links for opening a OneNote page."""
def __init__(
self, onenote_client_url=ExternalLink(), onenote_web_url=ExternalLink()
):
"""
:param ExternalLink onenote_client_url: Opens the page in the OneNote native client if it's installed.
:param ExternalLink onenote_web_url: Opens the page in OneNote on the web.
"""
super(PageLinks, self).__init__()
self.oneNoteClientUrl = onenote_client_url
self.oneNoteWebUrl = onenote_web_url
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
onenote_client_url: An ExternalLink object containing the URL to open the page in the OneNote native client application if installed on the user's device. Defaults to an empty ExternalLink() instance if not provided.
onenote_web_url: An ExternalLink object containing the URL to open the page in OneNote on the web (browser-based version). Defaults to an empty ExternalLink() instance if not provided.
Return Value
Instantiation returns a PageLinks object with two attributes (oneNoteClientUrl and oneNoteWebUrl) that store ExternalLink instances. The class itself doesn't have methods that return values beyond the inherited ClientValue functionality.
Class Interface
Methods
__init__(self, onenote_client_url=ExternalLink(), onenote_web_url=ExternalLink())
Purpose: Initializes a PageLinks instance with URLs for opening a OneNote page in different contexts
Parameters:
onenote_client_url: ExternalLink object for the native client URL, defaults to empty ExternalLink()onenote_web_url: ExternalLink object for the web browser URL, defaults to empty ExternalLink()
Returns: None (constructor)
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
oneNoteClientUrl |
ExternalLink | Stores the URL for opening the page in the OneNote native client application | instance |
oneNoteWebUrl |
ExternalLink | Stores the URL for opening the page in OneNote on the web (browser) | instance |
Dependencies
office365
Required Imports
from office365.onenote.pages.page_links import PageLinks
from office365.onenote.pages.external_link import ExternalLink
Usage Example
from office365.onenote.pages.page_links import PageLinks
from office365.onenote.pages.external_link import ExternalLink
# Create ExternalLink objects
client_link = ExternalLink()
client_link.href = 'onenote:https://example.com/page1'
web_link = ExternalLink()
web_link.href = 'https://www.onenote.com/page1'
# Create PageLinks instance
page_links = PageLinks(
onenote_client_url=client_link,
onenote_web_url=web_link
)
# Access the links
print(page_links.oneNoteClientUrl.href)
print(page_links.oneNoteWebUrl.href)
# Or create with defaults
default_links = PageLinks()
Best Practices
- This is an immutable-style value object; set the link URLs during instantiation or immediately after creation
- Always provide valid ExternalLink objects with proper href values for both client and web URLs when the links are known
- The class uses camelCase for internal attribute names (oneNoteClientUrl, oneNoteWebUrl) to match the Office365 API conventions, even though the constructor parameters use snake_case
- This class is typically not instantiated directly by end users but rather populated by the Office365 SDK when retrieving page information from the OneNote API
- Since it inherits from ClientValue, it supports serialization to/from JSON for API communication
- No validation is performed on the URLs; ensure ExternalLink objects contain valid URLs before creating PageLinks instances
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class ExternalLink 82.0% similar
-
class RecentNotebookLinks 79.7% similar
-
class OnenotePagePreviewLinks 74.8% similar
-
class SocialLink 63.1% similar
-
class OnenotePage 62.3% similar