🔍 Code Extractor

class SPOTenantWebTemplateCollection

Maturity: 24

A collection class that represents a set of SharePoint Online tenant web templates, inheriting from Entity and providing access to template items.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/administration/webs/templates/collection.py
Lines:
8 - 11
Complexity:
simple

Purpose

This class serves as a container for managing collections of SPOTenantWebTemplate objects in SharePoint Online tenant administration. It provides a property-based interface to access the underlying collection of web templates, which are used to define site structures and configurations at the tenant level. The class follows the Office365 SDK pattern for entity collections, wrapping the raw data in a strongly-typed collection interface.

Source Code

class SPOTenantWebTemplateCollection(Entity):
    @property
    def items(self):
        return self.properties.get("Items", ClientValueCollection(SPOTenantWebTemplate))

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

bases: Inherits from Entity class, which provides base functionality for SharePoint entities including property management, serialization, and client context handling

Return Value

Instantiation returns an SPOTenantWebTemplateCollection object that wraps a collection of web templates. The items property returns a ClientValueCollection containing SPOTenantWebTemplate objects, or an empty collection if no items exist.

Class Interface

Methods

@property items(self) -> ClientValueCollection[SPOTenantWebTemplate] property

Purpose: Retrieves the collection of SPOTenantWebTemplate objects contained in this collection

Returns: A ClientValueCollection containing SPOTenantWebTemplate objects. Returns an empty ClientValueCollection if no items are present in the properties dictionary.

Attributes

Name Type Description Scope
properties dict Inherited from Entity base class. Stores the raw property data including the 'Items' key which contains the collection of web templates instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value_collection import ClientValueCollection
from office365.sharepoint.entity import Entity
from office365.sharepoint.tenant.administration.webs.templates.template import SPOTenantWebTemplate

Usage Example

from office365.sharepoint.tenant.administration.webs.templates.collection import SPOTenantWebTemplateCollection
from office365.sharepoint.client_context import ClientContext

# Authenticate and get context
ctx = ClientContext(site_url).with_credentials(credentials)

# Typically obtained from tenant administration API
tenant = ctx.tenant
templates_collection = tenant.get_web_templates()
ctx.load(templates_collection)
ctx.execute_query()

# Access the items in the collection
for template in templates_collection.items:
    print(f"Template: {template.name}")

Best Practices

  • Always load the collection using ctx.load() and ctx.execute_query() before accessing items property
  • The items property returns a lazy-loaded collection that may be empty until the entity is properly loaded from SharePoint
  • This class is typically not instantiated directly but obtained through tenant administration API calls
  • Handle cases where the items collection might be empty or None
  • Ensure proper authentication and tenant admin permissions before attempting to access web template collections
  • The collection follows the Office365 SDK pattern where properties are stored in a properties dictionary

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class WebTemplateCollection 84.7% similar

    A collection class for managing SharePoint site templates (WebTemplate objects), providing methods to retrieve and work with multiple web templates.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/webs/template_collection.py
  • class SPOTenantWebTemplate 79.0% similar

    A client value class representing a SharePoint Online tenant web template in the Microsoft Online SharePoint Tenant Administration API.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/administration/webs/templates/template.py
  • class ListTemplateCollection 77.9% similar

    A collection class that manages and provides access to SharePoint list templates, extending EntityCollection to handle multiple ListTemplate instances.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/lists/template_collection.py
  • class WebTemplate 69.4% similar

    Represents a SharePoint site definition or site template that is used to instantiate a site, providing access to template metadata and configuration properties.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/webs/template.py
  • class WebCollection 68.0% similar

    WebCollection is a specialized collection class for managing SharePoint Web objects, providing methods to add new webs and handle web-specific resource paths.

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