Skip to content

Allow accessing source object model in sync_to/sync_from #199

Open
@draggeta

Description

@draggeta

Environment

  • DiffSync version: 1.7.0

Proposed Functionality

Similar I believe to #60.
Have the entire data model of the source available for create and update calls to the remote system.

Use Case

We currently want to sync some data between ITSM systems. ITSM A and B returns a list of available attachments, but not the data within. I can compare based on the data returned which attachments exists on both sides and compare. The used model is:

class Attachment(DiffSyncModel):
    _modelname = "attachment"
    _identifiers = ("name",)
    _shortname = ()
    _attributes = ()
    _children = {}

    id: str
    name: str

I do not want to compare on the id as they are only locally significant. However, to get the attachment content, I need the id. If you do a sync from A to B, that id becomes necessary, but the id of A is not available in the create function attributes or somewhere else.

As a workaround I edited the above class:

class Attachment(DiffSyncModel):
    _modelname = "attachment"
    _identifiers = ("name",)
    _shortname = ()
    _attributes = ("data",)
    _children = {}

    id: str
    name: str
    data: str | None = None

I create a diff and then edit, in a loop, the diff data property to include the id of A. In the create function for B I can then perform a call to the A source system to get the data and sync it.

Is there a better way to do this, where the source class or data is available in it's entirety?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions