class EntityType
A class that defines constants for different Microsoft Graph API search resource types.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/search/entity_type.py
1 - 21
simple
Purpose
EntityType serves as a namespace for string constants representing various Microsoft Graph entity types that can be searched. It provides a centralized, type-safe way to reference entity types like events, lists, sites, messages, drives, and external items when performing search operations in Microsoft Graph API integrations.
Source Code
class EntityType:
"""Search resource type"""
def __init__(self):
pass
event = "event"
list = "list"
site = "site"
listItem = "listItem"
message = "message"
drive = "drive"
driveItem = "driveItem"
externalItem = "externalItem"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
- | - |
Parameter Details
__init__: The constructor takes no parameters and performs no initialization. It exists only to allow instantiation of the class, though the class is primarily intended to be used as a namespace for its class-level string constants.
Return Value
Instantiating EntityType() returns an instance of the EntityType class. However, the class is designed to be used by accessing its class-level string attributes directly (e.g., EntityType.event) rather than through instance creation. Each attribute returns a string value representing a specific entity type.
Class Interface
Methods
__init__(self)
Purpose: Initializes an EntityType instance (though instantiation is not required for normal usage)
Returns: None - constructor returns an EntityType instance implicitly
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
event |
str | Constant representing the 'event' entity type for calendar events | class |
list |
str | Constant representing the 'list' entity type for SharePoint lists | class |
site |
str | Constant representing the 'site' entity type for SharePoint sites | class |
listItem |
str | Constant representing the 'listItem' entity type for items within SharePoint lists | class |
message |
str | Constant representing the 'message' entity type for email messages | class |
drive |
str | Constant representing the 'drive' entity type for OneDrive/SharePoint drives | class |
driveItem |
str | Constant representing the 'driveItem' entity type for files and folders in drives | class |
externalItem |
str | Constant representing the 'externalItem' entity type for external connector items | class |
Usage Example
# Access entity type constants directly from the class
from entity_type import EntityType
# Use constants to specify search resource types
search_type = EntityType.event
print(search_type) # Output: 'event'
# Typical usage in a search query context
if resource_type == EntityType.message:
# Handle message search
pass
elif resource_type == EntityType.driveItem:
# Handle drive item search
pass
# Can also instantiate (though not necessary)
entity_types = EntityType()
list_type = entity_types.list
print(list_type) # Output: 'list'
Best Practices
- Use class attributes directly without instantiation (e.g., EntityType.event) for cleaner code
- This class follows an enum-like pattern and should be treated as a read-only constant container
- Do not modify the class attributes at runtime as they represent fixed API entity type identifiers
- Consider using Python's enum.Enum for a more robust implementation if extending this class
- The class is stateless and thread-safe since it only contains string constants
- Instantiation is unnecessary; access attributes directly from the class itself
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class SearchEntity 64.0% similar
-
class SiteType 55.4% similar
-
class PageType 54.8% similar
-
class BodyType 53.5% similar
-
class CalendarType 52.3% similar