class SPOTenantWebTemplateCollection
A collection class that represents a set of SharePoint Online tenant web templates, inheriting from Entity and providing access to template items.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/administration/webs/templates/collection.py
8 - 11
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
-
class SPOTenantWebTemplate 79.0% similar
-
class ListTemplateCollection 77.9% similar
-
class WebTemplate 69.4% similar
-
class WebCollection 68.0% similar