🔍 Code Extractor

class EntityType

Maturity: 42

A class that defines constants for different Microsoft Graph API search resource types.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/search/entity_type.py
Lines:
1 - 21
Complexity:
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

    A wrapper class for the Microsoft Graph Search API endpoint that provides methods to query various Microsoft 365 resources including messages, events, drive items, and other entity types.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/search/entity.py
  • class SiteType 55.4% similar

    A simple enumeration-like class that defines constants for SharePoint site types.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sites/site_type.py
  • class PageType 54.8% similar

    An enumeration class that defines constants representing different SharePoint page types as specified in the MS-WSSFO3 protocol specification.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/pages/page_type.py
  • class BodyType 53.5% similar

    A simple enumeration-style class that defines constants for different body content types in HTTP requests or responses.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/body_type.py
  • class CalendarType 52.3% similar

    An enumeration class that defines calendar type constants as specified in Microsoft SharePoint protocols [MS-WSSFO2] and [MS-WSSFO3].

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