API Request - id_changed_object_type/action #2461

Closed
opened 2025-12-29 18:19:04 +01:00 by adam · 3 comments
Owner

Originally created by @zmaster7 on GitHub (Mar 13, 2019).

Environment

  • Python version: 3.5.2
  • NetBox version: 2.5.8

Proposed Functionality

From what I can tell, there is no way to pull possible values for "id_changed_object_type" ("content_type") for the changelog via API (/api/extras/object-changes/), and the "action" field only lists available ids without a description of said id (e.g. 1 = Created, 2 = Updated, 3 = Deleted)

I propose, if possible, to add the available options for "changed_object_type" and/or "action" under "/api/extras/_choices/", or a new "/api/extras/object-changes/_choices/" path with both an id and description/name.

Also, the "content_type" does not show up with a Get request on "/api/extras/object-changes/", so you cannot filter after the fact based on object type.

Use Case

Currently, in order to determine the id value of the object type for a change log entry, you would have to go to "/extras/changelog/" (not the API), select the object type you want to filter by, and look at the URI for "changed_object_type=#" (or inspect the dropdown field) for possible options.

It would be beneficial to gather the options via API, rather then hard coding the options and having them change.

Originally created by @zmaster7 on GitHub (Mar 13, 2019). <!-- NOTE: 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.5.2 * NetBox version: 2.5.8 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality From what I can tell, there is no way to pull possible values for "id_changed_object_type" ("content_type") for the changelog via API (/api/extras/object-changes/), and the "action" field only lists available ids without a description of said id (e.g. 1 = Created, 2 = Updated, 3 = Deleted) I propose, if possible, to add the available options for "changed_object_type" and/or "action" under "/api/extras/_choices/", or a new "/api/extras/object-changes/_choices/" path with both an id and description/name. Also, the "content_type" does not show up with a Get request on "/api/extras/object-changes/", so you cannot filter after the fact based on object type. <!-- 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 Currently, in order to determine the id value of the object type for a change log entry, you would have to go to "/extras/changelog/" (not the API), select the object type you want to filter by, and look at the URI for "changed_object_type=#" (or inspect the dropdown field) for possible options. It would be beneficial to gather the options via API, rather then hard coding the options and having them change.
adam added the type: bugstatus: accepted labels 2025-12-29 18:19:04 +01:00
adam closed this issue 2025-12-29 18:19:05 +01:00
Author
Owner

@zmaster7 commented on GitHub (Mar 25, 2019):

It looks like the content type values I would be looking for are pulled via the SQL table: django_content_type.

@zmaster7 commented on GitHub (Mar 25, 2019): It looks like the content type values I would be looking for are pulled via the SQL table: django_content_type.
Author
Owner

@jeremystretch commented on GitHub (Mar 28, 2019):

Corrected action to use ChoiceField serialization and added its key/value pairs to the _choices endpoint.

While the serializer had a content_type field defined, it was not being included in serialized output for some reason. I've changed this to changed_object_type and it now includes the content type of the changed object. (The content types are not included under the _choices endpoint because this is a read-only field.)

@jeremystretch commented on GitHub (Mar 28, 2019): Corrected `action` to use ChoiceField serialization and added its key/value pairs to the `_choices` endpoint. While the serializer had a `content_type` field defined, it was not being included in serialized output for some reason. I've changed this to `changed_object_type` and it now includes the content type of the changed object. (The content types are not included under the `_choices` endpoint because this is a read-only field.)
Author
Owner

@DanSheps commented on GitHub (Apr 3, 2019):

Please open a new issue for this

@DanSheps commented on GitHub (Apr 3, 2019): Please open a new issue for this
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2461