API - extras/image-attachments - Filter by Device/Rack/Site/... #4045

Closed
opened 2025-12-29 18:32:50 +01:00 by adam · 2 comments
Owner

Originally created by @Yentel on GitHub (Aug 31, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.7.3
  • NetBox version: 2.8.5

Proposed Functionality

As of now, using the api endpoint to retrieve images by device/site/rack is only possible by retrieving all image-attachments and then locally looping through them to find the required images. This is possible of course, but not scalable at all.
There is, according to the documentation, no possibility to filter this endpoint. The only two possible filters are limit and offset.

Another possibility is by adding a series of images to the respective parent objects (device,rack,site,...) themselves.

Use Case

Retrieving images for a certain object (device with id X, rack with id Y, site with id Z, ...)

Database Changes

None required as these objects are already linked to their models.

External Dependencies

None as far as I can think of.

Originally created by @Yentel on GitHub (Aug 31, 2020). Originally assigned to: @jeremystretch on GitHub. <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/forum/#!forum/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.7.3 * NetBox version: 2.8.5 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality As of now, using the api endpoint to retrieve images by device/site/rack is only possible by retrieving all image-attachments and then locally looping through them to find the required images. This is possible of course, but not scalable at all. There is, according to the documentation, no possibility to filter this endpoint. The only two possible filters are limit and offset. Another possibility is by adding a series of images to the respective parent objects (device,rack,site,...) themselves. <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case Retrieving images for a certain object (device with id X, rack with id Y, site with id Z, ...) <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes None required as these objects are already linked to their models. <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies None as far as I can think of.
adam added the status: acceptedtype: feature labels 2025-12-29 18:32:50 +01:00
adam closed this issue 2025-12-29 18:32:50 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 2, 2020):

Related to #4897

@jeremystretch commented on GitHub (Sep 2, 2020): Related to #4897
Author
Owner

@Yentel commented on GitHub (Nov 22, 2020):

Is there a possibility that this has not been resolved by this commit?

GET https://netbox.mycompany.com/api/extras/image-attachments/?content_type=dcim.device&object_id=2250 resulted in a 400 Bad Request response: {"content_type":["Select a valid choice. That choice is not one of the available choices."]}

However, when requesting the list option (/extras/image-attachments/), I get the object returned for which I'm looking.

{
        "id": 10,
        "url": "http://netbox.mycompany.com/api/extras/image-attachments/10/",
        "content_type": "dcim.device",
        "object_id": 2250,
        "parent": {
                "id": 2250,
                "url": "http://netbox.mycompany.com/api/dcim/devices/2250/",
                "name": "ROUTER",
                "display_name": "ROUTER"
        },
        "name": "",
        "image": "http://netbox.mycompany.com/media/image-attachments/device_2250_image33.jpg",
        "image_height": 1155,
        "image_width": 1540,
        "created": "2020-08-06T09:23:13.870529+02:00"
}
@Yentel commented on GitHub (Nov 22, 2020): Is there a possibility that this has not been resolved by this commit? ``` GET https://netbox.mycompany.com/api/extras/image-attachments/?content_type=dcim.device&object_id=2250 resulted in a 400 Bad Request response: {"content_type":["Select a valid choice. That choice is not one of the available choices."]} ``` However, when requesting the list option (/extras/image-attachments/), I get the object returned for which I'm looking. ``` { "id": 10, "url": "http://netbox.mycompany.com/api/extras/image-attachments/10/", "content_type": "dcim.device", "object_id": 2250, "parent": { "id": 2250, "url": "http://netbox.mycompany.com/api/dcim/devices/2250/", "name": "ROUTER", "display_name": "ROUTER" }, "name": "", "image": "http://netbox.mycompany.com/media/image-attachments/device_2250_image33.jpg", "image_height": 1155, "image_width": 1540, "created": "2020-08-06T09:23:13.870529+02:00" } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4045