Support adding/modifying DataFiles via REST API #11530

Closed
opened 2025-12-29 21:46:27 +01:00 by adam · 1 comment
Owner

Originally created by @Tindarid on GitHub (Aug 26, 2025).

NetBox version

v4.3.6

Feature type

New functionality

Proposed functionality

For example:

  • Having a directory of templates referencing each other, like here: https://github.com/jeremystretch/example-config-templates
  • new: Create DataFile object per file in the repository (specifying path/contents)
  • Create ConfigTemplate referencing master templates in the repository (in this example: access-switch.j2)
  • Rendering of access-switch.j2 works without defining DataSource

Use case

Would allow PUSH-ing templates with import capabilities, instead of PULL-ing them via defined data source: beneficial in certain infrastructure scenarios

Database changes

None: there is an unique constraint on Path already

External dependencies

N/A

Originally created by @Tindarid on GitHub (Aug 26, 2025). ### NetBox version v4.3.6 ### Feature type New functionality ### Proposed functionality - Allow POST/PUT requests for DataFile endpoints: `/api/core/data-files/` - This will allow using DataFileLoader from https://github.com/netbox-community/netbox/blob/main/netbox/utilities/jinja2.py, meaning that we can create templates which reference other templates (extends/include/import Jinja2 statements) without defining DataSource For example: * Having a directory of templates referencing each other, like here: https://github.com/jeremystretch/example-config-templates * new: Create DataFile object per file in the repository (specifying path/contents) * Create ConfigTemplate referencing master templates in the repository (in this example: `access-switch.j2`) * Rendering of `access-switch.j2` works without defining DataSource ### Use case Would allow PUSH-ing templates with import capabilities, instead of PULL-ing them via defined data source: beneficial in certain infrastructure scenarios ### Related - Solves: https://github.com/netbox-community/netbox/discussions/15505 - https://github.com/netbox-community/netbox/discussions/13602 - https://github.com/netbox-community/netbox/discussions/13575 ### Database changes None: there is an unique constraint on Path already ### External dependencies N/A
adam added the type: feature label 2025-12-29 21:46:27 +01:00
adam closed this issue 2025-12-29 21:46:27 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 28, 2025):

I'm afraid your proposal exceeds the intended use case foe data files. Data files merely represent literal files served by a data source, and are entirely dependent on the data source as the authority governing what files exist and their contents. If you wish to add a new data file, that operation must take place in the data source itself (e.g. by pushing a new commit to a git-backed data source).

@jeremystretch commented on GitHub (Aug 28, 2025): I'm afraid your proposal exceeds the intended use case foe data files. Data files merely represent literal files served by a data source, and are entirely dependent on the data source as the authority governing what files exist and their contents. If you wish to add a new data file, that operation must take place in the data source itself (e.g. by pushing a new commit to a git-backed data source).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11530