class TaxonomyMetadata
A client value class representing taxonomy metadata for SharePoint Publishing, specifically storing an anchor ID reference.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/taxonomy/metadata.py
4 - 13
simple
Purpose
TaxonomyMetadata is a data transfer object (DTO) that encapsulates taxonomy-related metadata for SharePoint Publishing operations. It inherits from ClientValue, making it suitable for serialization and transmission in SharePoint API calls. The class primarily stores an anchor ID that references a taxonomy term or location within SharePoint's managed metadata service. This class is used when working with SharePoint's taxonomy and term store functionality, allowing developers to associate content with specific taxonomy terms.
Source Code
class TaxonomyMetadata(ClientValue):
def __init__(self, anchor_id=None):
"""
:param str anchor_id:
"""
self.anchorId = anchor_id
@property
def entity_type_name(self):
return "SP.Publishing.TaxonomyMetadata"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
anchor_id: A string identifier that references a specific taxonomy term or anchor point in SharePoint's managed metadata service. This can be None if no anchor is specified. The anchor ID typically corresponds to a GUID or unique identifier for a term in the term store.
Return Value
Instantiation returns a TaxonomyMetadata object with the anchorId attribute set to the provided value (or None). The entity_type_name property returns the string 'SP.Publishing.TaxonomyMetadata', which identifies this object's type in SharePoint's client object model.
Class Interface
Methods
__init__(self, anchor_id=None) -> None
Purpose: Initializes a new TaxonomyMetadata instance with an optional anchor ID
Parameters:
anchor_id: Optional string representing the taxonomy term anchor identifier, defaults to None
Returns: None (constructor)
@property entity_type_name(self) -> str
property
Purpose: Returns the SharePoint entity type name for this metadata object
Returns: String 'SP.Publishing.TaxonomyMetadata' identifying the SharePoint entity type
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
anchorId |
str or None | Stores the taxonomy term anchor identifier as a string, or None if not specified. This is the primary data payload of the class. | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
Usage Example
from office365.runtime.client_value import ClientValue
from office365.sharepoint.publishing.taxonomy_metadata import TaxonomyMetadata
# Create a TaxonomyMetadata instance with an anchor ID
taxonomy_meta = TaxonomyMetadata(anchor_id="12345678-1234-1234-1234-123456789abc")
# Access the anchor ID
print(taxonomy_meta.anchorId) # Output: 12345678-1234-1234-1234-123456789abc
# Get the entity type name
print(taxonomy_meta.entity_type_name) # Output: SP.Publishing.TaxonomyMetadata
# Create instance without anchor ID
empty_taxonomy_meta = TaxonomyMetadata()
print(empty_taxonomy_meta.anchorId) # Output: None
Best Practices
- This class is a simple data container and should be instantiated with a valid anchor_id when referencing specific taxonomy terms
- The anchorId attribute is publicly accessible and can be modified after instantiation if needed
- This class inherits from ClientValue, which means it's designed for serialization in SharePoint API operations - do not add complex logic or methods that cannot be serialized
- The entity_type_name property should not be overridden as it identifies the SharePoint entity type for proper API communication
- When using with SharePoint APIs, ensure the anchor_id corresponds to a valid term GUID in the target SharePoint environment's term store
- This class is immutable in practice - create new instances rather than modifying existing ones when working with different taxonomy references
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class TaxonomyFieldValue 75.9% similar
-
class TaxonomyField 70.4% similar
-
class ContentTypeEntityData 68.1% similar
-
class TaxonomyFieldValueCollection 67.0% similar
-
class TaxonomyItem 66.5% similar