🔍 Code Extractor

class OnenoteSection

Maturity: 33

A section in a OneNote notebook. Sections can contain pages.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/sections/section.py
Lines:
14 - 104
Complexity:
moderate

Purpose

A section in a OneNote notebook. Sections can contain pages.

Source Code

class OnenoteSection(OnenoteEntityHierarchyModel):
    """A section in a OneNote notebook. Sections can contain pages."""

    def copy_to_section_group(
        self, group_id, _id, rename_as=None, site_collection_id=None, site_id=None
    ):
        """For Copy operations, you follow an asynchronous calling pattern: First call the Copy action,
        and then poll the operation endpoint for the result.

        :param str group_id: The id of the group to copy to. Use only when copying to a Microsoft 365 group.
        :param str _id: Required. The id of the destination section group.
        :param str rename_as: The name of the copy. Defaults to the name of the existing item.
        :param str site_collection_id:
        :param str site_id:
        """
        return_type = OnenoteOperation(self.context)
        payload = {
            "groupId": group_id,
            "id": _id,
            "renameAs": rename_as,
            "siteCollectionId": site_collection_id,
            "siteId": site_id,
        }
        qry = ServiceOperationQuery(
            self, "copyToSectionGroup", None, payload, None, return_type
        )
        self.context.add_query(qry)
        return return_type

    @property
    def is_default(self):
        # type: () -> Optional[bool]
        """Indicates whether this is the user's default section. Read-only."""
        return self.properties.get("isDefault", None)

    @property
    def links(self):
        """Links for opening the section. The oneNoteClientURL link opens the section in the OneNote native client
        if it's installed. The oneNoteWebURL link opens the section in OneNote on the web.
        """
        return self.properties.get("links", PageLinks())

    @property
    def pages(self):
        # type: () -> EntityCollection[OnenotePage]
        """
        The collection of pages in the section. Read-only. Nullable.
        """
        from office365.onenote.pages.page import OnenotePage  # noqa

        return self.properties.get(
            "pages",
            EntityCollection(
                self.context, OnenotePage, ResourcePath("pages", self.resource_path)
            ),
        )

    @property
    def parent_notebook(self):
        """
        The notebook that contains the page. Read-only.
        """
        from office365.onenote.notebooks.notebook import Notebook

        return self.properties.get(
            "parentNotebook",
            Notebook(self.context, ResourcePath("parentNotebook", self.resource_path)),
        )

    @property
    def parent_section_group(self):
        """
        The section group that contains the section. Read-only.
        """
        from office365.onenote.sectiongroups.section_group import SectionGroup

        return self.properties.get(
            "parentSectionGroup",
            SectionGroup(
                self.context, ResourcePath("parentSectionGroup", self.resource_path)
            ),
        )

    def get_property(self, name, default_value=None):
        if default_value is None:
            property_mapping = {
                "parentNotebook": self.parent_notebook,
                "parentSectionGroup": self.parent_section_group,
            }
            default_value = property_mapping.get(name, None)
        return super(OnenoteSection, self).get_property(name, default_value)

Parameters

Name Type Default Kind
bases OnenoteEntityHierarchyModel -

Parameter Details

bases: Parameter of type OnenoteEntityHierarchyModel

Return Value

Returns unspecified type

Class Interface

Methods

copy_to_section_group(self, group_id, _id, rename_as, site_collection_id, site_id)

Purpose: For Copy operations, you follow an asynchronous calling pattern: First call the Copy action, and then poll the operation endpoint for the result. :param str group_id: The id of the group to copy to. Use only when copying to a Microsoft 365 group. :param str _id: Required. The id of the destination section group. :param str rename_as: The name of the copy. Defaults to the name of the existing item. :param str site_collection_id: :param str site_id:

Parameters:

  • group_id: Parameter
  • _id: Parameter
  • rename_as: Parameter
  • site_collection_id: Parameter
  • site_id: Parameter

Returns: None

is_default(self) property

Purpose: Indicates whether this is the user's default section. Read-only.

Returns: None

links(self) property

Purpose: Links for opening the section. The oneNoteClientURL link opens the section in the OneNote native client if it's installed. The oneNoteWebURL link opens the section in OneNote on the web.

Returns: None

pages(self) property

Purpose: The collection of pages in the section. Read-only. Nullable.

Returns: None

parent_notebook(self) property

Purpose: The notebook that contains the page. Read-only.

Returns: None

parent_section_group(self) property

Purpose: The section group that contains the section. Read-only.

Returns: None

get_property(self, name, default_value)

Purpose: Retrieves property

Parameters:

  • name: Parameter
  • default_value: Parameter

Returns: None

Required Imports

from typing import TYPE_CHECKING
from typing import Optional
from office365.entity_collection import EntityCollection
from office365.onenote.entity_hierarchy_model import OnenoteEntityHierarchyModel
from office365.onenote.operations.onenote import OnenoteOperation

Usage Example

# Example usage:
# result = OnenoteSection(bases)

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class OnenotePage 79.2% similar

    A page in a OneNote notebook.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/pages/page.py
  • class SectionGroup 70.5% similar

    Represents a section group in a OneNote notebook that can contain both sections and nested section groups, providing hierarchical organization of OneNote content.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/sectiongroups/section_group.py
  • class Notebook 66.3% 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 OnenotePageCollection 63.7% similar

    A collection class for managing OneNote pages within a OneNote notebook, providing methods to create and manage multiple OnenotePage instances.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/pages/collection.py
  • class Onenote 62.6% 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
← Back to Browse