🔍 Code Extractor

class ContextCondition

Maturity: 47

A data class representing context conditions for a tenant in Microsoft Office Server Search REST API, containing properties for context condition type and source identifier.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/context_condition.py
Lines:
4 - 19
Complexity:
simple

Purpose

This class serves as a data transfer object (DTO) for representing context conditions in SharePoint/Office 365 search operations. It encapsulates the context condition type and source ID properties that describe search context conditions for a tenant. The class inherits from ClientValue, making it compatible with the Office 365 REST API client framework for serialization and transmission to SharePoint services.

Source Code

class ContextCondition(ClientValue):
    """
    This object contains properties that describe the context condition for the tenant.
    """

    def __init__(self, context_condition_type=None, source_id=None):
        """
        :param str context_condition_type: This property contains the context condition type for this context condition.
        :param str source_id: This property contains the source id for this context condition.
        """
        self.ContextConditionType = context_condition_type
        self.SourceId = source_id

    @property
    def entity_type_name(self):
        return "Microsoft.Office.Server.Search.REST.ContextCondition"

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

context_condition_type: A string representing the type of context condition being applied. This defines the category or classification of the context condition for search operations. Can be None if not specified during instantiation.

source_id: A string identifier for the source of this context condition. This uniquely identifies where the context condition originates from within the tenant. Can be None if not specified during instantiation.

Return Value

Instantiation returns a ContextCondition object with ContextConditionType and SourceId attributes set to the provided values (or None if not provided). The entity_type_name property returns the string 'Microsoft.Office.Server.Search.REST.ContextCondition', which is used for REST API serialization and type identification.

Class Interface

Methods

__init__(context_condition_type=None, source_id=None)

Purpose: Initializes a new ContextCondition instance with optional context condition type and source ID

Parameters:

  • context_condition_type: Optional string representing the type of context condition (default: None)
  • source_id: Optional string identifier for the source of this context condition (default: None)

Returns: None (constructor)

@property entity_type_name(self) -> str property

Purpose: Returns the fully qualified entity type name used for REST API serialization and type identification

Returns: String 'Microsoft.Office.Server.Search.REST.ContextCondition' representing the entity type in the Office Server Search REST API

Attributes

Name Type Description Scope
ContextConditionType str or None Stores the context condition type for this context condition. Represents the category or classification of the search context condition. instance
SourceId str or None Stores the source identifier for this context condition. Uniquely identifies the origin of the context condition within the tenant. instance

Dependencies

  • office365.runtime.client_value

Required Imports

from office365.runtime.client_value import ClientValue

Usage Example

from office365.runtime.client_value import ClientValue

# Create a context condition with both parameters
context_condition = ContextCondition(
    context_condition_type="LocationBased",
    source_id="site-123-456"
)

# Access the properties
print(context_condition.ContextConditionType)  # Output: LocationBased
print(context_condition.SourceId)  # Output: site-123-456
print(context_condition.entity_type_name)  # Output: Microsoft.Office.Server.Search.REST.ContextCondition

# Create with default values
default_condition = ContextCondition()
print(default_condition.ContextConditionType)  # Output: None
print(default_condition.SourceId)  # Output: None

Best Practices

  • This is a simple data container class with no complex state management or side effects
  • Both constructor parameters are optional and default to None, allowing flexible instantiation
  • The class is immutable in practice - attributes should be set during instantiation or immediately after
  • The entity_type_name property should not be overridden as it's used for REST API type identification
  • This class is typically instantiated and passed to SharePoint search API methods rather than used standalone
  • When using with Office 365 REST API, ensure the context_condition_type matches valid types expected by the SharePoint search service
  • The SourceId should correspond to valid source identifiers within your SharePoint tenant

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class QueryContext 76.1% similar

    QueryContext is a data container class that encapsulates query context properties for Microsoft Office Server Search REST API operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/context.py
  • class QueryCondition 74.5% similar

    QueryCondition is a data class that represents conditions for promoted search results in Microsoft Office Server Search REST API.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/condition.py
  • class SearchObjectOwnerResult 67.2% similar

    A data class representing the owner of a search object in Microsoft Office 365 Search REST API, containing identifiers for tenant, site collection, and site.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/object_owner_result.py
  • class PopularTenantQuery 65.3% similar

    A client value class representing a popular tenant query in Microsoft SharePoint Search API, used to interact with SharePoint's search query functionality for popular tenant-level queries.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/popular_tenant_query.py
  • class GroupCreationContext 65.2% similar

    A client value class representing the context for creating a SharePoint group, inheriting from ClientValue base class.

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