🔍 Code Extractor

class UpgradeInfo

Maturity: 51

A data class that encapsulates site collection upgrade information in SharePoint, tracking upgrade status, errors, warnings, and related metadata.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sites/upgrade_info.py
Lines:
6 - 44
Complexity:
simple

Purpose

This class serves as a data transfer object (DTO) for SharePoint site collection upgrade operations. It inherits from ClientValue and stores comprehensive information about upgrade processes including timing, status, error tracking, and log file locations. It's primarily used to represent the state and results of SharePoint site collection upgrades, whether build-to-build or version-to-version upgrades.

Source Code

class UpgradeInfo(ClientValue):
    """A class containing site collection upgrade information."""

    def __init__(
        self,
        error_file=None,
        errors=None,
        last_updated=datetime.datetime.min,
        log_file=None,
        request_date=datetime.datetime.min,
        retry_count=None,
        start_time=datetime.datetime.min,
        status=None,
        upgrade_type=None,
        warnings=None,
    ):
        """
        :param str error_file: Specifies the location of the file that contains upgrade errors.
        :param int errors: Specifies the number of errors encountered during the site collection upgrade.
        :param datetime.datetime last_updated: Specifies the DateTime of the latest upgrade progress update.
        :param str log_file: Specifies the location of the file that contains upgrade log.
        :param datetime.datetime request_date: Specifies the DateTime when the site collection upgrade was requested.
        :param int retry_count: Specifies how many times the site collection upgrade was attempted.
        :param datetime.datetime start_time: Specifies the DateTime when the site collection upgrade was started.
        :param int status: Specifies the current site collection upgrade status.
        :param int upgrade_type: Specifies the type of the site collection upgrade type. The type can be either a
             build-to-build upgrade, or a version-to-version upgrade.
        :param int warnings: Specifies the number of warnings encountered during the site collection upgrade.
        """
        self.ErrorFile = error_file
        self.Errors = errors
        self.LastUpdated = last_updated
        self.LogFile = log_file
        self.RequestDate = request_date
        self.RetryCount = retry_count
        self.StartTime = start_time
        self.Status = status
        self.UpgradeType = upgrade_type
        self.Warnings = warnings

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

error_file: String path to the file containing detailed upgrade error information. Defaults to None if no errors occurred or file not specified.

errors: Integer count of errors encountered during the site collection upgrade process. None if upgrade hasn't completed or no errors occurred.

last_updated: DateTime object representing when the upgrade progress was last updated. Defaults to datetime.datetime.min (January 1, 0001) if not set.

log_file: String path to the file containing the complete upgrade log with detailed operation information. Defaults to None if not specified.

request_date: DateTime object indicating when the site collection upgrade was initially requested. Defaults to datetime.datetime.min if not set.

retry_count: Integer representing how many times the upgrade operation has been attempted. None if no retries have occurred.

start_time: DateTime object marking when the site collection upgrade actually began execution. Defaults to datetime.datetime.min if not started.

status: Integer code representing the current upgrade status (e.g., pending, in progress, completed, failed). None if status is unknown.

upgrade_type: Integer code indicating the type of upgrade: build-to-build (minor) or version-to-version (major) upgrade. None if not specified.

warnings: Integer count of warnings encountered during the upgrade that didn't prevent completion. None if no warnings or upgrade incomplete.

Return Value

Instantiation returns an UpgradeInfo object containing all the upgrade-related information passed to the constructor. The object serves as a read/write container for upgrade metadata with public attributes accessible directly.

Class Interface

Attributes

Name Type Description Scope
ErrorFile str | None Path to the file containing upgrade error details instance
Errors int | None Count of errors encountered during upgrade instance
LastUpdated datetime.datetime Timestamp of the most recent upgrade progress update instance
LogFile str | None Path to the file containing the complete upgrade log instance
RequestDate datetime.datetime Timestamp when the upgrade was requested instance
RetryCount int | None Number of times the upgrade has been attempted instance
StartTime datetime.datetime Timestamp when the upgrade execution began instance
Status int | None Current status code of the upgrade operation instance
UpgradeType int | None Type code indicating build-to-build or version-to-version upgrade instance
Warnings int | None Count of warnings encountered during upgrade instance

Dependencies

  • datetime
  • office365.runtime.client_value

Required Imports

import datetime
from office365.runtime.client_value import ClientValue

Usage Example

import datetime
from office365.runtime.client_value import ClientValue
from office365.sharepoint.upgrade_info import UpgradeInfo

# Create an UpgradeInfo instance for a completed upgrade
upgrade_info = UpgradeInfo(
    error_file='/logs/errors.txt',
    errors=2,
    last_updated=datetime.datetime.now(),
    log_file='/logs/upgrade.log',
    request_date=datetime.datetime(2024, 1, 15, 10, 0, 0),
    retry_count=1,
    start_time=datetime.datetime(2024, 1, 15, 10, 5, 0),
    status=2,
    upgrade_type=1,
    warnings=5
)

# Access attributes
print(f'Upgrade status: {upgrade_info.Status}')
print(f'Errors: {upgrade_info.Errors}')
print(f'Warnings: {upgrade_info.Warnings}')
print(f'Log file: {upgrade_info.LogFile}')

# Modify attributes
upgrade_info.Status = 3
upgrade_info.LastUpdated = datetime.datetime.now()

Best Practices

  • This is a data container class with no business logic, so it's safe to instantiate and modify attributes directly.
  • Use datetime.datetime objects for all time-related fields rather than strings to ensure proper date handling.
  • Initialize with datetime.datetime.min for unset datetime fields to distinguish from None and actual dates.
  • The class inherits from ClientValue, which likely provides serialization capabilities for SharePoint API communication.
  • All attributes use PascalCase naming convention (e.g., ErrorFile, LastUpdated) following SharePoint API conventions.
  • This class is typically populated by SharePoint API responses rather than manually constructed in most use cases.
  • Status and UpgradeType are integer codes - refer to SharePoint documentation for valid values and their meanings.
  • The class is immutable in design intent but technically mutable - avoid modifying instances received from API calls.
  • When creating instances for testing or mocking, provide realistic datetime values rather than using defaults.

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SiteUserGroupInfo 70.6% similar

    A data class representing SharePoint site user group information in the Microsoft Online SharePoint Tenant Administration context.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/administration/site_user_group_info.py
  • class SiteInfoForSitePicker 69.6% similar

    A data transfer object representing site information for SharePoint site picker operations in Microsoft Online SharePoint Tenant Administration.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/administration/siteinfo_for_site_picker.py
  • class OrgNewsSiteInfo 69.6% similar

    A data class representing organizational news site information in SharePoint, inheriting from ClientValue to provide serialization capabilities for SharePoint API interactions.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/orgnewssite/info.py
  • class GroupSiteInfo 68.9% similar

    A data class representing information about a SharePoint group site, including its URL, status, and related metadata.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/portal/groups/site_info.py
  • class DocumentLibraryInformation 68.3% similar

    A data class that represents metadata and configuration information for a SharePoint document library on a site.

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