class GuidCollection
A specialized collection class for managing UUID (Globally Unique Identifier) values, extending ClientValueCollection to provide type-safe storage and manipulation of GUID objects.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/runtime/types/collections.py
14 - 19
simple
Purpose
GuidCollection serves as a type-safe container for managing collections of UUID objects within the Office365 API framework. It inherits from ClientValueCollection and specializes it for handling GUID/UUID values, ensuring that all items in the collection are valid UUID instances. This class is typically used when working with SharePoint or Office365 entities that require collections of unique identifiers, such as user IDs, document IDs, or other entity references.
Source Code
class GuidCollection(ClientValueCollection):
def __init__(self, initial_values=None):
"""
:type initial_values list[uuid] or None
"""
super(GuidCollection, self).__init__(uuid.UUID, initial_values)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValueCollection | - |
Parameter Details
initial_values: An optional list of UUID objects to initialize the collection with. Can be None to create an empty collection, or a list containing uuid.UUID instances. If provided, these values will populate the collection upon instantiation. The parameter accepts None or a list of UUID objects.
Return Value
Instantiation returns a GuidCollection object that can store and manage UUID values. The collection inherits all methods from ClientValueCollection, which typically include methods for adding, removing, iterating, and accessing UUID elements. Individual method returns depend on the inherited ClientValueCollection interface.
Class Interface
Methods
__init__(self, initial_values=None)
Purpose: Initializes a new GuidCollection instance with optional initial UUID values
Parameters:
initial_values: Optional list of uuid.UUID objects to populate the collection. Defaults to None for an empty collection.
Returns: None (constructor)
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
_item_type |
type | Inherited from ClientValueCollection, stores the type constraint (uuid.UUID) for items in this collection | instance |
_data |
list | Inherited from ClientValueCollection, stores the actual list of UUID objects in the collection | instance |
Dependencies
uuidoffice365
Required Imports
import uuid
from office365.runtime.client_value_collection import ClientValueCollection
Usage Example
import uuid
from office365.runtime.types.collections import GuidCollection
# Create an empty GUID collection
guid_collection = GuidCollection()
# Create a collection with initial UUIDs
initial_guids = [
uuid.UUID('12345678-1234-5678-1234-567812345678'),
uuid.UUID('87654321-4321-8765-4321-876543218765')
]
guid_collection_with_values = GuidCollection(initial_values=initial_guids)
# Add a new GUID to the collection (assuming inherited add method)
new_guid = uuid.uuid4()
guid_collection.add(new_guid)
# Iterate through the collection (assuming inherited iteration support)
for guid in guid_collection_with_values:
print(f"GUID: {guid}")
Best Practices
- Always pass valid uuid.UUID objects when initializing with initial_values, not string representations
- Use uuid.UUID() constructor or uuid.uuid4() to create valid UUID objects before adding to the collection
- The collection enforces type safety, so attempting to add non-UUID objects may raise errors
- This class is designed for use within the Office365 API context and may have specific serialization behavior for API calls
- Leverage inherited methods from ClientValueCollection for standard collection operations
- When working with Office365 entities, this collection type is typically used for properties that reference multiple entities by their unique identifiers
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class FieldGuid 69.5% similar
-
class StringCollection 67.1% similar
-
class GroupCollection 61.4% similar
-
class UserCollection 60.1% similar
-
class ClientObjectCollection 60.1% similar