Repository: netbox-community/netbox

Issue:
created & last_updated fields missing from some REST API calls
### NetBox version

3.1.6-dev

### Python version

3.8

### Steps to Reproduce

A number of REST API calls are missing created & last_updated fields in their response. No functional impact however for parity across all API calls perhaps it would be useful to have the fields returned consistently.

Examples:
/api/dcim/virtual-chassis/
/api/dcim/cables/
/api/dcim/power-panels/
/api/dcim/rack-reservations/ (Has created but not last_updated)


### Expected Behavior

created & last_updated fields are returned for all relevant objects

### Observed Behavior

created & last_updated are missing some some objects


Discussion:
Happy to submit a PR for this. 

If accepted, presumably this should be in feature not develop branch due to API changes?
Given that it's a bug, and the fix would restore the API's _intended_ functionality, it's fine to handle in the `develop` branch. (New features or functionality would need to be implemented in `feature`.)

Thanks for volunteering!

Resolving patch:
diff --git a/netbox/circuits/api/serializers.py b/netbox/circuits/api/serializers.py
--- a/netbox/circuits/api/serializers.py
+++ b/netbox/circuits/api/serializers.py
@@ -100,5 +100,5 @@ class Meta:
         fields = [
             'id', 'url', 'display', 'circuit', 'term_side', 'site', 'provider_network', 'port_speed', 'upstream_speed',
             'xconnect_id', 'pp_info', 'description', 'mark_connected', 'cable', 'link_peer', 'link_peer_type',
-            '_occupied',
+            '_occupied', 'created', 'last_updated',
         ]
diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py
--- a/netbox/dcim/api/serializers.py
+++ b/netbox/dcim/api/serializers.py
@@ -219,7 +219,7 @@ class RackReservationSerializer(PrimaryModelSerializer):
     class Meta:
         model = RackReservation
         fields = [
-            'id', 'url', 'display', 'rack', 'units', 'created', 'user', 'tenant', 'description', 'tags',
+            'id', 'url', 'display', 'rack', 'units', 'created', 'last_updated', 'user', 'tenant', 'description', 'tags',
             'custom_fields',
         ]
 
@@ -762,7 +762,7 @@ class Meta:
         fields = [
             'id', 'url', 'display', 'termination_a_type', 'termination_a_id', 'termination_a', 'termination_b_type',
             'termination_b_id', 'termination_b', 'type', 'status', 'tenant', 'label', 'color', 'length', 'length_unit',
-            'tags', 'custom_fields',
+            'tags', 'custom_fields', 'created', 'last_updated',
         ]
 
     def _get_termination(self, obj, side):
@@ -856,7 +856,10 @@ class VirtualChassisSerializer(PrimaryModelSerializer):
 
     class Meta:
         model = VirtualChassis
-        fields = ['id', 'url', 'display', 'name', 'domain', 'master', 'tags', 'custom_fields', 'member_count']
+        fields = [
+            'id', 'url', 'display', 'name', 'domain', 'master', 'tags', 'custom_fields', 'member_count',
+            'created', 'last_updated',
+        ]
 
 
 #
@@ -875,7 +878,10 @@ class PowerPanelSerializer(PrimaryModelSerializer):
 
     class Meta:
         model = PowerPanel
-        fields = ['id', 'url', 'display', 'site', 'location', 'name', 'tags', 'custom_fields', 'powerfeed_count']
+        fields = [
+            'id', 'url', 'display', 'site', 'location', 'name', 'tags', 'custom_fields', 'powerfeed_count',
+            'created', 'last_updated',
+        ]
 
 
 class PowerFeedSerializer(PrimaryModelSerializer, LinkTerminationSerializer, ConnectedEndpointSerializer):
diff --git a/netbox/extras/api/serializers.py b/netbox/extras/api/serializers.py
--- a/netbox/extras/api/serializers.py
+++ b/netbox/extras/api/serializers.py
@@ -61,7 +61,7 @@ class Meta:
         fields = [
             'id', 'url', 'display', 'content_types', 'name', 'type_create', 'type_update', 'type_delete', 'payload_url',
             'enabled', 'http_method', 'http_content_type', 'additional_headers', 'body_template', 'secret',
-            'conditions', 'ssl_verification', 'ca_file_path',
+            'conditions', 'ssl_verification', 'ca_file_path', 'created', 'last_updated',
         ]
 
 
@@ -82,7 +82,8 @@ class Meta:
         model = CustomField
         fields = [
             'id', 'url', 'display', 'content_types', 'type', 'name', 'label', 'description', 'required', 'filter_logic',
-            'default', 'weight', 'validation_minimum', 'validation_maximum', 'validation_regex', 'choices',
+            'default', 'weight', 'validation_minimum', 'validation_maximum', 'validation_regex', 'choices', 'created',
+            'last_updated',
         ]
 
 
@@ -100,7 +101,7 @@ class Meta:
         model = CustomLink
         fields = [
             'id', 'url', 'display', 'content_type', 'name', 'link_text', 'link_url', 'weight', 'group_name',
-            'button_class', 'new_window',
+            'button_class', 'new_window', 'created', 'last_updated',
         ]
 
 
@@ -118,7 +119,7 @@ class Meta:
         model = ExportTemplate
         fields = [
             'id', 'url', 'display', 'content_type', 'name', 'description', 'template_code', 'mime_type',
-            'file_extension', 'as_attachment',
+            'file_extension', 'as_attachment', 'created', 'last_updated',
         ]
 
 
@@ -132,7 +133,9 @@ class TagSerializer(ValidatedModelSerializer):
 
     class Meta:
         model = Tag
-        fields = ['id', 'url', 'display', 'name', 'slug', 'color', 'description', 'tagged_items']
+        fields = [
+            'id', 'url', 'display', 'name', 'slug', 'color', 'description', 'tagged_items', 'created', 'last_updated',
+        ]
 
 
 #


Test patch: