Skip to content

nautobot.apps.datasources

Utilities for an app to register datasource contents (for Git, etc.).

nautobot.apps.datasources.DatasourceContent

Parameters:

Name Type Description Default
name str

Human-readable name for this content type, such as "config contexts"

required
content_identifier str

Brief unique identifier of this content type; by convention a string such as "extras.configcontext"

required
icon str

Material Design Icons icon name, such as "mdi-code-json" or "mdi-script-text"

required
callback callable

Callback function to invoke whenever a given datasource is created, updated, or deleted. This callback should take three arguments (record, job_result, delete) where "record" is the GitRepository, etc. that is being refreshed, "job_result" is an extras.JobResult record for logging purposes, and "delete" is a boolean flag to distinguish between the "create/update" and "delete" cases.

required
weight int

Defines the order in which datasources will be loaded.

1000
Source code in nautobot/extras/registry.py
class DatasourceContent:
    """
    Args:
      name (str): Human-readable name for this content type, such as "config contexts"
      content_identifier (str): Brief unique identifier of this content type; by convention a string such as "extras.configcontext"
      icon (str): Material Design Icons icon name, such as "mdi-code-json" or "mdi-script-text"
      callback (callable): Callback function to invoke whenever a given datasource is created, updated, or deleted.
          This callback should take three arguments (record, job_result, delete) where "record" is the GitRepository, etc.
          that is being refreshed, "job_result" is an extras.JobResult record for logging purposes, and
          "delete" is a boolean flag to distinguish between the "create/update" and "delete" cases.
      weight (int): Defines the order in which datasources will be loaded.
    """

    __slots__ = ["name", "content_identifier", "icon", "callback", "weight"]

    def __init__(self, name, content_identifier, icon, callback, weight=1000):
        """Ensure datasource properties."""
        self.name = name
        self.content_identifier = content_identifier
        self.icon = icon
        self.callback = callback
        self.weight = weight

__init__(name, content_identifier, icon, callback, weight=1000)

Ensure datasource properties.

Source code in nautobot/extras/registry.py
def __init__(self, name, content_identifier, icon, callback, weight=1000):
    """Ensure datasource properties."""
    self.name = name
    self.content_identifier = content_identifier
    self.icon = icon
    self.callback = callback
    self.weight = weight