🔍 Code Extractor

class HomeSiteNavigationSettings

Maturity: 36

A class representing SharePoint home site navigation settings, providing functionality to manage global navigation configuration for a SharePoint home site.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/navigation/home_site_navigation_settings.py
Lines:
6 - 25
Complexity:
simple

Purpose

This class is part of the Office365 SharePoint REST API client library and provides an interface to interact with home site navigation settings. It allows developers to enable or disable global navigation for a SharePoint home site through the REST API. The class inherits from Entity, which provides base functionality for SharePoint entities, and uses the service operation query pattern to execute operations against the SharePoint REST endpoint.

Source Code

class HomeSiteNavigationSettings(Entity):
    def __init__(self, context, resource_path=None):
        if resource_path is None:
            resource_path = ResourcePath(
                "Microsoft.SharePoint.Navigation.REST.HomeSiteNavigationSettings"
            )
        super(HomeSiteNavigationSettings, self).__init__(context, resource_path)

    def enable_global_navigation(self, is_enabled):
        """
        :param bool is_enabled:
        """
        payload = {"isEnabled": is_enabled}
        qry = ServiceOperationQuery(self, "EnableGlobalNavigation", None, payload)
        self.context.add_query(qry)
        return self

    @property
    def entity_type_name(self):
        return "Microsoft.SharePoint.Navigation.REST.HomeSiteNavigationSettings"

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

context: The client context object that manages the connection to SharePoint and handles authentication. This is required for all SharePoint API operations and is inherited from the Entity base class.

resource_path: Optional ResourcePath object specifying the REST API endpoint path. If not provided, defaults to 'Microsoft.SharePoint.Navigation.REST.HomeSiteNavigationSettings'. This path is used to construct the full URL for API requests.

Return Value

The constructor returns an instance of HomeSiteNavigationSettings. The enable_global_navigation method returns self (the current instance) to allow method chaining. The entity_type_name property returns a string representing the SharePoint entity type name: 'Microsoft.SharePoint.Navigation.REST.HomeSiteNavigationSettings'.

Class Interface

Methods

__init__(self, context, resource_path=None)

Purpose: Initializes a new instance of HomeSiteNavigationSettings with the provided context and optional resource path

Parameters:

  • context: The SharePoint client context object for API communication
  • resource_path: Optional ResourcePath object; defaults to the standard home site navigation settings endpoint if None

Returns: None (constructor)

enable_global_navigation(self, is_enabled: bool) -> HomeSiteNavigationSettings

Purpose: Enables or disables global navigation for the home site by queuing a service operation

Parameters:

  • is_enabled: Boolean value indicating whether to enable (True) or disable (False) global navigation

Returns: Returns self to allow method chaining

@property entity_type_name(self) -> str property

Purpose: Returns the SharePoint entity type name for this navigation settings object

Returns: String 'Microsoft.SharePoint.Navigation.REST.HomeSiteNavigationSettings' representing the entity type

Attributes

Name Type Description Scope
context ClientContext Inherited from Entity base class; stores the SharePoint client context used for API operations instance
resource_path ResourcePath Inherited from Entity base class; stores the REST API endpoint path for this entity instance

Dependencies

  • office365-rest-python-client

Required Imports

from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.entity import Entity

Usage Example

from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.user_credential import UserCredential
from office365.sharepoint.navigation.home_site_navigation_settings import HomeSiteNavigationSettings

# Setup authentication and context
site_url = 'https://yourtenant.sharepoint.com/sites/yoursite'
username = 'user@yourtenant.onmicrosoft.com'
password = 'your_password'
credentials = UserCredential(username, password)
ctx = ClientContext(site_url).with_credentials(credentials)

# Create instance and enable global navigation
nav_settings = HomeSiteNavigationSettings(ctx)
nav_settings.enable_global_navigation(True)
ctx.execute_query()

# Method chaining is supported
nav_settings.enable_global_navigation(False)
ctx.execute_query()

Best Practices

  • Always call ctx.execute_query() after calling enable_global_navigation() to actually execute the operation against SharePoint
  • Ensure the context object has appropriate permissions before attempting to modify navigation settings
  • The enable_global_navigation method returns self, allowing for method chaining if multiple operations need to be queued
  • Handle authentication errors and network failures when executing queries against SharePoint
  • The class follows the repository pattern where operations are queued and executed in batch via the context
  • Do not instantiate this class directly without a valid SharePoint context object
  • The resource_path parameter should typically be left as None unless you need to target a specific custom endpoint

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class NavigationService 77.4% similar

    NavigationService is a REST-based service class for managing SharePoint navigation operations, including global navigation, menu states, and publishing navigation providers.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/navigation/navigation_service.py
  • class MetadataNavigationSettings 72.7% similar

    A class that manages metadata navigation and filtering settings for SharePoint lists, providing functionality to retrieve and configure metadata navigation settings.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/navigation/metadata_settings.py
  • class Navigation 72.0% similar

    Represents navigation operations at the SharePoint site collection level, providing access to Quick Launch and Top Navigation Bar node collections.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/navigation/navigation.py
  • class SuiteNavData 62.6% similar

    A SharePoint entity class representing Suite Navigation Data, which manages navigation information for the SharePoint suite bar.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/portal/suite_nav_data.py
  • class TenantAdminSettingsService 62.5% similar

    A service class for managing SharePoint Online tenant administration settings, providing access to tenant-level configuration and sharing status.

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