nautobot-app-ssot icon indicating copy to clipboard operation
nautobot-app-ssot copied to clipboard

Add common TypedDicts used for M2M into contrib.py

Open qduk opened this issue 1 year ago • 0 comments

Environment

  • Nautobot version: 1.6.4
  • nautobot-ssot version: 1.6.0

Proposed Functionality

Add common typeddict's that would be commonly used for many-to-many relationships to a a new file (or contrib.py) so that they can be imported and used without the end developer having to define them.

Some example TypedDicts we could include:

class TagDict(TypedDict):
    """Many-to-many relationship typed dict explaining which fields are interesting."""

    name: str

class IPAddressDict(TypedDict):
    """Many-to-many relationship typed dict explaining which fields are interesting."""

    host: str
    prefix_length: int

class ContentTypeDict(TypedDict):
    """Many-to-many relationship typed dict explaining which fields are interesting.
    Needed for content_types:
    """

    app_label: str
    model: str

Use Case

If I am creating an SSoT and need to use Tags or ContentTypes, I would typically have to define the TypedDict myself. Implementing this would allow us to import commonly used ones for ease of use.

qduk avatar Dec 22 '23 17:12 qduk