🔍 Code Extractor

class Synchronization

Maturity: 56

Represents Azure Active Directory (Azure AD) identity synchronization capabilities through Microsoft Graph API, managing automated provisioning and de-provisioning of user identities and roles.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/synchronization/synchronization.py
Lines:
8 - 45
Complexity:
moderate

Purpose

This class provides an interface to Azure AD identity synchronization (provisioning) functionality. It allows automation of user identity and role lifecycle management between Azure AD and supported cloud applications. The class exposes two main collections: synchronization jobs (which perform periodic background synchronization) and synchronization templates (which define synchronization configurations). It inherits from Entity, making it part of the Microsoft Graph API object model.

Source Code

class Synchronization(Entity):
    """
    Represents the capability for Azure Active Directory (Azure AD) identity synchronization through
    the Microsoft Graph API. Identity synchronization (also called provisioning) allows you to automate
    the provisioning (creation, maintenance) and de-provisioning (removal) of user identities and roles from
    Azure AD to supported cloud applications. For more information, see How Application Provisioning works
    in Azure Active Directory
    """

    @property
    def jobs(self):
        """
        Performs synchronization by periodically running in the background, polling for changes in one directory,
        and pushing them to another directory.
        """
        return self.properties.get(
            "jobs",
            EntityCollection(
                self.context,
                SynchronizationJob,
                ResourcePath("jobs", self.resource_path),
            ),
        )

    @property
    def templates(self):
        """
        Performs synchronization by periodically running in the background, polling for changes in one directory,
        and pushing them to another directory.
        """
        return self.properties.get(
            "templates",
            EntityCollection(
                self.context,
                SynchronizationTemplate,
                ResourcePath("templates", self.resource_path),
            ),
        )

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

context: The client context object required for making API calls to Microsoft Graph. Inherited from Entity base class, used to authenticate and communicate with the API.

resource_path: The resource path identifying this synchronization resource in the Microsoft Graph API hierarchy. Inherited from Entity base class.

Return Value

Instantiation returns a Synchronization object that provides access to synchronization jobs and templates through property accessors. The jobs property returns an EntityCollection of SynchronizationJob objects. The templates property returns an EntityCollection of SynchronizationTemplate objects. Both collections support standard collection operations for managing synchronization resources.

Class Interface

Methods

@property jobs(self) -> EntityCollection property

Purpose: Provides access to the collection of synchronization jobs that perform periodic background synchronization by polling for changes in one directory and pushing them to another

Returns: EntityCollection of SynchronizationJob objects representing all synchronization jobs associated with this synchronization resource

@property templates(self) -> EntityCollection property

Purpose: Provides access to the collection of synchronization templates that define synchronization configurations and schemas

Returns: EntityCollection of SynchronizationTemplate objects representing all synchronization templates available for this synchronization resource

Attributes

Name Type Description Scope
context ClientContext The client context object used for API communication, inherited from Entity base class instance
resource_path ResourcePath The resource path identifying this synchronization resource in the API hierarchy, inherited from Entity base class instance
properties dict Dictionary storing the entity properties including cached collections for jobs and templates, inherited from Entity base class instance

Dependencies

  • office365

Required Imports

from office365.directory.synchronization.synchronization import Synchronization
from office365.directory.synchronization.job import SynchronizationJob
from office365.directory.synchronization.template import SynchronizationTemplate
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.runtime.paths.resource_path import ResourcePath

Usage Example

# Assuming you have a configured Graph API client context
from office365.graph_client import GraphClient

# Initialize client with credentials
client = GraphClient.with_credentials(tenant_id, client_id, client_secret)

# Get synchronization for a service principal or application
service_principal = client.service_principals.get_by_id('sp-id')
sync = service_principal.synchronization

# Access synchronization jobs
jobs = sync.jobs
for job in jobs:
    print(f"Job ID: {job.id}, Status: {job.status}")

# Access synchronization templates
templates = sync.templates
for template in templates:
    print(f"Template ID: {template.id}")

# Get a specific job
specific_job = sync.jobs.get_by_id('job-id')
specific_job.get().execute_query()

Best Practices

  • Always ensure proper authentication and authorization before accessing synchronization resources
  • The class uses lazy loading for collections - properties are only populated when accessed
  • Jobs and templates are accessed through EntityCollection objects which support querying and filtering
  • This class should be obtained through a parent entity (like ServicePrincipal or Application) rather than instantiated directly
  • Use the context object consistently across related operations to maintain session state
  • Handle API rate limits and throttling when performing bulk operations on jobs or templates
  • Monitor synchronization job status regularly to detect and handle failures
  • Cache the collections if accessing them multiple times to avoid redundant API calls

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SynchronizationJob 71.6% similar

    Manages Microsoft 365 directory synchronization jobs that periodically poll for changes in one directory and push them to another directory, specific to an application instance in a tenant.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/synchronization/job.py
  • class SynchronizationSchema 63.9% similar

    A class representing a synchronization schema that defines what objects will be synchronized and how they will be synchronized between systems.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/synchronization/schema.py
  • class SynchronizationProgress 61.9% similar

    A class representing the progress of a synchronization job toward completion in Microsoft Office 365 services.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/synchronization/progress.py
  • class SynchronizationStatus 61.2% similar

    A data class representing the current status of a synchronization job, including progress details and quarantine information.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/synchronization/status.py
  • class Group 61.1% similar

    Represents an Azure Active Directory (Azure AD) group, which can be an Office 365 group or a security group, providing methods to manage group operations, memberships, and associated resources.

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