🔍 Code Extractor

class TenantAdminSettingsService

Maturity: 36

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

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/administration/settings_service.py
Lines:
10 - 56
Complexity:
moderate

Purpose

TenantAdminSettingsService provides an interface to interact with Microsoft SharePoint Online Tenant Administration settings. It allows administrators to query tenant sharing status, retrieve available managed paths for site creation, access SMTP server configuration, and manage groupify settings. This class is part of the Office365 REST API client library and inherits from Entity to provide standard entity operations.

Source Code

class TenantAdminSettingsService(Entity):
    """"""

    def __init__(self, context):
        static_path = ResourcePath(
            "Microsoft.Online.SharePoint.TenantAdministration.TenantAdminSettingsService"
        )
        super(TenantAdminSettingsService, self).__init__(context, static_path)

    def get_tenant_sharing_status(self):
        """"""
        return_type = ClientResult(self.context, int())
        qry = ServiceOperationQuery(
            self, "GetTenantSharingStatus", None, None, None, return_type
        )
        self.context.add_query(qry)
        return return_type

    @property
    def available_managed_paths_for_site_creation(self):
        """"""
        return self.properties.get(
            "AvailableManagedPathsForSiteCreation", StringCollection()
        )

    @property
    def disable_groupify(self):
        """"""
        return self.properties.get("DisableGroupify", DisableGroupify())

    @property
    def smtp_server(self):
        """"""
        return self.properties.get("SmtpServer", SmtpServer())

    @property
    def entity_type_name(self):
        return "Microsoft.Online.SharePoint.TenantAdministration.TenantAdminSettingsService"

    def get_property(self, name, default_value=None):
        if default_value is None:
            property_mapping = {
                "AvailableManagedPathsForSiteCreation": self.available_managed_paths_for_site_creation,
                "SmtpServer": self.smtp_server,
            }
            default_value = property_mapping.get(name, None)
        return super(TenantAdminSettingsService, self).get_property(name, default_value)

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

context: A client context object that maintains the connection and authentication state for SharePoint Online operations. This context is required for all API calls and is passed to the parent Entity class. It should be an instance of ClientContext or similar context object from the office365 library.

Return Value

The constructor returns an instance of TenantAdminSettingsService. The get_tenant_sharing_status method returns a ClientResult object containing an integer representing the tenant's sharing status. Properties return their respective types: StringCollection for available_managed_paths_for_site_creation, DisableGroupify object for disable_groupify, and SmtpServer object for smtp_server.

Class Interface

Methods

__init__(self, context)

Purpose: Initializes the TenantAdminSettingsService with a client context and sets up the static resource path for the service

Parameters:

  • context: Client context object for SharePoint Online operations

Returns: None (constructor)

get_tenant_sharing_status(self) -> ClientResult

Purpose: Queries the tenant's sharing status configuration and returns the result as an integer value

Returns: ClientResult object containing an integer representing the tenant sharing status. Must call context.execute_query() to populate the value.

@property available_managed_paths_for_site_creation(self) -> StringCollection property

Purpose: Gets the collection of available managed paths that can be used for site creation in the tenant

Returns: StringCollection containing the available managed paths

@property disable_groupify(self) -> DisableGroupify property

Purpose: Gets the groupify disable settings for the tenant, which controls whether sites can be converted to Microsoft 365 groups

Returns: DisableGroupify object containing groupify configuration

@property smtp_server(self) -> SmtpServer property

Purpose: Gets the SMTP server configuration for the tenant

Returns: SmtpServer object containing SMTP server settings

@property entity_type_name(self) -> str property

Purpose: Returns the fully qualified entity type name used for serialization and API communication

Returns: String containing the entity type name: 'Microsoft.Online.SharePoint.TenantAdministration.TenantAdminSettingsService'

get_property(self, name: str, default_value=None)

Purpose: Retrieves a property value by name with optional default value, providing custom mapping for specific properties

Parameters:

  • name: The name of the property to retrieve
  • default_value: Optional default value to return if property is not found

Returns: The property value if found, otherwise the default_value or mapped property object

Attributes

Name Type Description Scope
context ClientContext The client context object inherited from Entity, used for all API operations and authentication instance
properties dict Internal dictionary inherited from Entity that stores cached property values retrieved from the server instance
resource_path ResourcePath The static resource path pointing to the TenantAdminSettingsService endpoint in SharePoint Online instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_result import ClientResult
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.runtime.types.collections import StringCollection
from office365.sharepoint.entity import Entity
from office365.sharepoint.tenant.administration.smtp_server import SmtpServer
from office365.sharepoint.tenant.administration.types import DisableGroupify

Usage Example

from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.tenant.administration.tenant_admin_settings_service import TenantAdminSettingsService

# Create context with tenant admin URL
ctx = ClientContext('https://tenant-admin.sharepoint.com')
ctx.with_credentials(user_credentials)

# Instantiate the service
admin_settings = TenantAdminSettingsService(ctx)

# Get tenant sharing status
sharing_status = admin_settings.get_tenant_sharing_status()
ctx.execute_query()
print(f'Sharing status: {sharing_status.value}')

# Access available managed paths
managed_paths = admin_settings.available_managed_paths_for_site_creation
ctx.load(admin_settings)
ctx.execute_query()
for path in managed_paths:
    print(f'Path: {path}')

# Access SMTP server settings
smtp = admin_settings.smtp_server
ctx.load(admin_settings)
ctx.execute_query()
print(f'SMTP Server: {smtp}')

Best Practices

  • Always call ctx.execute_query() after querying methods like get_tenant_sharing_status() to execute the pending requests
  • Use ctx.load() before accessing properties to ensure they are populated from the server
  • Ensure the context is authenticated with tenant administrator credentials before using this service
  • The service uses a static resource path, so multiple instances with the same context will reference the same server resource
  • Handle ClientResult objects properly by accessing their .value property after execute_query()
  • Properties are lazily loaded and cached in the internal properties dictionary
  • The entity_type_name property is used internally for serialization and should not be modified

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class TenantSettings 79.6% similar

    TenantSettings is a class that manages SharePoint tenant-level configuration properties, specifically corporate catalog settings.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/settings.py
  • class Office365Tenant 78.1% similar

    Represents a SharePoint Online tenant and provides administrative operations for managing tenant-level settings, CDN configurations, external users, themes, and user profile properties.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/management/office365_tenant.py
  • class TenantAdminEndpoints 77.1% similar

    A SharePoint entity class representing tenant administration endpoints, providing access to Office 365 admin center endpoint information.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/administration/endpoints.py
  • class SiteCollectionManagementService 69.8% similar

    A service class for managing SharePoint Online site collections through the Tenant Administration API, providing operations for exporting site data and retrieving site creation information.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/administration/sites/collection_management_service.py
  • class TenantCdnApi 66.3% similar

    TenantCdnApi is a SharePoint entity class that provides access to the Tenant CDN (Content Delivery Network) API for managing CDN settings at the tenant level.

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