🔍 Code Extractor

class UsageDetails

Maturity: 50

A data class representing usage metadata for resources, tracking when a resource was last accessed and last modified by a user.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/insights/usage_details.py
Lines:
10 - 21
Complexity:
simple

Purpose

UsageDetails is a value object that encapsulates temporal information about resource usage in Microsoft Office 365 services. It stores two datetime values: when a resource was last accessed (viewed) and when it was last modified (edited) by a user. This class inherits from ClientValue, making it suitable for serialization and transmission in Office 365 API communications. It's typically used as a property of other resource objects to provide usage tracking information.

Source Code

class UsageDetails(ClientValue):
    """Complex type containing properties of Used items. Information on when the resource was last accessed (viewed)
    or modified (edited) by the user."""

    def __init__(self, last_accessed_datetime=None, last_modified_datetime=None):
        # type: (Optional[datetime], Optional[datetime]) -> None
        """
        :param last_accessed_datetime: The date and time the resource was last accessed by the user.
        :param last_modified_datetime: The date and time the resource was last modified by the user.
        """
        self.lastAccessedDateTime = last_accessed_datetime
        self.lastModifiedDateTime = last_modified_datetime

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

last_accessed_datetime: Optional datetime object representing when the resource was last accessed (viewed) by the user. Can be None if the resource has never been accessed or if this information is unavailable. Expected to be a Python datetime object from the datetime module.

last_modified_datetime: Optional datetime object representing when the resource was last modified (edited) by the user. Can be None if the resource has never been modified or if this information is unavailable. Expected to be a Python datetime object from the datetime module.

Return Value

Instantiation returns a UsageDetails object with two instance attributes: lastAccessedDateTime and lastModifiedDateTime. These attributes store the datetime values passed during initialization and can be accessed directly as properties of the instance. The class does not define any methods that return values beyond the inherited ClientValue methods.

Class Interface

Methods

__init__(self, last_accessed_datetime: Optional[datetime] = None, last_modified_datetime: Optional[datetime] = None) -> None

Purpose: Initializes a new UsageDetails instance with optional last accessed and last modified datetime values

Parameters:

  • last_accessed_datetime: Optional datetime object representing when the resource was last accessed by the user
  • last_modified_datetime: Optional datetime object representing when the resource was last modified by the user

Returns: None - this is a constructor that initializes the instance

Attributes

Name Type Description Scope
lastAccessedDateTime Optional[datetime] Stores the date and time when the resource was last accessed (viewed) by the user. Can be None if never accessed or information unavailable. instance
lastModifiedDateTime Optional[datetime] Stores the date and time when the resource was last modified (edited) by the user. Can be None if never modified or information unavailable. instance

Dependencies

  • office365
  • typing

Required Imports

from office365.runtime.client_value import ClientValue
from datetime import datetime
from typing import Optional

Usage Example

from datetime import datetime
from office365.runtime.client_value import ClientValue
from typing import Optional

class UsageDetails(ClientValue):
    def __init__(self, last_accessed_datetime=None, last_modified_datetime=None):
        self.lastAccessedDateTime = last_accessed_datetime
        self.lastModifiedDateTime = last_modified_datetime

# Create a UsageDetails instance with both timestamps
access_time = datetime(2024, 1, 15, 10, 30, 0)
modify_time = datetime(2024, 1, 16, 14, 45, 0)
usage = UsageDetails(last_accessed_datetime=access_time, last_modified_datetime=modify_time)

# Access the stored values
print(f"Last accessed: {usage.lastAccessedDateTime}")
print(f"Last modified: {usage.lastModifiedDateTime}")

# Create instance with only one timestamp
usage_partial = UsageDetails(last_accessed_datetime=access_time)
print(f"Accessed: {usage_partial.lastAccessedDateTime}")
print(f"Modified: {usage_partial.lastModifiedDateTime}")  # Will be None

# Create empty instance
usage_empty = UsageDetails()
print(f"Empty usage details: {usage_empty.lastAccessedDateTime}, {usage_empty.lastModifiedDateTime}")

Best Practices

  • Always use Python datetime objects for the timestamp parameters, not strings or other date representations.
  • This class is immutable by design - set the datetime values during initialization rather than modifying them later.
  • The attribute names use camelCase (lastAccessedDateTime, lastModifiedDateTime) to match Office 365 API conventions, even though the constructor parameters use snake_case.
  • Both parameters are optional and default to None, allowing partial usage information to be represented.
  • This class inherits from ClientValue, which likely provides serialization capabilities for Office 365 API communication - do not override inherited methods unless necessary.
  • When using this class in Office 365 API contexts, ensure datetime objects are timezone-aware if required by the API.
  • This is a data transfer object (DTO) - it should only hold data and not contain business logic.
  • Instances of this class are typically created by the Office 365 SDK when deserializing API responses, but can also be manually instantiated for testing or custom usage scenarios.

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SharingDetail 63.5% similar

    A data class representing detailed information about how a document or resource was shared in Microsoft 365, including who shared it, when, and through what method.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/insights/sharing_detail.py
  • class UsageInfo 62.5% similar

    A data class that encapsulates usage statistics for a SharePoint site collection, including bandwidth consumption, discussion storage, and visit counts.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sites/usage_info.py
  • class ResourceData 61.7% similar

    A data class representing resource data attached to change notifications sent to subscribers in Office 365 integrations. It extends ClientValue to support open-type properties.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/subscriptions/resource_data.py
  • class ActivityTimeFacet 59.9% similar

    A data class representing time-related facets of an activity, including when it was last recorded, observed, and recorded.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/activities/facets/activity_time.py
  • class PageDetails 58.3% similar

    PageDetails is a minimal data class that inherits from ClientValue, serving as a container for page-related details in the Office365 API context.

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