🔍 Code Extractor

class GuidCollection

Maturity: 29

A specialized collection class for managing UUID (Globally Unique Identifier) values, extending ClientValueCollection to provide type-safe storage and manipulation of GUID objects.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/runtime/types/collections.py
Lines:
14 - 19
Complexity:
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

  • uuid
  • office365

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

    A specialized Field class that represents a field containing globally unique identifier (GUID) values in SharePoint.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/guid.py
  • class StringCollection 67.1% similar

    A specialized collection class for managing a list of string values, inheriting from ClientValueCollection with string type specialization.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/runtime/types/collections.py
  • class GroupCollection 61.4% similar

    A collection class for managing Microsoft Graph API Group resources, providing methods to create, retrieve, and manage groups including Microsoft 365 groups and Security groups.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/groups/collection.py
  • class UserCollection 60.1% similar

    UserCollection is a specialized collection class for managing User objects in Microsoft 365/Office 365 directory services, providing methods to retrieve, create, and manage users with delta query support.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/users/collection.py
  • class ClientObjectCollection 60.1% similar

    A generic collection container class that manages collections of ClientObject instances with support for pagination, filtering, ordering, and lazy loading of items from a remote data source.

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