netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Inconsistent API for interface-templates that belongs to a particular device_type

Open rkiss opened this issue 1 year ago • 3 comments

Deployment Type

Self-hosted

NetBox Version

v3.7.2

Python Version

3.8

Steps to Reproduce

Create two "Device Type" objects named type1 and type2 and add an Interface named eth0 to each of them. Call /api/dcim/interface-templates/?name=eth0&device_type=type1.

Expected Behavior

A single object to be returned, the interface template named eth0 of the first device type

Observed Behavior

Two records returned, looks like the device_type=type1 is ignored. Per filtering rules should match the slug of the device_type

rkiss avatar Feb 15 '24 10:02 rkiss

API documentation doesn't list a device_type filter in https://demo.netbox.dev/api/schema/swagger-ui/#/dcim/dcim_interface_templates_list, only devicetype_id:

image

Note that all undefined filters are just ignored.

markkuleinio avatar Feb 15 '24 10:02 markkuleinio

I see.

Still, I think the API is a bit inconsistent here. For example the device have also a device_type but there we do can query either for id or for slug, see: https://netbox-dev.vpu-staging-apps.ti.intel.com/api/schema/swagger-ui/#/dcim/dcim_devices_list

The same approach shall be done everywhere.

rkiss avatar Feb 15 '24 11:02 rkiss

I see (and support) your point. I'd recommend editing the title of the issue to reflect the actual issue at hand.

markkuleinio avatar Feb 15 '24 11:02 markkuleinio

Only devicetype_id is supported for component templates, as has been pointed out. If you'd like to propose a new filter be added, please open a detailed feature request citing your use case.

jeremystretch avatar Feb 20 '24 21:02 jeremystretch