pynetbox icon indicating copy to clipboard operation
pynetbox copied to clipboard

Add sync() method/property for the core.data_sources endpoint

Open ifoughal opened this issue 1 month ago • 4 comments

pynetbox version

v7.5.0

NetBox version

v4.4.5

Feature type

Data model extension

Proposed functionality

when adding a data-source through the API, PyNetbox doesn't currently support the sync(); so we have to sync manually through the gui, in order to be able to use the context/template of the created data-source.

the sync() property of core.data_sources would let the user run the sync method through the API post create of the data-source.

Use case

creating a data-source through pynetbox & then creating config-templates source from that data-source is currently not supported, as the program would have to be suspended in order for the user to sync manually.

By adding a core.py model with a data_source class & sync property; the user would be able to sync the newly created data-source in order to git fetch/pull the files. and then creating the config-template objects associated with said files.

External dependencies

No response

ifoughal avatar Nov 17 '25 14:11 ifoughal

The feature is already developed and my PR is ready.

ifoughal avatar Nov 17 '25 14:11 ifoughal

@ifoughal, what exactly is it you're proposing to change with this FR?

jnovinger avatar Nov 17 '25 15:11 jnovinger

@ifoughal, what exactly is it you're proposing to change with this FR?

@jnovinger I've added core.py module to models, which includes the DataSources class with its sync method, which reflects the following api call: /api/core/data-sources/{id}/sync/

This in pynetbox translates to:

nb.core.data_sources.sync.create()

ifoughal avatar Nov 18 '25 06:11 ifoughal

@jnovinger ping!

I referred to the same logic as render_config property for devices:

@property
    def render_config(self):
        """Represents the ``render-config`` detail endpoint.

        Returns a DetailEndpoint object that is the interface for
        viewing response from the render-config endpoint.

        ## Returns
        DetailEndpoint object.

        ## Examples

        ```python
        device = nb.ipam.devices.get(123)
        device.render_config.create()
        ```
        """
        return DetailEndpoint(self, "render-config")

Except that in this issues case, it is applied on the core.data_sources endpoint, in order to trigger a sync.

ifoughal avatar Dec 01 '25 11:12 ifoughal