Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs Update: Clarify sublassing DiffSyncModels for different backends #52

Open
tyler-8 opened this issue Jun 3, 2021 · 1 comment
Open
Assignees
Labels
status: accepted This issue has been accepted by the maintainers team for implementation status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation type: documentation

Comments

@tyler-8
Copy link

tyler-8 commented Jun 3, 2021

Environment

  • DiffSync version: 1.3.0

Proposed Functionality

The README makes mention of extending a "base" DiffSyncModel for handling CRUD actions in a backend, but doesn't do a great job of visualizing this concept.

you need to extend your DiffSyncModel class(es) to define your own create, update and/or delete methods for each model.

I think extending the example out a little more would go a long way to showing how to build your models and adapters.

class Device(DiffSyncModel):
    """Example model of a network Device."""_modelname = "device"
    _identifiers = ("name",)
    _attributes = ()
    _children = {"interface": "interfaces"}
​
    name: str
    site_name: Optional[str]  # note that this attribute is NOT included in _attributes
    role: Optional[str]  # note that this attribute is NOT included in _attributes
    interfaces: List = list()
​
​
class SystemADevice(Device):

    system_A_unique_field: Optional[str] = None
    
    @classmethod
    def create(cls, diffsync, ids, attrs):
        """Talk to SystemA to create device"""
        passclass SystemBDevice(Device):
    
    system_B_unique_field: Optional[str] = None

    @classmethod
    def create(cls, diffsync, ids, attrs):
        """Talk to SystemB to create device"""
        pass

Use Case

This should help newbies (like myself) to get a better idea of how to architect a diffsync-based integration.

@dgarros dgarros added status: accepted This issue has been accepted by the maintainers team for implementation type: documentation labels Jun 18, 2021
@dgarros
Copy link
Contributor

dgarros commented Jun 18, 2021

I've created a new example that partially address this issue #53 but nonetheless we should plan to have a dedicated section of the doc on this

@dgarros dgarros added the status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation label Jun 18, 2021
@FragmentedPacket FragmentedPacket self-assigned this Oct 11, 2021
@FragmentedPacket FragmentedPacket removed their assignment Nov 12, 2021
@Kircheneer Kircheneer self-assigned this Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted This issue has been accepted by the maintainers team for implementation status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation type: documentation
Projects
None yet
Development

No branches or pull requests

4 participants